/* Kino theme: CONSOLE — a 1970s sci-fi control room.
   Amber phosphor for anything you can act on, cyan for instruments and labels, on slate.
   Ornaments (CSS only): scanlines, graticule wall, a lit grid floor that takes the poster's
   colour, a fixed targeting reticle around the case in focus, corner brackets as the
   focus ring, and a readout line that types itself in under the caption.
   Michroma (display, uppercase, used sparingly), IBM Plex Sans Condensed (UI),
   IBM Plex Mono (numbers, metadata, badges), Saira Condensed (spines).
   Motion: transform and opacity only. Everything is off under prefers-reduced-motion. */

/* ---------- Tokens ---------- */

[data-kino-theme='console'] {
  --bg: #0a141b; --surface: #0f1f29; --fg: #d6e4e6; --muted: #8aa3ab; --line: #1d3642;
  --accent: #ffb000; --accent-fg: #140c00; --accent-2: #4fd1d9;
  --floor: rgba(0, 0, 0, .55); --amb-opacity: .36;
  --amb-blur: 70px; --amb-radius: 40% / 30%;
  --font-display: 'Michroma', 'Eurostile', 'Square 721', sans-serif;
  --font-ui: 'IBM Plex Sans Condensed', 'Arial Narrow', system-ui, sans-serif;
  --font-spine: 'Saira Condensed', 'Arial Narrow', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', monospace;

  /* Scanlines replace the paper grain: dark 1px lines every 3px, multiplied, kept faint. */
  --grain-image: repeating-linear-gradient(0deg, rgba(0, 0, 0, .55) 0 1px, transparent 1px 3px);
  --grain-blend: multiply; --grain-opacity: .3;

  /* Graticule wall: 48px cyan grid with "+" marks every 96px, under a CRT vignette. */
  --wall:
    radial-gradient(120% 90% at 50% 38%, transparent 55%, rgba(0, 0, 0, .5) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96'%3E%3Cg fill='none' stroke='%234fd1d9'%3E%3Cpath d='M0 .5H96M.5 0V96M0 48.5H96M48.5 0V96' stroke-opacity='.055'/%3E%3Cpath d='M0 .5h6M90 .5h6M.5 0v6M.5 90v6' stroke-opacity='.3'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 96px 96px;

  --floor-line: linear-gradient(90deg, transparent, rgba(79, 209, 217, .7) 30%, #bdf6f9 50%, rgba(79, 209, 217, .7) 70%, transparent);
  --case-shadow: 0 26px 40px -24px rgba(0, 0, 0, .9), -1px 0 0 rgba(79, 209, 217, .4);
  --title-shadow: 0 0 18px rgba(255, 176, 0, .22);

  /* Private tokens (kc = Kino Console) */
  --kc-panel: #0c1a22;                     /* readout window; also the typing shutter */
  --kc-read: #a9c2c8;                      /* readout text, 9.6:1 on --kc-panel */
  --kc-grid: color-mix(in srgb, color-mix(in srgb, var(--accent-2), var(--amb) 40%) 42%, transparent);
  --kc-c: var(--accent-2);                 /* bracket colour */
  --kc-arm: 10px;                          /* bracket arm length */
  --kc-w: 2px;                             /* bracket stroke */
  --kc-step: steps(3, end);
  color-scheme: dark;
}

/* Four L-shaped corners drawn with eight background strokes. Shared by the focus ring,
   the shelf reticle and the focused viewport. */
[data-kino-theme='console'] :focus-visible,
[data-kino-theme='console'] .shelf-viewport::after {
  background-image:
    linear-gradient(var(--kc-c), var(--kc-c)), linear-gradient(var(--kc-c), var(--kc-c)),
    linear-gradient(var(--kc-c), var(--kc-c)), linear-gradient(var(--kc-c), var(--kc-c)),
    linear-gradient(var(--kc-c), var(--kc-c)), linear-gradient(var(--kc-c), var(--kc-c)),
    linear-gradient(var(--kc-c), var(--kc-c)), linear-gradient(var(--kc-c), var(--kc-c));
  background-position: 0 0, 0 0, 100% 0, 100% 0, 0 100%, 0 100%, 100% 100%, 100% 100%;
  background-size:
    var(--kc-arm) var(--kc-w), var(--kc-w) var(--kc-arm),
    var(--kc-arm) var(--kc-w), var(--kc-w) var(--kc-arm),
    var(--kc-arm) var(--kc-w), var(--kc-w) var(--kc-arm),
    var(--kc-arm) var(--kc-w), var(--kc-w) var(--kc-arm);
  background-repeat: no-repeat;
}

/* ---------- Focus: corner brackets replace the ring ---------- */

[data-kino-theme='console'] :focus-visible { outline: none; }
[data-kino-theme='console'] .shelf-viewport:focus-visible {
  box-shadow: none; --kc-arm: 22px; --kc-c: color-mix(in srgb, var(--accent-2) 70%, transparent);
}
[data-kino-theme='console'] .btn-primary:focus-visible { --kc-c: var(--accent-fg); --kc-w: 3px; }
[data-kino-theme='console'] .chip[aria-pressed='true']:focus-visible { --kc-c: var(--accent-fg); }
[data-kino-theme='console'] :is(.btn, .icon-btn, .chip, .back, .pill, .shelf-arrow, .episode, .field input):focus-visible {
  border-color: color-mix(in srgb, var(--accent-2) 45%, transparent);
}

/* ---------- Page, light, wall ---------- */

[data-kino-theme='console'] body { letter-spacing: .005em; }
[data-kino-theme='console'] .ambient { top: -20vh; width: 140vw; height: 66vh; }
[data-kino-theme='console'] ::selection { background: var(--accent); color: var(--accent-fg); }

/* ---------- Type ---------- */

[data-kino-theme='console'] :is(.display, .cap-title, .brand-mark, .hero-word, .section-head h2, .row-head h2, .dir-card h3, .avatar, .profile-face) {
  font-weight: 400; text-transform: uppercase; letter-spacing: .06em;
}
[data-kino-theme='console'] .page-head h1 { font-size: clamp(26px, 3.4vw, 44px); line-height: 1.1; }
[data-kino-theme='console'] .film-title { font-size: clamp(28px, 3.6vw, 52px); line-height: 1.14; }
[data-kino-theme='console'] .director-head h1 { font-size: clamp(30px, 4vw, 58px); line-height: 1.1; }
[data-kino-theme='console'] .profiles h1 { font-size: clamp(26px, 3.8vw, 48px); line-height: 1.15; }
[data-kino-theme='console'] .empty-home h2 { font-size: 24px; }

[data-kino-theme='console'] .eyebrow {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: .22em; color: var(--accent-2);
}
[data-kino-theme='console'] .eyebrow::before {
  content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 10px; vertical-align: 1px;
  background: var(--accent); box-shadow: 0 0 8px rgba(255, 176, 0, .6);
}
[data-kino-theme='console'] .meta {
  font-family: var(--font-mono); font-weight: 500; letter-spacing: .08em; color: var(--kc-read);
}
[data-kino-theme='console'] :is(.synopsis, .bio) {
  font-family: var(--font-ui); font-size: 19px; line-height: 1.58; color: var(--fg);
}
[data-kino-theme='console'] .byline { font-family: var(--font-ui); font-style: normal; }
[data-kino-theme='console'] .byline a { text-decoration-color: var(--accent); text-underline-offset: 3px; }
[data-kino-theme='console'] :is(.resume-card h3, .grid-item h3) {
  font-family: var(--font-ui); font-weight: 600; font-size: 17px; letter-spacing: .01em;
}
[data-kino-theme='console'] .dir-card h3 { font-size: 18px; line-height: 1.35; }
[data-kino-theme='console'] :is(.tick-label, .legend, .ep-time, .footer, .profile-tag) {
  font-family: var(--font-mono); font-weight: 500;
}
[data-kino-theme='console'] .footer { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
[data-kino-theme='console'] .tech dt { font-family: var(--font-mono); font-weight: 500; font-size: 10px; letter-spacing: .2em; color: var(--accent-2); }
[data-kino-theme='console'] .tech dd { font-size: 13px; letter-spacing: .02em; }
[data-kino-theme='console'] kbd { border-color: color-mix(in srgb, var(--accent-2) 50%, transparent); border-radius: 0; color: var(--accent-2); }

/* Badges on cases and spines: mono, like stamped part numbers */
[data-kino-theme='console'] .cover-badge { font-family: var(--font-mono); font-weight: 500; letter-spacing: .06em; border-width: .5cqw; }
[data-kino-theme='console'] .spine-badge { font-family: var(--font-mono); font-weight: 500; font-size: 15cqw; border-width: 1.5cqw; }

/* ---------- Top bar ---------- */

[data-kino-theme='console'] .topbar { box-shadow: inset 0 -1px 0 var(--line); }
[data-kino-theme='console'] .brand-mark { font-size: 21px; letter-spacing: .16em; }
[data-kino-theme='console'] .brand-sub { font-family: var(--font-mono); font-size: 10px; letter-spacing: .24em; color: var(--accent-2); }
[data-kino-theme='console'] .mainnav a { font-size: 13px; letter-spacing: .16em; }
[data-kino-theme='console'] .mainnav a[aria-current='page'] {
  color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent), 0 6px 14px -10px var(--accent);
}
[data-kino-theme='console'] .avatar { border-radius: 3px; font-size: 15px; letter-spacing: 0; }

/* ---------- Controls: square, hairline, amber when live ---------- */

[data-kino-theme='console'] :is(.icon-btn, .chips, .back, .pill, .shelf-arrow) { border-radius: 2px; }
[data-kino-theme='console'] :is(.resume-card, .dir-card, .theme-card, .sec-item, .episode, .missing-note) { border-radius: 2px; }
[data-kino-theme='console'] :is(.btn, .chip, .icon-btn, .back) { font-size: 13px; letter-spacing: .16em; }
[data-kino-theme='console'] .btn { border-radius: 0; }
[data-kino-theme='console'] .btn-primary { box-shadow: 0 0 22px -6px rgba(255, 176, 0, .55), inset 0 -2px 0 rgba(0, 0, 0, .22); }
[data-kino-theme='console'] :is(.icon-btn, .back, .pill, .shelf-arrow, .resume-card, .dir-card, .episode):hover {
  border-color: var(--accent-2);
}
[data-kino-theme='console'] .shelf-arrow { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 35%, transparent); }
[data-kino-theme='console'] .shelf-arrow:hover { color: var(--accent); border-color: var(--accent); }

/* Progress: a segmented amber LED bar */
[data-kino-theme='console'] .progress { border-radius: 0; background: var(--line); }
[data-kino-theme='console'] .progress span {
  background: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 8px);
}

