/* Layout: one long strip of embroidered linen. Stitched border bands top and
   bottom (like the tapestry's margins), scenes and text in the middle band,
   stylised trees as dividers between sections. */
:root {
  --linen: #e7e0d1;        /* ground cloth, sampled from the tapestry's linen */
  --linen-deep: #dcd3c0;   /* shadowed weave, cards */
  --ink: #2b2622;          /* blue-black wool: outlines and lettering */
  --muted: #625a50;
  --madder: #8f3a2a;       /* madder red */
  --woad: #36545c;         /* woad grey-blue, primary accent */
  --weld: #a8823a;         /* weld yellow */
  --sage: #66704f;         /* green wool */
  --rule: #b8ab92;
  --thread: #8f3a2a;
  --frame: #2b2622;        /* the dark museum wall the tapestry hangs on (frieze only) */
  --adder-outline: none;
  --display: "Uncial Antiqua", "Alegreya SC", Georgia, serif;
  --body: "Alegreya", Georgia, "Times New Roman", serif;
  --caps: "Alegreya SC", "Alegreya", Georgia, serif;
  --measure: 66ch;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --linen: #1d1b19; --linen-deep: #282521; --ink: #ebe3d3; --muted: #b3a894;
    --madder: #d77a62; --woad: #8fb0b8; --weld: #d6ae63; --sage: #a9b48c; --rule: #4a443c; --thread: #d77a62; --frame: #121110;
    --adder-outline: drop-shadow(0 0 1px #d8cdb7) drop-shadow(0 0 1px #d8cdb7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --linen: #1d1b19; --linen-deep: #282521; --ink: #ebe3d3; --muted: #b3a894;
    --madder: #d77a62; --woad: #8fb0b8; --weld: #d6ae63; --sage: #a9b48c; --rule: #4a443c; --thread: #d77a62; --frame: #121110;
    --adder-outline: drop-shadow(0 0 1px #d8cdb7) drop-shadow(0 0 1px #d8cdb7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--linen);
  /* faint plain weave */
  background-image:
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--ink) 4%, transparent) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--ink) 3%, transparent) 0 1px, transparent 1px 3px);
  color: var(--ink);
  font: 1.125rem/1.6 var(--body);
}
a { color: var(--woad); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--madder); }
:focus-visible { outline: 2px dashed var(--madder); outline-offset: 3px; }
.wrap { max-width: 1120px; margin-inline: auto; padding-inline: 16px; }

/* ---------- reading thread: stitches across the top as you scroll ---------- */
.thread {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: calc(4px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px); pointer-events: none;
}
.thread span {
  display: block; height: 4px; width: 0;
  background: repeating-linear-gradient(90deg, var(--thread) 0 9px, transparent 9px 13px);
}

/* ---------- border bands (the tapestry's upper and lower margins) ---------- */
.band {
  /* embroidered floral ribbon on black cloth; same strip top and bottom */
  height: 60px; background: #000 url("img/border-floral.webp") repeat-x 0 50% / auto 100%;
  border-block: 2px solid #a8823a;
}
.band.bottom { background-position: 40% 50%; }

