/* Historical notes — page chrome, text twin, panels, tour bar.
   Colour and font variables come from src/input.css (built into tailwind.css);
   this file only holds what utility classes cannot express. */


/* The nav is fixed, so every in-page jump stops clear of it instead of under it. */
html { scroll-padding-top: 5.5rem; }

.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;
}

#woven-skip {
  position: absolute; left: 0; top: 0; z-index: 90;
  transform: translateY(-120%);
  background: var(--walnut-700); color: var(--linen-50);
  padding: 0.75rem 1.25rem; font-family: var(--mono); font-size: 12px;
}
#woven-skip:focus { transform: translateY(0); outline: 2px solid var(--stain-light); outline-offset: 3px; }

/* ---------- first screen ----------
   The nav is a fixed 5rem band, so the intro and the stage share what is left
   of the viewport. The stage takes the remainder, which puts the reading window,
   the era controls, the year rail, and the key on the first screen at 1440x900
   without anyone scrolling. */

#woven-firstscreen {
  display: flex; flex-direction: column;
  min-height: calc(100vh - 5rem);
  min-height: calc(100dvh - 5rem);
}

/* No canvas, no first screen to reserve: the list starts right after the intro. */
body.twin-primary #woven-firstscreen { min-height: 0; }


/* ---------- stage ---------- */

#woven-stage { position: relative; flex: 1 1 auto; min-height: 440px; background: var(--walnut-950); border-top: 1px solid var(--walnut-600); border-bottom: 1px solid var(--walnut-600); }
body.twin-primary #woven-stage { display: none; }

/* Fullscreen renders the stage against the OS's black default backdrop unless
   given its own background, so the walnut tone carries through instead. */
#woven-stage:fullscreen { background: var(--walnut-900); width: 100%; height: 100%; }
#woven-stage:-webkit-full-screen { background: var(--walnut-900); width: 100%; height: 100%; }

/* Absolutely positioned so the drawing-buffer size can never feed back into
   page layout through the canvas's intrinsic aspect ratio. */
#woven-canvas { display: block; position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
#woven-canvas:focus-visible { outline: 2px solid var(--stain-light); outline-offset: 3px; }

/* The two control bars stack in one absolutely positioned block. When the first
   bar wraps to a second row the second bar moves down with it instead of being
   printed over. */
#woven-chrome { position: absolute; top: 0; left: 0; right: 0; z-index: 6; }

/* The bars are opaque, not translucent: a thread showing through a control is
   read as a thread the reader cannot reach. */
#woven-topbar {
  display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 0.75rem;
  background: var(--walnut-900); border-bottom: 1px solid var(--walnut-600);
}

/* Every control row keeps its label whole. On a narrow window the row scrolls
   sideways instead of squeezing the buttons; nothing is ever cut mid-word. */
.bar-scroll {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  min-width: 0; flex: 1 1 auto;
}
.bar-scroll > * { flex: 0 0 auto; white-space: nowrap; }

/* ---------- search ---------- */

#woven-searchform { display: flex; align-items: center; gap: 0.5rem; flex: 0 1 auto; }
#woven-search {
  background: var(--walnut-800); border: 1px solid var(--walnut-600);
  color: var(--linen-100); font-family: var(--mono); font-size: 12px;
  padding: 0.4rem 0.6rem; width: 12rem; min-width: 8rem;
}
#woven-search::placeholder { color: var(--linen-300); opacity: 0.8; }
#woven-search:focus-visible { outline: 2px solid var(--stain-light); outline-offset: 3px; }
#woven-search-count { font-family: var(--mono); font-size: 11px; color: var(--linen-300); white-space: nowrap; }

.woven-btn {
  position: relative; background: transparent; border: 1px solid var(--walnut-600);
  color: var(--linen-200); font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.12em; padding: 0.45rem 0.8rem; cursor: pointer;
  min-height: 44px; /* Apple's 44pt minimum touch target */
}
.woven-btn:hover { border-color: var(--oak-500); color: var(--linen-50); }
.woven-btn:hover::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--oak-500); transform: scaleX(1); transform-origin: left;
}
.woven-btn::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--oak-500); transform: scaleX(0); transform-origin: left; transition: transform 180ms; }
.woven-btn:focus-visible { outline: 2px solid var(--stain-light); outline-offset: 3px; }
.woven-btn[aria-pressed="true"] { background: var(--walnut-700); border-color: var(--oak-400); color: var(--stain-light); }

#woven-yearrail {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 4;
  display: flex; justify-content: space-between; padding: 0.35rem 0.75rem;
  background: var(--walnut-950); border-top: 1px solid var(--walnut-600);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em;
  color: var(--linen-200); pointer-events: none;
}

#woven-eranav {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  padding: 0.5rem 0.75rem; background: var(--walnut-900);
  border-bottom: 1px solid var(--walnut-600);
}
#woven-era-now { font-family: var(--mono); font-size: 12px; color: var(--linen-100); letter-spacing: 0.06em; }
/* Says why the page opens on a close-up instead of the whole 146 years. Hidden
   on the narrowest bar, where the row scrolls sideways and prose would bury the
   buttons. */