/* Timeline: square markers on a cyan axis */
[data-kino-theme='console'] .timeline-axis { border-top-color: color-mix(in srgb, var(--accent-2) 60%, transparent); }
[data-kino-theme='console'] .tick { background: var(--accent-2); }
[data-kino-theme='console'] .tl-dot,
[data-kino-theme='console'] .legend span::before { border-radius: 1px; }
[data-kino-theme='console'] .tl-dot.is-active { box-shadow: 0 0 0 4px rgba(255, 176, 0, .22), 0 0 14px rgba(255, 176, 0, .5); }

[data-kino-theme='console'] .ep-num { font-family: var(--font-mono); font-size: 18px; font-weight: 500; }
[data-kino-theme='console'] .episode.is-current { box-shadow: inset 3px 0 0 var(--accent); }

/* Section rules: a short amber segment lights the start of each hairline */
[data-kino-theme='console'] .section-head {
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 56px 2px no-repeat;
}
[data-kino-theme='console'] .section-head h2 { font-size: 17px; letter-spacing: .1em; }
[data-kino-theme='console'] .row-head h2 { font-size: clamp(16px, 1.5vw, 20px); letter-spacing: .1em; }

/* Forms and search: mono input, a prompt glyph */
[data-kino-theme='console'] .field input {
  border-radius: 0; background: var(--kc-panel); font-family: var(--font-mono); font-size: 15px;
}
[data-kino-theme='console'] .field input:focus { border-color: var(--accent); box-shadow: none; }
[data-kino-theme='console'] .search input {
  font-family: var(--font-mono); font-size: clamp(22px, 3vw, 36px); caret-color: var(--accent);
}
[data-kino-theme='console'] .search-top::before {
  content: '>'; font-family: var(--font-mono); font-size: clamp(22px, 3vw, 36px); color: var(--accent);
}

