/* Kino theme: CABINE, the projection booth.
   A near-black booth, one beam of light through dust falling onto the cases, film cans
   stencilled on their spines, sprocket holes down the page edges, a red tally lamp.
   Signature: the changeover cue. When the title in focus changes, the beam flickers for
   three frames and a cue dot ("cigarette burn") blinks in the top-right of the shelf.
   Everything here is scoped to [data-kino-theme='cabine'] and uses the hooks of
   docs/design/themes-contract.md. Motion is transform/opacity only. */

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

[data-kino-theme='cabine'] {
  /* booth, bench, lamp white, can grey, steel, tally red, tungsten */
  --bg: #0c0b0a; --surface: #161412; --fg: #ece4d4; --muted: #9a9185; --line: #2e2a25;
  /* #e4513a on --bg = 5.2:1, on --surface = 4.8:1 (small text OK); --accent-fg on it = 5.2:1 */
  --accent: #e4513a; --accent-fg: #0c0b0a; --accent-2: #f0c987;
  --floor: rgba(0, 0, 0, .82);
  --amb-opacity: .34; --amb-blur: 40px; --amb-radius: 0;
  --amb-clip: polygon(49% 0, 51% 0, 100% 100%, 0 100%);
  --grain-blend: screen; --grain-opacity: .38;
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-ui: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-spine: 'Stardos Stencil', Impact, 'Arial Narrow', sans-serif;
  --font-mono: 'Courier Prime', 'Courier New', ui-monospace, monospace;
  --floor-line: linear-gradient(90deg, transparent, rgba(240, 201, 135, .22) 35%, rgba(255, 236, 200, .38) 50%, rgba(240, 201, 135, .22) 65%, transparent);
  --case-shadow: 0 40px 50px -30px #000, 0 -1px 0 rgba(255, 236, 200, .14);
  --title-shadow: 0 0 22px rgba(240, 201, 135, .16);

  /* Dust and scratches, drawn in the body::before layer. Prime periods so the hairlines never
     line up into stripes. */
  --wall:
    radial-gradient(1.3px 1.3px at 23px 41px, rgba(255, 248, 232, .32), transparent) 0 0 / 173px 157px,
    radial-gradient(1px 1px at 97px 13px, rgba(255, 248, 232, .24), transparent) 0 0 / 211px 191px,
    radial-gradient(1.6px 1.1px at 61px 120px, rgba(0, 0, 0, .55), transparent) 0 0 / 149px 167px,
    repeating-linear-gradient(90deg, transparent 0 112px, rgba(236, 228, 212, .04) 112px 113px),
    repeating-linear-gradient(90deg, transparent 0 210px, rgba(236, 228, 212, .03) 210px 211px),
    repeating-linear-gradient(90deg, transparent 0 336px, rgba(0, 0, 0, .3) 336px 337px);
  --sprocket: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='24'%3E%3Crect x='3' y='7' width='8' height='10' rx='2' fill='%23ece4d4' fill-opacity='.09'/%3E%3C/svg%3E");
}

/* ---------- Page: film edges, dust, beam ---------- */

/* Sprocket strips down both edges. On the body itself so they scroll with the page, like film. */
[data-kino-theme='cabine'] body {
  background-image:
    var(--sprocket), var(--sprocket),
    linear-gradient(90deg, rgba(0, 0, 0, .32) 0 14px, transparent 14px calc(100% - 14px), rgba(0, 0, 0, .32) calc(100% - 14px));
  background-position: left top, right top, 0 0;
  background-repeat: repeat-y, repeat-y, no-repeat;
}

