/* Draft without direction: the palette and logo are stand-ins for the client's brand.
   --accent marks the brand colour slot and appears only on the primary action,
   the progress ring and the shades frame. */
:root {
  --ink: #17140f;
  --paper: #f3efe6;
  --muted: #5a5247;
  --accent: #ff6a2b;
  --on-dark: #f3efe6;
  --on-dark-muted: #b9b0a3;
  --chip: rgba(23, 20, 15, 0.78);
  /* System fonts: nothing extra to download on a crowded event network. */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

.screen { min-height: 100dvh; }

/* Viewfinder corners: the one motif, repeated on the QR, the face guide and the photo. */
.corners {
  --c: currentColor;
  --l: 22px;
  --w: 3px;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) top left / var(--w) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--l) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--w) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--w) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--w) var(--l) no-repeat;
}

/* Buttons */
.btn {
  font: inherit;
  font-weight: 650;
  min-height: 48px;
  padding: 0 22px;
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.btn.primary { background: var(--accent); color: var(--ink); }
.btn.primary:active { transform: translateY(1px); }
.btn.secondary { background: transparent; color: inherit; border-color: currentColor; }
.btn.ghost {
  background: var(--chip);
  color: var(--on-dark);
  border-color: transparent;
}
.btn:disabled { opacity: 0.55; cursor: progress; }

.fine { font-size: 0.875rem; color: var(--muted); margin: 0; }

/* Landing */
.landing {
  display: grid;
  gap: 40px;
  align-content: center;
  padding: calc(32px + var(--safe-top)) 20px calc(32px + var(--safe-bottom));
  max-width: 560px;
  margin: 0 auto;
}
.intro { display: grid; gap: 16px; justify-items: start; }
.logo-slot {
  margin: 0 0 24px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
  border: 2px dashed var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
}
h1 {
  margin: 0;
  font-size: clamp(2.25rem, 8vw, 3.75rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.lede { margin: 0 0 8px; font-size: 1.125rem; max-width: 34ch; }
.intro .btn { width: 100%; max-width: 320px; }
.notice {
  margin: 0;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-size: 0.9375rem;
}
.status:empty { display: none; }

.qr-card {
  display: grid;
  gap: 16px;
  justify-items: center;
  text-align: center;
  padding: 28px;
  border: 2px solid var(--ink);
  border-radius: 14px;
}
.qr-card h2 { margin: 0; font-size: 1.25rem; }
.qr-frame { padding: 18px; color: var(--ink); }
.qr { width: 188px; height: 188px; }
.qr svg { width: 100%; height: 100%; display: block; }
.qr-card .fine { max-width: 30ch; }

@media (min-width: 900px) {
  .landing {
    max-width: 1040px;
    grid-template-columns: 1.3fr 1fr;
    align-items: center;
    gap: 64px;
    padding: 64px 48px;
  }
}

/* Camera */
.camera {
  position: fixed;
  inset: 0;
  background: var(--ink);
  color: var(--on-dark);
  overflow: hidden;
}
/* Kept in the DOM but invisible: iOS Safari stops decoding frames for display:none video. */
.source-video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hud {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  pointer-events: none;
}
.hud button { pointer-events: auto; }

/* Rows are pinned so a hidden guide can't let the controls slide into the stretchy middle row. */
.prompt {
  grid-row: 1;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 8px 18px 8px 8px;
  background: var(--chip);
  border-radius: 999px;
  outline: none;
}
.prompt p { margin: 0; font-size: 1.125rem; font-weight: 650; }
.ring { width: 36px; height: 36px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring .track { stroke: rgba(243, 239, 230, 0.25); }
.ring .fill {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 113.1;
}

.guide {
  --l: 34px;
  --w: 4px;
  grid-row: 2;
  align-self: center;
  justify-self: center;
  width: min(62vw, 300px);
  aspect-ratio: 3 / 4;
  color: rgba(243, 239, 230, 0.85);
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: clamp(5rem, 28vw, 9rem);
  font-weight: 800;
  color: var(--on-dark);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
}

.controls {
  grid-row: 3;
  align-self: end;
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.controls .btn.secondary { background: var(--chip); color: var(--on-dark); border-color: var(--on-dark); }

.state-panel {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  max-width: 420px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
  justify-items: center;
  text-align: center;
  padding: 24px;
  background: var(--chip);
  border-radius: 14px;
}
.state-panel p { margin: 0; font-size: 1.0625rem; }
.bar { width: 100%; height: 6px; background: rgba(243, 239, 230, 0.2); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); }

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease-out;
}
.flash.on { opacity: 0.85; transition: none; }

.debug {
  position: absolute;
  left: 8px;
  bottom: calc(150px + var(--safe-bottom));
  margin: 0;
  padding: 8px 10px;
  font: 12px/1.4 ui-monospace, Menlo, monospace;
  color: var(--on-dark);
  background: var(--chip);
  border-radius: 6px;
  pointer-events: none;
}

/* Result */
.result {
  display: grid;
  gap: 16px;
  align-content: start;
  justify-items: center;
  padding: calc(20px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  background: var(--ink);
  color: var(--on-dark);
}
.result-title { margin: 0; font-size: 1.25rem; outline: none; }
#photo {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 68dvh;
  border-radius: 6px;
}
.result-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.result-actions .btn { min-width: 150px; }
.result .btn.secondary { color: var(--on-dark); }
.result .fine { color: var(--on-dark-muted); text-align: center; max-width: 36ch; }

@media (prefers-reduced-motion: reduce) {
  .flash, .flash.on { transition: none; }
}
