/* Library room (ported from the IATACF course room). One bold thing, the lectern: a plum player whose timeline
   carries a gold diamond at every chapter. The jacket wears the cartoon covers' own plum, cream and gold. */
:root {
  --plum: #2b1a33; --plum-2: #3d2848; --cream: #f6ead6; --gold-light: #d9b56a; --panel: #efe6f4;
  --rule: var(--line); --serif: "Fraunces", Georgia, serif; --sans: "Inter", system-ui, sans-serif;
}

/* Phones: the body is the scroll box (fixed bars never bounce), wide tables scroll inside, text boxes never zoom */
@media (max-width: 900px) {
  html, body { overscroll-behavior-y: none; }
  html { height: 100%; overflow: hidden; }
  body { position: relative; height: 100%; min-height: 0; overflow-x: hidden; overflow-y: auto; }
  table { display: block; overflow-x: auto; }
  body :is(input, textarea, select, .lectern-speed) { font-size: 16px; } /* "body" outweighs the later .lectern-speed font */
  /* the shelf is one row that swipes sideways ("body" outweighs the later grid), so the player sits on the first screen */
  body .room-shelf { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 80%; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; padding-bottom: 6px; }
  body .room-shelf-item { scroll-snap-align: start; }
}

[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.room-wrap { max-width: 1180px; margin: 0 auto; padding: 12px 22px 0; }
.room-wrap #lib-loading { margin: 3em 0; color: var(--muted); }
.room-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 24px; }
.room-h1 { margin: 0; font-size: clamp(1.7rem, 3.4vw, 2.4rem); }
.room-who { margin: 0; font-size: 15px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.lib-back-row { margin: 18px 0 0; }
.lib-hint { margin: 14px 0 0; color: var(--muted); }
.library #lib-grid { margin-top: 22px; }
.room-help { margin-top: 3em; color: var(--muted); font-size: 16px; }
.room-quiet { color: var(--muted); font: 400 16px/1.6 var(--sans); }

/* The shelf: one cartoon jacket per title, shown only to a buyer with more than one */
.room-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 12px; margin: 22px 0 0; }
.room-shelf-item {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); font: inherit;
}
.room-shelf-item img { width: 56px; height: 56px; object-fit: cover; flex: none; border-radius: 8px; }
.room-shelf-words { display: grid; gap: 2px; min-width: 0; }
.room-shelf-title { font: 600 16px/1.3 var(--serif); }
.room-shelf-meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.room-shelf-item:hover { border-color: var(--accent); }
.room-shelf-item[aria-pressed="true"] { border-color: var(--plum); box-shadow: inset 0 -3px 0 var(--gold); background: var(--panel); }

/* The cover, set like a book jacket: plum cloth, a gold hairline inside the edge, the cartoon flush on the right */
.room-course { padding-top: clamp(24px, 3.4vw, 44px); }
.room-hero {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 44%); align-items: stretch;
  background: var(--plum); color: var(--cream); border-radius: 20px; overflow: hidden; box-shadow: 8px 8px 0 var(--panel);
}
.room-hero::after { content: ""; position: absolute; inset: 12px; border: 1px solid rgba(217, 181, 106, 0.6); border-radius: 12px; pointer-events: none; }
.room-cover { display: block; width: 100%; height: 100%; aspect-ratio: 1; object-fit: cover; }
.room-hero-words {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; justify-items: start; align-content: center; min-width: 0;
  padding: clamp(36px, 5vw, 68px) clamp(28px, 4.5vw, 60px);
}
.room-hero .kicker { margin: 0; font: 600 13px/1.3 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-light); }
.room-hero .kicker::before { content: ""; display: inline-block; width: 8px; height: 8px; margin: 0 12px 1px 2px; transform: rotate(45deg); background: var(--gold); }
.room-title { margin: 0; font: 600 clamp(32px, 4.2vw, 56px)/1.06 var(--serif); max-width: 18ch; color: var(--cream); }
.room-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 0; color: rgba(246, 234, 214, 0.82); font-size: 16px; font-variant-numeric: tabular-nums; }
.room-diamonds { display: inline-flex; gap: 9px; padding: 0 3px; }
.room-diamond { width: 10px; height: 10px; transform: rotate(45deg); border: 1.5px solid rgba(246, 234, 214, 0.4); }
.room-diamond.is-started { border-color: var(--gold-light); }
.room-diamond.is-done { border-color: var(--gold-light); background: var(--gold-light); }
.room-hero .btn { background: var(--gold-light); color: var(--plum); }
.room-hero .btn:hover { background: var(--cream); color: var(--plum); }
.room-hero .room-handouts a { color: var(--cream); border-color: rgba(246, 234, 214, 0.4); }
.room-hero .room-handouts a:hover { background: var(--plum-2); }
.room-hero .room-handout-meta { color: rgba(246, 234, 214, 0.72); }

