/* Hallmark · shape: Workbench · genre: editorial · theme: Vellum (by request) · redesign: full
 * hero: Stage · nav: top printer ledger with four-mode switcher and chapter mile-drawer · footer: colophon ledger rule · imagery: 1884 E.W. Kemble engravings and cartographic river plates · signature: 1884 Vellum frontispiece and two-page River Ledger split-folio with unified bottom teleprompter dock · vellum: parchment, oxblood
 * axes: light/blackletter/cool · posture: committed · contrast: pass · fold: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P5 H5 E5 S5 R5 V5 · weakest: R, consolidated duplicate header and modal buttons into a four-mode ledger switcher and merged dual audio players into one bottom teleprompter dock */
/* Hallmark · dismissed 76 · Huck_Finn_chap_01a.jpg is E.W. Kemble's public-domain 1884 first-edition engraving credited in the figure caption */
@import url("./tokens.css");
@import url("./base.css");

html, body {
  overflow-x: clip;
  width: 100%;
  min-height: 100%;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.55;
  caret-color: var(--color-accent);
  scrollbar-color: var(--color-muted) var(--color-paper-2);
}

::selection {
  background: var(--color-accent-soft);
  color: var(--color-ink);
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--tracking-display);
  line-height: 0.96;
  color: var(--color-ink);
  overflow-wrap: break-word;
  min-width: 0;
  text-wrap: balance;
}

h3, h4 {
  font-family: var(--font-body);
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-ink);
  overflow-wrap: break-word;
  min-width: 0;
}

p {
  max-width: 65ch;
  color: var(--color-ink-2);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* Controls: all 8 states, instant focus-visible */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 36px;
  padding: 0 var(--space-md);
  border: var(--rule-hair) solid var(--color-ink);
  border-radius: var(--radius-card);
  background: transparent;
  color: var(--color-ink);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--text-sm);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}

.btn:hover {
  background: var(--color-paper-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: var(--rule-double) solid var(--color-focus);
  outline-offset: var(--space-3xs);
  transition: none;
}

.btn:disabled,
.btn[aria-disabled="true"],
.btn[aria-busy="true"] {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.btn--primary,
.btn--active,
.btn[aria-pressed="true"],
.btn[aria-selected="true"] {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-ink);
}

.btn--primary:hover,
.btn--active:hover,
.btn[aria-pressed="true"]:hover,
.btn[aria-selected="true"]:hover {
  background: var(--color-accent-deep);
  border-color: var(--color-accent-deep);
}

.btn--quiet {
  border-color: var(--color-rule);
  background: transparent;
  color: var(--color-ink-2);
}

.vl-input,
.vl-select {
  min-height: 36px;
  padding: 0 var(--space-sm);
  border: var(--rule-hair) solid var(--color-ink);
  border-radius: var(--radius-card);
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: 1.2;
  transition: border-color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
}

.vl-input:hover,
.vl-select:hover {
  background: var(--color-paper-2);
}

.vl-input:focus-visible,
.vl-select:focus-visible {
  outline: var(--rule-double) solid var(--color-focus);
  outline-offset: var(--space-3xs);
  transition: none;
}

.vl-input:disabled,
.vl-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.vl-input[aria-invalid="true"] {
  border-color: var(--color-error);
}

/* Top Printer Ledger Masthead */
.vl-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: var(--container);
  margin: 0 auto;
  border-left: var(--rule-hair) solid var(--color-rule);
  border-right: var(--rule-hair) solid var(--color-rule);
  background: var(--color-paper);
}

.vl-masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  border-bottom: var(--rule-double) double var(--color-ink);
  background: var(--color-paper);
}

.vl-brand {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  min-width: 0;
}

.vl-brand__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--display-weight);
  color: var(--color-ink);
  text-decoration: none;
  white-space: nowrap;
}

.vl-brand__edition {
  font-size: var(--text-xs);
  color: var(--color-muted);
  white-space: nowrap;
}

.vl-modes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
}

.vl-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
}