#woven-eranav-note { display: none; font-family: var(--mono); font-size: 11px; line-height: 1.5; color: var(--linen-300); }
@media (min-width: 700px) { #woven-eranav-note { display: inline; } }
/* It is a starting instruction, not a status: once the reader has zoomed or
   panned it is false, and it is taken away. This rule has to beat the one
   above it, which sets display on the same element. */
#woven-eranav-note[hidden] { display: none; }

/* Labels are DOM, sized in real pixels, always on an opaque plate so they never
   sit unreadably over geometry. */
#woven-labels, #woven-eras { position: absolute; inset: 0; z-index: 5; pointer-events: none; }

.thread-label {
  position: absolute; transform: translateY(-50%);
  display: inline-flex; align-items: baseline; gap: 0.5rem;
  max-width: 22rem; white-space: nowrap; overflow: hidden;
  background: rgba(11, 8, 6, 0.92); border-left: 2px solid var(--oak-400);
  padding: 2px 7px;
}
/* When a label runs out of room the name gives way, never the years: half a date
   reads as a wrong date. */
.thread-label b {
  font-family: 'DM Sans', sans-serif; font-weight: 600; font-size: 13px; color: var(--linen-50);
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.thread-label i { flex: none; font-family: var(--mono); font-style: normal; font-size: 11px; color: var(--linen-300); }
.thread-label.is-ghost { border-left-color: var(--thread-500); }
.thread-label.is-ghost b { color: var(--linen-200); }
.thread-label.is-hover, .thread-label.is-selected { border-left-color: var(--stain); }
.thread-label.is-hover b, .thread-label.is-selected b { color: #fff; }

.era-marker {
  position: absolute; left: 0.75rem; transform: translateY(-50%);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em;
  color: var(--linen-100); background: rgba(11, 8, 6, 0.92);
  border-left: 3px solid var(--oak-500); padding: 3px 8px;
  white-space: nowrap;
}
/* Zoomed right out the bands sit closer together than a full-size marker is
   tall. The marker shrinks so every band still gets named; a decade with no
   label reads as a decade with no papers. */
.era-marker.is-compact {
  font-size: 10px; line-height: 1.2; letter-spacing: 0.04em; padding: 1px 5px;
  border-left-width: 2px;
}

#woven-legend {
  position: absolute; right: 0.75rem; bottom: 0.75rem; z-index: 6; width: min(23rem, 46vw);
  background: rgba(11, 8, 6, 0.93); border: 1px solid var(--walnut-600); padding: 0.85rem;
}
#woven-legend .lg-lede { font-size: 14px; line-height: 1.5; color: var(--linen-100); margin-bottom: 0.6rem; }
#woven-legend ul { list-style: none; padding: 0; margin: 0; }
#woven-legend li { display: flex; align-items: center; gap: 0.55rem; font-size: 13px; line-height: 1.45; color: var(--linen-200); padding: 2px 0; }
#woven-legend .lg-rows { font-size: 12px; color: var(--linen-300); margin-top: 0.55rem; }
#woven-legend[data-collapsed="true"] .lg-body { display: none; }
#woven-legend[data-collapsed="true"] { width: auto; }

/* Docked key. Above 900px the key is a column beside the canvas, never a panel
   floating over the cloth, so it can never cover a thread row. The chrome bars
   stop at the dock edge so they line up with the canvas they belong to. */
@media (min-width: 900px) {
  #woven-canvas { width: calc(100% - 19rem); }
  #woven-stage.woven-legend-hidden #woven-canvas { width: 100%; }
  #woven-legend {
    right: 0; top: 0; bottom: 0; left: auto; width: 19rem; z-index: 7;
    overflow-y: auto; background: var(--walnut-900);
    border: 0; border-left: 1px solid var(--walnut-600); padding: 1rem;
  }
  #woven-legend[data-collapsed="true"] .lg-body { display: revert; }
  #woven-legend[data-collapsed="true"] { width: 19rem; }
  /* The chrome stops at the dock edge. The tour bar is not in this list: the
     key is hidden while a tour runs, so the bar takes the full stage width. */
  #woven-chrome, #woven-yearrail { right: 19rem; }
  #woven-stage.woven-legend-hidden #woven-chrome,
  #woven-stage.woven-legend-hidden #woven-yearrail { right: 0; }
}

#woven-tip {
  position: absolute; z-index: 8; max-width: 20rem; pointer-events: none;
  background: var(--walnut-700); border: 1px solid var(--walnut-600);
  padding: 0.5rem 0.7rem; color: var(--linen-200); font-size: 13px; line-height: 1.45;
}
#woven-tip[hidden] { display: none; }
#woven-tip .tip-name { display: block; color: var(--linen-50); font-weight: 600; }
#woven-tip .tip-meta, #woven-tip .tip-ev { display: block; font-family: var(--mono); font-size: 11px; color: var(--linen-300); }

