/* ——————————————————————————————————————————————
   The Dreyfus Lectures · restored edition
   A university-press critical edition, set in motion.
   —————————————————————————————————————————————— */

:root {
  --paper: #f6f1e6;
  --paper-deep: #ece5d3;
  --paper-veil: rgba(246, 241, 230, 0.88);
  --ink: #211d18;
  --ink-soft: #6b6254;
  --ink-faint: #968b78;
  --rule: #d8cfba;
  --rule-strong: #b9ad92;
  --accent: #8c2f1b;
  --accent-soft: rgba(140, 47, 27, 0.08);
  --highlight: rgba(176, 141, 62, 0.16);
  --highlight-strong: rgba(176, 141, 62, 0.30);
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --mono: "Spline Sans Mono", "SF Mono", ui-monospace, monospace;
  --col: 67ch;
  --note-w: 250px;
  --player-h: 92px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #181410;
    --paper-deep: #211c16;
    --paper-veil: rgba(24, 20, 16, 0.88);
    --ink: #e9e1cf;
    --ink-soft: #a89c86;
    --ink-faint: #776c5a;
    --rule: #383025;
    --rule-strong: #4d4233;
    --accent: #d96e4a;
    --accent-soft: rgba(217, 110, 74, 0.10);
    --highlight: rgba(176, 141, 62, 0.18);
    --highlight-strong: rgba(176, 141, 62, 0.34);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.62;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--highlight-strong); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.mono { font-family: var(--mono); }

/* ————— masthead ————— */

.masthead {
  max-width: 56rem;
  margin: 0 auto;
  padding: 4.5rem 1.5rem 0;
  text-align: center;
}

.masthead > * { animation: settle 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.masthead > *:nth-child(2) { animation-delay: 0.08s; }
.masthead > *:nth-child(3) { animation-delay: 0.16s; }
.masthead > *:nth-child(4) { animation-delay: 0.24s; }
.masthead > *:nth-child(5) { animation-delay: 0.32s; }

@keyframes settle {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 1rem;
}
.kicker a { color: inherit; }
.kicker .sep { color: var(--rule-strong); margin: 0 0.6em; }

.lecture-no {
  font-size: clamp(3.2rem, 9vw, 5.4rem);
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin: 0;
}

.lecture-title {
  font-size: clamp(1.25rem, 3.2vw, 1.7rem);
  font-weight: 400;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 0.6rem 0 0;
}

.meta-row {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin: 1.4rem 0 0;
  letter-spacing: 0.04em;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 0.6em;
  row-gap: 0.3em;
}
.meta-row > span { white-space: nowrap; }
.meta-row .restored { color: var(--accent); }

.double-rule {
  max-width: 56rem;
  margin: 2.6rem auto 0;
  padding: 0 1.5rem;
  border: 0;
}
.double-rule::before {
  content: "";
  display: block;
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  height: 4px;
}

/* ————— prologue: intro, readings, contents ————— */

.prologue {
  max-width: var(--col);
  margin: 0 auto;
  padding: 3rem 1.5rem 0;
}

.prologue .lede {
  font-size: 1.16rem;
  line-height: 1.66;
}
.prologue .lede::first-letter {
  font-size: 3.1em;
  font-style: italic;
  float: left;
  line-height: 0.82;
  padding: 0.07em 0.12em 0 0;
  color: var(--accent);
}

.panel {
  margin: 2.8rem 0 0;
  border-top: 1px solid var(--rule);
  padding-top: 1.4rem;
}

.panel h2 {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 1.1rem;
}

.readings { list-style: none; margin: 0; padding: 0; }
.readings li { margin: 0 0 1.15rem; padding-left: 1.4rem; position: relative; }
.readings li::before {
  content: "§";
  position: absolute; left: 0; top: 0;
  color: var(--accent);
  font-style: italic;
}
.readings .cite { display: block; }
.readings .cite em { font-style: italic; }
.readings .why {
  display: block;
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.readings .where {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
}

.contents { list-style: none; margin: 0; padding: 0; }
.contents li { margin: 0; }
.contents a {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  color: inherit;
  padding: 0.34rem 0;
  border-bottom: 1px dotted var(--rule);
}
.contents a:hover { text-decoration: none; color: var(--accent); }
.contents .n {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--accent);
  min-width: 2.2em;
}
.contents .dots { flex: 1; }
.contents .t-time {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-faint);
}

