/* ── Design tokens ──────────────────────────────────────────────────────────── */
:root {
  --bg:        #050A14;
  --pink:      #FF2D78;
  --cyan:      #00F5FF;
  --green:     #AAFF00;
  --purple:    #9B30FF;
  --white:     #F0F0FF;
  --dark-card: #0B1220;

  --glow-pink:   0 0 8px #FF2D78, 0 0 24px #FF2D78aa, 0 0 48px #FF2D7855;
  --glow-cyan:   0 0 8px #00F5FF, 0 0 24px #00F5FFaa, 0 0 48px #00F5FF55;
  --glow-purple: 0 0 8px #9B30FF, 0 0 24px #9B30FFaa;
  --glow-green:  0 0 8px #AAFF00, 0 0 24px #AAFF00aa;

  --font-display: 'Orbitron', monospace;
  --font-body:    'Rajdhani', sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; border: none; background: none; font-family: inherit; }
img    { display: block; max-width: 100%; }

/* ── Scanlines overlay ──────────────────────────────────────────────────────── */
#scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.08) 0px,
    rgba(0, 0, 0, 0.08) 1px,
    transparent 1px,
    transparent 3px
  );
}

/* ── Screens ────────────────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  overflow: hidden;
}
.screen.active { display: flex; }


/* ═══════════════════════════════════════════════════════════════════════════════
   SCREEN 1 — ATTRACT
══════════════════════════════════════════════════════════════════════════════ */
#screen-attract {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

/* Background layers — positioned behind content */
.background {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 0;
}
.background.active { display: block; }

/* Content above backgrounds */
.attract-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  padding: 32px;
}

/* Title */
.attract-header   { text-align: center; line-height: 1; }
.attract-sub      { font-family: var(--font-display); font-size: 1rem; letter-spacing: 0.8em; color: var(--cyan); margin-bottom: 8px; opacity: 0.8; }
.attract-title    { font-family: var(--font-display); font-size: clamp(3.5rem, 8vw, 7rem); font-weight: 900; letter-spacing: 0.05em; text-transform: uppercase; color: var(--white); text-shadow: var(--glow-cyan); }
.attract-title .accent-pink { color: var(--pink); text-shadow: var(--glow-pink); }
.attract-year     { font-family: var(--font-display); font-size: 0.9rem; letter-spacing: 0.6em; color: var(--purple); margin-top: 12px; }

/* Big start button */
.btn-start {
  position: relative;
  padding: 22px 52px;
  border: 2px solid var(--cyan);
  border-radius: 4px;
  background: transparent;
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  box-shadow: var(--glow-cyan), inset 0 0 30px rgba(0, 245, 255, 0.06);
  transition: box-shadow 0.2s, border-color 0.2s, color 0.2s;
}
.btn-start:hover,
.btn-start:focus-visible {
  border-color: var(--pink);
  color: var(--pink);
  box-shadow: var(--glow-pink), inset 0 0 30px rgba(255, 45, 120, 0.1);
}
.btn-start-text { position: relative; z-index: 1; }

/* Pulsing rings around start button */
.btn-start-ring {
  position: absolute;
  inset: -12px;
  border: 1px solid var(--cyan);
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
}
.btn-start-ring-1 { animation: ring-pulse 2.4s ease-out infinite; }
.btn-start-ring-2 { animation: ring-pulse 2.4s ease-out 1.2s infinite; }

/* Background selector */
.bg-selector {
  display: flex;
  gap: 16px;
  align-items: center;
}

.bg-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.bg-option:hover { border-color: rgba(255,255,255,0.35); }
.bg-option.active {
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
}
.bg-thumb {
  width: 64px;
  height: 48px;
  border-radius: 3px;
  overflow: hidden;
}
.bg-option-label {
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.6);
}
.bg-option.active .bg-option-label { color: var(--cyan); }


/* ═══════════════════════════════════════════════════════════════════════════════
   SCREEN 2 — CAPTURE
══════════════════════════════════════════════════════════════════════════════ */
#screen-capture { background: var(--bg); }

.capture-background {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.capture-layout {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  height: 100%;
}

/* Camera area */
.capture-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 16px;
}

.camera-frame {
  position: relative;
  width: 100%;
  max-width: 900px;
  aspect-ratio: 16/9;
  border: 2px solid rgba(0, 245, 255, 0.4);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--glow-cyan);
  background: #000;
}

#camera-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror for natural selfie positioning */
  display: block;
}