/* ---------- publication panel ---------- */

#woven-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 92vw); z-index: 9;
  overflow-y: auto; padding: 1.5rem; background: var(--walnut-700);
  border-left: 1px solid var(--walnut-600); color: var(--linen-200);
}
#woven-panel[hidden] { display: none; }
#woven-panel h2 { font-family: 'Libre Franklin', Arial, sans-serif; font-weight: 800; font-size: 1.6rem; color: var(--linen-50); line-height: 1.15; padding-right: 5rem; margin-top: 0.4rem; }
#woven-panel h3 { font-family: 'Libre Franklin', Arial, sans-serif; font-weight: 700; font-size: 1rem; color: var(--linen-100); margin-top: 1.5rem; }
#woven-panel p { margin-top: 0.6rem; line-height: 1.6; }
#woven-panel .p-meta { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: var(--linen-300); }
#woven-panel .p-close { position: absolute; top: 0.75rem; right: 0.75rem; }

.evidence-card { border: 1px solid var(--walnut-600); padding: 1rem; margin-top: 0.75rem; background: var(--walnut-700); }
.evidence-card cite { font-family: var(--mono); font-size: 12px; color: var(--linen-300); font-style: normal; display: block; }
.evidence-card .ev-rights { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: var(--stain-light); display: block; margin-bottom: 0.4rem; }
.evidence-card[data-rights="metadata_only"] { padding: 2rem 1rem; }
.evidence-card[data-rights="metadata_only"] .shelf-label { font-size: 19px; color: var(--linen-100); padding: 1rem 0; }
.evidence-card[data-rights="crop_first"] img { border: 1px solid var(--stain); padding: 4px; }
.evidence-card img { display: block; width: 100%; height: auto; }

.rail-wood {
  height: 3px; border: 0;
  background-image:
    linear-gradient(180deg, var(--oak-300) 0%, var(--oak-400) 35%, var(--oak-500) 36%, var(--oak-500) 72%, var(--walnut-600) 73%, var(--walnut-700) 100%),
    linear-gradient(90deg, var(--oak-500) 0%, #5e4b34 17%, var(--oak-500) 18%, var(--oak-500) 41%, #5a4830 42%, var(--oak-500) 43%, var(--oak-500) 78%, #604d36 79%, var(--oak-500) 100%);
  background-blend-mode: multiply;
}

.link-thread { text-decoration: underline; text-decoration-style: dotted; text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: var(--thread-400); color: var(--linen-100); }
.link-thread:hover { text-decoration-color: var(--stain); }

/* ---------- tour ---------- */

#woven-tourbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 9;
  background: var(--walnut-800); border-top: 3px solid var(--oak-500);
  padding: 0.7rem 0.9rem; display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center;
}
#woven-tourbar[hidden] { display: none; }
#woven-tourbar .tour-title { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; color: var(--linen-300); }
#woven-tourbar .tour-counter { font-family: var(--mono); font-size: 11px; color: var(--linen-100); }
#woven-rail { display: flex; gap: 3px; }
#woven-rail i { width: 10px; height: 3px; background: var(--walnut-600); display: block; }
#woven-rail i.on { background: var(--stain); }
#woven-tourbar [data-act="exit"] .lbl-short { display: none; }

/* The era crossing, named. It sits top-centre, clear of the era markers on the
   left edge, and it reads as a signpost rather than as a stray box. */
#woven-transit {
  position: absolute; z-index: 8; left: 50%; transform: translateX(-50%);
  top: calc(var(--woven-chrome-h, 5.5rem) + 0.7rem);
  display: flex; align-items: baseline; gap: 0.55rem; pointer-events: none;
  background: var(--walnut-700); border: 1px solid var(--oak-500);
  border-left: 3px solid var(--stain); padding: 0.45rem 0.85rem;
  max-width: min(24rem, 86vw);
}
#woven-transit[hidden] { display: none; }
#woven-transit .tr-eyebrow {
  flex: none; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.14em; color: var(--linen-300);
}
#woven-transit b {
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.06em;
  color: var(--linen-50); white-space: nowrap;
}
/* The lighter voice for a long move that stays inside one era band: no band
   boundary crossed, so it says only where it is headed, and says it quietly. */
#woven-transit.tr-light {
  padding: 0.35rem 0.7rem; opacity: 0.88; border-left-color: var(--oak-400);
}

#woven-overlay { position: absolute; z-index: 7; max-width: 26rem; pointer-events: auto; }
#woven-overlay[hidden] { display: none; }
#woven-overlay figure { margin: 0; background: var(--walnut-700); border: 1px solid var(--walnut-600); padding: 0.9rem; }
#woven-overlay figcaption { font-size: 15px; color: var(--linen-100); line-height: 1.5; }
#woven-overlay cite { display: block; font-family: var(--mono); font-size: 11px; color: var(--linen-300); font-style: normal; margin-top: 0.5rem; user-select: text; }
#woven-overlay .rights { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: var(--stain); margin-top: 0.4rem; }

