/* ==========================================================================
   Through Their Eyes — app styles
   Ported verbatim from the V2 prototype (<style> in "V2 Through Their Eyes.html"),
   reorganized by section. Design tokens (§3.5 of the coder handoff) at top.
   ========================================================================== */

/* ---------- 1. tokens ---------- */
:root {
  --bg: #111412;
  --bg-hi: #171b17;
  --bg-deep: #0b0d0b;
  --lid: #070907;
  --surface: #1a1e1a;
  --surface-2: #232823;
  --fg: #ece8dd;
  --muted: #a29d90;
  --border: rgba(255,255,255,0.10);
  --border-strong: rgba(255,255,255,0.24);
  --accent: #d9a441;
  --accent-ink: #201809;
  --accent-soft: rgba(217,164,65,0.16);
  --danger: #e2694f;
  --shadow: 0 18px 50px rgba(0,0,0,0.45);

  --font-display: 'Iowan Old Style', 'Charter', Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
}

/* ---------- 2. base ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* [hidden] must win over any display rule (the About sheet would render open otherwise). */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: radial-gradient(130% 90% at 50% 0%, var(--bg-hi) 0%, var(--bg) 58%);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px; line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
img, svg, video { display: block; }
button { font: inherit; cursor: pointer; color: inherit; }
:focus-visible { outline: 2px solid var(--border-strong); outline-offset: 2px; }
p { text-wrap: pretty; }
h1, h2 { text-wrap: balance; }

/* ---------- 3. header ---------- */
.top {
  width: 100%; max-width: 960px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 8px;
}
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-size: 18px; letter-spacing: -0.01em; }
.brand svg { width: 21px; height: 21px; }
.top-right { display: flex; align-items: center; gap: 10px; }
.tag {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 4px 9px;
}
.btn-ghost { background: none; border: none; color: var(--muted); font-size: 13.5px; padding: 7px 10px; border-radius: 8px; }
.btn-ghost:hover { color: var(--fg); }

/* ---------- 4. app column / viewport shell ---------- */
.app {
  flex: 1; min-height: 0; width: 100%; max-width: 960px; margin: 0 auto;
  display: flex; flex-direction: column; padding: 0 16px;
}
.stage { flex: 1; min-height: 210px; display: grid; }
.viewport {
  position: relative; border-radius: 18px; overflow: hidden;
  background: var(--bg-deep); border: 1px solid var(--border); box-shadow: var(--shadow);
}
/* inner vignette over the scene (z 10, between scene and controls) */
.viewport::after {
  content: ""; position: absolute; inset: 0; z-index: 10; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 0 90px rgba(0,0,0,0.38);
}
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#cssImg, #cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hidden { display: none !important; }
/* ghost: kept in the document but invisible — required so iOS Safari keeps
   serving video frames to WebGL (video must not be display:none). */
.ghost { width: 2px !important; height: 2px !important; opacity: 0 !important; pointer-events: none; top: 0; left: 0; }

/* ---------- 5. overlays inside viewport ---------- */
.spk {
  position: absolute; top: 14px; left: 14px; z-index: 20;
  max-width: min(320px, calc(100% - 128px));
  padding: 12px 16px 13px; border-radius: 14px;
  background: rgba(11,13,11,0.62); border: 1px solid var(--border);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.spk .idx {
  display: block; font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.spk h1 { margin: 2px 0 3px; font-family: var(--font-display); font-style: italic; font-weight: 500; font-size: 27px; line-height: 1.1; letter-spacing: -0.01em; }
.spk p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--muted); }

