/* Reel player shell. One dark look on purpose: the stage is a black screen, like the original demos.
   Modes: [data-mode=page] — a page with title, captions and chapters; [data-mode=embed] — fills an iframe;
   .reel--fs — fullscreen (native or pseudo on iPhone); [data-mode=still] — a single frame for thumbnails. */
:root { color-scheme: dark; }
html, body { margin: 0; }
html:not([data-theme="light"]), html:not([data-theme="light"]) body { background: #000; }
html.reel-lock, html.reel-lock body { overflow: hidden; overscroll-behavior: none; }
[hidden] { display: none !important; }

.reel {
  --bg: #000000;
  --panel: #16110f;
  --line: #2e2622;
  --text: #f7f2ef;
  --muted: #8f847e;
  --brand: #d9d1cc;
  --accent: #ff7433;
  --accent-soft: #ff9f70;
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --btn: 40px;
  color: var(--text);
  background: var(--bg);
  font-family: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
@media (pointer: coarse) { .reel { --btn: 44px; } }
.reel *, .reel *::before, .reel *::after { box-sizing: border-box; }
.reel-error { padding: 40px 16px; color: #8f847e; font-family: system-ui, sans-serif; text-align: center; }

/* ---------- page */
.reel[data-mode="page"] {
  max-width: 1760px;
  margin-inline: auto;
  padding: max(20px, env(safe-area-inset-top, 0px)) var(--gutter) max(48px, env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 16px;
}
.reel-head { display: grid; gap: 4px; }
.reel-kicker { margin: 0; font: 600 12px/1.3 "JetBrains Mono", ui-monospace, Menlo, monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.reel-title { margin: 0; font-weight: 700; font-size: clamp(22px, 2.4vw, 32px); line-height: 1.1; letter-spacing: -.015em; text-wrap: balance; }

.reel-player { position: relative; background: var(--bg); border: 1px solid var(--panel); border-radius: 18px; overflow: hidden; }
.reel-stage { position: relative; display: flex; justify-content: center; align-items: center; background: var(--bg); touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.reel-canvas { display: block; cursor: pointer; }
.reel-videos video, .reel-hidden-video { position: absolute; left: 0; top: 0; width: 2px; height: 2px; opacity: .01; pointer-events: none; }

/* start on a poster frame: a pill at the bottom of the stage, so the title stays readable */
.reel-start {
  position: absolute; left: 50%; bottom: 9%; translate: -50% 0;
  height: 56px; padding: 0 24px 0 20px; border-radius: 999px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px; background: var(--accent); color: #100c0a;
  font: 600 17px/1 "Onest", system-ui, sans-serif; white-space: nowrap;
  box-shadow: 0 0 0 8px rgba(255, 116, 51, .16), 0 0 50px rgba(255, 106, 26, .4);
  transition: transform .2s ease, box-shadow .2s ease;
}
.reel-start:hover { transform: scale(1.04); box-shadow: 0 0 0 12px rgba(255, 116, 51, .2), 0 0 70px rgba(255, 106, 26, .5); }
.reel-start svg { width: 18px; height: 18px; fill: currentColor; }
.reel-start .reel-start-dur { font: 500 14px/1 "JetBrains Mono", ui-monospace, monospace; opacity: .7; }
.reel-start:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 6px; }
/* start on a black screen, like the original demos: a big round button in the middle */
.reel[data-start="black"] .reel-start { bottom: auto; top: 50%; translate: -50% -50%; width: clamp(64px, 9vw, 104px); height: auto; aspect-ratio: 1; padding: 0; justify-content: center; border-radius: 50%; }
.reel[data-start="black"] .reel-start span { display: none; }
.reel[data-start="black"] .reel-start svg { width: 38%; height: 38%; margin-left: 8%; }

.reel-end { position: absolute; left: 0; right: 0; bottom: 12%; display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; padding-inline: 16px; }
.reel-end .reel-btn { height: 48px; padding: 0 20px; font-size: 16px; }
.reel-cta { display: inline-flex; align-items: center; height: 48px; padding: 0 22px; border-radius: 12px; background: var(--accent); color: #100c0a; font-weight: 600; text-decoration: none; }

.reel-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 62%; overflow: auto;
  background: rgba(12, 9, 8, .94); border-top: 1px solid var(--line); padding: 16px 20px 20px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.reel-sheet .reel-cap-title { font-size: 18px; }

/* ---------- controls */
.reel-controls {
  display: flex; align-items: center; gap: 6px 8px; padding: 10px 12px;
  border-top: 1px solid var(--panel); background: var(--bg);
}
.reel-btn {
  appearance: none; height: var(--btn); min-width: var(--btn); padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  font: 500 14px/1 inherit; font-family: inherit; cursor: pointer;
}
.reel-btn:hover { border-color: var(--muted); }
.reel-btn.primary { background: var(--accent); border-color: var(--accent); color: #100c0a; min-width: calc(var(--btn) + 8px); }
.reel-btn.is-on { border-color: var(--accent); color: var(--accent-soft); }
.reel-btn svg { width: 16px; height: 16px; fill: currentColor; }
.reel-btn:focus-visible, .reel-scrub input:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.reel-scrub { flex: 1 1 120px; min-width: 60px; position: relative; height: var(--btn); display: flex; align-items: center; }
.reel-scrub input { width: 100%; margin: 0; accent-color: var(--accent); cursor: pointer; }
.reel-marks { position: absolute; left: 0; right: 0; bottom: 2px; height: 6px; pointer-events: none; }
.reel-marks i { position: absolute; top: 0; width: 1px; height: 6px; background: var(--muted); }
.reel-time { font: 500 13px/1 "JetBrains Mono", ui-monospace, Menlo, monospace; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }
.reel-textbtn { display: none; }

/* ---------- captions and chapters (page mode) */
.reel-caption { display: grid; gap: 6px; max-width: 900px; min-width: 0; }
.reel-caption.is-empty { display: none; }
.reel-cap-meta { margin: 0; font: 500 13px/1 "JetBrains Mono", ui-monospace, Menlo, monospace; color: var(--muted); }
.reel-cap-meta:empty { display: none; }
.reel-cap-title { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 700; text-wrap: balance; }
.reel-cap-text { margin: 0; max-width: 75ch; color: var(--brand); }
.reel-chapters { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.reel-chapters button {
  appearance: none; border: 1px solid var(--line); background: transparent; color: var(--brand);
  border-radius: 999px; padding: 8px 14px; font: 500 14px/1.2 inherit; font-family: inherit; cursor: pointer;
}
.reel-chapters button:hover { border-color: var(--muted); }
.reel-chapters button.is-on { border-color: var(--accent); color: var(--text); background: rgba(255, 116, 51, .1); }
.reel-chapters:empty { display: none; }
.reel-rotate { display: none; margin: 0; font-size: 14px; color: var(--muted); }

/* page on a phone: the player goes edge to edge */
@media (max-width: 640px) {
  .reel[data-mode="page"] { gap: 12px; }
  .reel[data-mode="page"] .reel-player { margin-inline: calc(-1 * var(--gutter)); border-radius: 0; border-inline: 0; }
  .reel[data-mode="page"].reel--can-rotate .reel-rotate { display: block; }
  .reel-cap-title { font-size: 19px; }
}
/* phone on its side: the stage takes the whole height, the title goes away */
@media (max-height: 520px) and (orientation: landscape) {
  .reel[data-mode="page"] { padding-top: 6px; gap: 10px; }
  .reel[data-mode="page"] .reel-head { display: none; }
}
/* narrow bars: keep what matters */
@media (max-width: 480px) {
  .reel-speed, .reel-time { display: none; }
  .reel-controls { gap: 6px; padding: 8px; }
}
@media (max-width: 360px) { .reel-prev { display: none; } }

/* ---------- embed: fills the iframe, no page chrome */
.reel[data-mode="embed"] { position: fixed; inset: 0; display: flex; flex-direction: column; }
.reel[data-mode="embed"] .reel-head,
.reel[data-mode="embed"] .reel-caption,
.reel[data-mode="embed"] .reel-chapters,
.reel[data-mode="embed"] .reel-rotate { display: none; }
.reel[data-mode="embed"] .reel-player { flex: 1; display: flex; flex-direction: column; border: 0; border-radius: 0; min-height: 0; }
.reel[data-mode="embed"] .reel-stage { flex: 1; min-height: 0; }
.reel[data-mode="embed"] .reel-textbtn { display: inline-flex; }

/* ---------- fullscreen (native or pseudo) */
.reel.reel--fs { position: fixed; inset: 0; z-index: 2147483000; padding: 0; margin: 0; max-width: none; display: block; background: #000; }
.reel.reel--fs .reel-head, .reel.reel--fs .reel-caption, .reel.reel--fs .reel-chapters, .reel.reel--fs .reel-rotate { display: none; }
.reel.reel--fs .reel-player { height: 100%; border: 0; border-radius: 0; margin: 0; }
.reel.reel--fs .reel-stage { height: 100vh; height: 100dvh; }
.reel.reel--fs .reel-textbtn { display: inline-flex; }
.reel.reel--fs .reel-controls {
  position: absolute; left: 0; right: 0; bottom: 0; border: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, .85) 45%);
  padding: 28px max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  transition: opacity .35s ease;
}
.reel.reel--fs.reel--playing:not(.reel--peek) .reel-controls { opacity: 0; pointer-events: none; }
.reel.reel--fs .reel-sheet { bottom: 72px; }

/* ---------- still: only the frame */
.reel[data-mode="still"] { position: fixed; inset: 0; display: grid; place-items: center; }
.reel[data-mode="still"] > :not(.reel-player), .reel[data-mode="still"] .reel-controls,
.reel[data-mode="still"] .reel-start, .reel[data-mode="still"] .reel-end { display: none !important; }
.reel[data-mode="still"] .reel-player { border: 0; border-radius: 0; }

@media (prefers-reduced-motion: reduce) { .reel * { transition: none !important; } }

/* ---------- server pages: login and catalog */
.reel-login, .reel-catalog { min-height: 100vh; min-height: 100dvh; color: #f7f2ef; font-family: "Onest", system-ui, sans-serif; padding: 32px 16px; box-sizing: border-box; }
.reel-login { display: grid; place-items: center; }
.reel-login form { display: grid; gap: 14px; width: min(100%, 360px); --btn: 44px; }
.reel-login label { display: grid; gap: 6px; color: #8f847e; font-size: 14px; }
.reel-login input { height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid #2e2622; background: #16110f; color: #f7f2ef; font: inherit; }
.reel-login .reel-btn { height: 44px; border-radius: 10px; border: 1px solid #ff7433; background: #ff7433; color: #100c0a; font: 600 15px/1 "Onest", system-ui, sans-serif; cursor: pointer; }
.reel-login-err { margin: 0; color: #e5342b; font-size: 14px; }
.reel-catalog { max-width: 960px; margin: 0 auto; }
.reel-catalog ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 16px; }
.reel-catalog li { border: 1px solid #2e2622; border-radius: 14px; padding: 16px 18px; display: grid; gap: 6px; }
.reel-cat-title { color: #f7f2ef; font-weight: 700; font-size: 19px; text-decoration: none; }
.reel-cat-title:hover { color: #ff9f70; }
.reel-catalog p { margin: 0; color: #d9d1cc; }
.reel-catalog code { font: 12px/1.5 "JetBrains Mono", ui-monospace, monospace; color: #8f847e; overflow-wrap: anywhere; }

/* ---------- light site (data-theme="light" on the page, strict.css loaded): white canvas, the player stays a dark frame */
html[data-theme="light"] .reel[data-mode="page"] { background: transparent; color: var(--st-text-2); padding-top: 20px; }
html[data-theme="light"] .reel[data-mode="page"] .reel-kicker { color: var(--st-text-3); }
html[data-theme="light"] .reel[data-mode="page"] .reel-title { color: var(--st-text); font: 500 clamp(30px, 4vw, 52px)/1 var(--font-display); letter-spacing: -.035em; }
html[data-theme="light"] .reel[data-mode="page"] .reel-player { border: 0; border-radius: 20px; box-shadow: 0 24px 60px -30px rgba(16, 12, 10, .45); }
html[data-theme="light"] .reel[data-mode="page"] .reel-cap-meta { color: var(--st-text-3); }
html[data-theme="light"] .reel[data-mode="page"] .reel-cap-title { color: var(--st-text); font-family: var(--font-display); font-weight: 500; letter-spacing: -.02em; }
html[data-theme="light"] .reel[data-mode="page"] .reel-cap-text { color: var(--st-text-2); }
html[data-theme="light"] .reel[data-mode="page"] .reel-rotate { color: var(--st-text-3); }
html[data-theme="light"] .reel-chapters button { border-color: var(--st-line-2); background: var(--st-surface); color: var(--st-text-2); }
html[data-theme="light"] .reel-chapters button:hover { border-color: var(--st-line-3); color: var(--st-text); }
html[data-theme="light"] .reel-chapters button.is-on { border-color: var(--st-accent-line); background: var(--st-accent-tint); color: var(--st-text); }
html[data-theme="light"] .reel.reel--fs { background: #000; }
@media (max-width: 640px) { html[data-theme="light"] .reel[data-mode="page"] .reel-player { border-radius: 0; box-shadow: none; } }
/* the capsule on a player page has no table of contents: the title sits where the section would be */
.cap-toc--static { cursor: default; }
.cap-toc--static:hover { background: transparent !important; }

/* login on the light site */
html[data-theme="light"] .reel-login { color: var(--st-text-2); background: var(--st-bg); }
html[data-theme="light"] .reel-login .reel-kicker { color: var(--st-accent-text); }
html[data-theme="light"] .reel-login .reel-title { color: var(--st-text); font: 500 34px/1.05 var(--font-display); letter-spacing: -.03em; }
html[data-theme="light"] .reel-login label { color: var(--st-text-3); }
html[data-theme="light"] .reel-login input { border-color: var(--st-line-2); background: var(--st-surface); color: var(--st-text); }
html[data-theme="light"] .reel-login input:focus { outline: none; border-color: var(--st-accent-line); box-shadow: var(--st-ring); }
html[data-theme="light"] .reel-login .reel-btn { border-color: var(--st-inverse); background: var(--st-inverse); color: var(--st-on-inverse); }