/* The card sits between the control bars and whatever is below it — the year
   rail, or the tour bar while a thread plays. Both heights are measured and
   published as custom properties, so a long stop never grows under either and
   never has its last line cut: it scrolls, with a visible bar to say so. */
#woven-card {
  position: absolute; left: 0.9rem; z-index: 7; max-width: 30rem;
  bottom: calc(var(--woven-tourbar-h, 0px) + var(--woven-rail-h, 2.2rem) + 0.6rem);
  max-height: calc(100% - var(--woven-chrome-h, 5.5rem) - var(--woven-tourbar-h, 0px) - var(--woven-rail-h, 2.2rem) - 1.6rem);
  /* The card is the frame; the copy inside it is what scrolls, so the "more"
     control can sit below the copy instead of over it. */
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--walnut-800); border: 1px solid var(--walnut-600); padding: 1rem;
}
#woven-card .card-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  /* A wide, coloured, always-reserved bar. A thin overlay bar is invisible on a
     dark card, and an invisible bar is how a scrolling card reads as a cut one. */
  scrollbar-width: auto; scrollbar-color: var(--oak-400) var(--walnut-700);
  scrollbar-gutter: stable;
}
#woven-card .card-body::-webkit-scrollbar { width: 10px; }
#woven-card .card-body::-webkit-scrollbar-track { background: var(--walnut-700); }
#woven-card .card-body::-webkit-scrollbar-thumb { background: var(--oak-400); }
#woven-card[hidden] { display: none; }
#woven-card h3 { font-family: 'Libre Franklin', Arial, sans-serif; font-weight: 800; font-size: 24px; color: var(--linen-50); line-height: 1.15; }
#woven-card p { font-size: 16px; line-height: 1.6; color: var(--linen-200); margin-top: 0.6rem; }
#woven-card .flag { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: var(--stain); margin-top: 0.5rem; }
#woven-card .band { font-family: var(--mono); font-size: 11px; color: var(--thread-400); }
/* Stuck to the bottom edge of the card while there is copy below it. The
   gradient tells the eye the text continues; the button moves it down. */
/* A footer under the copy, outside the box that scrolls, so it never covers a
   line of type. */
#woven-card .card-more {
  flex: 0 0 auto;
  margin: 0 -1rem -1rem; padding: 0.6rem 1rem; text-align: right;
  background: var(--walnut-800); border-top: 1px solid var(--walnut-600);
}
#woven-card .card-more[hidden] { display: none; }
#woven-card .card-more button { padding: 0.3rem 0.6rem; font-size: 11px; }

/* Cards that cover the stage. They start below the control bars so the bars stay
   reachable, and they scroll inside themselves rather than run off the stage. */
#woven-ghostcard, #woven-help-card, #woven-tourpicker {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10;
  top: var(--woven-chrome-h, 5.5rem);
  /* Flex, not grid, and centred the safe way. A grid item taller than its track
     overflows off both ends, which put the heading and the way out above the top
     edge of the stage where no pointer can reach them. */
  display: flex; align-items: safe center; justify-content: center;
  background: rgba(11, 8, 6, 0.9); padding: 1rem;
  overflow: hidden; overscroll-behavior: contain;
}
#woven-ghostcard[hidden], #woven-help-card[hidden], #woven-tourpicker[hidden] { display: none; }
/* Capped against the box the reader can actually see — the stage between the
   control bars and the foot — never against the window. A viewport cap measured
   765px inside a 446px stage and put the way out off screen. */
#woven-ghostcard .inner, #woven-help-card .inner, #woven-tourpicker .inner {
  max-width: 34rem; width: 100%; background: var(--walnut-800);
  border: 1px solid var(--walnut-600);
  max-height: 100%; min-height: 0;
  display: flex; flex-direction: column; overflow: hidden;
}
/* The head — title and Close — is a fixed row at the top of the card. Only the
   body under it scrolls, so closing is always one reach away. */
