/* The Technium — Spoken Edition
   Print-archive aesthetic: the library is one long table of contents. */

:root {
  --paper: #f5efe2;
  --paper-deep: #ece3cf;
  --ink: #211c12;
  --ink-soft: #5c5442;
  --ink-faint: #a2977d;
  --signal: #c23a17;          /* broadcast red */
  --signal-soft: #c23a1722;
  --console: #1d1811;         /* player bar */
  --console-ink: #f0e8d6;
  --leader: #b5aa8e;
  --serif-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --serif-body: "Newsreader", Charter, Georgia, serif;
  --row-h: 2.6rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17130c;
    --paper-deep: #0f0c07;
    --ink: #eadfc6;
    --ink-soft: #b0a488;
    --ink-faint: #6f6550;
    --signal: #e8562c;
    --signal-soft: #e8562c26;
    --console: #0b0906;
    --console-ink: #eadfc6;
    --leader: #4a4232;
  }
}

* { box-sizing: border-box; }
/* The hidden attribute must always win: author display rules (flex,
   inline-block…) otherwise override the UA's [hidden] { display: none }. */
[hidden] { display: none !important; }
/* Clearance for the fixed player bar — only while it's actually shown, so an
   idle page has no dead space below the footer. */
body.has-player { padding-bottom: 9.5rem; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(ellipse at top, #fff3 0%, transparent 60%);
  color: var(--ink);
  font-family: var(--serif-body);
  font-size: 17px;
  line-height: 1.45;
  padding-bottom: 2rem; /* minimal when no player; .has-player reserves more */
}

/* ---------- masthead ---------- */
.masthead { max-width: 46rem; margin: 0 auto; padding: 2.2rem 1.2rem 0.6rem; }
.mast-rule { border-top: 3px double var(--ink); margin-bottom: 1rem; position: relative; }
.mast-rule::after { content: ""; display: block; border-top: 1px solid var(--ink); margin-top: 2px; }
.masthead h1 {
  font-family: var(--serif-display);
  font-weight: 850;
  font-variation-settings: "opsz" 144, "SOFT" 40;
  font-size: clamp(2.6rem, 9vw, 4.4rem);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 0.95;
}
.mast-sub { margin: 0.5rem 0 0; color: var(--ink-soft); font-style: italic; }
.spoken { color: var(--signal); font-style: normal; font-variant: small-caps; letter-spacing: 0.08em; font-weight: 600; }
.mast-stats { margin: 0.15rem 0 0; font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.mast-sync { margin: 0.1rem 0 0; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.mast-premium { margin: 0.1rem 0 0; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: #b8860b; }

.toolbar { display: flex; gap: 1rem; align-items: baseline; margin-top: 1.4rem; border-bottom: 1px solid var(--leader); padding-bottom: 0.6rem; }
.searchwrap { position: relative; flex: 1; }
#search {
  width: 100%; background: transparent; border: none; outline: none;
  font-family: var(--serif-body); font-style: italic; font-size: 1.05rem; color: var(--ink);
  border-bottom: 1px dotted transparent;
  padding-right: 1.6rem; /* room for the clear button */
}
#search::placeholder { color: var(--ink-faint); }
/* our own clear button replaces the inconsistent native one */
#search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-clear {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 1.2rem; line-height: 1;
  padding: 0.2rem 0.4rem; color: var(--ink-faint);
}
.search-clear:hover { color: var(--signal); }

/* ---------- library: the table of contents ---------- */
#library { max-width: 46rem; margin: 0 auto; padding: 0.8rem 1.2rem 3rem; }
.yeargroup { position: relative; margin-top: 2.2rem; }
.year {
  font-family: var(--serif-display);
  font-weight: 900; font-size: 2rem; line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1.2px var(--ink-faint);
  letter-spacing: 0.04em;
  margin: 0 0 0.6rem;
  user-select: none;
}
.row {
  display: flex; align-items: baseline; gap: 0.55rem;
  width: 100%; background: none; border: none; padding: 0.34rem 0;
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  border-bottom: none; position: relative;
}
.row:hover .t { color: var(--signal); }
.row .dot {
  flex: none; width: 9px; height: 9px; border-radius: 50%;
  border: 1.5px solid var(--ink-faint); background: transparent;
  transform: translateY(-1px);
}
.row.done .dot { background: var(--ink); border-color: var(--ink); }
.row.part .dot { background: linear-gradient(90deg, var(--signal) 50%, transparent 50%); border-color: var(--signal); }
.row.playing .dot { background: var(--signal); border-color: var(--signal); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px var(--signal-soft); } }
.row .t { font-size: 1.02rem; font-weight: 500; }
.row.playing .t { color: var(--signal); font-weight: 640; }
.row .leader { flex: 1; border-bottom: 1.5px dotted var(--leader); transform: translateY(-4px); min-width: 1.5rem; }
.row .m { flex: none; font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--ink-soft); }
.row .m .cached { color: var(--signal); }
.row .m .prem { color: #d4a017; font-size: 0.95em; }
.row.hidden { display: none; }

/* loading: the playing row's dot becomes a spinner */
.row.loading .dot {
  background: transparent;
  border: 1.5px solid var(--signal-soft);
  border-top-color: var(--signal);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: translateY(-1px) rotate(360deg); } }

