/* /videos/: playlist page. The site's own palette and type; the stage (video + strip) is always black.
   Rule that shapes this file: nothing may be drawn on top of the YouTube iframe (.screen). Subtitles,
   indicators, the hover time and the control bar all live in .strip, below the video. */
:root {
  --bg: #fbfbf9;
  --fg: #1b1c1e;
  --muted: #5f6267;
  --rule: #e4e3df;
  --raised: #f2f1ed;
  --hover: rgba(27, 28, 30, 0.05);
  --current: rgba(27, 28, 30, 0.09);
  --link-line: #b9b8b3;
  --accent: #e8a33d;
  --ring: #a8660f; /* focus ring on the light page (4.6:1); the black stage uses --accent */
  --side: 402px;
  --player-max: max(640px, min(1280px, calc((100vh - 290px) * 16 / 9)));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --fg: #e6e5e1;
    --muted: #9a9da2;
    --rule: #2a2b2e;
    --raised: #1c1d20;
    --hover: rgba(255, 255, 255, 0.05);
    --current: rgba(255, 255, 255, 0.09);
    --link-line: #55575c;
    --ring: #e8a33d;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.lock, html.lock body { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: inherit; text-decoration-color: var(--link-line); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.player :focus-visible { outline-color: var(--accent); }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { display: block; width: 24px; height: 24px; flex: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- top bar: our identity, a way back to the blog. Not sticky: it must never slide over the video. ---- */
.topbar {
  display: flex; align-items: center; gap: 0.45rem;
  height: 56px; padding: 0 24px;
  border-bottom: 1px solid var(--rule);
}
.topbar .home { font-weight: 600; text-decoration: none; }
.topbar .dot { color: var(--muted); }
.topbar .here { color: var(--muted); text-decoration: none; }
.topbar .blog { margin-left: auto; display: inline-flex; align-items: center; gap: 0.2rem; color: var(--muted); text-decoration: none; font-size: 14px; }
.topbar .blog .icon { width: 18px; height: 18px; }
.topbar .blog:hover { color: var(--fg); }

/* ---- page grid: player and info on the left, playlist on the right ---- */
.watch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side);
  grid-template-areas: "player side" "info side";
  column-gap: 24px;
  align-items: start;
  max-width: calc(var(--player-max) + var(--side) + 24px + 48px);
  margin: 0 auto;
  padding: 24px;
}
.watch.empty { display: block; color: var(--muted); }
.player { grid-area: player; }
.info { grid-area: info; }
.playlist { grid-area: side; }

/* ---- the stage ---- */
.player {
  position: relative;
  background: #000;
  color: #fff;
  border-radius: 0 0 12px 12px;
  color-scheme: dark;
  --cue-size: min(calc(var(--cue-base, 18px) * var(--cue-scale, 1)), 11vh);
}
.player:focus { outline: none; }
.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  /* YouTube RMF: the embedded player's viewport is at least 200 x 200 px, in every layout. */
  min-width: 200px;
  min-height: 200px;
  background: #000;
}
.screen iframe { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border: 0; }
.facade { position: absolute; inset: 0; background: #000; }
.facade img { display: block; width: 100%; height: 100%; object-fit: contain; }
.facade-btn {
  position: absolute; inset: 0; display: block;
  width: 100%; height: 100%; padding: 0; border: 0;
  background: transparent; color: #fff; cursor: pointer;
}
.facade-play {
  position: absolute; left: 50%; top: 50%;
  display: grid; place-items: center;
  width: 76px; height: 76px; margin: -38px 0 0 -38px;
  border: 2px solid rgba(255, 255, 255, 0.85); border-radius: 50%;
  background: rgba(20, 21, 23, 0.72); color: #fff;
  transition: background 0.15s, transform 0.15s;
}
.facade-play .icon { width: 34px; height: 34px; margin-left: 4px; }
.facade-btn:hover .facade-play, .facade-btn:focus-visible .facade-play { background: var(--accent); transform: scale(1.06); }
.facade-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }

/* ---- the strip below the video ---- */
.strip {
  position: relative;
  padding: 0 12px 4px;
  border-radius: inherit;
  background: #000;
  user-select: none;
  -webkit-user-select: none;
}
/* The subtitle band always holds two lines at the chosen size, whether a cue is showing, captions
   are off (c) or a notice is up, so the strip never changes height and the video never resizes.
   Only the size setting (+ / -) changes it. A line too wide for the band is shrunk to fit (--fit,
   set by player.js) instead of wrapping onto a third line. */
