/* ==========================================================================
   Base: tokens, the 1920×1080 stage, type, and shared pieces
   (caret, frosted glass, Morse symbols, the MorseTyper hint, captions).
   Art direction follows the intro and the design drafts: near-black field,
   Be Vietnam Pro Thin/Medium, coral accents, Morse dots and dashes as the
   recurring motif, frosted glass with a bright top bevel (Windows Terminal).
   ========================================================================== */

@font-face {
  font-family: Vietnam;
  src: url('../assets/fonts/BeVietnamPro-Thin.ttf') format('truetype');
  font-weight: 100;
  font-display: block;
}
@font-face {
  font-family: Vietnam;
  src: url('../assets/fonts/BeVietnamPro-Medium.ttf') format('truetype');
  font-weight: 500;
  font-display: block;
}
@font-face {
  font-family: Vietnam;
  src: url('../assets/fonts/BeVietnamPro-MediumItalic.ttf') format('truetype');
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0a0a0a;             /* the field the intro's collision leaves behind */
  --bg-raise: #141414;
  --ink: #ededed;            /* LEARNING white */
  --ink-soft: #c4c4c4;
  --ink-dim: #8d8d8d;        /* captions and labels */
  --ink-faint: #555;
  --ink-ghost: #3a3a3a;
  --line: rgba(255, 255, 255, .12);
  --line-strong: rgba(255, 255, 255, .26);
  --accent: #f0705a;         /* INTRUSIVE coral, on dark */
  --accent-deep: #cf3d20;    /* brand red */
  --accent-soft: rgba(240, 112, 90, .16);
  --accent-glow: rgba(240, 112, 90, .4);
  --pending: #6a6a6a;        /* symbols still being learned */
  --success: #78b92b;        /* MorseTyper success green */
  --glass-top: rgba(255, 255, 255, .085);
  --glass-bottom: rgba(255, 255, 255, .025);
  --glass-border: rgba(255, 255, 255, .16);
  --font: Vietnam, 'Segoe UI', system-ui, sans-serif;
  --paper-font: Georgia, 'Times New Roman', serif;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body { -webkit-font-smoothing: antialiased; }

/* ---------- Layers ---------- */
#deck { position: fixed; inset: 0; overflow: hidden; background: var(--bg); cursor: default; }
#deck.is-idle { cursor: none; }
#vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 75% 70% at 50% 47%, #1a1a1a 0%, #0d0d0d 55%, #050505 100%);
}
#dust { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#frames { position: absolute; inset: 0; pointer-events: none; }
#frames iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}
#stage-wrap { position: absolute; inset: 0; overflow: hidden; }
#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1080px;
  transform-origin: 0 0;
  overflow: visible;
}
#grain {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.94' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23fff' filter='url(%23n)' opacity='.6' d='M0 0h180v180H0z'/%3E%3C/svg%3E");
}

.scene { position: absolute; inset: 0; }
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.abs { position: absolute; }

/* ---------- Type ---------- */
.kicker {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.kicker b { color: var(--accent); font-weight: 500; }
.headline { font-size: 68px; font-weight: 100; letter-spacing: .005em; line-height: 1.12; -webkit-text-stroke: .6px currentColor; }
.headline strong { font-weight: 500; -webkit-text-stroke: 0; }
.label {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.thin { font-weight: 100; -webkit-text-stroke: .5px currentColor; }
.medium { font-weight: 500; }
.accent { color: var(--accent); }
.dim { color: var(--ink-dim); }

/* Letters split for signal entries and forgetting */
.ch { display: inline-block; white-space: pre; }
.word { display: inline-block; white-space: nowrap; }

/* ---------- Caret (blink timing of the app: 1.06 s) ---------- */
.caret {
  display: inline-block;
  width: .085em;
  min-width: 4px;
  height: 1.08em;
  margin-left: .06em;
  vertical-align: -.2em;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 18px var(--accent-glow);
  animation: caret-blink 1.06s steps(1) infinite;
}
.caret[data-typing="1"] { animation: none; opacity: 1; }
.caret[data-off="1"] { visibility: hidden; }
@keyframes caret-blink { 50% { opacity: 0; } }

/* ---------- Frosted glass ---------- */
.glass {
  position: absolute;
  border-radius: 22px;
  border: 1.5px solid var(--glass-border);
  background: linear-gradient(180deg, var(--glass-top), var(--glass-bottom) 60%);
  -webkit-backdrop-filter: blur(26px) saturate(1.25);
  backdrop-filter: blur(26px) saturate(1.25);
  box-shadow:
    inset 0 1.5px 0 rgba(255, 255, 255, .22),
    inset 0 -1px 0 rgba(255, 255, 255, .04),
    0 40px 90px rgba(0, 0, 0, .55),
    0 4px 14px rgba(0, 0, 0, .35);
  overflow: hidden;
}
/* A soft light sweep across the glass, like a softbox in the reflection */
.glass::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .06) 45%, transparent 60%);
}

