:root {
  --bg: #ffffff;
  --ink: #111111;
  --muted: #6e6e6e;
  --rule: #d4d4d4;
  /* One typeface everywhere: Schibsted Grotesk. */
  --sans: "Schibsted Grotesk", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: var(--sans);
  --mono: var(--sans);
  --video-w: 960px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Corners */
.corner {
  position: fixed;
  top: 28px;
  z-index: 30;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0;
}
.corner-left { left: 32px; }
.corner-left span { display: block; }
.corner-right { right: 32px; text-align: right; }
.corner-center { left: 50%; transform: translateX(-50%); text-align: center; white-space: nowrap; }
.bib-link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; transition: text-decoration-color .2s; }
.bib-link:hover { text-decoration-color: var(--ink); }

/* Bibliography page */
.bib-page { position: fixed; inset: 0; z-index: 25; overflow-y: auto; background: var(--bg); animation: fadeIn .4s ease both; }
.bib-page::before { content: ""; position: sticky; top: 0; display: block; height: 96px; margin-bottom: -96px; z-index: 1; background: linear-gradient(var(--bg) 60%, rgba(255,255,255,0)); pointer-events: none; }
.bib-wrap { width: min(760px, calc(100% - 32px)); margin: 0 auto; padding: 130px 0 100px; }
.bib-wrap h1 { margin-bottom: 40px; text-align: center; }
.bib-wrap h3 { margin: 48px 0 18px; text-align: center; font-family: var(--mono); font-size: 12px; line-height: 1.4; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); font-weight: 400; }
.bib-wrap ul { list-style: none; margin: 0; padding: 0; }
.bib-wrap li { font-size: 16px; line-height: 1.55; margin-bottom: 12px; padding-left: 2em; text-indent: -2em; }
.bib-wrap a { color: inherit; text-underline-offset: 2px; overflow-wrap: anywhere; }
body.bib-open .pager { display: none; }

.file-warning {
  position: fixed; left: 50%; top: 24px; transform: translateX(-50%);
  z-index: 40; max-width: 560px; padding: 10px 14px;
  background: #111; color: #fff; font-size: 13px; border-radius: 6px; text-align: center;
}
.file-warning code { background: rgba(255,255,255,.14); padding: 1px 5px; border-radius: 3px; }

/* Slides */
main { position: relative; height: 100vh; }
.slide {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: fadeIn .5s ease both;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Text slides */
.slide-text .text-wrap { width: min(680px, 86vw); }
.slide-text .text-wrap.wide { width: min(980px, 88vw); }
.slide-lens .text-wrap { width: min(980px, 88vw); text-align: center; }
.lens-blurb { margin: 28px auto 0; max-width: 560px; text-wrap: balance; font-size: 18px; line-height: 1.5; color: var(--ink); }
.lens-blurb:empty { display: none; }
.kicker {
  margin: 0 0 20px; font-family: var(--mono); font-size: 12px; line-height: 1.4; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); font-weight: 400;
}
h1 {
  margin: 0; font-family: var(--sans); font-weight: 500;
  font-size: clamp(38px, 4.8vw, 70px); line-height: 1.04; letter-spacing: -0.035em;
}
h1 + .intro-body { margin-top: 32px; }
.intro-body p { margin: 0 0 14px; font-size: 18px; line-height: 1.5; max-width: 600px; }
.howto { margin: 28px 0 0; font-family: var(--mono); font-size: 12px; color: var(--ink); display: flex; align-items: center; gap: 10px; }
@media (min-width: 760px) { .howto { white-space: nowrap; } }
.begin {
  margin-top: 30px; padding: 0; border: 0; background: transparent;
  cursor: pointer; font-family: var(--sans); font-size: 15px; font-weight: 500; letter-spacing: 0; transition: opacity .2s;
}
.begin span { display: inline-block; transition: transform .2s; }
.begin:hover span { transform: translateX(4px); }

.outro { margin: 0 0 40px; font-size: clamp(26px, 2.8vw, 38px); font-family: var(--sans); font-weight: 500; letter-spacing: -0.025em; line-height: 1.25; max-width: 860px; }
.cited { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; border-top: 1px solid var(--rule); padding-top: 24px; max-height: 46vh; overflow: auto; }
.cited ul { list-style: none; margin: 0 0 22px; padding: 0; }
.cited li { font-size: 13px; line-height: 1.45; margin-bottom: 9px; padding-left: 1.6em; text-indent: -1.6em; }
.cited a { color: inherit; text-underline-offset: 2px; }

/* Ad slide */
.slide-ad { gap: 0; }
.video-frame {
  position: relative; width: var(--video-w); aspect-ratio: 16 / 9; background: #000;
}
.video-frame iframe, #player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.file-video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; object-fit: contain; }
.video-frame.file iframe, .video-frame.file #player { visibility: hidden; }
.ad-lens { width: var(--video-w); margin: 0 0 12px; font-family: var(--mono); font-size: 12px; line-height: 1.4; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); }
.lens-readings { margin: 28px 0 0; padding-top: 16px; border-top: 1px solid var(--ink); font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--ink); max-width: 600px; }
.preview-placeholder {
  position: absolute; inset: 0; background: #1b1b1b center / cover no-repeat;
  display: flex; align-items: center; justify-content: center; color: #8a8a8a; font-size: 13px;
}
.edit-catcher { position: absolute; inset: 0; cursor: crosshair; z-index: 5; background: rgba(255,255,255,.04); outline: 1px dashed rgba(255,255,255,.6); outline-offset: -1px; }

