/*
  Every booth screen, styled as the quiz's first build (03-web first-build:
  css/base.css, start.css, quiz.css, result.css), so the two read as one
  product. Brand values come from brand/brand.css; the camera's own values
  from css/theme.css. The booth's own screens (the face-outline start, the
  camera, the scan and the reading drawing) use the same type and colours.
*/

/* ================================================================ tokens (as the quiz's base.css) */

:root {
  --step--2: 0.75rem;   /* 12 */
  --step--1: 0.875rem;  /* 14 */
  --step-0: 1rem;       /* 16 */
  --step-1: 1.125rem;   /* 18 */
  --step-2: 1.3125rem;  /* 21 */
  --step-3: 1.5rem;     /* 24 */
  --step-4: 2.25rem;    /* 36 */
  --step-5: 3rem;       /* 48 */
  --step-6: 3.75rem;    /* 60 */

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --gutter: max(24px, var(--safe-left), var(--safe-right));
}

/* ================================================================ base */

*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--color-paper);
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden; /* the screens scroll, not the page */
  overscroll-behavior: none;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-text);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-kerning: normal;
}

/* Full screen from the Home Screen: a black band behind iOS's white status bar. Zero in a browser tab. */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--safe-top);
  background: var(--color-brand);
  pointer-events: none;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
h1, h2, h3, h4 { color: var(--color-heading); }
img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Buttons: square, uppercase and letter-spaced, as on the brand website */
.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 0 28px;
  border: 1px solid transparent;
  border-radius: var(--radius-button);
  font: 600 var(--step--1) / 1 var(--font-text);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.2s, opacity 0.2s, transform 0.15s var(--ease-out);
}

.button:active:not(:disabled) { transform: scale(0.985); }
.button:disabled { cursor: default; opacity: 0.45; }
.button-primary { background: var(--color-brand); color: var(--color-on-brand); }
.button-primary:active:not(:disabled) { background: var(--color-brand-deep); }
.button-quiet { background: transparent; border-color: var(--color-heading); color: var(--color-heading); }
.button-quiet:active:not(:disabled) { background: var(--color-backdrop); }

.link {
  appearance: none;
  padding: 10px 0;
  border: 0;
  background: none;
  color: var(--color-heading);
  font-size: var(--step--1);
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}

.logo { display: block; width: auto; height: auto; max-width: 100%; }

/* The tagline as the brand writes it (as on the quiz): lower case, Futura-style, key words in bold */
.tagline {
  font: 400 var(--step-1) / 1.3 var(--font-display);
  letter-spacing: 0.01em;
}

.tagline b { font-weight: 600; }

.fine-print {
  font-size: var(--step--2);
  line-height: 1.55;
  color: var(--color-ink-soft);
  max-width: 44ch;
}

/* ================================================================ the app frame */