/* ---------- Morse symbols (dot = 1, dash ≈ 2.8 wide, as in the mark) ---------- */
.morse { display: inline-flex; align-items: center; gap: .32em; vertical-align: middle; }
.morse i {
  display: block;
  flex: none;
  width: .42em;
  height: .42em;
  border-radius: 1em;
  background: currentColor;
}
.morse i.dash { width: 1.18em; }
.morse.outline i { background: transparent; box-shadow: inset 0 0 0 .08em currentColor; }

/* ---------- Signal particles (letters arriving as Morse, after the intro) ---------- */
.sig {
  position: absolute;
  display: grid;
  place-items: center;
  transform-origin: 50% 50%;
  pointer-events: none;
  will-change: transform, opacity, filter;
}
.sig-code { display: flex; gap: .16em; align-items: center; justify-content: center; }
.sig-code i { display: block; width: .13em; height: .13em; border-radius: 1em; background: currentColor; box-shadow: 0 0 .2em rgba(255, 220, 200, .5); }
.sig-code i.dash { width: .42em; }
.sig-glyph { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); white-space: pre; opacity: 0; }

/* ---------- MorseTyper caret hint (geometry and colours of the app,
   as in resources/web-demo: 30 px tall pill, symbols 4.5 / 12.5 px) ---------- */
.mt-hint {
  --s: 2.6;
  position: absolute;
  height: calc(30px * var(--s));
  border-radius: calc(15px * var(--s));
  background: #e0e0e0;
  box-shadow: 0 calc(8px * var(--s)) calc(22px * var(--s)) rgba(0, 0, 0, .45);
  transform-origin: 0 0;
  font-weight: 500;
}
.mt-hint-letter {
  position: absolute;
  left: calc(8px * var(--s));
  top: 0;
  width: calc(20px * var(--s));
  height: calc(30px * var(--s));
  display: grid;
  place-items: center;
  font-size: calc(20px * var(--s));
  line-height: 1;
  color: var(--accent-deep);
}
.mt-hint-divider {
  position: absolute;
  left: calc(32px * var(--s));
  top: calc(8px * var(--s));
  width: max(1px, calc(1px * var(--s)));
  height: calc(14px * var(--s));
  background: rgba(47, 47, 47, .22);
}
.mt-hint-code {
  position: absolute;
  left: calc(39px * var(--s));
  top: 0;
  height: calc(30px * var(--s));
  display: flex;
  align-items: center;
  gap: calc(3px * var(--s));
}
.mt-hint-code i {
  display: block;
  flex: none;
  width: calc(4.5px * var(--s));
  height: calc(4.5px * var(--s));
  border-radius: calc(3px * var(--s));
  background: rgba(47, 47, 47, .2);
}
.mt-hint-code i.dash { width: calc(12.5px * var(--s)); }
.mt-hint-code i.on { background: var(--accent-deep); }
.mt-hint.is-correct .mt-hint-code i { background: var(--success); }

/* ---------- Captions (optional; C toggles) ---------- */
.captions {
  position: absolute;
  left: 50%;
  bottom: 46px;
  z-index: 50;
  width: 1500px;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .4s ease;
}
.captions.is-on { opacity: 1; }
.caption-line {
  max-width: 1500px;
  padding: 14px 28px 16px;
  border-radius: 14px;
  background: rgba(8, 8, 8, .78);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
  font-size: 31px;
  font-weight: 500;
  line-height: 1.42;
  letter-spacing: .005em;
  text-align: center;
  color: #f2f2f2;
  transition: opacity .25s ease;
}
.caption-line:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  .caret { animation: none; }
}