.timeline { position: relative; width: var(--video-w); height: 18px; margin-top: 10px; }
.timeline::before { content: ""; position: absolute; left: 0; right: 0; top: 8px; height: 1px; background: var(--rule); }
.timeline-progress { position: absolute; left: 0; top: 8px; height: 1px; width: 0; background: var(--ink); }
.tick {
  position: absolute; top: 4px; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--ink); cursor: pointer; padding: 0;
  transition: background .2s, transform .2s;
}
.tick:hover { transform: scale(1.3); }
.tick.done, .tick.active { background: var(--ink); }

.ad-info { width: var(--video-w); margin-top: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 20px; }
.ad-info h2 { margin: 0; font-size: 18px; font-weight: 500; letter-spacing: -0.005em; }
.ad-info .sep { color: var(--muted); font-weight: 400; margin: 0 4px; }
.ad-info p { margin: 0; font-family: var(--mono); font-size: 12px; line-height: 1.4; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink); font-weight: 400; }

/* Annotations */
.lines { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 20; overflow: visible; }
.lines .ann-line { fill: none; stroke: var(--ink); stroke-width: 1.25; transition: stroke-dashoffset .7s cubic-bezier(.6,0,.2,1), opacity .4s; }
.lines .ann-dot { fill: #000; stroke: #fff; stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: pop .35s cubic-bezier(.3,1.6,.5,1) both; transition: opacity .4s; }
.lines .ann-pulse { fill: none; stroke: #fff; stroke-width: 1.5; transform-box: fill-box; transform-origin: center; animation: pulse 1.6s ease-out infinite; }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes pulse { from { transform: scale(1); opacity: .9; } to { transform: scale(3.2); opacity: 0; } }
.lines .leaving { opacity: 0; }

.blurbs { position: fixed; inset: 0; pointer-events: none; z-index: 21; }
/* Notes stack in one column; the newest is black, earlier ones still showing turn grey. */
.note-col { position: absolute; display: flex; flex-direction: column; gap: 22px; }
.blurb {
  opacity: 0; transform: translateY(4px); transition: opacity .45s ease .3s, transform .45s ease .3s, color .4s;
}
.blurb.show { opacity: 1; transform: none; }
.blurb .text { font-size: 15px; line-height: 1.5; text-wrap: pretty; }
.blurb:not(:last-child) { color: var(--muted); }
.blurb .aside { display: block; margin-top: 8px; font-style: italic; }


/* Read more popup */

/* Section jump menu (bottom left) */
.jump { position: fixed; left: 32px; bottom: 36px; z-index: 30; display: flex; gap: 14px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.jump button { padding: 0 0 2px; border: 0; border-bottom: 1px solid transparent; background: none; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--muted); transition: color .2s, border-color .2s; }
.jump button:hover { color: var(--ink); }
.jump button[aria-current="true"] { color: var(--ink); border-bottom-color: var(--ink); }
body.bib-open .jump { display: none; }
@media (max-width: 700px) { .jump { display: none; } }

.course-link { color: var(--ink); text-decoration: none; cursor: pointer; }
.course-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Pager */
.pager {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 16px; font-family: var(--mono); font-size: 12px; line-height: 1.4; letter-spacing: 0.04em; color: var(--ink); font-weight: 400;
}
.pager button {
  width: 38px; height: 38px; border: 0; background: transparent;
  cursor: pointer; font-family: var(--sans); font-size: 18px; color: var(--ink); transition: transform .2s;
}
#prevBtn:hover:not(:disabled) { transform: translateX(-3px); }
#nextBtn:hover:not(:disabled) { transform: translateX(3px); }
.pager button:disabled { opacity: .3; cursor: default; }

/* Edit mode */
.edit-panel {
  position: fixed; left: 24px; bottom: 24px; z-index: 40; width: 300px; max-height: 40vh; overflow: auto;
  background: #111; color: #eee; border-radius: 8px; padding: 12px 14px; font-size: 12px;
}
.edit-time { font-size: 18px; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.edit-hint { color: #aaa; margin-bottom: 8px; }
.edit-panel pre { margin: 0; white-space: pre-wrap; font-size: 12px; color: #cfe; }

/* Narrow screens (body.narrow, set from app.js): notes go under the video and the page scrolls */
.note-slot { display: none; }
body.narrow { overflow: auto; height: auto; }
body.narrow main { height: auto; min-height: 100vh; }
body.narrow .slide { position: relative; inset: auto; min-height: 100vh; justify-content: flex-start; padding: 110px 16px 120px; }
body.narrow .slide-text { justify-content: center; }
body.narrow .corner { position: absolute; top: 16px; }
body.narrow .corner-left { left: 16px; }
body.narrow .corner-right { right: 16px; }
@media (max-width: 560px) { .corner-center { top: 70px; } body.narrow .corner-center { top: 70px; } }
body.narrow .lines, body.narrow .blurbs { position: absolute; }
body.narrow .note-slot { display: block; width: var(--video-w); min-height: 190px; margin-top: 28px; }
body.narrow .cited { grid-template-columns: 1fr; max-height: none; }
body.narrow .ad-info { flex-direction: column; gap: 2px; }