/* Downloads: the workbook under the cover, a part's audio and transcript under the part */
.room-handouts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 12px; width: 100%; }
.room-handouts a { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--plum); border-radius: 12px; color: var(--ink); text-decoration: none; height: 100%; }
.room-handouts a:hover { background: var(--panel); }
.room-handout-name { font: 600 17px/1.3 var(--serif); }
.room-handout-meta { display: flex; gap: 12px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.room-handouts.is-course { max-width: 520px; }

/* Parts beside the open part */
.room-body { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: clamp(24px, 3.6vw, 56px); padding-top: clamp(24px, 3.6vw, 44px); align-items: start; }
.room-side { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; }
.room-list-head { font: 500 15px/1.3 var(--sans); color: var(--muted); margin: 0 0 8px; }
.room-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--plum); }
.room-row {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; grid-template-areas: "n title title" "n time state";
  gap: 2px 10px; width: 100%; padding: 12px 10px 12px 0; text-align: left; cursor: pointer;
  background: none; border: 0; border-bottom: 1px solid var(--rule); color: var(--ink); font: inherit;
}
.room-row-n { grid-area: n; font: 600 22px/1.1 var(--serif); color: var(--accent-deep); text-align: right; }
.room-row-title { grid-area: title; font: 500 16px/1.35 var(--serif); }
.room-row-time { grid-area: time; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.room-row-state { grid-area: state; font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.room-row[data-state="done"] .room-row-state::before,
.room-row[data-state="started"] .room-row-state::before { content: ""; width: 7px; height: 7px; transform: rotate(45deg); border: 1.5px solid var(--gold); }
.room-row[data-state="done"] .room-row-state::before { background: var(--gold); }
.room-row:hover .room-row-title { color: var(--accent-deep); }
.room-row[aria-current] { background: var(--panel); box-shadow: inset 3px 0 0 var(--gold); }

/* The open part */
.room-stage {
  display: grid; gap: 24px; min-width: 0; padding: clamp(18px, 3vw, 32px);
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
}
.room-stage-head { display: grid; gap: 6px; }
.room-stage-head .kicker { margin: 0; font: 600 13px/1.3 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-deep); }
.room-stage-facts { margin: 0; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.room-stage-title { margin: 0; font: 600 clamp(28px, 3.2vw, 42px)/1.1 var(--serif); }

/* The lectern */
.lectern { background: var(--plum); color: var(--cream); border-radius: 16px; padding: 20px clamp(16px, 3vw, 28px) 16px; display: grid; gap: 12px; }
.lectern audio { display: none; }
.lectern-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 16px; }
.lectern-play { position: relative; width: 52px; height: 52px; padding: 0; background: none; border: 0; cursor: pointer; }
.lectern-play::before { content: ""; position: absolute; inset: 6px; border-radius: 10px; background: var(--gold-light); transition: background 0.15s; }
.lectern-play:hover::before { background: var(--cream); }
.lectern-play:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }
.lectern-glyph { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform: translate(-35%, -50%);
  border-style: solid; border-width: 8px 0 8px 13px; border-color: transparent transparent transparent var(--plum); }