/* ————— transcript ————— */

.transcript {
  margin: 4rem auto 0;
  padding: 0 1.5rem;
  max-width: calc(var(--col) + var(--note-w) + 3.5rem);
}

.chapter-head {
  max-width: var(--col);
  margin: 4.2rem 0 1.8rem;
  scroll-margin-top: 2rem;
}
.chapter-head .roman {
  display: block;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--accent);
  margin-bottom: 0.15rem;
}
.chapter-head h2 {
  font-size: 1.5rem;
  font-weight: 500;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  line-height: 1.25;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 1rem;
}
.chapter-head .jump {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-variant: normal;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  white-space: nowrap;
}
.chapter-head .jump:hover { color: var(--accent); text-decoration: none; }

.block {
  display: grid;
  grid-template-columns: minmax(0, var(--col)) var(--note-w);
  column-gap: 3.5rem;
  margin: 0 0 1.45rem;
}

.block > p {
  grid-column: 1;
  margin: 0;
}

.qa > p {
  border-left: 2px solid var(--rule-strong);
  padding-left: 1.1rem;
  font-size: 0.98em;
}
.qa .who {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 0.2rem;
}

.notes {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
}
.note {
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--ink-soft);
  border-top: 1px solid var(--rule);
  padding-top: 0.5rem;
  transition: color 0.4s;
}
/* a second note on the same block stacks below the first */
.note + .note { margin-top: 0.9rem; }
.note .term {
  display: block;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-size: 0.95rem;
}
.note .de {
  font-style: italic;
  color: var(--ink-faint);
  font-size: 0.8rem;
  display: block;
  margin-bottom: 0.15rem;
}

.seg {
  cursor: pointer;
  border-radius: 3px;
  padding: 0.05em 0.05em;
  margin: -0.05em -0.05em;
  transition: background-color 0.25s ease;
}
.seg:hover { background: var(--accent-soft); }
.seg.active { background: var(--highlight-strong); }
.block.played .seg { color: color-mix(in srgb, var(--ink) 78%, var(--paper)); }
.block.played .seg.active { color: var(--ink); }

/* ————— colophon ————— */

.colophon {
  max-width: var(--col);
  margin: 5rem auto 0;
  padding: 2.2rem 1.5rem 4rem;
  border-top: 1px solid var(--rule-strong);
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.colophon h2 {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0 0 1rem;
  color: var(--ink-soft);
}
.colophon h3 {
  font-size: 1rem;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin: 2rem 0 0.5rem;
  color: var(--ink);
}
.cuts { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.cuts td {
  padding: 0.4rem 0.6rem 0.4rem 0;
  border-top: 1px dotted var(--rule);
  vertical-align: top;
}
.cuts .tc { font-family: var(--mono); font-size: 0.74rem; color: var(--ink-faint); white-space: nowrap; }
.cuts .dur { font-family: var(--mono); font-size: 0.74rem; color: var(--ink-faint); text-align: right; white-space: nowrap; }

/* ————— player ————— */

body { padding-bottom: calc(var(--player-h) + 2.5rem); }

.player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: var(--paper-veil);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
  border-top: 1px solid var(--rule-strong);
}

.player-inner {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0.7rem 1.2rem 0.85rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "play info ctrl" "play track ctrl";
  column-gap: 1.1rem;
  row-gap: 0.45rem;
  align-items: center;
}

.btn-play {
  grid-area: play;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--paper);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, background 0.2s;
}
.btn-play:hover { transform: scale(1.05); }
.btn-play:active { transform: scale(0.97); }
.btn-play svg { width: 20px; height: 20px; fill: currentColor; }
.btn-play .i-pause { display: none; }
.player.playing .i-play { display: none; }
.player.playing .i-pause { display: block; }

