/* IN16BARS web tokens and base components.
 *
 * Every value is taken from the app or the existing marketing:
 *   colours      marketing/tools/make_creative.py (BRIGHT, DIM, RED), the live support page
 *   heat colours SectionCardView.swift (.yellow/.orange/.red; iOS dark-mode system values)
 *   buttons      VHSButtonStyle.swift
 *   VHS effects  VHSEffect.swift (scanlines, noise, warm grade, vignette, tracking glitch, chromatic text)
 *   wordmark     ParallaxTitleView.swift (IN16 tracking 4pt, BARS tracking 10pt at 56pt)
 * Dark only, like the app. See STYLE.md for how and when to use each piece.
 * Paths assume this file sits at /style/tokens.css next to /assets/.
 */

@font-face {
  font-family: "VCR OSD Mono";
  src: url("../assets/fonts/vcr-osd-mono.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* Colour */
  --bg: #000000;            /* screen black */
  --fg: #fff5eb;            /* cream: the icon's lettering; headings and key text */
  --fg-body: #e6ded4;       /* long-form body text */
  --dim: #918b86;           /* the icon's stripe gap; OSD labels, captions, secondary text */
  --rule: #2a2724;          /* hairlines and dividers */
  --rec: #e62828;           /* the REC dot, and nothing else */
  --surface: rgb(255 255 255 / 0.10);          /* section card base */
  --button: rgb(255 255 255 / 0.15);           /* VHS button */
  --button-hover: rgb(255 255 255 / 0.25);
  --button-pressed: rgb(255 255 255 / 0.35);
  --heat-1: #ffd60a;        /* section hit 1 word  (iOS systemYellow, dark) */
  --heat-2: #ff9f0a;        /* section hit 2 words (iOS systemOrange, dark) */
  --heat-3: #ff453a;        /* section hit 3 words (iOS systemRed, dark) */
  --warm-glow: rgb(255 217 179 / 0.09);        /* centre glow behind hero art */

  /* Type */
  --font-vhs: "VCR OSD Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --font-body: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --text-osd: 15px;
  --text-small: 14px;
  --text-body: 17px;
  --text-h3: 18px;
  --text-h2: clamp(22px, 5vw, 30px);
  --text-h1: clamp(30px, 8vw, 46px);
  --text-display: clamp(44px, 13vw, 120px);
  --track-osd: 0.05em;
  --track-head: 0.04em;
  --track-display: 0.06em;

  /* Layout */
  --gutter: 16px;
  --measure: 720px;         /* text column */
  --wide: 1120px;           /* screenshot rows, hero */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
  --space-6: 64px;
  --space-7: 96px;
  --radius-panel: 12px;

  /* Effects (keep them faint: the app runs them at these strengths) */
  --scanline-page: rgb(255 255 255 / 0.025);   /* page background lines on black */
  --scanline-image: rgb(0 0 0 / 0.15);         /* lines over imagery (app value) */
  --vignette: rgb(0 0 0 / 0.7);
  --glitch: rgb(255 255 255 / 0.15);
  --noise-opacity: 0.06;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--fg);
  background: var(--bg);
  background-image: repeating-linear-gradient(to bottom, var(--scanline-page) 0 2px, transparent 2px 6px);
  font: var(--text-body)/1.6 var(--font-body);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, .vhs {
  font-family: var(--font-vhs);
  font-weight: normal;
  letter-spacing: var(--track-head);
  text-transform: uppercase;  /* write headings in normal case in the HTML */
}
h1 { font-size: var(--text-h1); line-height: 1.15; margin: 0 0 var(--space-1); }
h2 { font-size: var(--text-h2); line-height: 1.2; margin: var(--space-6) 0 var(--space-2); }
h3 { font-size: var(--text-h3); line-height: 1.3; margin: var(--space-4) 0 var(--space-1); }

p, li, dd { color: var(--fg-body); }
a { color: var(--fg); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 var(--gutter); }
.wrap--wide { max-width: var(--wide); }
.dim { color: var(--dim); }
.small { font-size: var(--text-small); }
hr, .rule { border: 0; border-top: 1px solid var(--rule); margin: var(--space-5) 0; }

/* ---------- OSD bar: PLAY ▶ on the left, ● REC on the right ---------- */

.osd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  font: var(--text-osd)/1 var(--font-vhs);
  letter-spacing: var(--track-osd);
  text-transform: uppercase;
  color: var(--dim);
}
.osd .glyph { height: 0.75em; width: auto; margin-left: 0.4em; vertical-align: baseline; }
.rec::before {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 0.5em;
  border-radius: 50%;
  background: var(--rec);
  vertical-align: -0.05em;
}

/* ---------- Wordmark ---------- */

.wordmark {
  margin: 0;
  font: var(--text-display)/1 var(--font-vhs);
  letter-spacing: var(--track-display);
  color: var(--fg);
  text-transform: uppercase;
}
/* Stacked IN16 / BARS, as on the icon and the app's title screen */
.wordmark--stacked { display: inline-grid; justify-items: center; }
.wordmark--stacked > :first-child { letter-spacing: 0.07em; }
.wordmark--stacked > :last-child { letter-spacing: 0.18em; }

/* Scanline lettering: cream rows with dim gaps, as on the icon and store art.
 * About 27 stripes per capital at large sizes, never thinner than 4px. */
.scanline-text {
  --stripe: max(4px, 0.026em);
  color: transparent;
  background: repeating-linear-gradient(
    to bottom,
    var(--fg) 0 calc(var(--stripe) * 0.625),
    var(--dim) calc(var(--stripe) * 0.625) var(--stripe)
  );
  -webkit-background-clip: text;
  background-clip: text;
}