#woven-ghostcard .card-head, #woven-help-card .card-head, #woven-tourpicker .card-head {
  flex: 0 0 auto;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
  padding: 1rem 1.25rem 0.7rem;
  background: var(--walnut-800); border-bottom: 1px solid var(--walnut-600);
}
#woven-ghostcard .card-head .woven-btn,
#woven-help-card .card-head .woven-btn,
#woven-tourpicker .card-head .woven-btn { flex: 0 0 auto; }
#woven-ghostcard .card-scroll, #woven-help-card .card-scroll, #woven-tourpicker .card-scroll {
  flex: 1 1 auto; min-height: 0; padding: 1rem 1.25rem 1.25rem;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: auto; scrollbar-color: var(--oak-400) var(--walnut-700);
}
#woven-help-card .card-scroll::-webkit-scrollbar,
#woven-tourpicker .card-scroll::-webkit-scrollbar,
#woven-ghostcard .card-scroll::-webkit-scrollbar { width: 10px; }
#woven-help-card .card-scroll::-webkit-scrollbar-track,
#woven-tourpicker .card-scroll::-webkit-scrollbar-track,
#woven-ghostcard .card-scroll::-webkit-scrollbar-track { background: var(--walnut-700); }
#woven-help-card .card-scroll::-webkit-scrollbar-thumb,
#woven-tourpicker .card-scroll::-webkit-scrollbar-thumb,
#woven-ghostcard .card-scroll::-webkit-scrollbar-thumb { background: var(--oak-400); }
/* A card with no head of its own still gets its top padding back. */
#woven-ghostcard .inner > .card-scroll:first-child { padding-top: 1.25rem; }
#woven-ghostcard h3, #woven-help-card h3, #woven-tourpicker h3 { font-family: 'Libre Franklin', Arial, sans-serif; font-weight: 800; font-size: 24px; color: var(--linen-50); }
#woven-ghostcard p, #woven-help-card p, #woven-tourpicker p { margin-top: 0.75rem; line-height: 1.6; color: var(--linen-200); }
#woven-help-card h4, #woven-tourpicker h4 { font-family: 'Libre Franklin', Arial, sans-serif; font-weight: 700; font-size: 1rem; color: var(--linen-100); margin-top: 1.1rem; }
#woven-help-card dl { margin-top: 0.5rem; font-family: var(--mono); font-size: 12px; color: var(--linen-200); }
#woven-help-card dt { color: var(--linen-50); margin-top: 0.5rem; }

#woven-tourpicker ul { list-style: none; padding: 0; margin: 0.5rem 0 0; }
#woven-tourpicker li { border-top: 1px solid var(--walnut-600); padding: 0.7rem 0; }
#woven-tourpicker .tp-title { display: block; font-family: 'Libre Franklin', Arial, sans-serif; font-weight: 700; font-size: 1rem; color: var(--linen-50); }
#woven-tourpicker .tp-meta { display: block; font-family: var(--mono); font-size: 11px; color: var(--linen-300); margin: 0.2rem 0 0.5rem; }

/* On the right, because the left edge of the stage belongs to the era markers.
   The roll used to sit on top of them, so a reader watching names go past had no
   way to tell which decade they were in. The key is hidden while the roll runs,
   so this column is free. */
#woven-ghostnames {
  position: absolute; right: 0.9rem; left: auto; z-index: 8;
  top: calc(var(--woven-chrome-h, 5.5rem) + 0.6rem);
  bottom: calc(var(--woven-rail-h, 2.2rem) + 0.8rem);
  width: min(22rem, 60vw); overflow-y: auto; overscroll-behavior: contain;
  background: var(--walnut-900); border: 1px solid var(--walnut-600); padding: 0.8rem 1rem;
}
#woven-ghostnames[hidden] { display: none; }
#woven-ghostnames li { color: var(--linen-100); font-size: 15px; line-height: 1.5; }
#woven-ghostnames .g-place { color: var(--thread-400); font-family: var(--mono); font-size: 11px; }
#woven-ghostnames .g-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.6rem; }
#woven-ghostnames .g-head span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: var(--linen-300); }

#woven-notice { position: absolute; left: 0.9rem; top: calc(var(--woven-chrome-h, 5.5rem) + 0.6rem); z-index: 8; background: var(--walnut-700); border: 1px solid var(--walnut-600); padding: 0.6rem 0.8rem; font-family: var(--mono); font-size: 11px; color: var(--linen-200); }

/* A deep wheel-zoom into a gap between threads is a blank stretch of cloth
   with nothing on it. This says so, centred over that blank stretch, and it
   is gone the moment a thread is back in view — it never blocks a click. */
#woven-empty-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 6; pointer-events: none; text-align: center;
  background: var(--walnut-700); border: 1px solid var(--walnut-600);
  padding: 0.6rem 1rem; font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.03em; color: var(--linen-200);
}
#woven-empty-hint[hidden] { display: none; }
#woven-notice[hidden] { display: none; }

/* ---------- twin ---------- */

#woven-banner { border: 1px solid var(--walnut-600); background: var(--walnut-800); padding: 1rem; margin-bottom: 1.5rem; }
#woven-banner[hidden] { display: none; }