.app { position: fixed; inset: 0; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.is-active { display: flex; flex-direction: column; }
.screen.is-entering { animation: screen-in 380ms var(--ease-out) both; }

@keyframes screen-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ================================================================ 1. start (the booth's own, in the quiz's start layout) */

.start-stage {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  height: clamp(340px, 52svh, 560px);
  padding: calc(var(--safe-top) + 28px) var(--gutter) 0;
  background: var(--color-backdrop);
  overflow: hidden;
}

/* The logo, large and centred, with the tagline under it */
.brand-lockup {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  align-self: center;
  text-align: center;
}

.brand-lockup .logo { width: min(240px, 64vw); }
.brand-lockup .tagline { color: var(--color-ink); }

/* The booth's face outline fills the rest of the panel */
.intro__art { position: relative; flex: 1; min-height: 160px; margin-top: 8px; }
.intro__art canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.start-copy {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 28px var(--gutter) calc(var(--safe-bottom) + 28px);
}

.start-title {
  font: var(--display-weight) clamp(2.5rem, 10.6vw, 3.75rem) / 1.06 var(--font-display);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.start-intro { margin-top: 16px; font-size: var(--step-0); color: var(--color-ink); max-width: 34ch; }
.start-copy .button { margin-top: 28px; }

.consent {
  margin-top: 14px;
  font: 500 var(--step--2) / 1.5 var(--font-text);
  letter-spacing: 0.06em;
  color: var(--color-ink-soft);
}

.start-copy .link { margin-top: 10px; align-self: flex-start; }
.start-copy .fine-print { margin-top: 18px; }

/* ================================================================ 2. camera and scan (the booth's own) */

.camera { overflow: hidden; }

.stage { position: absolute; inset: 0; overflow: hidden; }

.stage video,
.stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror, so moving left moves left */
}

/* A test photo is shown unmirrored: it isn't a mirror. Placed by main.js. */
.stage img { object-fit: contain; transform: none; background: var(--color-backdrop); }
.stage img.is-placed { inset: auto; object-fit: fill; background: none; }

.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.veil { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.veil__fill { fill: var(--color-veil); }

.rim { fill: none; stroke: var(--color-guide); stroke-width: 1.5; transition: stroke 300ms ease, stroke-width 300ms ease; }

/* The scan's progress runs round the oval in the accent, like the question progress bar. */
.rim--progress { stroke: var(--color-accent); stroke-width: 3; stroke-linecap: square; transition: none; }

.camera.is-ready .rim:not(.rim--progress) { stroke: var(--color-brand); stroke-width: 2; }

.camera-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(var(--safe-top) + 56px);
  padding: var(--safe-top) var(--gutter) 0 10px;
}

.camera-bar .logo { width: 132px; }

.guide {
  position: absolute;
  left: 0; right: 0;
  top: var(--guide-top, 70%);
  padding: 0 var(--gutter) calc(var(--safe-bottom) + 20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center; /* centred under the centred oval */
  gap: 14px;
}

.guide__hint {
  font: var(--heading-weight) clamp(1.5rem, 6.6vw, 1.875rem) / 1.2 var(--font-display);
  color: var(--color-heading);
  min-height: 1.2em;
  text-wrap: balance;
}

.guide__note { font-size: var(--step--1); color: var(--color-ink-soft); }

.checks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 22px;
  font: 600 var(--step--2) / 1 var(--font-text);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  color: var(--color-ink-soft);
}

.checks li { display: flex; align-items: center; gap: 8px; }

.checks li::before {
  content: '';
  width: 10px; height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--color-ink-soft);
  transition: background-color 200ms ease, box-shadow 200ms ease;
}

.checks li.is-ok { color: var(--color-heading); }
.checks li.is-ok::before { background: var(--color-brand); box-shadow: inset 0 0 0 1.5px var(--color-brand); }

#read-anyway { width: auto; }

.camera.is-scanning .checks,
.camera.is-scanning .guide__note,
.camera.is-scanning #read-anyway { visibility: hidden; }

/* ================================================================ camera didn't start */

.notice { padding: calc(var(--safe-top) + 28px) var(--gutter) calc(var(--safe-bottom) + 28px); }
.notice__logo { width: 160px; }
.notice__body { margin: auto 0; display: flex; flex-direction: column; align-items: stretch; gap: 20px; max-width: 34em; }

/* ================================================================ 3. questions (as the quiz's quiz.css) */

.quiz-header {
  position: sticky;
  top: 0;
  z-index: 5;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(var(--safe-top) + 56px);
  padding: var(--safe-top) var(--gutter) 0 10px;
  background: var(--color-paper);
}

.quiz-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0 14px 0 6px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--color-heading);
  font: 600 var(--step--2) / 1 var(--font-text);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}

.camera-bar .quiz-back { padding-left: 14px; }
.quiz-back:active { background: var(--color-backdrop); }
.icon { display: inline-flex; }

.quiz-count {
  font: 500 var(--step--2) / 1 var(--font-text);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  color: var(--color-ink-soft);
  font-variant-numeric: tabular-nums;
}

.quiz-progress { position: sticky; top: calc(var(--safe-top) + 56px); z-index: 5; flex: none; height: 2px; background: var(--color-line); }

.quiz-bar {
  display: block;
  height: 100%;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.7s var(--ease-out);
}

.quiz-slot { flex: 1; display: flex; flex-direction: column; }
.question { flex: 1; display: flex; flex-direction: column; padding-top: 36px; }

.question-text {
  margin: 0 var(--gutter) 32px;
  font: var(--heading-weight) clamp(1.75rem, 7.8vw, 2.125rem) / 1.18 var(--font-display);
  letter-spacing: -0.005em;
  text-wrap: balance;
  outline: none;
}

.options { list-style: none; padding: 0; border-top: 1px solid var(--color-line); }
.options li { border-bottom: 1px solid var(--color-line); }

.option {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.option-face {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 16px var(--gutter);
  transition: background-color 0.15s;
}

.option:active > .option-face { background: var(--color-backdrop); }
.option-label { font-size: var(--step-0); font-weight: 500; line-height: 1.4; }

.option-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--color-ink-soft);
  border-radius: 50%;
}