/* ---------- reader overlay ---------- */
.reader {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto;
  background: var(--paper);
  animation: rise 0.22s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.reader-inner { max-width: 40rem; margin: 0 auto; padding: 3.2rem 1.4rem 12rem; }
.reader-close {
  position: fixed; top: 0.8rem; right: 1rem; z-index: 41;
  font-size: 1.8rem; line-height: 1; background: var(--paper-deep); color: var(--ink);
  border: 1px solid var(--leader); border-radius: 50%; width: 2.4rem; height: 2.4rem; cursor: pointer;
}
.reader-kicker { color: var(--signal); font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 700; margin: 0; }
.reader-listen {
  display: inline-block; margin: 0 0 1.2rem; padding: 0.45rem 1rem;
  background: var(--signal); color: #fff; border: none; border-radius: 999px;
  font-family: inherit; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.06em;
  cursor: pointer;
}
.reader-listen:hover { filter: brightness(1.12); }
.reader h2 { font-family: var(--serif-display); font-weight: 800; font-size: 2rem; line-height: 1.1; margin: 0.3rem 0 1.4rem; }
#readerBody p { margin: 0 0 1.05em; font-size: 1.1rem; line-height: 1.62; }
#readerBody p:first-of-type::first-letter {
  font-family: var(--serif-display); font-weight: 900; font-size: 3.1em;
  float: left; line-height: 0.82; padding: 0.04em 0.08em 0 0; color: var(--signal);
}
.reader-src a { color: var(--signal); }

