/* =========================================================
   Flashbox — Photobooth stylesheet
   Design tokens live at the top; everything below consumes them.
   ========================================================= */

:root {
  /* Color */
  --paper: #FBF6EC;
  --ink: #241F26;
  --ink-soft: #5B5560;
  --line: #E7DFD0;
  --pink: #FF4D8D;
  --pink-deep: #E23F79;
  --yellow: #FFC857;
  --mint: #3FC7B8;
  --purple: #7B61FF;
  --surface: #FFFFFF;
  --surface-alt: #F4EEE0;
  --danger: #D6432F;
  --danger-bg: #FBE4DF;

  /* Type */
  --font-display: 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Work Sans', system-ui, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, monospace;

  /* Layout */
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --shadow-soft: 0 10px 30px -12px rgba(36, 31, 38, 0.25);
  --shadow-card: 0 4px 16px -6px rgba(36, 31, 38, 0.14);
  --content-width: 1180px;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0 0 0.4em; line-height: 1.08; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 2px;
}

img, canvas, video { max-width: 100%; display: block; }

/* ---------- Curtain signature element ---------- */
.curtain {
  display: flex;
  height: 14px;
  width: 100%;
  overflow: hidden;
}
.curtain-stripe {
  flex: 1 0 auto;
  height: 100%;
}
.curtain-stripe:nth-child(8n+1) { background: var(--pink); }
.curtain-stripe:nth-child(8n+2) { background: var(--yellow); }
.curtain-stripe:nth-child(8n+3) { background: var(--mint); }
.curtain-stripe:nth-child(8n+4) { background: var(--purple); }
.curtain-stripe:nth-child(8n+5) { background: var(--ink); }
.curtain-stripe:nth-child(8n+6) { background: var(--pink); }
.curtain-stripe:nth-child(8n+7) { background: var(--mint); }
.curtain-stripe:nth-child(8n+8) { background: var(--yellow); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(251, 246, 236, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--ink);
}
.brand-mark { color: var(--pink); font-size: 1.1em; }
.topnav {
  display: flex;
  gap: 22px;
  margin-left: 8px;
  flex: 1;
}
.topnav a {
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.topnav a:hover { color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 22px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--pink);
  color: white;
  box-shadow: var(--shadow-card);
}
.btn-primary:hover:not(:disabled) { background: var(--pink-deep); box-shadow: var(--shadow-soft); }
.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}
.btn-outline:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: var(--surface-alt); }
.btn-large { padding: 15px 30px; font-size: 1.02rem; }
.btn-small { padding: 8px 16px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ---------- Sections ---------- */
.section {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 72px 24px;
}
.section-alt { background: var(--surface-alt); max-width: none; }
.section-alt > * { max-width: var(--content-width); margin-left: auto; margin-right: auto; }
.section-head { max-width: 640px; margin-bottom: 40px; }
.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  color: var(--pink-deep);
  font-weight: 700;
  margin-bottom: 10px;
}
.section-sub { color: var(--ink-soft); font-size: 1.05rem; }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
  padding-top: 56px;
}
.hero h1 { font-size: clamp(2.2rem, 4vw, 3.4rem); }
.lede { font-size: 1.1rem; color: var(--ink-soft); max-width: 480px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: 999px;
  max-width: fit-content;
}
.privacy-badge.small { font-size: 0.78rem; margin-top: 14px; margin-bottom: 0; }

.hero-visual { display: flex; justify-content: center; }
.hero-strip {
  background: var(--ink);
  padding: 16px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 220px;
  box-shadow: var(--shadow-soft);
  transform: rotate(3deg);
}
.hero-frame {
  aspect-ratio: 4/3;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--pink), var(--purple));
}
.hero-frame:nth-child(2) { background: linear-gradient(135deg, var(--mint), var(--purple)); }
.hero-frame:nth-child(3) { background: linear-gradient(135deg, var(--yellow), var(--pink)); }