/* 1884 Edition Cover & River Atlas Frontispiece (Hero Stage) */
.vl-frontispiece {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--gap-columns);
  align-items: center;
  min-height: 76dvh;
  padding: var(--space-xl) var(--space-lg);
  border-bottom: var(--rule-double) double var(--color-ink);
  background: var(--color-paper);
}

.vl-frontispiece__copy {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-width: 0;
}

.vl-frontispiece__headline {
  font-size: var(--text-display);
  line-height: 0.94;
}

.vl-frontispiece__lede {
  font-family: var(--font-outlier);
  font-size: var(--text-lead);
  line-height: 1.45;
  color: var(--color-ink-2);
  max-width: 48ch;
}

.vl-frontispiece__cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.vl-frontispiece__plate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-paper-2);
  border: var(--rule-hair) solid var(--color-ink);
}

.vl-engraving {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin: 0;
  min-width: 0;
}

.vl-engraving__img {
  width: 100%;
  height: 300px;
  object-fit: contain;
  background: var(--color-paper);
  border: var(--rule-hair) solid var(--color-rule);
  padding: var(--space-xs);
}

.vl-engraving__caption {
  font-size: var(--text-xs);
  color: var(--color-muted);
  line-height: 1.35;
}

.vl-ledger-preview {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--color-paper);
  border: var(--rule-hair) solid var(--color-rule);
}

.vl-ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}

.vl-ledger-table th {
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--color-muted);
  text-align: left;
  padding: var(--space-2xs) var(--space-xs);
  border-bottom: var(--rule-double) double var(--color-ink);
}

.vl-ledger-table td {
  padding: var(--space-xs);
  border-top: var(--rule-hair) solid var(--color-rule);
  color: var(--color-ink);
  vertical-align: top;
}

.vl-ledger-table tr.is-interactive {
  cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out);
}

.vl-ledger-table tr.is-interactive:hover {
  background: var(--color-accent-soft);
}

.vl-num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--color-accent);
  font-weight: 600;
  white-space: nowrap;
}

/* River Ledger Split-Folio Workbench */
.vl-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  flex: 1;
  min-height: 78dvh;
  background: var(--color-paper);
  position: relative;
}

.vl-workbench--single {
  grid-template-columns: minmax(0, 1fr);
}

/* Collapsible River Mile-Marker Chapter Drawer */
.vl-drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 340px;
  max-width: 90%;
  z-index: var(--z-dropdown);
  background: var(--color-paper-2);
  border-right: var(--rule-double) double var(--color-ink);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform var(--dur-short) var(--ease-out);
}

.vl-drawer.is-closed {
  transform: translateX(-102%);
  pointer-events: none;
}

.vl-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-bottom: var(--rule-hair) solid var(--color-ink);
}

.vl-drawer__search {
  padding: var(--space-sm) var(--space-md);
  border-bottom: var(--rule-hair) solid var(--color-rule);
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.vl-drawer__list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xs);
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

.vl-chapter-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-xs);
  width: 100%;
  text-align: left;
  padding: var(--space-xs) var(--space-sm);
  border: var(--rule-hair) solid transparent;
  border-radius: var(--radius-card);
  background: transparent;
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out);
}

.vl-chapter-item:hover {
  background: var(--color-accent-soft);
}

.vl-chapter-item:focus-visible {
  outline: var(--rule-double) solid var(--color-focus);
  outline-offset: -2px;
  transition: none;
}

.vl-chapter-item.is-active {
  background: var(--color-accent);
  color: var(--color-accent-ink);
  font-weight: 600;
}

/* Left Folio Sheet: Unabridged 1884 Reader */
.vl-sheet-left {
  display: flex;
  flex-direction: column;
  border-right: var(--rule-double) double var(--color-ink);
  min-width: 0;
  background: var(--color-paper);
}

.vl-sheet-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-bottom: var(--rule-hair) solid var(--color-rule);
  background: var(--color-paper-2);
}

.vl-sheet-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  max-height: 76dvh;
}

