/*
 * asciitube.com: a video site's layout (masthead with one field, rail, chips, a grid of 16:9 tiles,
 * a watch page with the picture large and "up next" beside it), drawn as a text interface: one
 * monospace face, 1 px rules, square frames, no shadows, one accent (phosphor green), every picture
 * ASCII. Dark by default; "paper" when the system is light. Video screens are always black.
 * Nothing here is YouTube's: no red, no Roboto, no pill buttons, no play-triangle mark.
 */
:root {
  color-scheme: dark;
  --bg: #0b0b0b;
  --surface: #121212;
  --surface-2: #1b1b1b;
  --line: #2a2a2a;
  --line-strong: #3d3d3d;
  --fg: #e8e8e8;
  --muted: #8f8f8f;
  --accent: #7cf29a;
  --accent-ink: #07130b;
  --danger: #ff8a7a;
  --screen-fg: #e8e8e8;
  --screen-muted: #9a9a9a;
  --masthead-h: 56px;
  --rail-w: 220px;
  --hit: 36px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f1ea;
    --surface: #ece8de;
    --surface-2: #e3ded1;
    --line: #d2cbbb;
    --line-strong: #aea591;
    --fg: #1b1b1b;
    --muted: #5c574d;
    --accent: #0a7a3a;
    --accent-ink: #f4f1ea;
    --danger: #b3261e;
  }
}
@media (pointer: coarse) {
  :root { --hit: 44px; }
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--masthead-h) + 12px); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.55 var(--mono); }
body { min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
code { font: inherit; color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; padding: 8px 12px; background: var(--accent); color: var(--accent-ink); }
.skip:focus { top: 8px; }

/* Buttons: square, 1 px frame. */
button { font: inherit; color: inherit; }
.button, .panel-action { display: inline-flex; align-items: center; gap: 8px; min-height: var(--hit); padding: 6px 14px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--fg); cursor: pointer; text-decoration: none; }
.button:hover, .panel-action:hover { border-color: var(--fg); }
.button-primary, .panel-action { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.button-primary:hover, .panel-action:hover { border-color: var(--fg); }
.button-quiet { background: transparent; }
.link-button { padding: 0; border: 0; background: none; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.icon-button { display: inline-grid; place-items: center; min-width: var(--hit); height: var(--hit); padding: 0 8px; border: 1px solid transparent; background: transparent; color: var(--fg); cursor: pointer; }
.icon-button:hover:not(:disabled) { border-color: var(--line-strong); }
button:disabled { opacity: 0.4; cursor: default; }

/* Masthead: mark, the one field, the extension. */
.masthead { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: var(--masthead-h); padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.rail-toggle { font-size: 20px; }
.brand { flex: none; display: inline-flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; font-weight: 700; font-size: 17px; letter-spacing: 0.02em; }
.brand .mark { width: 15px; height: 21px; color: var(--accent); flex: none; }
.search { display: flex; flex: 1 1 auto; min-width: 0; max-width: 640px; margin: 0 auto; }
.search input { flex: 1; min-width: 0; height: 40px; padding: 0 12px; font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line-strong); border-right: 0; border-radius: 0; -webkit-appearance: none; appearance: none; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.search input[aria-invalid="true"] { border-color: var(--danger); }
.search input[aria-invalid="true"]:focus-visible { outline-color: var(--danger); }
.search-go { width: 52px; height: 40px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--fg); cursor: pointer; font-size: 17px; }
.search-go:hover { border-color: var(--fg); }
.search-message { margin: 0; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); text-align: center; overflow-wrap: anywhere; }
.search-message[data-kind="error"] { color: var(--danger); }
.search-message[hidden] { display: none; }
.get-extension { white-space: nowrap; }

/* Shell: rail + main. The rail is a drawer below 1100 px. */
.shell { flex: 1; display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.rail { position: sticky; top: var(--masthead-h); align-self: start; max-height: calc(100vh - var(--masthead-h)); overflow: auto; padding: 16px 12px 24px; border-right: 1px solid var(--line); }
.rail-nav { list-style: none; margin: 0; padding: 0; }
.rail-nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; color: var(--fg); text-decoration: none; border: 1px solid transparent; }
.rail-nav a:hover { border-color: var(--line-strong); }
.rail-nav a[aria-current="page"] { color: var(--accent); border-color: var(--line); background: var(--surface); }
.rail-nav a span { width: 1.2em; text-align: center; color: var(--muted); }
.rail-nav a[aria-current="page"] span { color: var(--accent); }
.rail-settings { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.rail-heading { margin: 0 10px 8px; color: var(--muted); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.rail-group { margin: 0 0 12px; padding: 0 10px; border: 0; }
.rail-group legend { padding: 0; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.radio { display: flex; align-items: center; gap: 8px; min-height: 32px; cursor: pointer; }
.radio input { -webkit-appearance: none; appearance: none; margin: 0; width: 3ch; height: 1.2em; font: inherit; color: var(--muted); cursor: pointer; }
.radio input::before { content: "( )"; }
.radio input:checked::before { content: "(•)"; color: var(--accent); }
.radio input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rail-toggle { display: none; }
/* The watch page has no rail column either (the video gets the width; see .watch). */
body[data-page="watch"] .rail-toggle { display: inline-grid; }
body[data-page="watch"] .shell { grid-template-columns: minmax(0, 1fr); }
body[data-page="watch"] .rail { position: fixed; top: var(--masthead-h); left: 0; bottom: 0; z-index: 25; width: min(280px, 85vw); max-height: none; background: var(--bg); transform: translateX(-102%); visibility: hidden; }
body[data-page="watch"].rail-open .rail { transform: none; visibility: visible; }
body[data-page="watch"].rail-open::after { content: ""; position: fixed; inset: var(--masthead-h) 0 0 0; z-index: 24; background: rgba(0, 0, 0, 0.5); }
@media (max-width: 1099px) {
  .rail-toggle { display: inline-grid; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; top: var(--masthead-h); left: 0; bottom: 0; z-index: 25; width: min(280px, 85vw); max-height: none; background: var(--bg); transform: translateX(-102%); visibility: hidden; }
  body.rail-open .rail { transform: none; visibility: visible; }
  body.rail-open::after { content: ""; position: fixed; inset: var(--masthead-h) 0 0 0; z-index: 24; background: rgba(0, 0, 0, 0.5); }
}
@media (prefers-reduced-motion: no-preference) {
  .rail { transition: transform 0.15s ease-out, visibility 0.15s; }
}
@media (min-width: 1100px) and (prefers-reduced-motion: no-preference) {
  body:not([data-page="watch"]) .rail { transition: none; }
}
.main { min-width: 0; width: 100%; max-width: 1720px; padding: 24px 32px 48px; }
.main:focus { outline: none; }
.app { display: flex; flex-direction: column; gap: 20px; }

/* Cards and the state panel: a framed box, one sentence, one button. */
.card { padding: 16px 18px; border: 1px solid var(--line-strong); background: var(--surface); }
.card-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.card p { margin: 0 0 8px; }

/* The ASCII screen (both players): black, the film's aspect ratio. */
.screen { position: relative; width: 100%; aspect-ratio: var(--ar, 1.7778); background: #000; color: var(--screen-fg); }
.screen > canvas { z-index: 2; }
.source-video { position: absolute; inset: 0; width: 100%; height: 100%; }
.panel { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; padding: 16px; background: #050505; color: var(--screen-fg); }
.panel[hidden] { display: none; }
.panel-card { display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 62ch; padding: 18px 22px; border: 1px solid #3d3d3d; text-align: center; }
.panel-title { margin: 0; font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.panel-body { margin: 0; color: var(--screen-muted); overflow-wrap: anywhere; }
.panel-body[hidden] { display: none; }
.panel-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.panel-actions:empty { display: none; }
.panel[aria-busy="true"] .panel-title::after { content: "▌"; margin-left: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .panel[aria-busy="true"] .panel-title::after { animation: blink 1s steps(1) infinite; }
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-color-scheme: light) {
  .panel-action { background: #7cf29a; border-color: #7cf29a; color: #07130b; }
}

/* Curated player: the ASCII canvas over our own <video> (nothing else over it, no clipping
   ancestor: see curated-player.ts), then the control bar. */
.player { display: flex; flex-direction: column; width: 100%; min-width: 0; background: #000; border: 1px solid var(--line-strong); }
.controls { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; padding: 4px 6px; background: var(--surface); border-top: 1px solid var(--line); }
.controls .glyph { font-size: 15px; line-height: 1; }
.controls .control-sound[aria-pressed="false"] .glyph { text-decoration: line-through; text-decoration-thickness: 2px; opacity: 0.7; }
.controls .control-sound[aria-pressed="true"] { color: var(--accent); }
.controls .seek { flex: 1 1 auto; min-width: 80px; height: var(--hit); margin: 0 6px; accent-color: var(--accent); }
.controls .time { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.controls-spacer { display: none; }
.player:fullscreen { border: 0; width: 100vw; height: 100vh; }
.player:fullscreen .screen-area { container-type: size; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.player:fullscreen .screen { width: min(100cqw, calc(100cqh * var(--ar))); }
/* Narrow: two rows (the seek bar on its own row, full width; the buttons under it). */
@media (max-width: 559px) {
  .controls { flex-wrap: wrap; row-gap: 0; padding: 2px 4px 4px; }
  .controls .seek { order: -1; flex: 1 0 100%; width: 100%; margin: 0; }
  .controls-spacer { display: block; flex: 1; }
}

/* Home: the hero. */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 24px; align-items: start; }
.hero .player { width: min(100%, calc((100vh - var(--masthead-h) - 250px) * var(--ar, 1.7778))); min-width: min(100%, 480px); }
.hero-meta { display: flex; flex-direction: column; gap: 10px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.eyebrow::before { content: "● "; }
.hero-title { margin: 0; font-size: 28px; }
.hero-sub { margin: 0; color: var(--muted); }
.hero-blurb { margin: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.credit { margin: 0; color: var(--muted); font-size: 13px; }
.hero-hint { margin: 4px 0 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface); font-size: 13px; }
@media (max-width: 999px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero .player { width: 100%; min-width: 0; }
}

/* Chips: square, bracket-free text, the chosen one in the accent. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); cursor: pointer; text-decoration: none; font-size: 14px; }
.chip:hover { border-color: var(--fg); }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed="true"]::before { content: ">\00a0"; }
.chip-link { color: var(--muted); }

/* Sections, tiles and rows. */
.section[hidden] { display: none; }
.section-title { margin: 0 0 12px; font-size: 18px; }
.section-title::before { content: "## "; color: var(--accent); }
.sub-title { margin: 16px 0 6px; font-size: 13px; color: var(--muted); font-weight: 400; letter-spacing: 0.08em; text-transform: uppercase; }
.results { margin: 0 0 12px; color: var(--muted); }
.results:empty { display: none; }
.empty { margin: 0; color: var(--muted); }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px 16px; }
.tile[hidden] { display: none; }
.tile-link { display: flex; flex-direction: column; gap: 8px; width: 100%; padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; }
.tile-thumb { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; background: var(--surface); border: 1px solid var(--line); }
.tile-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tile-link:hover .tile-thumb, .tile-link:focus-visible .tile-thumb, .tile-link[aria-current="true"] .tile-thumb { border-color: var(--accent); }
.tile-link:focus-visible { outline-offset: 4px; }
.tile-duration { position: absolute; right: 6px; bottom: 6px; padding: 0 5px; background: rgba(0, 0, 0, 0.85); color: #e8e8e8; border: 1px solid #444; font-size: 12px; font-variant-numeric: tabular-nums; }
.tile-duration::before { content: "["; color: #8f8f8f; }
.tile-duration::after { content: "]"; color: #8f8f8f; }
.tile-text { display: flex; flex-direction: column; gap: 2px; }
.tile-title { font-weight: 700; }
.tile-meta { color: var(--muted); font-size: 13px; }
.tile-link[aria-current="true"] .tile-title::after { content: "  ● playing"; color: var(--accent); font-weight: 400; font-size: 12px; }
.rows { list-style: none; margin: 0 0 8px; padding: 0; }
.row-link { display: grid; grid-template-columns: 1.5em minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; min-height: var(--hit); padding: 4px 8px; border: 1px solid transparent; background: none; color: var(--fg); text-align: left; cursor: pointer; }
.row-link:hover { border-color: var(--line-strong); background: var(--surface); }
.row-glyph { color: var(--accent); }
.row-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
@media (max-width: 599px) {
  .tiles { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .tile-link { display: grid; grid-template-columns: minmax(120px, 44%) minmax(0, 1fr); gap: 12px; align-items: start; }
}

/* Watch page: the ASCII first, YouTube's player beside it, its own box, nothing over it. The
   player gets up to 768 CSS px (half the width below that): measured (e2e/capture.mjs, 2026-10-16),
   a smaller player costs frames. At 447 px Chrome raised the captured tab's scale to DPR 3 (the
   whole page drawn at 3x) and the capture fell to 46 of 60 fps, or without that boost YouTube chose
   480p30; at 645 px a 24 fps film drew 20.4 of 24; at 768 px every frame of 60, 30 and 24 fps.
   Stacked below 1100 px: ASCII first, then the player at full width. */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) min(768px, calc(50% - 12px)); gap: 24px; align-items: start; }
.watch-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.watch-ascii { display: flex; flex-direction: column; gap: 8px; }
.screen-capture { border: 1px solid var(--line-strong); }
.callout { margin: 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface); }
.callout[hidden] { display: none; }
.watch-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; min-height: var(--hit); }
.share-status { margin: 0; color: var(--muted); font-size: 13px; }
.share-status[data-share="on"] { color: var(--accent); }
.watch-title { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.how { border: 1px solid var(--line); }
.how summary { padding: 8px 12px; cursor: pointer; }
.how-body { padding: 0 12px 4px; color: var(--muted); }
.how-body p { margin: 0 0 10px; }
.watch-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.watch-player { display: flex; flex-direction: column; gap: 6px; }
/* Element Capture target: its own stacking context, flat (no 3D), holding only the iframe. */
.player-box { position: relative; width: 100%; min-width: 356px; max-width: 100%; aspect-ratio: 16 / 9; background: #000; isolation: isolate; transform-style: flat; }
.player-box .embed { display: block; width: 100%; height: 100%; border: 0; }
.placeholder { margin: 0; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--screen-muted); border: 1px dashed #3d3d3d; }
.source-link { font-size: 13px; align-self: flex-start; }
.source-link[hidden] { display: none; }
.up-next { border-top: 1px solid var(--line); padding-top: 12px; }
.up-next .row-link { grid-template-columns: 1.5em minmax(0, 1fr); row-gap: 0; padding: 6px 8px; }
.up-next .row-meta { grid-column: 2; }
.watch-unsupported { max-width: 72ch; }
@media (max-width: 1099px) {
  .watch { grid-template-columns: minmax(0, 1fr); }
  .player-box { min-width: 0; }
}

/* Prose pages: about, privacy. */
.prose { max-width: 74ch; }
.prose h1 { font-size: 28px; margin: 8px 0 12px; }
.prose h2 { font-size: 20px; margin: 32px 0 8px; }
.prose h2::before { content: "## "; color: var(--accent); }
.prose h3 { font-size: 16px; margin: 20px 0 6px; }
.prose p, .prose li { overflow-wrap: anywhere; }
.prose ul { padding-left: 2.2ch; }
.prose li { margin-bottom: 6px; }
.lede { font-size: 16px; color: var(--fg); }
.summary ul { margin: 0; padding-left: 2.2ch; }
.credits li { margin-bottom: 10px; }
.not-found { max-width: 70ch; }
.not-found-art { margin: 8px 0 16px; color: var(--accent); font-size: 13px; line-height: 1.2; }

/* Footer. */
.footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding: 16px 32px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.footer-link { color: var(--fg); }
.footer-soon { color: var(--muted); }
.footer-note { margin: 0; }

/* Phones. */
@media (max-width: 699px) {
  :root { --masthead-h: 52px; }
  .masthead { gap: 6px; padding: 0 8px; }
  .brand-name { display: none; }
  .get-extension { display: none; }
  .main { padding: 0 0 32px; }
  .app { gap: 16px; }
  .hero { gap: 12px; }
  .hero .player { border-left: 0; border-right: 0; }
  .hero-meta, .chips, .section, .watch-main > :not(.watch-ascii), .watch-side, .prose, .not-found, .watch-unsupported { margin-left: 12px; margin-right: 12px; }
  .main > .prose, .main > .not-found { padding-top: 16px; }
  .hero-title { font-size: 22px; }
  .footer { padding: 16px 12px 24px; }
}
/* A phone turned sideways: the hero fills the screen (iPhone has no element fullscreen). */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .masthead { position: static; }
  .hero .player { width: min(100%, calc((100svh - 58px) * var(--ar, 1.7778))); min-width: 0; margin: 0 auto; }
  .hero { grid-template-columns: minmax(0, 1fr); }
}

@media (forced-colors: active) {
  .chip[aria-pressed="true"], .rail-nav a[aria-current="page"] { outline: 2px solid CanvasText; }
}