/* Dust layer: jumps between three positions (gate weave), denser in the upper half where the beam is. */
[data-kino-theme='cabine'] body::before {
  inset: -24px;
  -webkit-mask-image: linear-gradient(180deg, #000 0, #000 55%, rgba(0, 0, 0, .3) 100%);
  mask-image: linear-gradient(180deg, #000 0, #000 55%, rgba(0, 0, 0, .3) 100%);
  will-change: transform;
  animation: cabine-dust .36s step-end infinite;
}
@keyframes cabine-dust {
  0% { transform: translate3d(0, 0, 0); }
  33% { transform: translate3d(-17px, 9px, 0); }
  66% { transform: translate3d(11px, -13px, 0); }
}

/* The projection beam: from a point at the top centre, widening onto the shelf, with a hot
   lamp at the lens and a brighter core. Fades out before the captions so text keeps contrast. */
[data-kino-theme='cabine'] .ambient {
  top: -2vh; width: 140vw; height: 104vh;
  background-image:
    radial-gradient(18% 16% at 50% 0, rgba(255, 244, 222, .9), transparent 72%),
    linear-gradient(90deg, transparent 34%, rgba(255, 240, 214, .26) 50%, transparent 66%);
  -webkit-mask-image: linear-gradient(180deg, #000 0, #000 42%, rgba(0, 0, 0, .22) 72%, transparent 92%);
  mask-image: linear-gradient(180deg, #000 0, #000 42%, rgba(0, 0, 0, .22) 72%, transparent 92%);
}

/* Changeover cue, part 1: the beam flickers for three frames when the title in focus changes.
   Leaving captions carry data-leaving for ~650 ms after each change. */
[data-kino-theme='cabine'][data-ambient='on']:has(.cap-item[data-leaving]) .ambient {
  animation: cabine-flicker .16s step-end 1;
}
@keyframes cabine-flicker {
  0% { opacity: .1; }
  33% { opacity: .64; }
  66% { opacity: .42; }
  100% { opacity: var(--amb-opacity); }
}

/* Changeover cue, part 2: the cue dot, top-right of the shelf "screen". */
[data-kino-theme='cabine'] .shelf-viewport::after {
  content: ''; position: absolute; top: 18px; right: max(28px, 4vw); z-index: 9000;
  width: 16px; height: 16px; border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, #fff7e6 0 34%, #f0c987 56%, rgba(240, 201, 135, 0) 72%);
  box-shadow: 0 0 0 1px rgba(12, 11, 10, .55), 0 0 16px 3px rgba(240, 201, 135, .3);
}
[data-kino-theme='cabine'] .shelf:has(.cap-item[data-leaving]) .shelf-viewport::after {
  animation: cabine-cue .42s step-end 1;
}
@keyframes cabine-cue {
  0% { opacity: 1; }
  38% { opacity: .2; }
  52% { opacity: 1; }
  100% { opacity: 0; }
}

/* Changeover cue, part 3: the new caption comes up with the same 3-frame flicker.
   The caption node is recreated on each focus change, so this replays without :has(). */
[data-kino-theme='cabine'] .cap-item { animation: cabine-cap .16s step-end 1; }
[data-kino-theme='cabine'] .cap-item[data-leaving] { animation: none; }
@keyframes cabine-cap {
  0% { opacity: .3; }
  33% { opacity: .9; }
  66% { opacity: .65; }
  100% { opacity: 1; }
}

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

[data-kino-theme='cabine'] .display,
[data-kino-theme='cabine'] .page-head h1,
[data-kino-theme='cabine'] .film-title,
[data-kino-theme='cabine'] .director-head h1,
[data-kino-theme='cabine'] .profiles h1 {
  font-weight: 700; letter-spacing: .005em; text-transform: uppercase; line-height: .94;
}
[data-kino-theme='cabine'] .section-head h2,
[data-kino-theme='cabine'] .row-head h2,
[data-kino-theme='cabine'] .dir-card h3 {
  font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
}
[data-kino-theme='cabine'] .cap-title {
  font-weight: 500; letter-spacing: .04em; text-transform: uppercase;
}
[data-kino-theme='cabine'] .grid-item h3,
[data-kino-theme='cabine'] .resume-card h3,
[data-kino-theme='cabine'] .ep-num,
[data-kino-theme='cabine'] .search input { font-weight: 500; letter-spacing: .01em; }
[data-kino-theme='cabine'] .brand-mark {
  font-family: var(--font-spine); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
[data-kino-theme='cabine'] .avatar,
[data-kino-theme='cabine'] .profile-face { font-weight: 700; }

/* "KINO" stencilled on the booth wall */
[data-kino-theme='cabine'] .hero-word {
  font-family: var(--font-spine); font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  color: color-mix(in srgb, color-mix(in srgb, var(--fg) 80%, var(--accent-2)) 62%, var(--bg));
}

/* Running text stays in Barlow, sentence case: the condensed caps are for labels only */
[data-kino-theme='cabine'] .synopsis,
[data-kino-theme='cabine'] .director-head .bio {
  font-family: var(--font-ui); font-weight: 400; line-height: 1.6; letter-spacing: 0;
}
[data-kino-theme='cabine'] .byline { font-family: var(--font-mono); font-style: normal; font-size: 15px; }

/* Reel and log notes in Courier */
[data-kino-theme='cabine'] .cap-meta,
[data-kino-theme='cabine'] .tick-label,
[data-kino-theme='cabine'] .demo-note { font-family: var(--font-mono); }
[data-kino-theme='cabine'] .cap-meta { font-size: 13.5px; letter-spacing: .01em; }
[data-kino-theme='cabine'] .cap-orig,
[data-kino-theme='cabine'] .cap-meta { text-shadow: 0 1px 2px rgba(0, 0, 0, .7); }

/* Tally lamp: the red "en cours" light before the eyebrow labels and the brand */
[data-kino-theme='cabine'] .eyebrow::before,
[data-kino-theme='cabine'] .brand-sub::before {
  content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%;
  vertical-align: 1px; background: var(--accent); box-shadow: 0 0 8px 1px rgba(228, 81, 58, .55);
}

/* ---------- Spines and covers: stencilled film cans, lit from above ---------- */

[data-kino-theme='cabine'] .spine {
  background-image: linear-gradient(180deg, rgba(255, 236, 200, .13) 0, transparent 24%, transparent 58%, rgba(0, 0, 0, .46) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 236, 200, .18), inset 2px 0 0 rgba(255, 255, 255, .06), inset -3px 0 6px rgba(0, 0, 0, .4);
}
[data-kino-theme='cabine'] .spine-title {
  font-weight: 700; letter-spacing: .07em;
  text-shadow: 0 0 1px color-mix(in srgb, currentColor 45%, transparent); /* spray overspray */
}
/* Director on a strip of camera tape, typed */
[data-kino-theme='cabine'] .spine-dir {
  padding: 0 3cqw; border-radius: 1px; opacity: 1;
  font-family: var(--font-mono); font-weight: 400; letter-spacing: 0;
  background: #e6dcc4; color: #17140f; box-shadow: 0 1px 0 rgba(0, 0, 0, .35);
}
[data-kino-theme='cabine'] .spine-badge,
[data-kino-theme='cabine'] .cover-badge,
[data-kino-theme='cabine'] .cover-title { font-weight: 700; }
[data-kino-theme='cabine'] .tape .cv { border-radius: 2px; }

/* Hard black floor, its front lip caught by the beam */
[data-kino-theme='cabine'] .shelf-floor {
  background: radial-gradient(50% 50% at 50% 42%, var(--floor) 0 52%, transparent 70%);
}

/* ---------- Surfaces and controls: steel boxes, square corners ---------- */

[data-kino-theme='cabine'] .topbar {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: none; backdrop-filter: none; /* cheaper on TV */
  box-shadow: 0 1px 0 var(--line);
}
[data-kino-theme='cabine'] .resume-card,
[data-kino-theme='cabine'] .dir-card,
[data-kino-theme='cabine'] .sec-item,
[data-kino-theme='cabine'] .theme-card,
[data-kino-theme='cabine'] .episode,
[data-kino-theme='cabine'] .field input {
  border-radius: 2px; background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 236, 200, .05);
}
[data-kino-theme='cabine'] .btn,
[data-kino-theme='cabine'] .chips,
[data-kino-theme='cabine'] .back,
[data-kino-theme='cabine'] .pill,
[data-kino-theme='cabine'] .icon-btn { border-radius: 2px; }
[data-kino-theme='cabine'] .btn-primary { box-shadow: 0 0 18px -4px rgba(228, 81, 58, .5); }
[data-kino-theme='cabine'] .resume-card:hover,
[data-kino-theme='cabine'] .dir-card:hover,
[data-kino-theme='cabine'] .episode:hover,
[data-kino-theme='cabine'] .pill:hover,
[data-kino-theme='cabine'] .icon-btn:hover,
[data-kino-theme='cabine'] .shelf-arrow:hover { border-color: var(--accent-2); }
[data-kino-theme='cabine'] .cap-title:hover { color: var(--accent-2); }

/* Tungsten focus ring: the brightest thing in the booth, visible from the sofa */
[data-kino-theme='cabine'] :focus-visible { outline-color: var(--accent-2); }
[data-kino-theme='cabine'] .shelf-viewport:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-2); }

/* Section rule: a hairline over a row of perforations, like the edge of a film strip */
[data-kino-theme='cabine'] .section-head {
  border-bottom-color: var(--line);
  background: repeating-linear-gradient(90deg, rgba(236, 228, 212, .1) 0 6px, transparent 6px 16px) left 0 bottom 4px / 100% 3px no-repeat;
}

/* Edge print on the footer rule */
[data-kino-theme='cabine'] .footer::before {
  content: 'KINO 35 \25B8  5219 \25B8  BOBINE 1/1' / '';
  position: absolute; top: -8px; right: 40px; padding: 0 8px; background: var(--bg);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; color: var(--muted);
}

/* ---------- Empty state: the countdown leader (ring, crosshair, sweep) ---------- */

[data-kino-theme='cabine'] .shelf-empty { position: relative; }
[data-kino-theme='cabine'] .shelf-empty::before,
[data-kino-theme='cabine'] .shelf-empty::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 132px; height: 132px;
  margin: -66px 0 0 -66px; border-radius: 50%; pointer-events: none;
}
[data-kino-theme='cabine'] .shelf-empty::before {
  background:
    linear-gradient(rgba(236, 228, 212, .12), rgba(236, 228, 212, .12)) center / 1px 100% no-repeat,
    linear-gradient(rgba(236, 228, 212, .12), rgba(236, 228, 212, .12)) center / 100% 1px no-repeat,
    radial-gradient(circle, transparent 0 44%, rgba(236, 228, 212, .14) 45% 46%, transparent 47% 66%, rgba(236, 228, 212, .14) 67% 68.5%, transparent 69.5%);
}
[data-kino-theme='cabine'] .shelf-empty::after {
  background: conic-gradient(rgba(240, 201, 135, .16) 0 60deg, transparent 60deg);
  will-change: transform;
  animation: cabine-leader 1s linear infinite;
}
@keyframes cabine-leader { to { transform: rotate(1turn); } }

/* ---------- Phones and narrow windows ---------- */

@media (max-width: 860px) {
  /* a wider cone, so the beam still reaches both ends of the shelf on a portrait screen */
  [data-kino-theme='cabine'] .ambient { width: 220vw; height: 90vh; }
  [data-kino-theme='cabine'] .shelf-viewport::after { top: 12px; right: 16px; width: 12px; height: 12px; }
  [data-kino-theme='cabine'] .footer::before { right: 16px; }
}

/* ---------- Reduced motion: no dust, no flicker, no cue, no sweep ---------- */

@media (prefers-reduced-motion: reduce) {
  [data-kino-theme='cabine'] body::before,
  [data-kino-theme='cabine'] .ambient,
  [data-kino-theme='cabine'] .cap-item,
  [data-kino-theme='cabine'] .shelf-viewport::after,
  [data-kino-theme='cabine'] .shelf-empty::after { animation: none; }
  [data-kino-theme='cabine'] body::before { will-change: auto; }
}