/* Countdown overlay */
.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  z-index: 2;
}
.countdown-overlay.hidden { display: none; }

.countdown-number {
  font-family: var(--font-display);
  font-size: clamp(6rem, 18vw, 14rem);
  font-weight: 900;
  color: var(--white);
  text-shadow: var(--glow-cyan);
  line-height: 1;
}

/* Flash overlay */
.flash-overlay {
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
}
.flash-overlay.hidden { display: none; }

/* Camera error overlay */
.camera-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(5, 10, 20, 0.92);
  z-index: 4;
  padding: 32px;
  text-align: center;
}
.camera-error.hidden { display: none; }
.camera-error-icon  { font-size: 3rem; }
.camera-error-title { font-family: var(--font-display); font-size: 1.2rem; color: var(--pink); text-shadow: var(--glow-pink); }
.camera-error-msg   { font-size: 1rem; color: rgba(240,240,255,0.7); max-width: 380px; line-height: 1.5; }

/* Shot progress dots */
.shot-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
}
.shot-label {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: rgba(255,255,255,0.4);
}
.shot-dots    { display: flex; gap: 10px; }
.shot-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  background: transparent;
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.shot-dot.active {
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
}
.shot-dot.done {
  background: var(--pink);
  border-color: var(--pink);
  box-shadow: var(--glow-pink);
}

/* Sidebar */
.capture-sidebar {
  width: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  background: rgba(0, 0, 0, 0.5);
  border-left: 1px solid rgba(0, 245, 255, 0.15);
  gap: 16px;
}
.sidebar-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  color: var(--cyan);
  opacity: 0.7;
}
.thumbnail-strip {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  flex: 1;
  align-items: center;
  justify-content: center;
}
.thumbnail-slot {
  width: 140px;
  height: 90px;
  border: 1px solid rgba(0, 245, 255, 0.25);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  background: rgba(0,0,0,0.4);
}
.thumbnail-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: rgba(0, 245, 255, 0.2);
}
.thumbnail-img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s;
  transform: scaleX(-1); /* match the mirrored preview */
}
.thumbnail-img.visible { opacity: 1; }


/* ═══════════════════════════════════════════════════════════════════════════════
   SCREEN 3 — STRIP DISPLAY
══════════════════════════════════════════════════════════════════════════════ */
#screen-strip {
  background: var(--bg);
  flex-direction: row;
}

/* Strip panel — left column */
.strip-panel {
  flex: 0 0 auto;
  width: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(0, 0, 0, 0.4);
  border-right: 1px solid rgba(0, 245, 255, 0.12);
}
.strip-wrapper {
  height: calc(100vh - 48px);
  display: flex;
  align-items: center;
  justify-content: center;
}
#strip-canvas {
  display: block;
  max-height: 100%;
  width: auto;
  border-radius: 2px;
}

/* Actions panel — right column */
.strip-actions {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  gap: 36px;
}
.strip-ready-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  color: var(--white);
  text-shadow: var(--glow-cyan);
}
.strip-ready-title .accent-cyan { color: var(--cyan); }

.strip-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 360px;
}