/* ---------- Home hero: the word as an outlined bulkhead stencil ---------- */

[data-kino-theme='console'] .hero-word {
  font-size: clamp(80px, 15vw, 250px); line-height: 1; letter-spacing: .08em;
  color: transparent; -webkit-text-stroke: 1px rgba(79, 209, 217, .32); text-shadow: none; opacity: 1;
}

/* ---------- Shelf: lit grid floor ---------- */

[data-kino-theme='console'] .shelf-floor {
  background:
    radial-gradient(50% 55% at 50% 45%, color-mix(in srgb, var(--amb) 26%, transparent), transparent 70%),
    linear-gradient(90deg, var(--kc-grid) 1px, transparent 1px) 50% 0 / 28px 100%,
    linear-gradient(var(--kc-grid) 1px, transparent 1px) 0 0 / 100% 12px,
    radial-gradient(50% 50% at 50% 40%, var(--floor), transparent 72%);
  -webkit-mask-image: radial-gradient(closest-side, #000 35%, transparent);
  mask-image: radial-gradient(closest-side, #000 35%, transparent);
  transform: translate(-50%, -50%) perspective(520px) rotateX(66deg) scale(1.2, 3.4);
}
[data-kino-theme='console'] .shelf-floor::after { height: 1px; box-shadow: 0 0 6px rgba(79, 209, 217, .6); }

/* ---------- Shelf: targeting reticle around the case in focus ----------
   The focused case always settles at the centre of the viewport, so the reticle is
   fixed there and the shelf slides through it. Sizes follow --d / --H from shelf.js. */

[data-kino-theme='console'] .shelf-viewport::after {
  content: ''; position: absolute; left: 50%; top: 50%; z-index: 2; pointer-events: none;
  --kc-arm: 18px; --kc-c: color-mix(in srgb, var(--accent-2) 80%, transparent);
  width: calc(var(--d) * 1.04 + 26px); height: calc(var(--H) * 1.04 + 26px);
  transform: translate(-50%, calc(-50% - var(--H) * .025)) rotate(-4.5deg);
  opacity: .85;
}
[data-kino-theme='console'] .shelf--arc .shelf-viewport::after {
  --kc-arm: 24px;
  width: calc(var(--d) * 1.05 + 30px); height: calc(var(--H) * 1.05 + 30px);
  transform: translate(-50%, calc(-50% + var(--H) * .012));
}
[data-kino-theme='console'] .shelf-viewport:focus-visible::after {
  --kc-c: var(--accent); --kc-w: 3px; opacity: 1;
  animation: kc-lock .36s steps(3, end) both;
}
[data-kino-theme='console'] .shelf--arc .shelf-viewport:focus-visible::after { animation-name: kc-lock-arc; }

/* ---------- Caption: label, title, typed readout ---------- */

[data-kino-theme='console'] .cap-title { font-size: clamp(18px, 1.9vw, 26px); line-height: 1.3; }
[data-kino-theme='console'] .shelf--straight .cap-title { font-size: clamp(15px, 1.35vw, 19px); }
[data-kino-theme='console'] .cap-orig {
  font-family: var(--font-mono); font-weight: 500; letter-spacing: .2em; color: var(--accent-2);
}

/* The readout window: a mono line in a slate panel with a cyan tab. */
[data-kino-theme='console'] .cap-meta {
  position: relative; display: inline-block; max-width: 100%; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
  margin-top: 3px; padding: 2px 10px 2px 12px;
  background: var(--kc-panel); box-shadow: inset 2px 0 0 var(--accent-2), 0 0 0 1px var(--line);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--kc-read);
}
/* Shutter: a panel-coloured block led by an amber cursor, stepping right to "type" the line.
   Its resting state is off to the right, so with no animation the text is simply shown. */
[data-kino-theme='console'] .cap-meta::before {
  content: ''; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(90deg, var(--accent) 0 .62em, var(--kc-panel) .62em);
  transform: translateX(101%);
  animation: kc-type 1s steps(26, end) .35s backwards;
}
/* Resting block cursor after the last character, blinking once the line is typed. */
[data-kino-theme='console'] .cap-meta::after {
  content: ''; display: inline-block; width: .6em; height: 1.05em; margin-left: .4em; vertical-align: -.2em;
  background: var(--accent);
  animation: kc-blink 1.1s linear 1.4s infinite;
}
[data-kino-theme='console'] .cap-item[data-leaving] .cap-meta::after { animation: none; opacity: 0; }

/* Graticule scale under the caption, drawn out from the centre in steps. */
[data-kino-theme='console'] .cap-item::after {
  content: ''; display: block; width: min(300px, 70%); height: 6px; margin-top: 5px;
  background:
    linear-gradient(rgba(79, 209, 217, .45), rgba(79, 209, 217, .45)) 0 100% / 100% 1px no-repeat,
    repeating-linear-gradient(90deg, rgba(79, 209, 217, .55) 0 1px, transparent 1px 10px) 0 100% / 100% 4px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 50% 100% / 2px 6px no-repeat;
  animation: kc-scale .4s steps(6, end) .1s backwards;
}

/* ---------- Keyframes (transform / opacity only) ---------- */

@keyframes kc-type { from { transform: translateX(0); } to { transform: translateX(101%); } }
@keyframes kc-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes kc-scale { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes kc-lock {
  from { transform: translate(-50%, calc(-50% - var(--H) * .025)) rotate(-4.5deg) scale(1.12); opacity: 0; }
  to { transform: translate(-50%, calc(-50% - var(--H) * .025)) rotate(-4.5deg) scale(1); opacity: 1; }
}
@keyframes kc-lock-arc {
  from { transform: translate(-50%, calc(-50% + var(--H) * .012)) scale(1.12); opacity: 0; }
  to { transform: translate(-50%, calc(-50% + var(--H) * .012)) scale(1); opacity: 1; }
}

/* ---------- Phones and small tablets ---------- */

@media (max-width: 860px) {
  [data-kino-theme='console'] {
    --grain-opacity: .22;
    --wall:
      radial-gradient(130% 90% at 50% 30%, transparent 50%, rgba(0, 0, 0, .5) 100%),
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96'%3E%3Cg fill='none' stroke='%234fd1d9'%3E%3Cpath d='M0 .5H96M.5 0V96' stroke-opacity='.05'/%3E%3Cpath d='M0 .5h6M90 .5h6M.5 0v6M.5 90v6' stroke-opacity='.28'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 96px 96px;
  }
  [data-kino-theme='console'] .ambient { top: -14vh; height: 52vh; }
  [data-kino-theme='console'] .brand-mark { font-size: 18px; }
  [data-kino-theme='console'] .hero-word { font-size: clamp(56px, 17vw, 120px); }
  [data-kino-theme='console'] .cap-title { font-size: clamp(15px, 4.4vw, 20px); }
  [data-kino-theme='console'] .shelf--straight .cap-title { font-size: 15px; }
  [data-kino-theme='console'] .cap-meta { font-size: 11px; letter-spacing: .02em; }
  [data-kino-theme='console'] .shelf-viewport::after { --kc-arm: 12px; }
  [data-kino-theme='console'] .shelf--arc .shelf-viewport::after { --kc-arm: 14px; }
  [data-kino-theme='console'] .shelf-floor { transform: translate(-50%, -50%) perspective(380px) rotateX(64deg) scale(1.1, 3); }
  [data-kino-theme='console'] :is(.synopsis, .bio) { font-size: 17px; }
  [data-kino-theme='console'] .search-top::before { display: none; }
}

/* ---------- Reduced motion: steady cursor, no typing, no lock-on ---------- */

@media (prefers-reduced-motion: reduce) {
  [data-kino-theme='console'] .cap-meta::before { animation: none; transform: translateX(101%); }
  [data-kino-theme='console'] .cap-meta::after,
  [data-kino-theme='console'] .cap-item::after,
  [data-kino-theme='console'] .shelf-viewport::after { animation: none; }
}