#woven-twin { max-width: 68rem; margin: 0 auto; padding: 3rem 1rem 4rem; }
#woven-twin h2 { font-family: 'Libre Franklin', Arial, sans-serif; font-weight: 800; font-size: 2rem; color: var(--linen-50); }
#woven-twin h3 { font-family: 'Libre Franklin', Arial, sans-serif; font-weight: 700; font-size: 1.25rem; color: var(--linen-100); margin-top: 2rem; }
#woven-twin h4 { font-family: 'Libre Franklin', Arial, sans-serif; font-weight: 700; font-size: 0.95rem; color: var(--linen-100); margin-top: 1rem; }
#woven-twin p { color: var(--linen-200); line-height: 1.65; margin-top: 0.6rem; max-width: 62ch; }
#woven-twin ol, #woven-twin ul { list-style: none; padding: 0; }
#woven-twin .era-band { border-top: 1px solid var(--walnut-600); margin-top: 1.5rem; padding-top: 0.5rem; }
#woven-twin .threads > li { border-bottom: 1px solid var(--walnut-600); }
#woven-twin .threads > li[aria-current="true"] { border-left: 3px solid var(--stain); padding-left: 0.6rem; }
#woven-twin .threads > li[data-in-tour="true"] .t-name { color: var(--stain-light); }
#woven-twin .t-open { display: grid; grid-template-columns: minmax(0, 2fr) 1fr 1fr 1fr 1fr; gap: 0.75rem; width: 100%; text-align: left; background: none; border: 0; color: inherit; padding: 0.7rem 0; cursor: pointer; align-items: baseline; }
#woven-twin .t-open:focus-visible { outline: 2px solid var(--stain-light); outline-offset: 3px; }
#woven-twin .t-name { font-family: 'Libre Franklin', Arial, sans-serif; font-weight: 700; font-size: 1rem; color: var(--linen-50); }
#woven-twin .t-place, #woven-twin .t-years, #woven-twin .t-evidence, #woven-twin .t-state { font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; color: var(--linen-300); }
#woven-twin li[data-ghost="true"] .t-evidence { color: var(--thread-400); }
#woven-twin .t-detail { padding: 0 0 1.25rem; }
#woven-twin .evidence-item { border-left: 1px solid var(--walnut-600); padding: 0.5rem 0 0.5rem 0.75rem; margin-top: 0.5rem; }
#woven-twin .ev-rights { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: var(--stain); }
#woven-twin cite { font-style: normal; font-family: var(--mono); font-size: 12px; color: var(--linen-300); }
#woven-twin .events li { display: flex; gap: 0.75rem; padding: 0.35rem 0; flex-wrap: wrap; }
#woven-twin .events li[aria-current="step"] { border-left: 3px solid var(--stain); padding-left: 0.5rem; }
#woven-twin .e-date { font-family: var(--mono); font-size: 11px; color: var(--thread-400); min-width: 6.5rem; }
#woven-twin .e-conf { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--stain); }
#woven-twin .t-play { background: none; border: 1px solid var(--walnut-600); color: var(--linen-200); font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; padding: 0.35rem 0.7rem; margin-top: 0.5rem; cursor: pointer; }
#woven-twin .t-play:hover { border-color: var(--oak-500); color: var(--linen-50); }
#woven-twin .t-play:focus-visible { outline: 2px solid var(--stain-light); outline-offset: 3px; }
#woven-twin .tour-list > li, #woven-twin .ghost-list > li { border-bottom: 1px solid var(--walnut-600); padding: 0.9rem 0; }
#woven-twin .ghost-list > li[aria-current="true"] { border-left: 3px solid var(--stain); padding-left: 0.6rem; }
#woven-twin .g-name { display: block; font-family: 'Libre Franklin', Arial, sans-serif; font-weight: 700; color: var(--linen-50); }
#woven-twin .g-place, #woven-twin .g-years { font-family: var(--mono); font-size: 11px; color: var(--linen-300); margin-right: 0.75rem; }
#woven-twin summary { cursor: pointer; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; color: var(--linen-300); margin-top: 0.5rem; padding-block: 0.85rem; }
/* Text-twin links sit in running lists; give each at least a 24px target. */
#woven-twin a.link-thread { display: inline-block; padding-block: 0.35rem; }
#woven-twin .warn { color: var(--stain); font-family: var(--mono); font-size: 12px; }
#woven-twin .e-desc { color: var(--linen-300); font-size: 14px; }