.zone {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  height: calc(var(--cue-size) * 1.35 * 2 + 16px);
  min-height: 34px;
  padding: 8px 0 6px;
  overflow: hidden;
  cursor: pointer;
}
.cue {
  margin: 0;
  max-width: 100%;
  font-size: calc(var(--cue-size) * var(--fit, 1));
  line-height: 1.35;
  font-weight: 500;
  text-align: center;
  white-space: pre;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}
.cue:not(.on), .captions-off .cue, .has-notice .cue { visibility: hidden; }
.notice {
  position: absolute; left: 8px; right: 8px; top: 50%;
  display: none; margin: 0;
  font-size: 13px; color: rgba(255, 255, 255, 0.75); text-align: center;
  transform: translateY(-50%);
}
.has-notice .notice { display: block; }
.notice a { color: #fff; }

.osd {
  position: absolute; top: 50%;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  opacity: 0; transform: translateY(-50%);
  transition: opacity 0.15s;
  pointer-events: none;
}
.osd.show { opacity: 1; }
.osd .icon { width: 18px; height: 18px; }
.osd-left { left: 0; }
.osd-right { right: 0; flex-direction: row-reverse; }
.osd-center { left: 50%; transform: translate(-50%, -50%); }

.tip {
  position: absolute; bottom: 0; left: var(--x, 50%);
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.94); color: #111;
  font-size: 12px; font-variant-numeric: tabular-nums;
  opacity: 0; transform: translateX(-50%);
  pointer-events: none;
}
.player.hovering .tip { opacity: 1; }

/* progress bar */
.progress { position: relative; display: flex; align-items: center; height: 16px; cursor: pointer; touch-action: none; outline: none; }
.progress .track { position: relative; width: 100%; height: 3px; background: rgba(255, 255, 255, 0.25); transition: height 0.1s; }
.player.hovering .track, .player.scrubbing .track, .progress:focus-visible .track { height: 5px; }
.track > div { position: absolute; inset: 0; transform: scaleX(0); transform-origin: 0 50%; }
.buffer { background: rgba(255, 255, 255, 0.4); }
.hover { z-index: 1; background: rgba(255, 255, 255, 0.45); opacity: 0; }
.player.hovering .hover { opacity: 1; }
.played { z-index: 2; background: var(--accent); }
.knob {
  position: absolute; z-index: 3; left: var(--x, 0%); top: 50%;
  width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px;
  border-radius: 50%; background: var(--accent);
  transform: scale(0); transition: transform 0.1s;
}
.player.hovering .knob, .player.scrubbing .knob, .progress:focus-visible .knob { transform: scale(1); }
.progress:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* control row */
.controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 44px; transition: opacity 0.2s; }
.controls .left, .controls .right { display: flex; align-items: center; gap: 2px; min-width: 0; }
.ctl {
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; color: #fff;
  cursor: pointer; opacity: 0.9;
}
.ctl:hover { opacity: 1; background: rgba(255, 255, 255, 0.1); }
.ctl:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ctl[disabled] { opacity: 0.35; cursor: default; background: transparent; }
#btn-play .icon { width: 28px; height: 28px; }
.volume { display: flex; align-items: center; }
.vol {
  width: 0; margin: 0; opacity: 0;
  accent-color: #fff;
  transition: width 0.2s, opacity 0.2s, margin 0.2s;
}
.volume:hover .vol, .volume:focus-within .vol { width: 72px; margin: 0 8px 0 2px; opacity: 1; }
.time { padding: 0 8px; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; color: rgba(255, 255, 255, 0.9); }
#btn-cc { position: relative; }
#btn-cc[aria-pressed="true"]::after {
  content: ""; position: absolute; left: 9px; right: 9px; bottom: 5px;
  height: 3px; border-radius: 2px; background: var(--accent);
}
.switch { width: 50px; border-radius: 20px; }
.switch .track-s { position: relative; display: block; width: 30px; height: 14px; border-radius: 7px; background: rgba(255, 255, 255, 0.3); transition: background 0.15s; }
.switch .thumb-s { position: absolute; top: -3px; left: -2px; display: block; width: 20px; height: 20px; border-radius: 50%; background: #bdbdbd; transition: transform 0.15s, background 0.15s; }
.switch[aria-checked="true"] .track-s { background: rgba(232, 163, 61, 0.55); }
.switch[aria-checked="true"] .thumb-s { transform: translateX(14px); background: #fff; }

/* controls fade while playing and the pointer rests; the strip keeps its place, nothing moves */
.player.idle .controls, .player.idle .progress { opacity: 0; }
.player.idle .strip, .player.idle.is-fs { cursor: none; }
@media (hover: none) {
  .player.idle .controls, .player.idle .progress { opacity: 1; }
}

/* settings menu: opens below the strip, or inside it in fullscreen (it never covers the video) */
.menu {
  position: absolute; z-index: 30; right: 12px; top: 100%;
  min-width: 250px; margin-top: 6px; padding: 8px 0;
  border-radius: 12px;
  background: rgba(28, 28, 30, 0.97); color: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  font-size: 14px;
}
.player.is-fs .menu { position: static; width: max-content; margin: 0 0 8px auto; }
.menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 16px;
  border: 0; background: transparent; color: inherit;
  font: inherit; text-align: left; cursor: pointer;
}
.menu button:hover { background: rgba(255, 255, 255, 0.1); }
.menu button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.menu-note { margin: 0 0 4px; padding: 2px 16px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.15); font-size: 12px; color: rgba(255, 255, 255, 0.7); }
.menu .icon { width: 18px; height: 18px; }
.menu .val { margin-left: auto; color: rgba(255, 255, 255, 0.7); }
.menu-back { margin-bottom: 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important; font-weight: 600; }
.menu-options { max-height: 260px; overflow-y: auto; }
.menu-options .icon { visibility: hidden; }
.menu-options [aria-checked="true"] .icon { visibility: visible; }