.player-info {
  grid-area: info;
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  min-width: 0;
}
.now-chapter {
  font-variant: small-caps;
  letter-spacing: 0.05em;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.now-chapter .roman-sm { font-style: italic; color: var(--accent); margin-right: 0.45em; }
.time {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  white-space: nowrap;
  margin-left: auto;
}
.time .cur { color: var(--ink-soft); }

.track {
  grid-area: track;
  display: flex;
  gap: 3px;
  height: 18px;
  align-items: center;
  cursor: pointer;
  touch-action: none;
}
.track .ch-seg {
  position: relative;
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
  transition: height 0.15s ease;
}
.track:hover .ch-seg, .track.scrubbing .ch-seg { height: 7px; }
.track .fill {
  position: absolute;
  inset: 0 100% 0 0;
  background: var(--accent);
  border-radius: 2px;
}

.player-ctrl {
  grid-area: ctrl;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.pbtn {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.42rem 0.7rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.pbtn:hover { border-color: var(--rule-strong); color: var(--ink); }
.pbtn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--paper); }

.pill {
  position: fixed;
  bottom: calc(var(--player-h) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  z-index: 49;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.pill.show { opacity: 1; pointer-events: auto; transform: translateX(-50%); }

/* ————— index page ————— */

.course-hero {
  max-width: 56rem;
  margin: 0 auto;
  padding: 5.5rem 1.5rem 0;
  text-align: center;
}
.course-hero h1 {
  font-size: clamp(2.6rem, 7.5vw, 4.6rem);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.012em;
  margin: 1.2rem 0 0;
}
.course-hero h1 em { font-style: italic; }
.course-hero .byline {
  font-variant: small-caps;
  letter-spacing: 0.1em;
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin: 1.1rem 0 0;
}
.course-hero .blurb {
  max-width: 38rem;
  margin: 1.6rem auto 0;
  font-size: 1.06rem;
  color: var(--ink-soft);
}

.lecture-list {
  max-width: 44rem;
  margin: 3.2rem auto 0;
  padding: 0 1.5rem 2rem;
  list-style: none;
}
.lecture-list li { margin: 0; }
.lecture-list a, .lecture-list .pending {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.78rem 0.2rem;
  border-bottom: 1px solid var(--rule);
  color: inherit;
}
.lecture-list a:hover { text-decoration: none; background: var(--accent-soft); }
.lecture-list .n {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
  min-width: 2.4em;
}
.lecture-list .pending .n { color: var(--ink-faint); }
.lecture-list .lt { flex: 1; }
.lecture-list .pending .lt { color: var(--ink-faint); }
.lecture-list .badge {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}
.lecture-list .pending .badge { color: var(--ink-faint); border-style: dotted; }
.lecture-list .dur { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint); }

.site-foot {
  max-width: 44rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 3.5rem;
  font-size: 0.84rem;
  color: var(--ink-faint);
  text-align: center;
}

/* ————— responsive ————— */

@media (max-width: 1080px) {
  .transcript { max-width: calc(var(--col) + 3rem); }
  .block { grid-template-columns: minmax(0, var(--col)); }
  .notes {
    grid-column: 1;
    grid-row: auto;
    order: 2;
  }
  .note {
    margin-top: 0.7rem;
    border-top: none;
    border-left: 2px solid var(--rule-strong);
    padding: 0.1rem 0 0.1rem 0.9rem;
    max-width: 34rem;
  }
  .note + .note { margin-top: 0.7rem; }
}

@media (max-width: 700px) {
  body { font-size: 16px; --player-h: 132px; }
  .player-inner {
    grid-template-columns: auto 1fr;
    grid-template-areas: "play info" "track track" "ctrl ctrl";
    padding: 0.6rem 1rem 0.7rem;
  }
  .btn-play { width: 46px; height: 46px; }
  .player-ctrl { justify-content: center; }
  .masthead { padding-top: 3rem; }
}

/* ————— print: a clean reading copy ————— */

@media print {
  .player, .pill, .contents, .skip-link { display: none !important; }
  body { padding-bottom: 0; background: #fff; color: #000; }
  .seg { cursor: auto; }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* ————— prev / next lecture nav ————— */
.lecture-nav {
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 1.5rem 3.2rem;
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
}
.lecture-nav a {
  text-decoration: none;
  color: var(--ink);
  max-width: 46%;
}
.lecture-nav a.next { margin-left: auto; text-align: right; }
.lecture-nav .dir {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-bottom: 0.3rem;
}
.lecture-nav .which { font-style: italic; color: var(--accent); }
.lecture-nav a:hover .which { text-decoration: underline; }
