/* The Tune on a Single Syllable — essay site styles */

:root {
  --bg: #0c0e16;
  --bg-2: #12152100;
  --surface: #141827;
  --surface-2: #1b2033;
  --text: #ece6d9;
  --text-2: #b5ad9c;
  --muted: #7f7868;
  --rule: #272c3d;
  --ember: #f08a2c;
  --ember-2: #ffb15c;
  --gold: #e6b84a;
  --blue: #6f86d6;
  --staff: #3a4160;
  --hero-fade: rgba(12, 14, 22, 0);
  --hero-solid: #0c0e16;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --display: "Fraunces", "Newsreader", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --measure: 66ch;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #f1eadc;
  --text: #1c1a17;
  --text-2: #4e483f;
  --muted: #7d7568;
  --rule: #e2d9c8;
  --ember: #c8561a;
  --ember-2: #e0702e;
  --gold: #a9801c;
  --blue: #3b55b5;
  --staff: #cfc4ad;
  --hero-fade: rgba(246, 241, 231, 0);
  --hero-solid: #f6f1e7;
  --shadow: 0 30px 80px rgba(60, 40, 10, 0.18);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.65;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
}

::selection { background: var(--ember); color: #0c0e16; }

a { color: var(--ember-2); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--ember-2) 45%, transparent); transition: border-color 0.2s; }
a:hover { border-bottom-color: var(--ember-2); }

img { max-width: 100%; height: auto; display: block; }

/* Progress bar */
.progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%;
  background: transparent; z-index: 50; pointer-events: none;
}
.progress > span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--ember), var(--gold));
  box-shadow: 0 0 12px var(--ember);
  transition: width 0.1s linear;
}