/* ---------- player console ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--console); color: var(--console-ink);
  border-top: 3px solid var(--signal);
  padding: 0.55rem 1rem calc(0.8rem + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px #0005;
}
.player > * { max-width: 46rem; margin-left: auto; margin-right: auto; }
.seekwrap { position: relative; }
#seek {
  width: 100%; appearance: none; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--signal) var(--fill, 0%), #ffffff2a var(--fill, 0%));
  outline: none; margin: 0.2rem 0 0;
}
#seek::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--signal); border: 2px solid var(--console);
  box-shadow: 0 0 0 1px var(--signal);
}
#seek:disabled::-webkit-slider-thumb { background: #777; box-shadow: 0 0 0 1px #777; }

/* indeterminate: sweeping signal while a first render streams in */
.seekwrap.indeterminate #seek {
  background: repeating-linear-gradient(90deg,
    #ffffff2a 0 12px, var(--signal-soft) 12px 24px);
  background-size: 48px 100%;
  animation: sweep 0.9s linear infinite;
}
@keyframes sweep { to { background-position: 48px 0; } }
.times { display: flex; justify-content: space-between; font-size: 0.72rem; color: #ffffff88; font-variant-numeric: tabular-nums; margin-top: 0.15rem; }

.deck { display: grid; grid-template-columns: 1fr auto auto; gap: 0.9rem; align-items: center; margin-top: 0.25rem; }
.now { min-width: 0; }
.now-text { background: none; border: none; color: inherit; font: inherit; text-align: left; padding: 0; cursor: pointer; display: grid; min-width: 0; width: 100%; }
.now-title {
  font-family: var(--serif-display); font-weight: 640; font-size: 1.02rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.now-text:hover .now-title { color: var(--signal); }
.now-meta { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: #ffffff77; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.controls { display: flex; gap: 0.4rem; align-items: center; }
.ctl {
  background: none; border: 1px solid #ffffff33; color: var(--console-ink);
  width: 2.5rem; height: 2.5rem; border-radius: 50%; cursor: pointer; font-size: 0.9rem;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.ctl:hover { border-color: var(--signal); }
/* skip buttons: bare white arrows, no chrome */
.ctl-skip {
  border: none; background: none; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.12s ease, transform 0.08s ease;
}
.ctl-skip:hover { color: var(--signal); }
.ctl-skip:active { transform: scale(0.92); }
.ctl-play {
  width: 3.2rem; height: 3.2rem; background: var(--signal); border-color: var(--signal); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.ctl-play:hover { filter: brightness(1.12); }
/* SVG glyphs: identical everywhere (no emoji boxes on mobile) and truly
   centered — the play triangle gets a 2px optical nudge right. */
.ctl-play .ic-play { display: block; margin-left: 2px; }
.ctl-play .ic-pause { display: none; }
.ctl-play.playing .ic-play { display: none; }
.ctl-play.playing .ic-pause { display: block; }

/* loading/buffering: play button shows a rotating ring over a dimmed glyph */
.ctl-play.busy { position: relative; color: #ffffff55; }
.ctl-play.busy::after {
  content: '';
  position: absolute; inset: 5px;
  border: 3px solid #ffffff3a;
  border-top-color: #fff;
  border-radius: 50%;
  animation: ringspin 0.8s linear infinite;
}
@keyframes ringspin { to { transform: rotate(360deg); } }

.modes { display: flex; gap: 0.4rem; }
.pill {
  background: none; border: 1px solid #ffffff33; color: #ffffffaa;
  font-family: inherit; font-size: 0.72rem; letter-spacing: 0.12em; font-weight: 700;
  padding: 0.35rem 0.6rem; border-radius: 999px; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.pill:hover { border-color: var(--signal); color: var(--console-ink); }
.pill-speed {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--console);
  color-scheme: dark;
  padding-right: 1.35rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6'%3E%3Cpath d='M0 0l4 6 4-6z' fill='%23ffffffaa'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
}
.pill-speed option { background: var(--console); color: var(--console-ink); }
.pill-share { display: inline-flex; align-items: center; justify-content: center; padding: 0.35rem 0.55rem; }

/* ---------- endnote: terms · byline · links · build ---------- */
.endnote { max-width: 46rem; margin: 0 auto; padding: 0 1.2rem 2.4rem; text-align: center; }
.terms {
  max-width: 34rem; margin: 0 auto 0.6rem;
  font-size: 0.78rem; line-height: 1.55; color: var(--ink-faint);
  border-top: 1px solid var(--leader); padding-top: 1.1rem;
}
.terms a, .byline a { color: var(--ink-soft); }
.terms a:hover, .byline a:hover { color: var(--signal); }
.byline { max-width: 34rem; margin: 0 auto 0.9rem; font-size: 0.74rem; line-height: 1.5; color: var(--ink-faint); }
/* utility links, grouped and divided, separate from the prose above */
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; margin: 0; }
.foot-links > *:not(:first-child) { border-left: 1px solid var(--leader); }
.linklike {
  background: none; border: none; cursor: pointer; padding: 0.2rem 0.9rem;
  font-family: inherit; font-size: 0.7rem; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--ink-faint); text-decoration: none;
}
.linklike:hover { color: var(--signal); }
.build-tag { margin: 1rem 0 0; font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); opacity: 0.7; }
.backtop { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.9rem; }
.backtop svg { display: block; }
/* the "2004" jump-to-bottom link in the masthead stats */
.jump { color: var(--signal); text-decoration: none; border-bottom: 1px dotted var(--signal); }
.jump:hover { border-bottom-style: solid; }

/* ---------- add-to-home-screen hint ---------- */
.install-hint {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 56; max-width: min(88vw, 22rem);
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--leader); border-top: 4px solid var(--signal);
  padding: 1.1rem 1.3rem; text-align: center;
  box-shadow: 0 10px 40px #0005;
}
.install-hint p { margin: 0 0 0.7rem; line-height: 1.5; }

/* ---------- update pill (centered in the viewport) ---------- */
.update-bar {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 55; max-width: 90vw;
  background: var(--signal); color: #fff; border: none; border-radius: 999px;
  font-family: inherit; font-size: 0.95rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 0.75rem 1.5rem; cursor: pointer;
  box-shadow: 0 6px 24px #0007;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 10.5rem; transform: translateX(-50%) translateY(8px);
  z-index: 60; max-width: min(92vw, 30rem);
  background: var(--ink); color: var(--paper);
  font-size: 0.85rem; padding: 0.6rem 1rem; border-radius: 4px;
  border-left: 4px solid var(--signal);
  box-shadow: 0 6px 24px #0006;
  opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.renderNote { font-size: 0.72rem; color: var(--signal); margin-top: 0.35rem; letter-spacing: 0.06em; animation: blink 2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.45; } }

@media (max-width: 560px) {
  .deck { grid-template-columns: 1fr auto; }
  .modes { grid-column: 1 / -1; justify-content: center; margin-top: 0.1rem; }
  body.has-player { padding-bottom: 11.5rem; }
  /* Masthead: give the edition label its own line and keep the micro-lines
     from orphan-wrapping. */
  .mast-sep { display: none; }
  .mast-sub .spoken { display: block; margin-bottom: 0.15rem; }
  .mast-stats, .mast-sync, .mast-premium { font-size: 0.68rem; letter-spacing: 0.1em; }
  /* footer links stack vertically — dropped dividers, roomier spacing */
  .foot-links { flex-direction: column; gap: 0.6rem; }
  .foot-links > *:not(:first-child) { border-left: none; }
}