.sources {
  position: absolute; top: 14px; right: 14px; z-index: 20;
  display: flex; align-items: center; gap: 8px;
}
.chip {
  width: 46px; height: 34px; border-radius: 9px;
  border: 1px solid var(--border-strong); background-size: cover; background-position: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.chip:hover { transform: translateY(-1px); }
.chip[aria-pressed="true"] { border-color: var(--fg); box-shadow: 0 0 0 1px var(--fg) inset, 0 4px 14px rgba(0,0,0,0.35); }
.iconbtn {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: rgba(11,13,11,0.62); border: 1px solid var(--border);
  color: var(--fg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.iconbtn:hover { border-color: var(--border-strong); }
.iconbtn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.iconbtn svg { width: 19px; height: 19px; }

.compare {
  position: absolute; left: 14px; bottom: 14px; z-index: 20;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 999px; font-size: 13px;
  background: rgba(11,13,11,0.62); border: 1px solid var(--border); color: var(--fg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.compare svg { width: 16px; height: 16px; color: var(--muted); }
.compare:hover { border-color: var(--border-strong); }
.compare[aria-pressed="true"] { border-color: var(--fg); }
.compare[aria-pressed="true"] svg { color: var(--fg); }

.err {
  position: absolute; inset: 0; z-index: 25; display: grid; place-items: center; padding: 20px;
  background: rgba(11,13,11,0.55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.err-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; max-width: 340px; }
.err-card h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; letter-spacing: -0.005em; }
.err-card p { margin: 0 0 14px; font-size: 13.5px; color: var(--muted); }
.err-actions { display: flex; gap: 10px; }
.btn-secondary {
  background: transparent; color: var(--fg); border: 1px solid var(--border-strong);
  border-radius: 9px; padding: 8px 14px; font-size: 13.5px; font-weight: 500;
}
.btn-secondary:hover { border-color: var(--fg); }
.btn-text { background: none; border: none; color: var(--muted); font-size: 13.5px; padding: 8px 6px; }
.btn-text:hover { color: var(--fg); }

.intro {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px;
  background: rgba(11,13,11,0.52); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  transition: opacity 0.4s ease;
}
.intro.gone { opacity: 0; pointer-events: none; }
.intro-card { max-width: 440px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 13px; }
.intro-card .eyebrow {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted); margin: 0;
}
.intro-card h2 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: clamp(28px, 4.6vw, 36px); line-height: 1.12; letter-spacing: -0.02em; }
.intro-card p { margin: 0; font-size: 15px; line-height: 1.6; color: var(--muted); max-width: 42ch; }
.btn-primary {
  margin-top: 4px; background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 12px; padding: 12px 24px;
  font-size: 15px; font-weight: 600; letter-spacing: 0.01em;
}
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 88%, black); }
.intro-card .fine { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; margin-top: 2px; }

/* blink lids (z 40 — above everything in the viewport except loading) */
.lid {
  position: absolute; left: 0; width: 100%; height: 50.5%; z-index: 40;
  background: var(--lid); transform: scaleY(0); pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.3, 0, 0.3, 1);
}
.lid.t { top: 0; transform-origin: top center; }
.lid.b { bottom: 0; transform-origin: bottom center; }
.viewport.blink .lid { transition-duration: 0.12s; transition-timing-function: ease-in; transform: scaleY(1); }