/* Primary + Secondary buttons */
.btn-primary,
.btn-secondary {
  width: 100%;
  padding: 18px 32px;
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: box-shadow 0.2s, opacity 0.2s;
}
.btn-primary {
  background: var(--pink);
  color: #fff;
  box-shadow: var(--glow-pink);
}
.btn-primary:hover  { box-shadow: 0 0 14px #FF2D78, 0 0 40px #FF2D78; }
.btn-primary:active { opacity: 0.8; }
.btn-secondary {
  background: transparent;
  color: var(--cyan);
  border: 2px solid var(--cyan);
  box-shadow: var(--glow-cyan);
}
.btn-secondary:hover  { box-shadow: 0 0 14px #00F5FF, 0 0 40px #00F5FF; }
.btn-secondary:active { opacity: 0.8; }

/* QR panel */
.qr-panel {
  width: 100%;
  max-width: 360px;
  background: var(--dark-card);
  border: 1px solid rgba(0, 245, 255, 0.2);
  border-radius: 6px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qr-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}
.qr-view.hidden { display: none; }

.qr-image {
  width: 220px;
  height: 220px;
  /* Keep QR modules crisp — no anti-aliasing blur */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  border-radius: 4px;
}

.qr-label {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
  text-align: center;
}

.qr-sublabel {
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: rgba(0, 245, 255, 0.4);
  text-align: center;
  text-transform: uppercase;
}

/* Loading state */
#qr-loading-view {
  padding: 16px 0;
  gap: 16px;
}
.qr-spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(0, 245, 255, 0.2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.qr-status-text {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  color: var(--cyan);
}

/* Error state */
.qr-error-text {
  font-size: 0.85rem;
  color: var(--pink);
  font-family: var(--font-body);
  line-height: 1.5;
  text-align: center;
  padding: 8px 0;
}

/* ── Utility ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }


/* ═══════════════════════════════════════════════════════════════════════════════
   PRINT OVERLAY
   Full-screen view that shows the strip at iPad Mini portrait scale.
   z-index is above the scanlines overlay (9999) so it covers everything.
══════════════════════════════════════════════════════════════════════════════ */
.print-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Strip fills the full viewport height; width scales naturally from aspect ratio.
   On iPad Mini portrait (768×1024) with a 1:2 strip this renders at ~512×1024 px,
   centered on the screen. The white border gives it a physical photo print look. */
.print-strip-img {
  height: 100vh;
  width: auto;
  max-width: 100vw;
  display: block;
  box-sizing: border-box;
  border: 18px solid #ffffff;
}

.btn-close-print {
  position: absolute;
  top: 20px;
  left: 20px;
  padding: 10px 20px;
  border: 2px solid var(--cyan);
  border-radius: 4px;
  background: rgba(5, 10, 20, 0.85);
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  box-shadow: var(--glow-cyan);
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-close-print:active { opacity: 0.7; }


/* ── Print media — hide UI chrome, show only the strip image ─────────────────
   Works when the user triggers browser print while the overlay is visible.   */
@media print {
  #scanlines,
  #screen-attract,
  #screen-capture,
  #screen-strip,
  .btn-close-print {
    display: none !important;
  }

  .print-overlay {
    display: flex !important;
    position: fixed;
    inset: 0;
    background: #fff;
  }

  .print-strip-img {
    height: 100vh;
    width: auto;
    max-width: 100%;
  }
}


/* ═══════════════════════════════════════════════════════════════════════════════
   PORTRAIT / IPAD MINI  (≤ 800 px wide — iPad Mini portrait is 768 pt)
   Overrides the landscape-first defaults above.
══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 800px) {

  /* ── Screen 1: Attract ─────────────────────────────────────────────────── */
  .attract-content { gap: 32px; padding: 24px 20px; }

  /* Scale title down so it fits the narrower viewport */
  .attract-title { font-size: clamp(2.8rem, 10vw, 5rem); }
  .attract-sub   { font-size: 0.85rem; letter-spacing: 0.6em; }
  .attract-year  { font-size: 0.75rem; letter-spacing: 0.4em; }

  /* Background selector: 4 thumbs in a tighter row */
  .bg-selector { gap: 10px; }
  .bg-thumb    { width: 52px; height: 38px; }

  /* ── Screen 2: Capture — stack camera above thumbnails ─────────────────── */
  .capture-layout {
    flex-direction: column;
  }

  .capture-main {
    padding: 12px 12px 8px;
    gap: 10px;
  }

  /* Camera fills the full width of a portrait viewport */
  .camera-frame {
    max-width: 100%;
  }

  /* Sidebar becomes a horizontal bar at the bottom */
  .capture-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    height: auto;
    padding: 8px 16px;
    border-left: none;
    border-top: 1px solid rgba(0, 245, 255, 0.15);
    gap: 12px;
  }

  /* "YOUR STRIP" label — hide in portrait to save horizontal space */
  .sidebar-label { display: none; }

  .thumbnail-strip {
    flex-direction: row;
    flex: 1;
    justify-content: center;
    gap: 8px;
  }

  .thumbnail-slot {
    width: 100px;
    height: 64px;
    flex-shrink: 0;
  }

  /* ── Screen 3: Strip display ────────────────────────────────────────────── */
  /* Keep side-by-side but tighten widths for the narrower viewport */
  .strip-panel {
    width: 240px;
    padding: 16px 10px;
  }

  .strip-actions {
    padding: 24px 16px;
    gap: 24px;
  }

  .strip-ready-title {
    font-size: clamp(1.4rem, 4vw, 2.2rem);
  }

  .strip-buttons,
  .qr-panel {
    max-width: 260px;
  }

  .qr-image {
    width: 180px;
    height: 180px;
  }
}