/* fullscreen: video on top, strip below, both inside the fullscreen element */
.player.is-fs {
  display: flex; flex-direction: column; width: 100%; height: 100%; border-radius: 0;
  --cue-size: min(calc(var(--cue-base, 18px) * var(--cue-scale, 1)), 11vh, max(10px, calc((100dvh - 290px) / 2.7)));
}
.player.pseudo-fs { position: fixed; inset: 0; z-index: 1000; height: 100dvh; margin: 0; }
.player.is-fs .screen { flex: 1 0 200px; aspect-ratio: auto; max-height: none; }
.player.is-fs .strip { display: flex; flex-direction: column; flex: 0 1 auto; min-height: 0; padding-bottom: max(4px, env(safe-area-inset-bottom)); }
.player.is-fs .strip > :not(.menu) { flex: none; }
.player.is-fs .menu { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
.player.is-fs .menu-options { max-height: none; }

/* ---- below the video ---- */
.info { min-width: 0; padding-top: 12px; }
.info h1 { margin: 0 0 10px; font-size: 20px; line-height: 1.4; font-weight: 600; overflow-wrap: anywhere; }
.owner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.channel { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--rule); border-radius: 50%; background: var(--raised); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: 18px;
  background: var(--raised); color: inherit;
  font: inherit; font-size: 14px; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.pill:hover { background: var(--current); }
.pill .icon { width: 18px; height: 18px; }
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; padding: 12px; border: 1px solid var(--rule); border-radius: 12px; }
.share-url { flex: 1 1 260px; }
.share-url input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--bg); color: inherit; font: inherit; font-size: 14px; }
.share-at { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.desc { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--raised); font-size: 14px; }
.desc p { margin: 0 0 6px; }
.desc p:last-child { margin: 0; }
.desc .meta { font-weight: 600; }
.notfound { max-width: 36rem; margin: 0 auto; padding: clamp(3rem, 12vh, 7rem) 24px 4rem; }
.notfound h1 { margin: 0 0 1rem; font-size: 1.35rem; }
.linklike { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-decoration-color: var(--link-line); text-underline-offset: 0.2em; cursor: pointer; }
.nojs { font-weight: 600; }
.shortcuts { margin-top: 16px; }
.shortcuts h2 { margin: 0 0 8px; font-size: 16px; }
.shortcuts table { width: 100%; border-collapse: collapse; font-size: 14px; }
.shortcuts td { padding: 5px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.shortcuts td:first-child { width: 9rem; white-space: nowrap; }
kbd {
  padding: 1px 6px;
  border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px;
  background: var(--bg);
  font: 12px ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
.src, .src-note { color: var(--muted); }
.src-note { margin: 8px 0 0; font-size: 13px; }

/* ---- playlist panel ---- */
.playlist {
  display: flex; flex-direction: column;
  min-width: 0;
  max-height: var(--player-h, 640px);
  border: 1px solid var(--rule); border-radius: 12px;
  overflow: hidden;
}
.pl-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px 8px 10px 16px; border-bottom: 1px solid var(--rule); background: var(--raised); }
.pl-heading { min-width: 0; }
.pl-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.pl-sub, .pl-next { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.pl-next { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); }
.collapse { color: var(--fg); }
.collapse:hover { background: var(--hover); }
.collapse .icon { transform: rotate(180deg); transition: transform 0.15s; }
.playlist.collapsed .collapse .icon { transform: none; }
.playlist.collapsed .pl-items { display: none; }
.playlist.collapsed .pl-head { border-bottom: 0; }
.pl-items { position: relative; flex: 1 1 auto; margin: 0; padding: 8px 0; list-style: none; overflow-y: auto; overscroll-behavior: contain; }
.item {
  display: grid; grid-template-columns: 24px 128px minmax(0, 1fr); align-items: center; gap: 8px;
  padding: 6px 12px 6px 4px;
  text-decoration: none;
}
.item:hover { background: var(--hover); }
.item[aria-current="true"] { background: var(--current); }
.item:focus-visible { outline-offset: -2px; }
.idx { font-size: 12px; text-align: center; color: var(--muted); }
.item[aria-current="true"] .idx { color: var(--ring); }
/* YouTube RMF: a thumbnail that starts playback is at least 120 x 70 px. */
.thumb { display: block; width: 128px; height: 72px; border-radius: 8px; object-fit: cover; background: var(--rule); }
.text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.t { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 14px; font-weight: 600; line-height: 1.35; }
.c { font-size: 12px; color: var(--muted); }

.foot { max-width: calc(var(--player-max) + var(--side) + 24px + 48px); margin: 8px auto 0; padding: 16px 24px 32px; color: var(--muted); font-size: 13px; }
.foot p { margin: 0; padding-top: 12px; border-top: 1px solid var(--rule); }

/* ---- wide: theater mode puts the video across the page, info and playlist below ---- */
@media (width >= 1000px) {
  .watch.theater {
    grid-template-columns: 1fr minmax(0, var(--player-max)) var(--side) 1fr;
    grid-template-areas: "player player player player" ". info side .";
    max-width: none;
    padding-top: 0;
  }
  .watch.theater .player:not(.is-fs) { margin: 0 -24px 0; border-radius: 0; }
  .watch.theater .screen { aspect-ratio: auto; height: min(56.25vw, calc(100vh - 56px - var(--strip-h, 110px))); }
  .watch.theater .playlist { max-height: 70vh; margin-top: 12px; }
}

/* ---- narrow: one column, the video edge to edge, the playlist right under it ---- */
@media (width < 1000px) {
  .watch { grid-template-columns: minmax(0, 1fr); grid-template-areas: "player" "side" "info"; padding: 0 0 16px; }
  .player { border-radius: 0; }
  .screen { max-height: max(200px, calc(100svh - 48px - var(--strip-h, 120px))); }
  .playlist { max-height: 360px; margin: 12px 12px 0; }
  .info { padding: 12px 12px 0; }
  #btn-theater { display: none; }
  .foot { padding: 16px 12px 24px; }
  .topbar { height: 48px; padding: 0 12px; }
}
@media (width <= 520px) {
  .strip { padding: 0 6px 2px; }
  .ctl { width: 36px; height: 36px; }
  .switch { width: 44px; }
  .time { padding: 0 4px; font-size: 12px; }
  .info h1 { font-size: 17px; }
}
@media (width <= 420px) {
  #btn-prev, #btn-next { display: none; }
}
/* Phones have hardware volume keys; the slider would push the time into the right-hand buttons. */
@media (width <= 420px), (hover: none) {
  .volume .vol { display: none; }
}
/* Windows High Contrast and other forced-colors modes drop backgrounds; redraw what carries meaning. */
@media (forced-colors: active) {
  .progress .track, .switch .track-s { outline: 1px solid CanvasText; }
  .played, .knob, .switch[aria-checked="true"] .thumb-s, #btn-cc[aria-pressed="true"]::after { forced-color-adjust: none; background: Highlight; }
  .switch .thumb-s { forced-color-adjust: none; background: ButtonText; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