.loading {
  position: absolute; inset: 0; z-index: 45; display: grid; place-items: center;
  background: var(--bg-deep); transition: opacity 0.45s ease;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading-inner { display: flex; flex-direction: column; align-items: center; gap: 13px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--fg); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-inner span { font-family: var(--font-mono); font-size: 12px; color: var(--muted); letter-spacing: 0.06em; }

.toast {
  position: absolute; left: 50%; bottom: 14px; z-index: 36;
  transform: translate(-50%, 8px);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px;
  color: var(--fg); font-size: 13px; padding: 9px 14px; max-width: calc(100% - 28px); text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 6. eye picker (horizontal, looped left <-> right) ---------- */
.wheelzone { position: relative; margin-top: 8px; }
.wheelwrap {
  position: relative; height: 104px; overflow: hidden; touch-action: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 10%, #000 90%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 10%, #000 90%, transparent 100%);
}
.wheel { position: absolute; inset: 0; }
.spoke {
  position: absolute; left: 0; top: 0; width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(26,30,26,0.82); border: 1px solid var(--border); color: var(--muted);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: transform 0.45s cubic-bezier(0.22, 0.85, 0.25, 1), opacity 0.25s ease, color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.spoke svg { width: 27px; height: 27px; }
.spoke:hover { color: var(--fg); border-color: var(--border-strong); }
.spoke[aria-checked="true"] {
  color: var(--accent); border-color: var(--accent);
  background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset;
}
/* while dragging: kill the transform transition for 1:1 finger tracking */
.wheel.drag .spoke { transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease; }

/* ---------- 7. about sheet ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px;
  background: rgba(5,7,5,0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.sheet {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  width: 100%; max-width: 620px; max-height: min(86dvh, 740px); overflow: auto;
  padding: 26px 26px 20px; box-shadow: var(--shadow);
}
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sheet h2 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 26px; letter-spacing: -0.015em; }
.sheet .lead { margin: 0 0 12px; font-size: 14px; line-height: 1.6; color: var(--muted); max-width: 62ch; }
.sheet .fineprint { margin: 0 0 18px; font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.sheet .fineprint strong { color: var(--fg); font-weight: 600; }
.alist { border-top: 1px solid var(--border); margin-bottom: 18px; }
.arow { display: grid; grid-template-columns: 30px 108px 1fr; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.arow svg { width: 20px; height: 20px; color: var(--muted); }
.arow .an { font-size: 13.5px; font-weight: 500; }
.arow .anote { font-size: 13px; color: var(--muted); line-height: 1.5; }
.credit { border-top: 1px solid var(--fg); padding-top: 14px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; line-height: 1.7; }

/* ---------- 8. footer ---------- */
.foot {
  padding: 9px 16px 12px; text-align: center;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em;
}

/* ---------- 9. responsive ---------- */
@media (max-width: 640px) {
  .spk { top: 10px; left: 10px; max-width: calc(100% - 104px); padding: 10px 13px 11px; }
  .spk h1 { font-size: 23px; }
  .spk p { font-size: 12.5px; }
  .sources { top: 10px; right: 10px; }
  .compare { left: 10px; bottom: 12px; }
  .brand { font-size: 16.5px; }
  .top { padding: 10px 12px 6px; }
  .top-right { gap: 4px; }
  .tag { display: none; }
  .foot { font-size: 10.5px; padding: 8px 12px 10px; overflow-wrap: anywhere; }
  .foot .f2, .foot .f3, .foot .fdot { display: none; }
  .foot .f4 { margin-left: 6px; }
  .app { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .spoke, .lid, .intro, .toast, .chip, .wheelwrap, .compare, .flip { transition: none !important; }
  .spinner { animation-duration: 1.6s; }
}

/* ---- support (buy me a coffee) ---- */
.support {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-deep);
}
.support .qr {
  width: 116px;
  height: 116px;
  flex: 0 0 auto;
  padding: 7px;
  background: #f5f2ea;
  border-radius: 8px;
  display: block;
}
.support .stxt { min-width: 0; }
.support .stitle { margin: 0 0 2px; font-weight: 600; color: var(--fg); }
.support .sdesc { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.support .suplink { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; font-size: 13px; }
.support .suplink svg { width: 17px; height: 17px; }
@media (max-width: 480px) {
  .support .qr { width: 96px; height: 96px; }
}

/* ---- safety notes ---- */
.intro-card .fine { display: block; }

/* ---- mobile dock picker + letterbox fit + fixes ---- */
body { touch-action: manipulation; }
.app { overflow: hidden; }
.wheelzone { position: absolute; left: 0; right: 0; bottom: 0; z-index: 15; pointer-events: none; }
.wheelwrap {
  margin: 0 auto; width: min(100%, 560px); height: 96px;
  background: rgba(11, 13, 11, 0.55);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 22px 22px 0 0;
  transition: transform 0.45s cubic-bezier(0.22, 0.85, 0.25, 1), background 0.3s ease;
  touch-action: none;
}
.app.dock-open .wheelwrap { background: rgba(11, 13, 11, 0.72); }
.wheelwrap.docked { transform: translateY(calc(100% - 14px)); }
.flip { position: absolute; right: 14px; bottom: 14px; z-index: 20; transition: bottom 0.35s ease, border-color 0.15s ease, background 0.15s ease; }
.compare { transition: bottom 0.35s ease, border-color 0.15s ease; }
.app.dock-open .compare { bottom: 108px; }
.app.dock-open .flip { bottom: 108px; }
@media (max-width: 640px) {
  .wheelwrap { height: 88px; }
  .flip { right: 10px; bottom: 12px; }
}
@media (max-width: 480px) {
  .spoke { width: 48px; height: 48px; }
  .spoke svg { width: 23px; height: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  .wheelwrap, .compare, .flip { transition: none !important; }
}

/* support card: never overflows, always centered */
.support { flex-wrap: wrap; justify-content: center; }
.support .stxt { flex: 1 1 220px; }
.support .suplink { max-width: 100%; flex-wrap: wrap; word-break: break-word; }
@media (max-width: 480px) {
  .support { flex-direction: column; text-align: center; }
  .support .stxt { display: flex; flex-direction: column; align-items: center; }
}