/* ---------- Camera ---------- */
.camera-layout {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 32px;
  align-items: start;
}
.camera-stage { display: flex; flex-direction: column; gap: 18px; }
.camera-viewport {
  position: relative;
  background: var(--ink);
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 4/3;
  box-shadow: var(--shadow-soft);
}
#video-preview {
  width: 100%; height: 100%; object-fit: cover;
  transform: scaleX(-1); /* mirror like a real mirror/booth */
}
.camera-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #DCD5E0;
  gap: 10px;
  text-align: center;
  padding: 20px;
}
.placeholder-icon { font-size: 2.4rem; }
.camera-error {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(36,31,38,0.92);
  color: #FBD9CE;
  text-align: center;
  padding: 30px;
  font-weight: 500;
}
.flash-overlay {
  position: absolute; inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
}
.flash-overlay.is-flashing {
  animation: flashPop 260ms ease-out;
}
@keyframes flashPop {
  0% { opacity: 0.95; }
  100% { opacity: 0; }
}
.countdown-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(36,31,38,0.35);
}
#countdown-number {
  font-family: var(--font-display);
  font-size: 6rem;
  color: white;
  text-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: countPulse 1s ease-in-out;
}
@keyframes countPulse {
  0% { transform: scale(1.4); opacity: 0; }
  30% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.9; }
}
.progress-pill {
  position: absolute;
  top: 14px; left: 14px;
  background: rgba(36,31,38,0.75);
  color: white;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
}
.camera-controls { display: flex; gap: 12px; flex-wrap: wrap; }
.camera-hint { font-size: 0.85rem; color: var(--ink-soft); margin-top: 8px; margin-bottom: 0; text-align: center; }

/* Camera Filter Bar */
.camera-filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.filter-bar-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-right: 4px;
}
.cam-filter-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cam-filter-btn:hover {
  border-color: var(--pink);
  color: var(--pink);
}
.cam-filter-btn.is-selected {
  background: var(--pink);
  border-color: var(--pink);
  color: white;
}

.camera-sidebar { display: flex; flex-direction: column; gap: 20px; }
.control-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-card);
}
.control-card h3 { font-size: 1.05rem; margin-bottom: 10px; }
.control-hint { font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 14px; }

.shot-count-group { display: flex; gap: 8px; }
.shot-count-btn {
  flex: 1;
  padding: 12px 0;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: var(--paper);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.shot-count-btn:hover { border-color: var(--purple); }
.shot-count-btn.is-selected {
  background: var(--purple);
  border-color: var(--purple);
  color: white;
}

.thumb-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb-strip img {
  width: 64px; height: 48px; object-fit: cover;
  border-radius: 8px; border: 2px solid var(--line);
}

/* ---------- Templates ---------- */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}
.template-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.template-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); }
.template-card.is-selected { border-color: var(--pink); box-shadow: var(--shadow-soft); }
.template-swatch {
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: 10px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  position: relative;
  overflow: hidden;
}
.template-swatch .mini-frame { flex: 1; border-radius: 4px; background: rgba(0,0,0,0.15); position: relative; z-index: 2; }