@media (max-width: 700px) {
  /* One scrolling row each, so the controls never eat half the stage. The row
     scrolls; the buttons keep their full width, so no label is cut. The bar is
     given a visible track and a fade at the right edge to say there is more. */
  #woven-eranav { flex-wrap: nowrap; align-items: stretch; }
  /* The search gets its own row here. Sharing the row with the button scroller
     left the field printed over the last button in it. */
  #woven-topbar { flex-wrap: wrap; align-items: stretch; row-gap: 0.45rem; }
  #woven-topbar .bar-scroll { flex: 1 1 100%; }
  #woven-topbar #woven-searchform { flex: 1 1 100%; }
  #woven-topbar .bar-scroll, #woven-eranav .bar-scroll {
    flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
    overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
    padding-bottom: 5px; scrollbar-width: thin;
    scrollbar-color: var(--oak-400) var(--walnut-700);
    mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent 100%);
  }
  .bar-scroll::-webkit-scrollbar { height: 5px; }
  .bar-scroll::-webkit-scrollbar-track { background: var(--walnut-700); }
  .bar-scroll::-webkit-scrollbar-thumb { background: var(--oak-400); }
  #woven-topbar .woven-btn, #woven-eranav .woven-btn { padding: 0.4rem 0.6rem; }
  #woven-search { flex: 1 1 auto; width: auto; min-width: 0; }
  /* The count fits now that the row is its own. It carries the enter hint, which
     is the only place the shortcut is written on a phone. */
  #woven-search-count { flex: 0 0 auto; font-size: 10px; }
  #woven-era-now { white-space: nowrap; }
  /* A wrapped tour bar took 175 of the 378 pixels the stage has on a phone and
     squeezed the story card down to a line and a half. One scrolling row of
     controls; the title and the progress ticks are in the card and the counter. */
  #woven-tourbar {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
    padding: 0.5rem 0.6rem; gap: 0.45rem; scrollbar-width: thin;
  }
  #woven-tourbar > * { flex: 0 0 auto; white-space: nowrap; }
  #woven-tourbar .tour-title, #woven-tourbar #woven-rail { display: none; }
  #woven-tourbar .woven-btn { padding: 0.4rem 0.6rem; }
  /* The way out comes first, then the way on. A row that scrolls sideways put
     "exit this thread" past the right edge, where a reader stuck in a story
     cannot find it. The counter is the one thing here that may be cut short. */
  #woven-tourbar [data-act="exit"] { order: -3; }
  #woven-tourbar [data-act="next"], #woven-tourbar [data-act="end"] { order: -2; }
  /* Pause is a first-class control, not something to be found by scrolling: on a
     phone it sits in the visible run of the bar beside "next stop". */
  #woven-tourbar [data-act="play"] { order: -1; }
  #woven-tourbar .tour-counter { order: -1; flex: 0 1 auto; min-width: 5rem; overflow: hidden; text-overflow: ellipsis; }
  /* The way out keeps its meaning in one word here, so the stop number, the way
     on, and the pause control all fit in the visible run of the bar. The full
     label stays as the button's accessible name. */
  #woven-tourbar [data-act="exit"] .lbl-full { display: none; }
  #woven-tourbar [data-act="exit"] .lbl-short { display: inline; }
  /* "Previous stop" is dropped here rather than parked off the right edge. The
     card, the counter, and the browser's own back gesture all still work. */
  #woven-tourbar [data-act="prev"] { display: none; }
  .thread-label { max-width: 58vw; }
  .thread-label b { font-size: 12px; }
  /* The ghost roll takes the right of the stage from 10.5rem in. The longest
     marker, the undated band, ran under it. It wraps here instead of reaching
     across, so the band name and its count both stay readable. */
  .era-marker { max-width: 8.5rem; white-space: normal; line-height: 1.3; }
  /* An opened key floats over the cloth here, so it never takes the whole
     stage: it stops short of the era controls and scrolls inside itself. It also
     sits above the year rail rather than on top of it. */
  #woven-legend {
    width: auto; max-width: 92vw; overflow: hidden;
    display: flex; flex-direction: column; align-items: flex-start;
    bottom: calc(var(--woven-rail-h, 2.2rem) + 0.5rem);
    max-height: calc(100% - var(--woven-chrome-h, 5.5rem) - var(--woven-rail-h, 2.2rem) - 1.2rem);
  }
  /* The panel keeps its close control and scrolls the copy beneath it, so the
     last line of the key is never the last line a reader can reach. */
  #woven-legend .lg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  /* The intro gives back space so the whole loom lands on the first screen of a
     phone. Below the fold, a zoomed-out overview is an overview of nothing. */
  #woven-intro { padding-top: 0.7rem; padding-bottom: 0.7rem; }
  #woven-intro .rail-wood { margin-top: 0.6rem; }
  #woven-intro p { font-size: 0.8125rem; line-height: 1.5; }
  /* A phone gives the story card about 250 pixels. Desktop type put 800 pixels
     of copy in it, so most of a stop sat below the fold. Smaller type and
     tighter padding roughly halve that, and the card still scrolls for the rest
     — with a wide bar, so a reader can see there is more. */
  #woven-card { padding: 0.7rem 0.75rem; left: 0.6rem; }
  #woven-card h3 { font-size: 18px; }
  #woven-card p { font-size: 14px; line-height: 1.5; margin-top: 0.45rem; }
  #woven-card .card-more { margin: 0 -0.75rem -0.7rem; padding: 0.45rem 0.75rem; }
}

@media (max-width: 700px) {
  /* On a phone the stage is a short strip, so a backdrop drawn inside it covered
     almost nothing: the heading and the toolbar behind the panel still took the
     tap. These cards cover the window while they are open. The panel is still
     held below the control bars, so it reads as belonging to the stage. */
  #woven-ghostcard, #woven-help-card, #woven-tourpicker {
    position: fixed; inset: 0; top: 0;
    padding: calc(var(--woven-chrome-h, 5.5rem) + 0.75rem) 0.75rem 0.75rem;
    background: rgba(11, 8, 6, 0.94);
  }
}

