/* camera chốn riêng, base: tokens, page column, screens and the stage. Controls are in camera-controls.css,
   the result sheet and editor in camera-sheet.css. Lamp yellow is kept for the shutter and the one primary
   button per view; selected items use the light ink. */
:root {
  --hue: 75;
  --bg: oklch(17% 0.016 var(--hue));
  --surface: oklch(21.5% 0.018 var(--hue));
  --surface-2: oklch(26% 0.02 var(--hue));
  --line: oklch(34% 0.022 var(--hue));
  --ink: oklch(94% 0.016 85);
  --ink-2: oklch(83% 0.02 82);
  --ink-3: oklch(70% 0.022 80);
  --lamp: oklch(86% 0.13 88);
  --lamp-ink: oklch(22% 0.03 80);
  --matcha: oklch(78% 0.09 135);
  --coral: oklch(74% 0.11 35);

  --font-hand: "Shantell Sans", "Be Vietnam Pro", system-ui, sans-serif;
  --font-bold: "League Spartan", "Be Vietnam Pro", system-ui, sans-serif;
  --font-body: "Be Vietnam Pro", system-ui, sans-serif;

  --step--1: 0.84rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.65rem;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --radius: 14px;
  --radius-sm: 8px;

  --dur-press: 120ms; --dur-state: 240ms;
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
}
@media (prefers-reduced-motion: reduce) {
  :root { --dur-press: 0ms; --dur-state: 0ms; }
  .spin, .stage__count b, .stage__flash, .rec-dot { animation: none !important; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 400 var(--step-0) / 1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2 { margin: 0; font-family: var(--font-hand); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: var(--step-2); }
h2 { font-size: var(--step-1); }
p { margin: 0; text-wrap: pretty; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* App column: full screen on phones, a phone-width card on desktop. */
.app {
  position: relative; display: flex; flex-direction: column;
  width: 100%; max-width: 440px; height: 100dvh; margin: 0 auto;
  padding: 0 var(--space-4);
  padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
  background: var(--bg);
}
@media (min-width: 600px) {
  body { display: grid; place-items: center; }
  .app {
    height: min(calc(100dvh - 32px), 880px); margin: 16px auto;
    border-radius: 28px; box-shadow: 0 0 0 1px var(--line), 0 24px 60px oklch(8% 0.02 var(--hue) / 0.55);
    overflow: hidden;
  }
}

.top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: max(var(--space-2), env(safe-area-inset-top)) 0 var(--space-2); flex: none; }
.back { display: inline-flex; align-items: center; gap: var(--space-1); min-height: 44px; padding-right: var(--space-2); font-size: var(--step--1); color: var(--ink-2); text-decoration: none; border-radius: 999px; }
.back:hover { color: var(--ink); }
.back .ico { width: 20px; height: 20px; }
.top__title { font-family: var(--font-hand); font-weight: 600; font-size: var(--step--1); color: var(--ink-3); }

/* Buttons. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: var(--space-2) var(--space-4); border: 0; border-radius: 999px;
  background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: var(--step--1); line-height: 1.25; text-align: center; text-decoration: none;
  transition: background var(--dur-state) var(--ease-out), transform var(--dur-press) var(--ease-out);
}
.btn:hover { background: var(--line); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn--lamp { background: var(--lamp); color: var(--lamp-ink); font-size: var(--step-0); }
.btn--lamp:hover { background: oklch(90% 0.12 88); }
.btn--line { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.btn--line:hover { background: var(--surface); }
.btn--wide { width: 100%; }
.roundbtn { display: grid; place-items: center; width: 52px; height: 52px; border: 0; border-radius: 50%; background: var(--surface-2); transition: background var(--dur-state) var(--ease-out), transform var(--dur-press) var(--ease-out); }
.roundbtn:hover { background: var(--line); }
.roundbtn:active { transform: scale(0.94); }
.roundbtn:disabled { opacity: 0.45; cursor: not-allowed; }
.roundbtn--sm { width: 44px; height: 44px; }
.linkbtn { min-height: 44px; margin: -12px -8px -12px 0; padding: 0 var(--space-3); border: 0; background: none; color: var(--lamp); font-weight: 600; font-size: var(--step--1); text-decoration: underline; text-underline-offset: 3px; }

/* Full-column screens: intro and every blocked state share one layout. */
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-4) 0; overflow-y: auto; }
.screen__art { display: grid; place-items: center; padding-top: var(--space-4); }
.art { width: min(72%, 260px); height: auto; }
.screen-light { position: fixed; inset: 0; z-index: 50; background: #fff6e6; opacity: 0; pointer-events: none; transition: opacity 120ms linear; }
.screen-light.is-on { opacity: 1; }
.perf { position: absolute; left: var(--space-3); bottom: var(--space-3); margin: 0; padding: var(--space-2); border-radius: var(--radius-sm); background: oklch(10% 0.01 var(--hue) / 0.75); color: var(--matcha); font: 500 11px / 1.35 "Chivo Mono", ui-monospace, monospace; pointer-events: none; white-space: pre; }
.screen__body { display: grid; gap: var(--space-3); margin-block: auto; }
.screen__body p { color: var(--ink-2); }
.screen__actions { display: grid; gap: var(--space-3); }
.privacy { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface); color: var(--ink-2); font-size: var(--step--1); }
.privacy .ico { width: 20px; height: 20px; margin-top: 2px; color: var(--matcha); }
.inapp-tip { display: grid; gap: var(--space-2); justify-items: start; padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface); box-shadow: inset 0 0 0 1px var(--lamp); font-size: var(--step--1); }
.inapp-tip b { color: var(--ink); }
.inapp-tip__link { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; -webkit-user-select: all; user-select: all; }
.inapp-tip__status:empty { display: none; }
html[data-inapp] [data-screen-name="denied"] .steps { display: none; } /* the address-bar steps do not exist in an app's browser */
.steps { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.steps li { display: grid; gap: 2px; padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface); font-size: var(--step--1); color: var(--ink-2); }
.steps b { font-family: var(--font-hand); font-weight: 600; color: var(--ink); font-size: var(--step-0); }