/* Swatch Patterns */
.swatch-pattern {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0.5;
  z-index: 1;
}
.swatch-pattern.pattern-checker {
  background-image: repeating-conic-gradient(rgba(255, 182, 193, 0.5) 0% 25%, transparent 0% 50%);
  background-size: 16px 16px;
}
.swatch-pattern.pattern-dots {
  background-image: radial-gradient(rgba(141, 168, 133, 0.5) 15%, transparent 16%);
  background-size: 10px 10px;
}
.swatch-pattern.pattern-grid {
  background-image: linear-gradient(rgba(139, 92, 246, 0.3) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(139, 92, 246, 0.3) 1px, transparent 1px);
  background-size: 12px 12px;
}
.swatch-pattern.pattern-stripes {
  background-image: repeating-linear-gradient(45deg, rgba(224, 192, 151, 0.4), rgba(224, 192, 151, 0.4) 4px, transparent 4px, transparent 8px);
}
.swatch-pattern.pattern-stars {
  background-image: 
    radial-gradient(circle at 3px 3px, rgba(240, 166, 202, 0.8) 1px, transparent 1px),
    radial-gradient(circle at 9px 9px, rgba(240, 166, 202, 0.8) 1px, transparent 1px);
  background-size: 12px 12px;
}
.swatch-pattern.pattern-hearts {
  background-image: radial-gradient(circle at 4px 4px, rgba(255, 77, 141, 0.5) 2px, transparent 2px);
  background-size: 14px 14px;
}
.swatch-pattern.pattern-flowers {
  background-image: radial-gradient(circle at 6px 6px, rgba(255, 255, 255, 0.8) 2px, transparent 2.5px),
                    radial-gradient(circle at 6px 6px, rgba(255, 200, 87, 0.9) 1px, transparent 1px);
  background-size: 16px 16px;
}
.swatch-pattern.pattern-cherries {
  background-image: radial-gradient(circle at 4px 6px, rgba(201, 24, 74, 0.6) 2px, transparent 2px),
                    radial-gradient(circle at 7px 6px, rgba(201, 24, 74, 0.6) 2px, transparent 2px);
  background-size: 18px 18px;
}
.swatch-pattern.pattern-bubbles {
  background-image: radial-gradient(circle at 5px 5px, transparent 2px, rgba(186, 230, 253, 0.7) 2px, rgba(186, 230, 253, 0.7) 3px, transparent 3px);
  background-size: 15px 15px;
}
.swatch-pattern.pattern-paws {
  background-image: radial-gradient(circle at 5px 6px, rgba(193, 154, 107, 0.5) 2.5px, transparent 2.5px);
  background-size: 14px 14px;
}
.template-card strong { display: block; font-size: 0.92rem; }
.template-card span.tc-desc { font-size: 0.78rem; color: var(--ink-soft); }

/* ---------- Customize ---------- */
.customize-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  align-items: start;
}
.customize-panel { display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 0.9rem; font-weight: 500; }
.field:last-child { margin-bottom: 0; }
.field span { color: var(--ink-soft); font-size: 0.82rem; }
.field input[type="text"] {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--paper);
}
.field input[type="color"] {
  width: 100%; height: 40px; border-radius: 8px; border: 1.5px solid var(--line); padding: 2px; background: var(--paper); cursor: pointer;
}
.field input[type="range"] { width: 100%; accent-color: var(--pink); }
.field-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.field-check { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; font-weight: 500; cursor: pointer; }
.field-check input { width: 18px; height: 18px; accent-color: var(--pink); }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.filter-btn {
  padding: 10px 4px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--paper);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.filter-btn.is-selected { border-color: var(--mint); background: var(--mint); color: white; }
.per-photo-filters { display: flex; flex-direction: column; gap: 8px; }
.per-photo-row { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.per-photo-row img { width: 46px; height: 34px; object-fit: cover; border-radius: 6px; }
.per-photo-row select { flex: 1; padding: 6px 8px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--paper); }

.customize-live { position: sticky; top: 90px; }
.live-label {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-bottom: 10px;
}
.live-preview-mount {
  display: flex;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.live-preview-mount canvas { border-radius: 10px; }

/* ---------- Final preview ---------- */
.final-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 32px;
  align-items: start;
}
.final-preview-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 320px;
  box-shadow: var(--shadow-card);
}
.final-empty-hint { color: var(--ink-soft); font-size: 0.95rem; margin: 0; }
#final-canvas,
.final-gif-preview {
  max-height: 480px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
}
.final-preview-wrap {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
}
.format-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.format-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--paper);
  font-weight: 700;
  cursor: pointer;
}
.format-btn.is-selected { border-color: var(--yellow); background: var(--yellow); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-soft);
  z-index: 100;
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.toast.is-error { background: var(--danger); }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 30px 24px 50px;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 30px; }
  .hero-visual { order: -1; }
  .camera-layout, .customize-layout, .final-layout { grid-template-columns: 1fr; }
  .customize-live { position: static; }
  .topnav { display: none; }
}
@media (max-width: 520px) {
  .section { padding: 48px 18px; }
  .field-row { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-strip { width: 170px; }
  .camera-controls {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  #start-camera-btn, #capture-sequence-btn, #retake-btn {
    grid-column: span 2;
    width: 100%;
  }
}