@media (max-width: 640px) {
  #woven-stage { min-height: 380px; }
  #woven-twin .t-open { grid-template-columns: 1fr; gap: 0.15rem; }
  #woven-panel { width: 100%; }
  /* Still a right-hand column, never the full stage width: the roll starts clear
     of the era markers on the left edge, which have to stay legible while it
     plays. Only the longest of them, the undated band, reaches under it. */
  #woven-ghostnames { left: 10.5rem; right: 0.7rem; width: auto; max-width: none; }
  #woven-card { max-width: calc(100% - 1.8rem); }
}

/* Short windows — a laptop at 1280x620, a phone turned sideways. The intro gives
   back its padding and the stage gives back its floor so the whole first screen
   still fits without scrolling. Last in the file so it wins over the width
   rules above. */
@media (max-height: 700px) {
  #woven-intro { padding-top: 0.6rem; padding-bottom: 0.6rem; }
  #woven-stage { min-height: 320px; }
}
@media (max-height: 600px) {
  #woven-intro { padding-top: 0.35rem; padding-bottom: 0.35rem; }
  #woven-intro .rail-wood { margin-top: 0.5rem; }
  #woven-intro p { font-size: 0.8125rem; line-height: 1.45; }
  #woven-stage { min-height: 285px; }
}
/* A short phone. The control bars take three rows here, and three rows of
   chrome over a 300-pixel stage leaves no loom. They give back their padding so
   the cloth and the era column keep the room they need. */
@media (max-width: 700px) and (max-height: 700px) {
  #woven-topbar { padding: 0.4rem 0.6rem; row-gap: 0.3rem; }
  #woven-eranav { padding: 0.3rem 0.6rem; }
  #woven-topbar .bar-scroll, #woven-eranav .bar-scroll { padding-bottom: 3px; }
  #woven-topbar .woven-btn, #woven-eranav .woven-btn { padding: 0.3rem 0.5rem; }
  #woven-search { padding: 0.3rem 0.5rem; }
}

@media (max-height: 520px) {
  #woven-stage { min-height: 260px; }
  #woven-legend { max-height: calc(100% - 6rem); overflow-y: auto; }
}

/* While a full-screen woven overlay (about, guided threads, ghost) is open on a
   narrow screen, the fixed site header is made inert by script so a tap meant
   for the overlay's own backdrop cannot reach the hamburger button underneath
   it. This is the fallback for browsers that honor pointer-events but not the
   inert attribute yet. */
[inert] { pointer-events: none; }

@media (prefers-contrast: more), (forced-colors: active) {
  .rail-wood { background-image: none; background-color: CanvasText; }
}
@media (prefers-reduced-motion: reduce) {
  .woven-btn::after { transition: none; }
}

/* ---------- flat timeline: the dock offset and its own controls ----------
   The publication index and record panel dock at the width the hall's
   stylesheet sets on #woven-stage (--exhibit-dock). The year rail, the DOM
   labels, and the era markers are flat-timeline-only, so their offset against
   that same dock lives here rather than in the hall's stylesheet. These rules
   used to live in woven-exhibit.css, removed with the 3D exhibit view; the
   hall never showed the dock-based #woven-legend column, so that stays
   hidden here too. */
#woven-stage #woven-legend { display: none; }
#woven-stage #woven-yearrail { right: var(--exhibit-dock, 0px); }
#woven-stage #woven-labels, #woven-stage #woven-eras { right: var(--exhibit-dock, 0px); }
#woven-stage.woven-legend-hidden #woven-canvas { width: 100%; }
#woven-stage.woven-legend-hidden #woven-chrome,
#woven-stage.woven-legend-hidden #woven-yearrail { right: 0; }
#woven-stage.woven-legend-hidden #woven-browser { display: none; }

/* The flat timeline's own zoom controls. Hidden outside timeline mode and
   while a tour or the gaps roll takes the dock's place. */
#woven-timeline-controls { position: absolute; left: 1rem; bottom: 2.5rem; display: flex; gap: 0.4rem; z-index: 5; }
#woven-timeline-controls button { min-width: 44px; min-height: 44px; font-size: 1.2rem; }
#woven-stage:not([data-view="timeline"]) #woven-timeline-controls,
#woven-stage.woven-legend-hidden #woven-timeline-controls { display: none; }

@media (max-width: 899px) {
  #woven-stage.woven-legend-hidden { height: 720px; }
  #woven-stage.woven-legend-hidden #woven-canvas { height: 100%; }
  #woven-stage.woven-legend-hidden #woven-yearrail { bottom: 0; }
  #woven-timeline-controls { top: calc(var(--plot-height) - 80px); bottom: auto; }
}