.is-playing .lectern-glyph { width: 12px; height: 15px; transform: translate(-50%, -50%); border: 0; border-left: 4px solid var(--plum); border-right: 4px solid var(--plum); }
.lectern-time { font: 500 15px/1 var(--sans); font-variant-numeric: tabular-nums; color: var(--gold-light); min-width: 4ch; }
.lectern-line { position: relative; height: 28px; display: grid; align-items: center; }
/* With the recording's waveform, the timeline is the waveform: played bars in gold, the rest faint, the range input on top */
.lectern-wave { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--gold-light); --wave-rest: rgba(246, 234, 214, 0.24); pointer-events: none; }
.lectern-line:has(> .lectern-wave:not([hidden])) { height: 56px; }
.lectern-line:has(> .lectern-wave:not([hidden])) .lectern-bar { height: 100%; background: transparent; }
.lectern-line:has(> .lectern-wave:not([hidden])) .lectern-bar::-webkit-slider-thumb { width: 3px; height: 56px; transform: none; border: 0; background: var(--cream); }
.lectern-line:has(> .lectern-wave:not([hidden])) .lectern-bar::-moz-range-thumb { width: 3px; height: 56px; transform: none; border: 0; background: var(--cream); }
.lectern-line:has(> .lectern-wave:not([hidden])) .lectern-marks { top: auto; bottom: -3px; }
.lectern-marks { position: absolute; left: 7px; right: 7px; top: 50%; height: 0; pointer-events: none; z-index: 1; }
.lectern-mark { position: absolute; top: -4px; width: 8px; height: 8px; margin-left: -4px; transform: rotate(45deg); background: var(--gold-light); border: 1.5px solid var(--plum); }
.lectern-bar {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px; margin: 0; cursor: pointer; background:
  linear-gradient(to right, var(--gold-light) var(--played, 0%), rgba(246, 234, 214, 0.22) var(--played, 0%));
}
.lectern-bar::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; background: var(--gold-light); border: 2px solid var(--plum); transform: rotate(45deg); position: relative; z-index: 2; }
.lectern-bar::-moz-range-thumb { width: 12px; height: 12px; border-radius: 0; background: var(--gold-light); border: 2px solid var(--plum); transform: rotate(45deg); }
.lectern-bar:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 6px; }
.lectern-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding-left: 68px; font-size: 15px; }
.lectern-note { margin: 10px 0 0; padding-left: 68px; color: var(--gold-light); font-size: 15px; }
.lectern-skip { background: none; border: 0; padding: 4px 0; color: var(--cream); font: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(246, 234, 214, 0.3); text-underline-offset: 4px; }
.lectern-skip:hover { text-decoration-color: var(--gold-light); }
.lectern-skip:focus-visible, .lectern-speed:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }
.lectern-speed-label { margin-left: auto; color: rgba(246, 234, 214, 0.78); }
.lectern-speed { font: inherit; color: var(--cream); background: var(--plum-2); border: 1px solid rgba(246, 234, 214, 0.3); border-radius: 8px; padding: 4px 6px; }

/* Chapters */
.room-chapter-box summary { cursor: pointer; font: 500 15px/1.3 var(--sans); color: var(--muted); padding-bottom: 8px; }
.room-chapter-box summary:hover { color: var(--ink); }
.room-chapters { list-style: none; margin: 0; padding: 0; columns: 2 280px; column-gap: 32px; }
.room-chapters li { break-inside: avoid; }
.room-chapter {
  display: grid; grid-template-columns: 5ch minmax(0, 1fr); gap: 12px; width: 100%; padding: 9px 0; text-align: left;
  background: none; border: 0; border-top: 1px solid var(--rule); color: var(--ink); font: 400 15px/1.4 var(--sans); cursor: pointer;
}
.room-chapter-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.room-chapter:hover { color: var(--accent-deep); }
.room-chapter[aria-current] { font-weight: 600; }
.room-chapter[aria-current] .room-chapter-time { color: var(--accent-deep); }