/* Camera layout: the picture takes whatever height the controls leave. */
.cam { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.stage { position: relative; flex: 1; min-height: 0; border-radius: var(--radius); overflow: hidden; background: oklch(12% 0.012 var(--hue)); }
.stage__layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
#overlay-canvas { pointer-events: none; }
.source-video { position: absolute; width: 2px; height: 2px; left: 0; top: 0; opacity: 0; pointer-events: none; }

.stage__status, .stage__rec, .stage__hint {
  position: absolute; display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-3); border-radius: 999px; font-size: var(--step--1);
  background: oklch(14% 0.016 var(--hue) / 0.78); color: var(--ink);
}
.stage__status { top: var(--space-3); left: var(--space-3); max-width: calc(100% - 24px); min-height: 32px; }
.stage__rec { top: var(--space-3); left: 50%; transform: translateX(-50%); font-variant-numeric: tabular-nums; font-weight: 600; }
.stage__rec i { width: 10px; height: 10px; border-radius: 50%; background: var(--coral); animation: blink 1s steps(2, start) infinite; }
.stage__hint { bottom: var(--space-3); left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); text-align: center; }
@keyframes blink { to { opacity: 0.25; } }

.stage__count { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.stage__count b { font-family: var(--font-hand); font-weight: 700; font-size: 7rem; line-height: 1; color: var(--ink); text-shadow: 0 2px 24px oklch(8% 0.02 var(--hue) / 0.7); animation: pop 0.9s var(--ease-out) both; }
@keyframes pop { from { transform: scale(1.5); opacity: 0; } 25% { opacity: 1; } to { transform: scale(0.9); opacity: 0.85; } }
.stage__count small { position: absolute; bottom: 14%; font-size: var(--step--1); color: var(--ink); background: oklch(14% 0.016 var(--hue) / 0.78); padding: var(--space-1) var(--space-3); border-radius: 999px; }
.stage__flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.stage__flash.is-on { animation: flash 0.28s ease-out; }
@keyframes flash { from { opacity: 0.9; } to { opacity: 0; } }

.stage__loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--space-3); background: oklch(14% 0.016 var(--hue) / 0.9); color: var(--ink-2); font-size: var(--step--1); }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--lamp); animation: spin 0.8s linear infinite; }
.spin--lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: absolute; left: 50%; bottom: var(--space-4); transform: translate(-50%, 8px); max-width: calc(100% - 32px); padding: var(--space-2) var(--space-4); border-radius: 999px; background: var(--ink); color: var(--bg); font-size: var(--step--1); font-weight: 600; opacity: 0; pointer-events: none; transition: opacity var(--dur-state) var(--ease-out), transform var(--dur-state) var(--ease-out); text-align: center; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

