/* ============================================================================
 * SpecEnvoy — "The <Instrument> Through Time" — SHARED timeline styles
 * Vertical "river of time": eras stack top→bottom; desktop gets a sticky era
 * rail on the left; mobile is a single scrolling column with a full-screen
 * placard sheet. Mobile-first; the @media (min-width:820px) block adds desktop.
 * Uses the site palette from /style.css (:root vars).
 * ========================================================================== */

.tl-wide { max-width: 1080px; }

/* ---------------------------------------------------------------- intro --- */
.tl-intro { color: var(--muted); margin: -6px 0 26px; max-width: 640px; }

/* top toolbar: a quiet text KEY (left) + the Hide-all control (right) */
.tl-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 22px; }
.tl-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 15px;
  font-size: 12.5px; color: var(--muted); flex: 1 1 auto; min-width: 0; }
.tl-key .kt { text-transform: uppercase; letter-spacing: .1em; font-size: 10.5px; opacity: .7; }
.tl-key .k { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tl-key .kd { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.tl-key .kd.sig { background: var(--heart); }
.tl-key .ks { font-weight: 700; font-size: 11.5px; line-height: 1; color: var(--accent); width: 12px; text-align: center; flex: none; }
.tl-key .ks.pz { color: #b078dc; }
.tl-toolbar .era-allbtn { flex: none; font-size: 13px; color: var(--ink); background: var(--card);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 15px; cursor: pointer; }
.tl-toolbar .era-allbtn:hover { background: rgba(255,255,255,.08); border-color: rgba(91,134,236,.45); }

/* ============================================================== timeline === */
/* the river spine (the vertical line everything hangs off). Painted as a
   background so it fills the timeline's full height reliably in every browser —
   Firefox won't stretch a top+bottom-anchored absolute pseudo-element inside an
   auto-height container (Chrome does), so the line was missing there. */
.timeline {
  position: relative;
  background-image: linear-gradient(180deg, transparent, var(--border) 8px, var(--border) calc(100% - 8px), transparent);
  background-repeat: no-repeat;
  background-size: 2px 100%;
  background-position: 13px 0;
}

/* --- era block --- */
.era { position: relative; padding: 0 0 10px 40px; margin-bottom: 26px; }
.era-head { position: relative; margin: 0 0 6px; cursor: pointer; user-select: none; border-radius: 8px; }
.era-head:hover { background: rgba(255,255,255,.03); }
.era-node { /* the clickable node on the spine */
  position: absolute; left: -33px; top: 7px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--bg-top); border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(59,111,224,.12); cursor: pointer; transition: transform .15s ease, background .15s ease;
}
.era-head:hover .era-node { transform: scale(1.18); background: var(--accent); }
.era-name { font-size: clamp(20px, 4.5vw, 26px); font-weight: 700; letter-spacing: -.01em; display: inline; }
.era-span { font-size: 13px; color: var(--muted); margin-left: 10px; white-space: nowrap; }
.era-blurb { color: var(--muted); font-size: 14.5px; margin: 4px 0 16px; max-width: 620px; }
.era-toggle { float: right; color: var(--muted); font-size: 13px; border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px; background: var(--card); }

/* --- composer cards inside an era --- */
.composer-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }

.composer {
  position: relative;
  display: flex; gap: 14px; align-items: center; text-align: left;
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--card); color: inherit; cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
/* "▶ N" playable badge on composers that have play-with-score pieces */
.composer .c-play {
  position: absolute; top: 8px; right: 8px;
  font-size: 11px; font-weight: 600; color: #fff; background: var(--accent);
  border-radius: 999px; padding: 2px 8px; letter-spacing: .01em; white-space: nowrap;
}
.composer .c-play .c-ens { opacity: .92; margin-left: 1px; }
.composer:hover { transform: translateY(-2px); border-color: rgba(91,134,236,.45); background: rgba(255,255,255,.06); }
.composer:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.composer .avatar {
  flex: 0 0 auto; width: 58px; height: 58px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(150deg, #24315c, #161f3d); display: grid; place-items: center;
  border: 1px solid var(--border);
}
.composer .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.composer .avatar .monogram { font-size: 22px; font-weight: 700; color: #9fb2e8; letter-spacing: .02em; }

.composer .who { min-width: 0; }
.composer .cname { font-weight: 650; font-size: 16.5px; }
.composer .clife { font-size: 13px; color: var(--muted); margin-top: 1px; }
.composer .cwhy { font-size: 13.5px; color: var(--muted); margin-top: 5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* collapsed era */
.era.collapsed .composer-grid, .era.collapsed .era-blurb { display: none; }

/* ============================================ desktop: sticky era rail ===== */
@media (min-width: 820px) {
  .tl-stage { display: grid; grid-template-columns: 190px 1fr; gap: 36px; align-items: start; }
  .era-rail { position: sticky; top: 20px; display: block; }
  .era-rail .rail-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
    color: var(--muted); margin-bottom: 12px; }
  .era-rail a { display: block; padding: 8px 12px; border-radius: 10px; color: var(--muted);
    text-decoration: none; font-size: 14.5px; border: 1px solid transparent; transition: .15s; }
  .era-rail a:hover { color: var(--ink); background: var(--card); }
  .era-rail a.active { color: var(--ink); background: var(--accent-soft); border-color: rgba(59,111,224,.35); }
  .era-rail a .yrs { display: block; font-size: 12px; color: var(--muted); }
  .composer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 819px) { .era-rail { display: none; } }

/* =============================================== placard (composer card) === */
.scrim {
  position: fixed; inset: 0; background: rgba(4,7,16,.66); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .22s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.placard {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, #141d3a, #0d142b);
  border: 1px solid var(--border); border-radius: 18px; padding: 26px 26px 30px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
  transform: translateY(16px) scale(.985); transition: transform .26s cubic-bezier(.2,.8,.2,1);
}
.scrim.open .placard { transform: none; }
.placard .close {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card); color: var(--ink); font-size: 18px;
  cursor: pointer; line-height: 1;
}
.placard .close:hover { background: rgba(255,255,255,.08); }

.placard .p-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; padding-right: 30px; }
.placard .p-portrait {
  flex: 0 0 auto; width: 92px; height: 92px; border-radius: 12px; overflow: hidden;
  background: linear-gradient(150deg, #24315c, #161f3d); display: grid; place-items: center;
  border: 1px solid var(--border);
}
.placard .p-portrait img { width: 100%; height: 100%; object-fit: cover; }
.placard .p-portrait .monogram { font-size: 34px; font-weight: 700; color: #9fb2e8; }
.placard .p-name { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.placard .p-life { color: var(--muted); font-size: 14px; margin-top: 2px; }
.placard .p-era { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--accent);
  border: 1px solid rgba(59,111,224,.4); border-radius: 999px; padding: 2px 10px; }

.placard .p-bio { font-size: 15px; line-height: 1.62; margin: 4px 0 6px; }
.placard .p-why { font-size: 14px; color: var(--muted); border-left: 2px solid var(--heart);
  padding-left: 12px; margin: 14px 0 18px; }

.placard .works-title { font-size: 13px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin: 18px 0 10px; }
.work {
  border: 1px solid var(--border); border-radius: 12px; padding: 13px 14px; margin-bottom: 10px;
  background: var(--card);
}
.work .w-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.work .w-title { font-weight: 600; font-size: 15px; }
.work .w-year { color: var(--muted); font-size: 13px; white-space: nowrap; }
.work .w-blurb { color: var(--muted); font-size: 13.5px; margin-top: 5px; }
.work .w-sig { display: inline-block; margin-left: 8px; font-size: 11px; color: var(--heart);
  border: 1px solid rgba(255,93,143,.4); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.work .w-links { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 8px; }
.work .w-links a { font-size: 12.5px; color: var(--accent); text-decoration: none;
  border: 1px solid rgba(59,111,224,.3); border-radius: 999px; padding: 3px 10px; }
.work .w-links a:hover { background: var(--accent-soft); }

.placard .p-source { font-size: 12px; color: var(--muted); margin-top: 16px; }
.placard .p-source a { color: var(--muted); }

/* mobile: placard becomes a bottom sheet that slides up */
@media (max-width: 560px) {
  .scrim { align-items: flex-end; padding: 0; }
  .placard { max-width: 100%; max-height: 90vh; border-radius: 20px 20px 0 0;
    transform: translateY(100%); }
  .scrim.open .placard { transform: none; }
}

/* the "Play with score" button in a work card */
.work .w-links .w-play {
  font-size: 12.5px; color: #fff; background: var(--accent); border: 1px solid var(--accent);
  border-radius: 999px; padding: 4px 12px; cursor: pointer; font-weight: 600;
}
.work .w-links .w-play:hover { background: #4f7ce6; }
.work .w-links .w-ens {
  font-size: 12px; color: var(--accent); background: var(--accent-soft);
  border: 1px solid transparent; border-radius: 999px; padding: 4px 11px; font-weight: 600;
  align-self: center;
}

/* ============================================================ work view === */
/* Layout: a FIXED header + a FIXED transport with only the SCORE scrolling in
   between. So the play/pause, tempo and close controls never move out of reach
   while the music plays, and the score's auto-follow only nudges the score
   itself — it can't drag the whole panel around under the user. */
.wv-scrim { z-index: 80; }
.workview {
  position: relative; width: 100%; max-width: 760px; max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: #0f1730; border: 1px solid var(--border); border-radius: 18px;
  padding: 22px 22px 20px; box-shadow: 0 30px 80px rgba(0,0,0,.55);
  transform: translateY(16px) scale(.985); transition: transform .26s cubic-bezier(.2,.8,.2,1);
}
.wv-scrim.open .workview { transform: none; }
.workview .close {
  position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card); color: var(--ink); font-size: 20px;
  cursor: pointer; line-height: 1; z-index: 3;
}
.workview .close:hover { background: rgba(255,255,255,.08); }
/* mobile grab-handle: a draggable bar that says "pull down to close" */
.wv-grip { display: none; }
.wv-head { flex: 0 0 auto; padding-right: 44px; margin-bottom: 12px; }
.wv-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.wv-sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; }

/* the score: light "paper" panel; the ONLY scrolling region of the work view */
.wv-scorewrap {
  flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;
  background: #f7f5ef; border-radius: 12px; padding: 10px 8px;
}
.wv-score { min-height: 120px; }
/* Force dark ink on the cream paper. Verovio glyphs (clef, noteheads…) paint in
   currentColor; the page's body color is light, so we must pin it dark here or
   the noteheads render near-white and vanish on the paper. */
/* Force dark ink. Note stems/ledger lines/ties are drawn with STROKE (inherited
   from the page's light text colour), so we must pin BOTH fill and stroke dark or
   the stems render near-white and vanish. */
.wv-score svg { width: 100%; height: auto; display: block; color: #1a1a1a; fill: #1a1a1a; stroke: #1a1a1a; }
/* color too: Verovio's note group is class="note", which collides with the site's
   .note callout (color:--ink); its stems stroke with currentColor, so without this
   they'd inherit the light colour and vanish. */
.wv-score svg * { fill: #1a1a1a; stroke: #1a1a1a; color: #1a1a1a; }
/* Verovio names its note group class="layer", which collides with the site's
   crossfade ".layer { opacity:0 }" rule in /style.css and hides every note.
   Re-assert sane values for the score's layer (SVG <g> ignores the rest). */
.wv-score svg .layer { opacity: 1; position: static; background: none; }
.wv-loading { color: #555; font-size: 14px; text-align: center; padding: 40px 10px; }
.wv-loading.wv-error { color: #b23; }

/* the playing note lights up */
.wv-score .note.playing, .wv-score .note.playing * { fill: #d6336c !important; stroke: #d6336c !important; }

/* a slim progress bar between score and transport — shows position, seekable */
.wv-progress { flex: 0 0 auto; height: 16px; margin: 10px 0 2px; position: relative; cursor: pointer; }
.wv-progress .track { position: absolute; top: 7px; left: 0; right: 0; height: 3px; border-radius: 2px; background: rgba(255,255,255,.14); }
.wv-progress .fill { position: absolute; top: 7px; left: 0; height: 3px; border-radius: 2px; background: var(--accent); width: 0; }
.wv-progress .knob { position: absolute; top: 2px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%;
  background: #fff; border: 1px solid var(--accent); left: 0; box-shadow: 0 1px 3px rgba(0,0,0,.4); }

/* transport — fixed at the foot of the panel, always reachable */
.wv-transport { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }
.wv-btn {
  font-size: 14px; color: var(--ink); background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 18px; cursor: pointer; font-weight: 600; min-width: 96px;
}
.wv-btn:hover { background: rgba(255,255,255,.08); }
.wv-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; min-width: 116px; }
.wv-btn.primary:hover { background: #4f7ce6; }
.wv-tempo { display: flex; align-items: center; gap: 9px; margin-left: auto; font-size: 13px; color: var(--muted); }
.wv-tempo input[type=range] { width: 120px; accent-color: var(--accent); }
.wv-tval { min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }
.wv-note { flex: 0 0 auto; font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.5; }
.wv-note .wv-src { color: var(--accent); text-decoration: none; white-space: nowrap; }
.wv-note .wv-src:hover { text-decoration: underline; }

/* mobile: bottom sheet with a grab-handle; pull the handle down to close */
@media (max-width: 560px) {
  .wv-scrim { align-items: flex-end; padding: 0; }
  .workview { max-width: 100%; max-height: 94vh; border-radius: 20px 20px 0 0; transform: translateY(100%); padding: 8px 16px 14px; }
  .wv-scrim.open .workview { transform: none; }
  .wv-grip { display: block; flex: 0 0 auto; width: 40px; height: 5px; border-radius: 3px;
    background: rgba(255,255,255,.28); margin: 2px auto 10px; }
  .workview .close { top: 14px; }
  .wv-tempo { width: 100%; margin-left: 0; justify-content: space-between; }
  .wv-tempo input[type=range] { flex: 1; width: auto; }
  .wv-btn { min-width: 84px; padding: 11px 16px; }
  .wv-btn.primary { min-width: 104px; }
}

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .composer, .placard, .scrim, .workview { transition: none; }
}

/* ============================================== instrument switcher strip === */
/* "Cello · Violin · …" — links to the sibling "Through Time" timelines. The
   current instrument renders as a highlighted non-link. */
.tl-switch {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 0 0 18px;
}
.tl-switch a, .tl-switch .on {
  font-size: 13.5px; padding: 5px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--muted); text-decoration: none; transition: .15s;
}
.tl-switch a:hover { color: var(--ink); border-color: rgba(91,134,236,.45); background: rgba(255,255,255,.06); }
.tl-switch .on { color: #fff; background: var(--accent); border-color: var(--accent); font-weight: 600; }

/* solo ⇄ ensemble toggle in the work-view transport */
.wv-btn.wv-ens { min-width: 128px; }
.wv-btn.wv-ens.on { border-color: rgba(91,134,236,.55); color: var(--accent); }
.wv-btn.wv-pizz { min-width: 118px; }
.wv-btn.wv-pizz.on { border-color: rgba(176,120,220,.6); color: #b078dc; background: rgba(176,120,220,.10); }

/* pizzicato badges (piece has plucked passages, played automatically) */
.composer .c-play .c-pizz { opacity: .95; margin-left: 1px; color: #b078dc; }
.work .w-links .w-pizz {
  font-size: 12px; color: #b078dc; background: rgba(176,120,220,.12);
  border: 1px solid transparent; border-radius: 999px; padding: 4px 11px; font-weight: 600;
  align-self: center;
}


/* ---- A–B practice loop (v12) ---- */
.wv-btn.wv-loop.arming { border-color: #f3c849; color: #f3c849; animation: wvLoopPulse 1.1s ease-in-out infinite; }
@keyframes wvLoopPulse { 50% { box-shadow: 0 0 0 4px rgba(243,200,73,.18); } }
.wv-btn.wv-loop.on, .wv-btn.wv-count.on { border-color: #f3c849; color: #0e1730; background: #f3c849; }
.wv-score.wv-looparm { cursor: crosshair; }
.wv-score .note.loop-a, .wv-score .note.loop-a * { fill: #b8860b !important; stroke: #b8860b !important; }
.wv-loopmark { position: absolute; top: 0; width: 12px; height: 16px; margin-left: -6px;
  border-radius: 3px 3px 6px 6px; background: #f3c849; cursor: ew-resize; z-index: 3;
  box-shadow: 0 1px 3px rgba(0,0,0,.5); touch-action: none; }
.wv-loopmark.b { background: #ffb347; }

/* ---- optional lyrics panel (v13): PD hymn/song texts, sing along ---- */
/* Sits between the transport and the credit note. The work view keeps the
   score as its main scroll region, so the lyrics get their own capped-height
   scroll box instead of growing the panel. */
.wv-lyrics { display: none; flex: 0 0 auto; overflow: auto; overscroll-behavior: contain;
  margin-top: 10px; padding: 14px 16px 10px; max-height: 34vh;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.wv-lyrics.open { display: block; }
.lyr-cols { column-width: 250px; column-gap: 30px; }
.lyr-verse { break-inside: avoid; -webkit-column-break-inside: avoid; page-break-inside: avoid;
  margin: 0 0 12px; font-size: 13.5px; line-height: 1.65; color: var(--ink); }
.lyr-verse p { margin: 2px 0 0; }
.lyr-no { display: inline-block; font-size: 11px; font-weight: 700; color: #f3c849; letter-spacing: .04em; }
.lyr-refrain p { font-style: italic; }
.lyr-verse .lyr-zh { color: var(--muted); font-size: 12.5px; font-style: normal; margin-top: 4px; }
.lyr-by { font-size: 11.5px; color: var(--muted); margin-top: 6px; border-top: 1px solid var(--border); padding-top: 8px; }
.wv-btn.wv-lyrbtn.on { border-color: #f3c849; color: #0e1730; background: #f3c849; }
@media (max-width: 560px) { .wv-lyrics { max-height: 30vh; } .lyr-cols { column-width: auto; } }

/* ---- karaoke mode (v67): score.lyrics.sync lights the sung word ---- */
/* Single column (the highlight follows the music down the verse); each verse
   is tappable to jump playback to the pass that sings it. */
.wv-lyrics.lyr-karaoke { max-height: 42vh; }
.lyr-karaoke .lyr-cols { column-width: auto; columns: 1; }
.lyr-karaoke .lyr-verse { font-size: 15px; line-height: 1.95; transition: opacity .25s ease; }
.lyr-karaoke .lyr-verse.lyr-click { cursor: pointer; border-radius: 8px;
  padding: 3px 8px; margin: 0 -8px 12px; }
.lyr-karaoke .lyr-verse.lyr-click:hover { background: rgba(243, 200, 73, .08); }
/* once a pass is playing, spotlight the active verse and dim the rest */
.lyr-karaoke.lyr-playing .lyr-verse:not(.lyr-active) { opacity: .4; }
.lyr-karaoke.lyr-playing .lyr-verse.lyr-active { opacity: 1; }
.lyr-karaoke .syl { border-radius: 4px; padding: 1px 1px; transition: color .1s ease, background-color .1s ease; }
.lyr-karaoke .syl.past { color: #f3c849; }                        /* already sung */
.lyr-karaoke .syl.now { color: #0e1730; background: #f3c849; }    /* singing right now */
@media (max-width: 560px) { .wv-lyrics.lyr-karaoke { max-height: 34vh; } .lyr-karaoke .lyr-verse { font-size: 14.5px; } }

/* ---- piano keyboard strip (v12) ---- */
.wv-keys { flex: 0 0 auto; margin: 8px 0 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.wv-kb { position: relative; display: flex; height: 46px; border-radius: 6px; overflow: hidden;
  border: 1px solid #26355c; background: #0e1730; }
.wv-kb .wk { flex: 1; background: #e8ecf6; border-right: 1px solid #b9c2d8; border-radius: 0 0 2px 2px; }
.wv-kb .wk:last-child { border-right: none; }
.wv-kb .wk.on { background: #f3c849; }
.wv-kb .bk { position: absolute; top: 0; height: 58%; background: #141d38; border: 1px solid #060b18;
  border-top: none; border-radius: 0 0 3px 3px; z-index: 2; }
.wv-kb .bk.on { background: #c9982a; border-color: #8a6a14; }
@media (max-width: 560px) { .wv-kb { height: 38px; } }

/* one-time practice-features hint pill (v66) — gold, tap or 12s to dismiss */
.wv-hint { margin: 8px 14px 0; padding: 8px 15px; border-radius: 999px; width: max-content; max-width: 92%;
  font-size: 12.5px; font-weight: 600; color: #2a2005; cursor: pointer;
  background: linear-gradient(92deg, #f3c849, #ffd76a); box-shadow: 0 6px 18px -10px #f3c849; }
.wv-hint:hover { filter: brightness(1.05); }