/* Notes, cheat sheet, transcript and sources */
.room-tablist { display: flex; flex-wrap: wrap; gap: 0 28px; border-bottom: 1px solid var(--plum); }
.room-tab { background: none; border: 0; padding: 12px 0 10px; font: 500 18px/1.3 var(--serif); color: var(--muted); cursor: pointer; }
.room-tab:hover { color: var(--ink); }
.room-tab[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 -3px 0 var(--gold); }
.room-panel { padding-top: 24px; font: 400 18px/1.75 var(--serif); max-width: 66ch; }
.room-panel:focus-visible { outline-offset: 8px; }
.room-panel h3 { font: 600 24px/1.25 var(--serif); margin: 1.6em 0 0.5em; }
.room-panel > h3:first-child { margin-top: 0; }
.room-panel h4 { font: 600 18px/1.3 var(--serif); margin: 1.4em 0 0.4em; }
.sheet-title { font: 600 26px/1.25 var(--serif); }
.sheet-hook { font: italic 400 21px/1.6 var(--serif); border-left: 3px solid var(--gold); padding: 4px 0 4px 18px; background: linear-gradient(to right, var(--panel), transparent); }
.sheet-part { margin-top: 2em; }
.room-panel .sheet-spine { list-style: none; padding: 0; margin: 0; }
.sheet-spine li { padding: 0 0 1.1em 18px; border-left: 2px solid var(--gold); }
.sheet-spine strong { display: block; }
.sheet-chip { display: inline-block; padding: 1px 10px 2px; border-radius: 999px; font: 600 15px/1.5 var(--sans); background: var(--panel); border: 1px solid var(--rule); }
.sheet-chip.is-person { background: #f5e8c8; }
.sheet-chip.is-org { background: #dfe6f5; }
.sheet-chip.is-concept { background: #ece2f7; }
.sheet-chip.is-event { background: #f6dfdc; }
.room-panel .sheet-kind { font: 600 13px/1.3 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 1.2em 0 0.5em; }
.room-panel .sheet-who, .room-panel .sheet-ties, .room-panel .sheet-facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.sheet-who li { display: grid; grid-template-columns: minmax(0, 13em) minmax(0, 1fr); gap: 4px 16px; align-items: start; }
.sheet-who .sheet-chip { justify-self: start; }
.sheet-role { font: 400 16px/1.55 var(--sans); }
.sheet-verb { font: italic 400 16px/1.5 var(--serif); color: var(--muted); }
.sheet-facts li { padding: 10px 14px; background: var(--panel); border-left: 3px solid var(--gold); }
.room-sources { list-style: none; padding: 0; margin: 0 0 1em; }
.room-sources li { display: grid; gap: 2px; padding: 12px 0; border-top: 1px solid var(--rule); }
.room-sources a { font: 400 17px/1.45 var(--serif); color: var(--accent-deep); overflow-wrap: anywhere; }
.room-source-site { font: 400 14px/1.4 var(--sans); color: var(--muted); overflow-wrap: anywhere; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-deep); font: inherit; text-decoration: underline; cursor: pointer; }
.room-lesson-files h4 { font: 500 15px/1.3 var(--sans); color: var(--muted); margin: 0 0 10px; }
.room-handouts.is-lesson { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px; }
.room-handouts.is-lesson a { padding: 10px 12px; border-color: var(--line); border-top: 3px solid var(--gold); background: var(--paper); }
.room-handouts.is-lesson .room-handout-name { font-size: 16px; }

/* A title whose room is not built yet: one plain player per part */
.room-plain { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 16px; }
.room-plain li { display: grid; gap: 8px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.room-plain audio { width: 100%; }

@media (max-width: 900px) {
  .room-hero, .room-body { grid-template-columns: minmax(0, 1fr); }
  .room-cover { grid-row: 1; aspect-ratio: 3 / 2; }
  .room-side { position: static; max-height: none; overflow: visible; order: 2; }
  .sheet-who li { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .room-wrap { padding: 8px 14px 0; }
  .lectern-row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "play now total" "line line line"; row-gap: 10px; }
  .lectern-play { grid-area: play; }
  .lectern-row > .lectern-time:first-of-type { grid-area: now; }
  .lectern-row > .lectern-time:last-of-type { grid-area: total; text-align: right; }
  .lectern-line { grid-area: line; }
  .lectern-tools, .lectern-note { padding-left: 0; }
  .room-stage { padding: 14px 12px; box-shadow: none; }
  .room-stage-title { font-size: 26px; }
  .room-panel { font-size: 17px; }
  .room-hero { box-shadow: none; }
  .room-hero::after { inset: 8px; }
  .room-hero-words { padding: 28px 22px 32px; }
}