.vl-prose {
  font-family: var(--font-outlier);
  font-size: var(--text-lg);
  line-height: 1.68;
  color: var(--color-ink);
  max-width: 65ch;
  margin: 0 auto;
}

.vl-prose p {
  font-family: var(--font-outlier);
  font-size: inherit;
  line-height: inherit;
  color: var(--color-ink);
  margin-bottom: var(--space-md);
  max-width: 65ch;
}

.vl-sentence {
  cursor: pointer;
  border-radius: var(--radius-card);
  transition: background-color var(--dur-micro) var(--ease-out);
}

.vl-sentence:hover {
  background: var(--color-paper-2);
}

.vl-sentence.is-active {
  background: var(--color-accent-soft);
  outline: var(--rule-hair) solid var(--color-accent);
}

.vl-word.is-active {
  background: var(--color-accent);
  color: var(--color-accent-ink);
  padding: 0 var(--space-3xs);
  border-radius: var(--radius-card);
}

/* Right Folio Sheet: Marginalia & Study Apparatus */
.vl-sheet-right {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--color-paper);
}

.vl-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  padding: var(--space-sm) var(--space-lg);
  border-bottom: var(--rule-hair) solid var(--color-rule);
  background: var(--color-paper-2);
}

.vl-marginalia-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  max-height: 76dvh;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Ruled Ledger Blocks (no nested cards or shadows) */
.vl-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-top: var(--space-md);
  border-top: var(--rule-hair) solid var(--color-ink);
}

.vl-section--double {
  border-top: var(--rule-double) double var(--color-ink);
}

.vl-well {
  padding: var(--space-md);
  background: var(--color-paper-2);
  border-top: var(--rule-hair) solid var(--color-ink);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.vl-band-pigment {
  padding: var(--space-md);
  background: var(--color-field);
  color: var(--color-accent-ink);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.vl-band-pigment h3,
.vl-band-pigment p,
.vl-band-pigment strong {
  color: var(--color-accent-ink);
}

.vl-meta {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-muted);
  line-height: 1.4;
}

.vl-quote {
  font-family: var(--font-outlier);
  font-style: italic;
  font-size: var(--text-md);
  line-height: 1.55;
  padding-left: var(--space-md);
  border-left: var(--rule-double) solid var(--color-accent);
  color: var(--color-ink);
  margin: var(--space-xs) 0;
}

/* Full-Folio Views (Modes 2, 3, 4) */
.vl-full-folio {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  overflow-y: auto;
  max-height: 78dvh;
}

.vl-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--gap-columns);
}

.vl-grid-3 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-lg);
}

/* Unified Bottom Ledger Audio & Teleprompter Dock */
.vl-audio-dock {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky-nav);
  background: var(--color-paper-2);
  border-top: var(--rule-double) double var(--color-ink);
  padding: var(--space-xs) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.vl-audio-dock__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.vl-audio-dock__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
}

.vl-range {
  width: 220px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.vl-range:focus-visible {
  outline: var(--rule-double) solid var(--color-focus);
  outline-offset: var(--space-3xs);
}

.vl-teleprompter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-top: var(--space-2xs);
  border-top: var(--rule-hair) solid var(--color-rule);
  font-size: var(--text-xs);
}

.vl-teleprompter-bar__line {
  font-family: var(--font-outlier);
  color: var(--color-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90ch;
}

/* Colophon Footer */
.vl-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  border-top: var(--rule-hair) solid var(--color-rule);
  background: var(--color-paper);
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .vl-frontispiece,
  .vl-workbench,
  .vl-grid-2,
  .vl-grid-3,
  .vl-frontispiece__plate {
    grid-template-columns: minmax(0, 1fr);
  }
  .vl-sheet-left {
    border-right: none;
    border-bottom: var(--rule-double) double var(--color-ink);
  }
  .vl-sheet-scroll,
  .vl-marginalia-scroll,
  .vl-full-folio {
    max-height: none;
  }
  .vl-range {
    width: 140px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