/* ---------- header ---------- */
.site-head { padding-block: 20px 12px; }
.site-head .wrap { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
.brand { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.brand b { font: 400 clamp(1.9rem, 5vw, 2.6rem)/1 var(--display); letter-spacing: .01em; }
.brand small { font: .95rem/1.3 var(--caps); color: var(--muted); letter-spacing: .06em; margin-top: 6px; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font: 1.05rem var(--caps); letter-spacing: .06em; }
.nav a { color: var(--ink); text-decoration: none; padding-block: 4px; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a[aria-current="page"] { border-bottom: 2px dashed var(--madder); color: var(--ink); }

/* ---------- frieze (hero) ---------- */
.frieze { margin-block: 8px 0; background: var(--frame); padding-block: 22px 6px; }
.frieze-scroll {
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
  scrollbar-width: thin; scrollbar-color: #6b6256 transparent; cursor: grab;
}
.frieze-scroll.dragging { cursor: grabbing; scroll-snap-type: none; }
.frieze-scroll.dragging img { pointer-events: none; }
.frieze-strip { display: flex; width: max-content; }
.scene { scroll-snap-align: start; flex: none; text-decoration: none; display: flex; flex-direction: column; }
.scene img {
  display: block; height: clamp(170px, 23vw, 290px); width: auto; max-width: none;
  box-shadow: 0 6px 18px rgb(0 0 0 / .45); user-select: none; -webkit-user-drag: none;
}
.scene figcaption { padding: 12px 18px 10px; display: grid; gap: 2px; }
.scene .cap { font: 600 .82rem var(--caps); letter-spacing: .16em; color: #e9c98f; }
.scene .era { font: 1rem var(--caps); letter-spacing: .04em; color: #d8cfbf; }
.scene .era b { color: #fff8ea; font-weight: 600; }
.scene:hover .era b, .scene:focus-visible .era b { text-decoration: underline; text-decoration-color: #e9c98f; text-underline-offset: 4px; }
.frieze-controls { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; padding-block: 6px 12px; }
.frieze-controls p { margin: 0; color: #c9bfae; font-size: .95rem; }
.frieze-controls .btns { display: flex; gap: 8px; }
.stitch-btn {
  font: 1rem var(--caps); letter-spacing: .05em; color: #f1e8d8; background: transparent;
  border: 2px dashed #8a7f6f; border-radius: 3px; padding: 6px 14px; cursor: pointer; min-height: 40px;
}
.stitch-btn:hover { border-color: #e9c98f; color: #e9c98f; }


/* ---------- sections ---------- */
main { padding-block: 8px 48px; }
.sec { padding-block: 36px 8px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 18px; }
.latin { display: block; font: 600 .8rem var(--caps); letter-spacing: .18em; color: var(--madder); text-transform: uppercase; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; }
.sec-head h2 { font: 400 clamp(1.6rem, 3.6vw, 2.2rem) var(--display); margin: 4px 0 0; }
.sec-head a { font: 1rem var(--caps); letter-spacing: .05em; }

.tree-rule { display: flex; align-items: center; gap: 14px; color: var(--sage); margin-block: 28px 0; }
.tree-rule::before, .tree-rule::after { content: ""; flex: 1; border-top: 2px dashed var(--rule); }
.tree-rule img { width: 41px; height: 88px; flex: none; filter: var(--adder-outline); }

/* dispatch (featured news) */
.dispatch {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 28px;
  background: var(--linen-deep); border: 2px dashed var(--rule); padding: clamp(18px, 3vw, 32px); border-radius: 4px;
}
.dispatch h3 { font: 400 clamp(1.5rem, 3.4vw, 2.1rem)/1.15 var(--display); margin: 6px 0 12px; }
.dispatch h3 a { color: var(--ink); text-decoration: none; }
.dispatch h3 a:hover { color: var(--madder); }
.dispatch p { margin: 0 0 12px; max-width: var(--measure); }
.facts { margin: 0; display: grid; gap: 10px; align-content: start; border-left: 3px solid var(--madder); padding-left: 18px; }
.facts div { display: grid; gap: 0; }
.facts dt { font: .82rem var(--caps); letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.facts dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font: .8rem var(--caps); letter-spacing: .12em; text-transform: uppercase; color: var(--linen); background: var(--madder); padding: 2px 10px; border-radius: 2px; }

/* news list */
.news-list { list-style: none; margin: 0; padding: 0; display: grid; }
.news-list li { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 4px 20px; padding-block: 14px; border-bottom: 1px dashed var(--rule); }
.news-list time { font: .95rem var(--caps); color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .03em; padding-top: 2px; }
.news-list a { font-size: 1.12rem; font-weight: 500; color: var(--ink); text-decoration: none; }
.news-list a:hover { color: var(--madder); text-decoration: underline; }
.news-list .meta { grid-column: 2; font-size: .9rem; color: var(--muted); }

/* the four ages */
.ages { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.age { display: flex; flex-direction: column; gap: 6px; padding: 18px 16px 16px; text-decoration: none; color: var(--ink); border-top: 6px solid var(--c); background: var(--linen-deep); border-radius: 0 0 4px 4px; }
.age:hover { outline: 2px dashed var(--c); outline-offset: -2px; }
.age .yr { font: 600 .85rem var(--caps); letter-spacing: .12em; color: var(--c); }
.age strong { font: 400 1.35rem/1.15 var(--display); }
.age span:last-child { font-size: .98rem; color: var(--muted); }

/* library columns */
.shelves { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 32px; }
.shelf h3 { font: 600 1.05rem var(--caps); letter-spacing: .08em; margin: 0 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--rule); }
.shelf ul { list-style: none; margin: 0; padding: 0; }
.shelf li { padding-block: 5px; }
.shelf a { color: var(--ink); text-decoration: none; }
.shelf a:hover { color: var(--madder); text-decoration: underline; }

/* ---------- news page tools ---------- */
.tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
.tools input {
  font: 1.05rem var(--body); color: var(--ink); background: var(--linen-deep); border: 2px dashed var(--rule);
  border-radius: 3px; padding: 8px 12px; flex: 1 1 260px; min-width: 0;
}
.tools input:focus { border-color: var(--woad); outline: none; }
.years { display: flex; flex-wrap: wrap; gap: 6px; }
.years button {
  font: .95rem var(--caps); color: var(--ink); background: transparent; border: 1px solid var(--rule);
  border-radius: 2px; padding: 4px 10px; cursor: pointer; font-variant-numeric: tabular-nums; min-height: 34px;
}
.years button[aria-pressed="true"] { background: var(--woad); color: var(--linen); border-color: var(--woad); }
.count { color: var(--muted); font-size: .95rem; margin: 0 0 6px; }
.empty { padding: 20px 0; color: var(--muted); }

/* ---------- article pages ---------- */
.crumbs { font: .95rem var(--caps); letter-spacing: .05em; color: var(--muted); margin: 24px 0 0; }
.crumbs a { color: var(--muted); }
.article-head { max-width: var(--measure); padding-block: 8px 12px; }
.article-head h1 { font: 400 clamp(1.8rem, 4.6vw, 2.8rem)/1.12 var(--display); margin: 8px 0 10px; }
.article-head .meta { color: var(--muted); font-size: 1rem; }
.prose { max-width: var(--measure); }
.prose p, .prose ul, .prose ol, .prose blockquote { margin: 0 0 1em; }
.prose h2, .prose h3, .prose h4 { font: 600 1.3rem/1.25 var(--caps); letter-spacing: .03em; margin: 1.6em 0 .5em; }
.prose hr { border: 0; border-top: 2px dashed var(--rule); margin: 1.8em 0; }
.prose blockquote { border-left: 3px solid var(--weld); padding-left: 16px; font-style: italic; }
.prose a { overflow-wrap: anywhere; }
.prose .watch a, .prose .clips a {
  display: inline-block; font: 1rem var(--caps); letter-spacing: .04em; text-decoration: none;
  border: 2px dashed var(--woad); padding: 6px 14px; border-radius: 3px; overflow-wrap: normal;
}
.prose .watch a::before, .prose .clips a::before { content: "\25B6\00a0"; font-size: .8em; }
.prose .clips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.note {
  max-width: var(--measure); background: var(--linen-deep); border-left: 4px solid var(--weld);
  padding: 14px 18px; margin: 24px 0; font-size: 1rem; border-radius: 0 3px 3px 0;
}
.note p { margin: 0; }
.related { max-width: var(--measure); margin-top: 36px; padding-top: 18px; border-top: 2px dashed var(--rule); display: flex; flex-wrap: wrap; gap: 10px 24px; font: 1rem var(--caps); }

/* ---------- footer ---------- */
.site-foot { padding-block: 0 32px; color: var(--muted); font-size: .95rem; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.site-foot p { margin: 0; max-width: 60ch; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .ages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shelves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dispatch { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  body { font-size: 1.06rem; }
  .band { height: 44px; }
  .ages, .shelves { grid-template-columns: minmax(0, 1fr); }
  .news-list li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .news-list .meta { grid-column: 1; }
  .nav { gap: 2px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .frieze-scroll { scroll-behavior: auto; }
  .thread span { transition: none; }
}

/* ---------- frieze: intro card, timeline, pinned (desktop) mode ---------- */
.frieze-intro {
  flex: none; width: min(78vw, 420px); padding: 18px 40px 18px 24px; align-self: center; scroll-snap-align: start;
  display: flex; flex-direction: column; gap: 10px; color: #e6dccb;
}
.frieze-intro .cap { font: 600 .82rem var(--caps); letter-spacing: .2em; color: #e9c98f; }
.frieze-intro h2 { font: 400 clamp(1.7rem, 3.2vw, 2.5rem)/1.1 var(--display); margin: 0; color: #fff8ea; }
.frieze-intro p { margin: 0; font-size: 1.05rem; line-height: 1.5; color: #cfc5b4; max-width: 30ch; }
.frieze-controls { flex-direction: column; align-items: stretch; }
.timeline { display: grid; gap: 10px; }
.timeline .track { height: 4px; background: #463f37; border-radius: 2px; overflow: hidden; }
.timeline .fill {
  display: block; height: 100%; width: 0;
  background: repeating-linear-gradient(90deg, #e9c98f 0 9px, transparent 9px 13px);
}
.stops { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stops button {
  display: grid; gap: 0; text-align: left; background: transparent; color: #cfc5b4; cursor: pointer;
  border: 0; border-top: 2px solid transparent; padding: 6px 2px 2px; font: .95rem var(--caps); min-height: 44px;
}
.stops button b { font-weight: 600; color: #fff8ea; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.stops button span { font-size: .85rem; letter-spacing: .03em; }
.stops button:hover, .stops button[aria-current="true"] { border-top-color: #e9c98f; color: #e9c98f; }
.stops button[aria-current="true"] b { color: #e9c98f; }
.frieze-controls .hint { margin: 0; color: #a99f8f; font-size: .92rem; }

/* pinned: the page scroll drives the tapestry sideways */
.frieze.is-pinned { height: 100vh; height: 100svh; display: flex; flex-direction: column; justify-content: center; padding-block: 0; }
.frieze.is-pinned .frieze-scroll { overflow: hidden; cursor: default; scroll-snap-type: none; }
.frieze.is-pinned .scene img { height: min(56vh, 460px); }
.frieze.is-pinned .frieze-strip { will-change: transform; }

@media (max-width: 560px) {
  .stops button span { display: none; }
  .frieze-intro { width: 70vw; padding-inline: 18px 24px; }
}

/* ---------- series page panel + zoom viewer ---------- */
.panel { margin: 8px 0 26px; max-width: 1100px; }
.panel-open {
  display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; position: relative; text-align: left;
}
.panel-open img { display: block; width: 100%; height: auto; box-shadow: 0 4px 14px rgb(0 0 0 / .25); }
.panel-cta {
  position: absolute; right: 12px; bottom: 12px; font: 600 .9rem var(--caps); letter-spacing: .05em;
  color: #fff8ea; background: rgb(30 27 24 / .82); padding: 7px 12px; border-radius: 3px;
}
.panel-open:hover .panel-cta, .panel-open:focus-visible .panel-cta { background: var(--madder); }
dialog.zoom {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #121110; color: #e6dccb; flex-direction: column;
}
dialog.zoom[open] { display: flex; }
dialog.zoom::backdrop { background: rgb(0 0 0 / .8); }
.zoom-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
}
.zoom-bar p { margin: 0; font-size: .95rem; color: #b9ae9c; }
.zoom-btns { display: flex; gap: 8px; }
.zoom-btns button {
  font: 1rem var(--caps); color: #f1e8d8; background: transparent; border: 2px dashed #8a7f6f;
  border-radius: 3px; min-width: 44px; min-height: 40px; padding: 4px 12px; cursor: pointer;
}
.zoom-btns button:hover { border-color: #e9c98f; color: #e9c98f; }
.zoom-view { flex: 1; min-height: 0; }

/* skip past the tapestry */
.frieze-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.skip-frieze {
  font: 600 1rem var(--caps); letter-spacing: .05em; color: #fff8ea; text-decoration: none;
  border: 2px dashed #e9c98f; border-radius: 3px; padding: 8px 16px; min-height: 44px;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.skip-frieze:hover, .skip-frieze:focus-visible { background: #e9c98f; color: #1d1b19; }