/* Top bar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  font-family: var(--sans); font-size: 0.8rem; letter-spacing: 0.04em;
  color: var(--text-2);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar .brand {
  color: inherit; border: 1px solid transparent; opacity: 0.9; text-transform: uppercase;
  padding: 10px 14px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 70%, transparent); backdrop-filter: blur(10px);
  transition: border-color 0.2s;
}
.hero .topbar .brand { background: transparent; }
.topbar .brand:hover { color: var(--ember-2); }
.theme-toggle {
  appearance: none; border: 1px solid var(--rule); background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(10px); color: var(--text); border-radius: 999px;
  width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}
.theme-toggle:hover { transform: rotate(15deg); border-color: var(--ember); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: block; }
:root[data-theme="light"] .theme-toggle .moon { display: none; }

/* Hero */
.hero {
  position: relative; min-height: 100svh;
  display: grid; align-items: end;
  overflow: hidden;
  isolation: isolate;
}
.hero-art {
  position: absolute; inset: 0; z-index: -2;
  width: 100%; height: 100%; object-fit: cover; object-position: center;
  transform: scale(1.06);
  animation: hero-drift 24s ease-in-out infinite alternate;
}
@keyframes hero-drift { from { transform: scale(1.06) translateY(0); } to { transform: scale(1.12) translateY(-2%); } }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(to bottom, rgba(12, 14, 22, 0.35) 0%, rgba(12, 14, 22, 0.15) 35%, var(--hero-solid) 92%),
    radial-gradient(60% 50% at 30% 70%, rgba(12, 14, 22, 0.55), transparent 70%);
}
:root[data-theme="light"] .hero::before {
  background:
    linear-gradient(to bottom, rgba(12, 14, 22, 0.25) 0%, rgba(12, 14, 22, 0.15) 40%, rgba(12, 14, 22, 0.82) 72%, rgba(14, 16, 24, 0.96) 100%);
}
:root[data-theme="light"] .hero { border-bottom: 1px solid var(--rule); }
.hero-inner {
  position: relative; width: min(1100px, 100% - 40px); margin: 0 auto;
  padding: 18vh 0 10vh;
  color: #f3eee2;
}
.eyebrow {
  font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ember-2); margin: 0 0 18px; display: flex; align-items: center; gap: 14px;
}
.eyebrow::before { content: ""; width: 36px; height: 1px; background: currentColor; opacity: 0.8; }
.hero h1 {
  font-family: var(--display); font-weight: 300; font-variation-settings: "opsz" 144, "SOFT" 40;
  font-size: clamp(2.8rem, 8.5vw, 7.2rem); line-height: 0.98; letter-spacing: -0.02em;
  margin: 0 0 22px; max-width: 12ch;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.45);
}
.hero h1 em { font-style: italic; color: var(--ember-2); font-weight: 400; }
.hero .dek {
  font-family: var(--serif); font-size: clamp(1.15rem, 2.2vw, 1.55rem); line-height: 1.4;
  max-width: 34ch; margin: 0 0 32px; color: #e3dccd; font-style: italic;
}
.byline {
  font-family: var(--sans); font-size: 0.85rem; letter-spacing: 0.02em; color: #cfc7b7;
  display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center;
}
.byline strong { color: #fff; font-weight: 600; }
.byline .dot { opacity: 0.4; }
.scroll-cue {
  position: absolute; right: 24px; bottom: 28px;
  font-family: var(--sans); font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: #cfc7b7; writing-mode: vertical-rl; display: flex; align-items: center; gap: 10px;
}
.scroll-cue::after { content: ""; width: 1px; height: 46px; background: linear-gradient(var(--ember-2), transparent); animation: cue 1.8s ease-in-out infinite; }
@keyframes cue { 0%, 100% { opacity: 0.3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(6px); } }

/* Layout */
.layout {
  width: min(1180px, 100% - 40px); margin: 0 auto;
  display: grid; grid-template-columns: 1fr; gap: 0 60px;
  padding: 40px 0 80px;
}
@media (min-width: 1100px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
}

/* TOC */
.toc { display: none; }
@media (min-width: 1100px) {
  .toc {
    display: block; position: sticky; top: 90px; align-self: start;
    font-family: var(--sans); font-size: 0.8rem; line-height: 1.4;
    padding-right: 12px;
  }
}
.toc h2 { font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; font-weight: 600; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc li a {
  display: block; padding: 7px 0 7px 16px; border: 0; color: var(--text-2);
  margin-left: -1px; border-left: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.toc li a:hover { color: var(--text); }
.toc li a.active { color: var(--ember-2); border-left-color: var(--ember); }
.toc .num { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }

/* Essay */
.essay { max-width: var(--measure); }
.essay section { padding: 36px 0 20px; }
.essay section + section { border-top: 1px solid var(--rule); }
.essay h2 {
  font-family: var(--display); font-weight: 400; font-variation-settings: "opsz" 72, "SOFT" 30;
  font-size: clamp(1.7rem, 3.4vw, 2.4rem); line-height: 1.12; letter-spacing: -0.01em;
  margin: 0 0 26px; scroll-margin-top: 80px;
}
.essay h2 .num {
  display: block; font-family: var(--sans); font-size: 0.75rem; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--ember-2); margin-bottom: 14px; font-weight: 600;
}
.essay p { margin: 0 0 1.25em; }
.essay p strong { font-weight: 600; color: var(--text); font-variation-settings: "opsz" 24; }
.essay ul { padding-left: 1.2em; margin: 0 0 1.4em; }
.essay li { margin: 0 0 0.6em; padding-left: 0.2em; }
.essay li::marker { color: var(--ember); }
.essay em { font-style: italic; }

/* Drop cap on each section opener */
.essay section > p.lede::first-letter {
  font-family: var(--display); font-weight: 300; font-variation-settings: "opsz" 144, "SOFT" 60;
  float: left; font-size: 4.6em; line-height: 0.78; padding: 0.08em 0.12em 0 0;
  color: var(--ember-2);
}

/* Pull quotes */
.pull {
  margin: 44px 0 44px -8px; padding: 6px 0 6px 26px;
  border-left: 3px solid var(--ember);
  font-family: var(--display); font-weight: 300; font-style: italic;
  font-variation-settings: "opsz" 72, "SOFT" 60;
  font-size: clamp(1.35rem, 2.6vw, 1.85rem); line-height: 1.3; color: var(--text);
}
@media (min-width: 1100px) {
  .pull { margin-left: -40px; }
}

/* Figures */
figure.art { margin: 48px 0; }
figure.art img { border-radius: 10px; box-shadow: var(--shadow); }
figure.art figcaption, .fig-caption {
  font-family: var(--sans); font-size: 0.78rem; color: var(--muted); margin-top: 12px; line-height: 1.5;
}
@media (min-width: 1100px) {
  figure.art.wide { margin-left: -120px; margin-right: -120px; }
}

/* Contour explorer */
.explorer {
  margin: 48px 0 56px; padding: 26px 26px 22px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--rule); border-radius: 16px;
  box-shadow: var(--shadow);
}
@media (min-width: 1100px) { .explorer { margin-left: -60px; margin-right: -60px; padding: 32px; } }
.explorer-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.explorer h3 { font-family: var(--display); font-weight: 400; font-size: 1.45rem; margin: 0; font-variation-settings: "opsz" 48; }
.explorer .hint { font-family: var(--sans); font-size: 0.75rem; color: var(--muted); letter-spacing: 0.04em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; }
.chip {
  appearance: none; cursor: pointer; font-family: var(--sans); font-size: 0.82rem; font-weight: 600;
  letter-spacing: 0.02em; color: var(--text-2); background: transparent;
  border: 1px solid var(--rule); border-radius: 999px; padding: 8px 14px;
  transition: all 0.2s;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip[aria-pressed="true"] { color: #0c0e16; background: var(--ember-2); border-color: var(--ember-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ember) 25%, transparent); }
.staff-wrap { position: relative; }
.staff { width: 100%; height: auto; display: block; }
.staff .line { stroke: var(--staff); stroke-width: 1; }
.staff .level-label { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
.staff .ghost { fill: none; stroke: var(--staff); stroke-width: 1.5; stroke-dasharray: 3 5; opacity: 0.6; }
.staff .contour { fill: none; stroke: url(#emberGrad); stroke-width: 6; stroke-linecap: round; filter: url(#glow); }
.staff .spark { fill: #fff3d6; filter: url(#glow); }
.staff .word { font-family: var(--display); font-style: italic; font-size: 30px; fill: var(--text); font-weight: 300; }
.readout {
  display: grid; grid-template-columns: 1fr; gap: 14px 24px; margin-top: 14px;
  font-family: var(--sans);
}
@media (min-width: 720px) { .readout { grid-template-columns: 1.4fr 1fr; } }
.readout .gloss { font-family: var(--serif); font-size: 1.15rem; line-height: 1.45; color: var(--text); margin: 0; }
.readout .gloss em { color: var(--ember-2); }
.readout dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 0.8rem; align-content: start; }
.readout dt { color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.68rem; padding-top: 2px; }
.readout dd { margin: 0; color: var(--text-2); font-variant-numeric: tabular-nums; }
.readout dd code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.78rem; color: var(--text); }

/* Sources */
.sources { font-size: 0.95rem; color: var(--text-2); }
.sources ul { padding-left: 1.1em; }
.sources li { margin-bottom: 0.5em; }

/* Colophon */
.colophon {
  border-top: 1px solid var(--rule); margin-top: 20px; padding: 48px 0 60px;
  font-family: var(--sans); font-size: 0.85rem; line-height: 1.6; color: var(--text-2);
}
.colophon .inner { width: min(1180px, 100% - 40px); margin: 0 auto; display: grid; gap: 28px; }
@media (min-width: 900px) { .colophon .inner { grid-template-columns: 1.2fr 1fr 1fr; } }
.colophon h3 { font-family: var(--display); font-weight: 400; font-size: 1.2rem; color: var(--text); margin: 0 0 10px; }
.colophon p { margin: 0 0 10px; }
.colophon .mark { font-family: var(--display); font-style: italic; font-size: 2rem; color: var(--ember-2); line-height: 1; margin-bottom: 14px; }
.colophon .fine { font-size: 0.75rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .hero-art { animation: none; }
  .scroll-cue::after { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---------- Read-along ---------- */
.w { border-radius: 3px; transition: background-color 0.12s, color 0.12s; }
.player-open .w { cursor: pointer; }
.player-open .w:hover { background: color-mix(in srgb, var(--ember) 18%, transparent); }
.w.reading { background: var(--ember-2); color: #0c0e16; box-shadow: 0 0 0 2px var(--ember-2); }
[data-b].reading-block { position: relative; }
.essay p.reading-block::before, .essay li.reading-block::before, .essay h2.reading-block::before {
  content: ""; position: absolute; left: -22px; top: 0.35em; bottom: 0.35em; width: 3px; border-radius: 2px;
  background: linear-gradient(var(--ember), var(--gold)); opacity: 0.9;
}
.player-open body, body.player-open { padding-bottom: 110px; }

.listen-cta {
  appearance: none; cursor: pointer; margin-top: 26px;
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--sans); font-size: 0.9rem; font-weight: 600; letter-spacing: 0.02em;
  color: #0c0e16; background: linear-gradient(135deg, var(--ember-2), var(--gold));
  border: 0; border-radius: 999px; padding: 12px 20px 12px 14px;
  box-shadow: 0 10px 30px rgba(240, 138, 44, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}
.listen-cta:hover { transform: translateY(-1px); box-shadow: 0 14px 36px rgba(240, 138, 44, 0.45); }
.listen-cta svg { width: 26px; height: 26px; fill: currentColor; background: rgba(12, 14, 22, 0.18); border-radius: 50%; padding: 5px; }
.listen-cta small { font-weight: 400; opacity: 0.75; }

.h-listen {
  appearance: none; cursor: pointer; vertical-align: middle; margin-left: 12px;
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--rule); background: transparent;
  position: relative; transition: border-color 0.2s, background-color 0.2s;
}
.h-listen::before { content: ""; position: absolute; left: 11px; top: 8px; border-style: solid; border-width: 7px 0 7px 11px; border-color: transparent transparent transparent var(--ember-2); }
.h-listen:hover { border-color: var(--ember); background: color-mix(in srgb, var(--ember) 12%, transparent); }

.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(16px);
  border-top: 1px solid var(--rule); box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
  font-family: var(--sans);
}
.player-inner { width: min(1180px, 100% - 24px); margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 12px 0; }
.player button { font-family: inherit; }
.player-play {
  appearance: none; cursor: pointer; flex: none; width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: linear-gradient(135deg, var(--ember-2), var(--gold)); color: #0c0e16; display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(240, 138, 44, 0.35);
}
.player-play svg { width: 22px; height: 22px; fill: currentColor; }
.player-play .ico-pause { display: none; }
.player.playing .ico-pause { display: block; }
.player.playing .ico-play { display: none; }
.player-mid { flex: 1 1 auto; min-width: 0; }
.player-row { display: flex; justify-content: space-between; gap: 10px; font-size: 0.78rem; margin-bottom: 6px; }
.player-label { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.player-bar { height: 6px; border-radius: 3px; background: var(--rule); cursor: pointer; overflow: hidden; }
.player-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ember), var(--gold)); }
.player-controls { display: flex; align-items: center; gap: 8px; flex: none; }
.player-controls > button {
  appearance: none; cursor: pointer; border: 1px solid var(--rule); background: transparent; color: var(--text-2);
  border-radius: 999px; height: 34px; min-width: 34px; padding: 0 10px; font-size: 0.78rem; font-weight: 600;
}
.player-controls > button:hover { color: var(--text); border-color: var(--muted); }
.player-follow[aria-pressed="true"] { color: var(--ember-2); border-color: var(--ember); }
.player-field { display: flex; flex-direction: column; font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); gap: 2px; }
.player-field select {
  font-family: var(--sans); font-size: 0.78rem; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--rule); border-radius: 8px; padding: 5px 8px; max-width: 220px;
}
@media (max-width: 760px) {
  .player-inner { flex-wrap: wrap; }
  .player-mid { order: 1; flex-basis: 100%; }
  .player-play { order: 0; }
  .player-controls { order: 0; margin-left: auto; }
  .player-field span { display: none; }
  .player-field select { max-width: 120px; }
  .player-follow { display: none; }
  body.player-open { padding-bottom: 150px; }
}

/* Hear it */
.hear-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-family: var(--sans); font-size: 0.78rem; color: var(--muted); }
.hear, .tone-line {
  appearance: none; cursor: pointer; font-family: var(--sans); font-weight: 600; font-size: 0.82rem;
  color: var(--text); background: color-mix(in srgb, var(--ember) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--ember) 45%, transparent); border-radius: 999px; padding: 8px 14px 8px 12px;
  display: inline-flex; align-items: center; gap: 10px; transition: background-color 0.2s, border-color 0.2s;
}
.hear::before, .tone-play { content: ""; display: inline-block; width: 0; height: 0; border-style: solid; border-width: 6px 0 6px 10px; border-color: transparent transparent transparent var(--ember-2); }
.hear:hover, .tone-line:hover { background: color-mix(in srgb, var(--ember) 26%, transparent); border-color: var(--ember); }
.tone-playing { background: var(--ember-2) !important; color: #0c0e16 !important; }
.tone-playing::before, .tone-playing .tone-play { border-left-color: #0c0e16; }

.tones {
  margin: 40px 0; padding: 22px 24px;
  border: 1px solid var(--rule); border-radius: 14px; background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.tones-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tones h3 { font-family: var(--display); font-weight: 400; font-size: 1.3rem; margin: 0; }
.tones-voice { font-family: var(--sans); font-size: 0.75rem; color: var(--muted); }
.tones-blurb { font-size: 0.95rem; color: var(--text-2); margin: 8px 0 16px; }
.tones ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.tones li { margin: 0; padding: 0; }
.tone-line { font-family: var(--serif); font-weight: 400; font-size: 1.02rem; font-style: italic; }
.tone-line:disabled { opacity: 0.4; cursor: default; }