/* Chromatic split (app ChromaticText). Display sizes only, never body text. */
.chromatic { text-shadow: -1.5px 0 rgb(255 0 0 / 0.7), 1.5px 0 rgb(0 0 255 / 0.7); }

/* ---------- Buttons and the App Store badge ---------- */

.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: 0;
  background: var(--button);
  color: var(--fg);
  font: 18px/1.2 var(--font-vhs);
  letter-spacing: var(--track-head);
  text-align: center;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--button-hover); }
.btn:active { background: var(--button-pressed); }

.badge { display: inline-block; line-height: 0; }
.badge img { height: 54px; width: auto; }  /* Apple's badge, unmodified; 40px tall minimum on screen */

/* ---------- The words ---------- */

/* Stacked, like the YOUR WORDS overlay */
.words { text-align: center; font-family: var(--font-vhs); text-transform: uppercase; }
.words__label { font-size: 12px; letter-spacing: 0.3em; color: var(--dim); }
.words__list {
  list-style: none;
  margin: var(--space-1) 0 0;
  padding: 0;
  font-size: clamp(32px, 9vw, 56px);
  line-height: 1.15;
  color: var(--fg);
}
/* Inline: LIFT · LUCKY · ROAD */
.words-inline { font-family: var(--font-vhs); letter-spacing: var(--track-osd); text-transform: uppercase; }

/* ---------- Section card (SectionCardView) ----------
 * <div class="card" data-hits="2" data-mult="3">
 *   <span class="card__index">04</span>
 *   <p class="card__lyrics">…</p>
 *   <span class="card__points">20 <b>x3</b></span>
 * </div>
 */
.card {
  --heat: transparent;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-1);
  align-items: start;
  padding: 6px 8px;
  background: var(--surface);
  font-family: var(--font-vhs);
  text-transform: uppercase;
}
.card[data-hits="1"] { --heat: var(--heat-1); }
.card[data-hits="2"] { --heat: var(--heat-2); }
.card[data-hits="3"] { --heat: var(--heat-3); }
.card:not([data-hits="0"]) {
  background:
    linear-gradient(to right,
      color-mix(in srgb, var(--heat) 90%, transparent) 0 3px,
      color-mix(in srgb, var(--heat) 22%, transparent) 3px),
    var(--surface);
}
.card[data-hits="0"] { opacity: 0.5; }  /* "dead air" */
.card__index { font-size: 10px; color: rgb(255 255 255 / 0.5); padding-top: 2px; }
.card__lyrics { margin: 0; font-size: 12px; line-height: 1.35; color: var(--fg); }
.card__points { align-self: center; white-space: nowrap; font-size: 15px; color: var(--fg); }
.card__points b { font-weight: normal; font-size: 1.4em; color: var(--heat); }

.total { font: clamp(28px, 7vw, 40px)/1 var(--font-vhs); letter-spacing: var(--track-head); text-align: center; }

/* ---------- Imagery ---------- */

/* Raw iPhone screenshots: round to the display's corner shape */
.shot { display: block; width: 100%; height: auto; border-radius: 13.7% / 6.3%; border: 1px solid var(--rule); }
/* Store composites already carry their frame and caption */
.shot--store { border: 0; border-radius: 0; }
.app-icon { border-radius: 22.37%; }

/* ---------- VHS stage: hero backdrop ---------- */

.vhs-stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: radial-gradient(ellipse at center, var(--warm-glow), transparent 70%), var(--bg);
}
/* Scanlines and vignette over everything in the stage */
.vhs-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, var(--scanline-image) 0 2px, transparent 2px 6px),
    radial-gradient(ellipse at center, transparent 55%, var(--vignette));
}
/* Film grain */
.vhs-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: var(--noise-opacity);
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* Giant ghosted "16" behind the wordmark (aria-hidden) */
.ghost-16 {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: grid;
  place-items: center;
  font: min(90vw, 80vh)/1 var(--font-vhs);
  opacity: 0.05;
  user-select: none;
  pointer-events: none;
}
/* Tracking glitch: a faint bar that flashes for 0.15 s every 4 s (app values) */
.glitch-bar {
  position: absolute;
  left: -5px;
  right: -5px;
  height: 6px;
  z-index: 3;
  background: var(--glitch);
  opacity: 0;
  pointer-events: none;
  animation: tracking 16s steps(1, end) infinite;
}
@keyframes tracking {
  0%     { opacity: 1; top: 22%; height: 4px; transform: translateX(3px); }
  0.94%  { opacity: 0; }
  25%    { opacity: 1; top: 71%; height: 8px; transform: translateX(-4px); }
  25.94% { opacity: 0; }
  50%    { opacity: 1; top: 47%; height: 3px; transform: translateX(2px); }
  50.94% { opacity: 0; }
  75%    { opacity: 1; top: 86%; height: 6px; transform: translateX(-2px); }
  75.94% { opacity: 0; }
  100%   { opacity: 0; }
}

/* Camcorder timestamp, bottom-left (decorative; see STYLE.md for the script) */
.timestamp {
  font: 12px/1.5 var(--font-vhs);
  letter-spacing: var(--track-osd);
  color: var(--dim);
  white-space: pre;
}
.timestamp .glyph { height: 1em; width: auto; vertical-align: -0.1em; margin-right: 0.4em; }

/* ---------- Accessibility ---------- */

@media (prefers-reduced-motion: reduce) {
  .glitch-bar { display: none; }
  html { scroll-behavior: auto; }
}

@media (forced-colors: active) {
  .scanline-text { color: CanvasText; background: none; }
  .chromatic { text-shadow: none; }
}