.options--multi .option-mark { border-radius: 0; } /* squares for "pick several" */
.option-mark svg { opacity: 0; }

/* The black layer spreads from the tap point (views.js sets --x and --y). */
.option-fill {
  position: absolute;
  inset: 0;
  background: var(--color-brand);
  color: var(--color-on-brand);
  clip-path: circle(0 at var(--x, 50%) var(--y, 50%));
  transition: clip-path 0.45s var(--ease-out);
  pointer-events: none;
}

.option[aria-pressed="true"] .option-fill { clip-path: circle(150% at var(--x, 50%) var(--y, 50%)); }
.option-fill .option-face { background: none; }
.option-fill .option-mark { background: var(--color-on-brand); border-color: var(--color-on-brand); color: var(--color-brand); }
.option-fill .option-mark svg { opacity: 1; }

/* The check mark draws itself once the fill has spread. */
.option-fill .option-mark path { stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset 0.32s var(--ease-out) 0.12s; }
.option[aria-pressed="true"] .option-fill .option-mark path { stroke-dashoffset: 0; }

.option[aria-disabled="true"] .option-label { color: var(--color-ink-soft); }

.question-hint { margin-bottom: 12px; font-size: var(--step--1); color: var(--color-brand); }
.question-hint:empty { display: none; }

.question-actions {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 16px var(--gutter) calc(var(--safe-bottom) + 16px);
  background: var(--color-paper);
}

/* ================================================================ 4. result (as the quiz's result.css; no Buy Now) */

.result-screen.is-active { display: block; } /* one scrolling column */

.result-hero {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: calc(var(--safe-top) + 20px) var(--gutter) 36px;
  background: var(--color-brand);
  color: var(--color-on-brand);
}

.result-hero h1, .result-hero h2, .result-hero h3 { color: var(--color-on-brand); }
.result-hero-top .logo { width: min(210px, 56vw); }

/* The booth's reading drawing: the guest's face points, in white */
.reading__art { position: relative; width: min(100%, 360px); aspect-ratio: 4 / 5; margin: 0 auto; }
.reading__art canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.result-kicker {
  margin-bottom: 12px;
  font: 600 var(--step--2) / 1.4 var(--font-text);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-on-brand);
  opacity: 0.75;
}

/* The booth's one-line reading ("An oval face with…") */
.reading__headline {
  font: var(--display-weight) clamp(1.875rem, 8.4vw, 2.5rem) / 1.12 var(--font-display);
  letter-spacing: -0.01em;
  text-wrap: balance;
  outline: none;
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 20px;
  margin-top: 20px;
  font-size: var(--step--1);
}

.facts dt {
  font: 600 var(--step--2) / 1.8 var(--font-text);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  opacity: 0.75;
}

.profile { list-style: none; padding: 0; margin-top: 28px; }
.profile-item { padding: 14px 0 16px; border-top: 1px solid rgb(255 255 255 / 0.22); }

.profile-label {
  display: block;
  font: var(--display-weight) clamp(2.25rem, 11vw, 3rem) / 1.08 var(--font-display);
  letter-spacing: -0.01em;
}

.profile-text { display: block; margin-top: 6px; max-width: 36ch; font-size: var(--step--1); opacity: 0.82; }

.result-main { padding: 44px var(--gutter) calc(var(--safe-bottom) + 40px); }

/* Section titles: uppercase Montserrat, as on the brand website */
.result-heading { font: 300 var(--step-3) / 1.2 var(--font-text); letter-spacing: 0.1em; text-transform: uppercase; }
.result-note { margin-top: 10px; color: var(--color-ink-soft); max-width: 40ch; }

.product-list { list-style: none; display: grid; gap: 56px; margin-top: 28px; padding: 0; }

/* Every photo is a cut-out, straight on the backdrop and never blended, so products keep their true colours (as the quiz) */
.product-figure {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 0.9;
  margin: 0 calc(var(--gutter) * -1);
  background: var(--color-backdrop);
  border-radius: var(--radius-panel);
  overflow: hidden;
}

.product-figure img { width: 82%; height: auto; aspect-ratio: 1; object-fit: contain; }

.product-body { padding-top: 24px; }

/* The step: a small pink-red label above the name, clearly unlike it */
.product-step {
  margin-bottom: 10px;
  font: 600 var(--step--2) / 1 var(--font-text);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.product-name { font: var(--heading-weight) clamp(1.75rem, 7.6vw, 2rem) / 1.15 var(--font-display); letter-spacing: -0.005em; }

.product-line {
  margin-top: 8px;
  font: 500 var(--step--2) / 1.3 var(--font-text);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  color: var(--color-ink-soft);
}

.product-summary { margin-top: 16px; font-size: var(--step-0); max-width: 40ch; }

.product-detail { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--color-line); }

.product-detail h4 {
  margin-bottom: 8px;
  font: 600 var(--step--2) / 1.3 var(--font-text);
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
}

.product-detail p, .product-reasons { font-size: var(--step--1); color: var(--color-ink); line-height: 1.65; max-width: 44ch; }

.product-warning {
  margin-top: 20px;
  padding: 12px 14px;
  background: var(--color-backdrop);
  border-left: 3px solid var(--color-accent);
  font-size: var(--step--1);
  line-height: 1.5;
  color: var(--color-ink);
}

.result-extras { margin-top: 72px; }

.product .is-missing { display: inline-block; padding: 6px 10px; border: 1.5px dashed var(--color-accent); color: var(--color-ink); font-weight: 600; }

.product-reasons { padding-left: 1.1em; }
.product-reasons li + li { margin-top: 4px; }
.product-reasons li::marker { color: var(--color-accent); }

.result-actions { display: grid; gap: 12px; margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--color-line); }
.result-actions .fine-print { margin-top: 4px; }

/* The reveal: the black panel rises, then the words follow (the drawing draws itself). */
.result-screen.is-entering { animation: none; }
.result-screen.is-entering .result-hero { animation: panel-in 900ms cubic-bezier(0.65, 0, 0.35, 1) both; }
.result-screen.is-entering .result-hero-body { animation: rise 700ms var(--ease-out) 800ms both; }
.result-screen.is-entering .result-main { animation: rise 700ms var(--ease-out) 1100ms both; }

@keyframes panel-in { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ================================================================ wider screens (as the quiz) */

@media (min-width: 768px) {
  .quiz-slot, .quiz-header, .quiz-progress { width: 100%; max-width: 720px; margin: 0 auto; }
  .question { padding: 72px 0 0; }
  .question-text { font-size: var(--step-5); line-height: 1.1; margin-bottom: 48px; }
  .question-actions { position: static; margin-top: 32px; padding: 0 var(--gutter) 48px; }
  .question-actions .button, .notice .button { width: auto; min-width: 240px; }
  .notice__body { align-items: flex-start; }
  .guide__hint { font-size: var(--step-4); }
  .camera-bar .logo { width: 160px; }
}

/* Desktop and tablet landscape: panel on the left, words on the right */
@media (min-width: 900px) {
  .intro.is-active { display: grid; grid-template-columns: 1.1fr 1fr; }
  .start-stage { height: auto; min-height: 100%; padding: calc(var(--safe-top) + 48px) 48px 48px max(48px, var(--safe-left)); }
  .brand-lockup .logo { width: 300px; }
  .start-copy { justify-content: center; max-width: 520px; padding: 48px max(64px, var(--safe-right)) calc(var(--safe-bottom) + 48px) 64px; }
  .start-copy .button { width: auto; align-self: flex-start; min-width: 240px; }

  .result-screen.is-active { display: grid; grid-template-columns: minmax(380px, 0.9fr) 1fr; align-items: start; }
  .result-hero {
    position: sticky;
    top: 0;
    min-height: 100%;
    padding: calc(var(--safe-top) + 40px) 56px calc(var(--safe-bottom) + 56px) max(56px, var(--safe-left));
  }
  .profile-label { font-size: var(--step-6); }
  .result-hero-top .logo { width: 240px; }
  .result-main { max-width: 640px; padding: 72px max(64px, var(--safe-right)) calc(var(--safe-bottom) + 64px) 64px; }
  .product-figure { margin: 0; }
  .result-actions .button { width: auto; justify-self: start; min-width: 240px; }
}

/* ================================================================ test mode (?debug=1) */

.debug-panel {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 16px));
  max-height: 45vh;
  overflow: auto;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.82);
  color: #eeeeee;
  font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre;
  pointer-events: none;
}

body:not([data-screen='screen-camera']) .debug-panel { display: none; }

.debug-data {
  margin: 32px 0 0;
  padding: 12px;
  background: var(--color-backdrop);
  font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

/* ================================================================ reduced motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
}
