/*
 * Goblin Software: site stylesheet. One file, no framework.
 * Theme: dark "Forge Night" by default; light (cream paper) follows the system
 * unless html[data-theme="dark"]; html[data-theme="light"] forces light.
 * Correct with JavaScript off. System font stacks only.
 *
 * CLASS CONTRACT (later steps rely on these names):
 *   .skip-link                     skip to content link
 *   .site-header .brand .nav       header, brand mark, navigation links
 *   .brand-logo                    small logo before the brand text
 *   .goblin-corner                 black rounded square fixed to the bottom-right corner,
 *                                  holding the goblin (data-clip names the page clip)
 *   .goblin-still .goblin-play     the neutral still, and the overlay that shows a clip strip
 *   .is-playing .clip-<name>       added by goblin.js while a clip plays (one of 8 clips)
 *   .theme-toggle                  theme button (hidden unless html.js)
 *   .wrap                          centred content column
 *   .hero .hero-text .hero-goblin  hero block, its text, goblin image
 *   .story .story-beat            a story: .story-text (narration, .story-icon) beside .story-card;
 *                                  .story-stageable adds .story-step sentinels, .is-staged pins the stage
 *   .projects .project             project cards (.project-tile, .project-body,
 *                                  .project-title)
 *   .filters                       The Library's kind filter bar (aria-current marks the active link)
 *   .lore .lore-layout            The Library's lore view, its grid of rail plus main column
 *   .lore-nav .lore-main          topic rail (chips on phones), topic sections
 *   .lore-topic .lore-grid        one topic section, its grid of .project cards
 *   .tag + .tag-planned            small chip for an entry tag (always has text)
 *   .rows .row                     list rows (.row-title, .row-meta); .row-stack stacks title, summary, meta
 *   .site-footer                   footer, fixed to the bottom of the screen
 *   .crumbs                        breadcrumb trail at the top of main
 *   .tag-placeholder               quiet "placeholder" marker beside a title or meta line
 *   .ribbon .notice                full-width announcement banner under the header (notice.md)
 *   .notfound                      404 layout (.notfound-code)
 *   .reading                       Theme-aware parchment panel (h1-h3 small caps)
 *   .reading-wide                  wider .reading panel for papers (80% of --page)
 *   .muted                         muted text
 *   .scene .scene-left .scene-right  text beside a sticky figure (figure side)
 *   .scene-text .scene-figure      the two columns of a scene
 *   .is-visible                    added by reveal.js when a column scrolls in
 *   .voiced .voice-<slug>          page told by a cast character: sets --voice
 *                                  (accent on the page) and --voice-paper (on paper)
 *   .article-head                  top of a narrated article: title block left, picture right
 *   .article-head-text             its left column: h1, "Told by" line, meta line
 *   .byline-avatar                 the narrator's picture (112px in .article-head, 72px elsewhere)
 *   .byline-text .byline-by        the "Told by" line, its label,
 *   .byline-name .byline-epithet   the character's name and epithet
 *   .cast-epithet .cast-portrait   a character's page: the epithet line, the large picture
 */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-bottom: calc(var(--footer-h) + var(--space-3));
}

body {
  position: relative;
  isolation: isolate;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-size);
  line-height: 1.6;
  padding-bottom: var(--footer-h);
}

/* The existing landscape gives spare margins a setting without competing
   with text. This fixed decorative layer never receives pointer input. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--world-opacity);
  background: linear-gradient(var(--world-veil), var(--world-veil)), url("img/hero.webp") center / cover no-repeat;
}

img { max-width: 100%; height: auto; display: block; }
main p > img { display: block; max-width: 100%; height: auto; margin-left: auto; margin-right: auto; }

/* Keep this portrait workspace crop visible as a whole; the full-size link
   below it provides a closer view of terminal text. */
.reading img[src$="/bailey-agent-panes.webp"] {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(28rem, 60vh);
  max-height: min(28rem, 60svh);
  object-fit: contain;
}

a { color: var(--link); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  line-height: 1.2;
  margin: 0 0 var(--space-3);
}
h1 { font-size: 2.2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 var(--space-3); }
code { font-family: var(--font-mono); font-size: 0.92em; }

.muted { color: var(--muted); }

.wrap {
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--space-3);
}

/* skip link */
.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -4rem;
  z-index: 100;
  padding: var(--space-2) var(--space-3);
  background: var(--ember);
  color: var(--on-ember);
  font-weight: 700;
  border-radius: var(--radius);
}
.skip-link:focus { top: var(--space-2); }

/* header */
.site-header { background: var(--surface); }
.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  max-width: var(--page);
  margin: 0 auto;
  padding: var(--space-3);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--ember); }
.brand-logo { width: 40px; height: 40px; }
.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}
.nav a { padding: var(--space-1) 0; }

.theme-toggle {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-1) var(--space-3);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--ember); }
html:not(.js) .theme-toggle { display: none; }

/* hero */
.hero {
  position: relative;
  isolation: isolate;
  background:
    linear-gradient(var(--hero-fade), var(--hero-fade)),
    url("img/hero-workshop.webp") center 48% / cover no-repeat;
  background-color: var(--bg);
  border-bottom: 1px solid var(--border);
}
.hero .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
}
.hero-text {
  flex: 1 1 18rem;
  min-width: 0;
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--hero-panel-bg);
  color: var(--hero-panel-ink);
}
.hero-text h1 { color: inherit; }
.hero-text a { color: var(--hero-panel-link); }
.hero-text p { max-width: 32rem; }
.hero-goblin {
  order: -1;
  flex: 0 1 15rem;
  width: auto;
  max-width: 60%;
  max-height: 34vh;
  margin: 0 auto;
  object-fit: contain;
}

.hero + .wrap { padding-top: var(--space-4); }

/* project cards */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: var(--space-3);
  margin: var(--space-4) 0;
  padding: 0;
  list-style: none;
}
.project {
  display: flex;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
}
.project-tile { flex: 0 0 72px; width: 72px; height: 72px; border-radius: 8px; }
.project-body { min-width: 0; }
.project-title { font-family: var(--font-serif); font-size: 1.15rem; margin: 0 0 var(--space-1); }

/* The Library: kind filter bar */
.filters ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-3) 0;
  padding: 0;
  list-style: none;
}
.filters a {
  display: block;
  padding: var(--space-1) var(--space-3);
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
  text-decoration: none;
}
.filters a:hover { color: var(--text); border-color: var(--ember); }
.filters a[aria-current="true"] { color: var(--text); border-color: var(--ember); }

/* The Library's lore view: topic rail beside a grid of cards */
.lore-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
}
.lore-main { min-width: 0; }
.lore-layout > .lore-main:only-child { grid-column: 1 / -1; }
.lore-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.lore-nav a {
  display: block;
  padding: var(--space-1) var(--space-3);
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
  text-decoration: none;
}
.lore-nav a:hover { color: var(--text); border-color: var(--ember); }
.lore-topic { scroll-margin-top: var(--space-4); margin-bottom: var(--space-5); }
.lore-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.lore-grid .project-body { flex: 1 1 auto; }

@media (min-width: 40rem) {
  .lore-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 56rem) {
  .lore-layout { grid-template-columns: 11rem minmax(0, 1fr); gap: var(--space-5); }
  .lore-nav {
    position: sticky;
    top: var(--space-4);
    align-self: start;
  }
  .lore-nav ul { display: block; }
  .lore-nav li { margin: 0; }
  .lore-nav a {
    padding: var(--space-1) var(--space-2);
    background: none;
    border: 0;
    border-radius: 2px;
  }
  .lore-nav a:hover { text-decoration: underline; }
}

/* chips: entry tags and the placeholder marker */
.tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.1rem 0.55rem;
  border: 1px solid currentColor;
  border-radius: 999px;
}
.tag-planned { color: var(--st-planned); }
.tag-placeholder {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  border-color: var(--border);
}

/* list rows */
.rows { margin: var(--space-4) 0; padding: 0; list-style: none; }
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.row-stack { display: block; }
.row-stack p { margin: var(--space-1) 0; }
.row-stack .row-title { margin: 0; }
.row-title { font-family: var(--font-serif); font-size: 1.1rem; }
.row-meta { color: var(--muted); font-size: 0.9rem; }

/* footer */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-3);
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}
.site-footer p { margin: 0; }

/* corner goblin */
.goblin-corner {
  position: fixed;
  right: var(--space-3);
  bottom: calc(var(--footer-h) + var(--space-2));
  z-index: 10;
  width: var(--goblin-size);
  height: var(--goblin-size);
  overflow: hidden;
  background: var(--goblin-square);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}
.goblin-still {
  display: block;
  width: 100%;
  height: 100%;
}
.goblin-play {
  display: none;
  position: absolute;
  inset: 0;
  background-size: 800% 100%;
  background-repeat: no-repeat;
}
.goblin-corner.is-playing .goblin-play {
  display: block;
  animation: goblin-strip 2.29s steps(8, jump-none) 1 both;
}
.goblin-corner.clip-smirk-right .goblin-play { background-image: url(img/goblin/smirk-right.webp); }
.goblin-corner.clip-smile-left .goblin-play { background-image: url(img/goblin/smile-left.webp); }
.goblin-corner.clip-scared-up .goblin-play { background-image: url(img/goblin/scared-up.webp); }
.goblin-corner.clip-mean-down .goblin-play { background-image: url(img/goblin/mean-down.webp); }
.goblin-corner.clip-dagger .goblin-play { background-image: url(img/goblin/dagger.webp); }
.goblin-corner.clip-greedy .goblin-play { background-image: url(img/goblin/greedy.webp); }
.goblin-corner.clip-magic .goblin-play { background-image: url(img/goblin/magic.webp); }
.goblin-corner.clip-wink .goblin-play { background-image: url(img/goblin/wink.webp); }
@keyframes goblin-strip {
  from { background-position: 0 0; }
  to { background-position: 100% 0; }
}

/* breadcrumbs */
.crumbs {
  max-width: var(--page);
  margin: 0 auto var(--space-3);
  padding: var(--space-2) var(--space-3) 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.crumbs li + li::before {
  content: "/";
  content: "/" / "";
  margin-right: var(--space-2);
}
.crumbs a { color: var(--link); }

/* announcement banner (notice.md) */
.ribbon {
  display: block;
  padding: var(--space-2) var(--space-3);
  background: var(--ember);
  color: var(--on-ember);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}
.ribbon a { color: inherit; text-decoration: underline; }

/* 404 */
.notfound {
  max-width: var(--measure);
  margin: var(--space-6) auto;
  padding: 0 var(--space-3);
  text-align: center;
}
.notfound-code {
  display: block;
  font-family: var(--font-serif);
  font-size: 5rem;
  line-height: 1;
  color: var(--ember);
  margin-bottom: var(--space-3);
}

/* Shared reading surface: warm parchment, quiet edges and a bounded text measure. */
.reading {
  position: relative;
  isolation: isolate;
  max-width: 60rem;
  margin: var(--space-5) auto;
  padding: var(--space-5) var(--space-4);
  background: var(--paper);
  color: var(--paper-ink);
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  box-shadow: inset 0 0 0 5px var(--paper-rim), var(--shadow);
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
/* Cover the complete parchment, including long pages. The translucent tint
 * preserves contrast; the isolated layer never covers text or links. */
.reading::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(var(--paper-tint), var(--paper-tint)), url("img/parchment-reading.webp");
  background-size: var(--paper-texture-size);
  background-position: center;
  background-repeat: var(--paper-texture-repeat);
  pointer-events: none;
}
.reading-wide { max-width: calc(var(--page) * 0.8); }
.reading-body { max-width: var(--measure); margin: 0 auto; }
.reading h1, .reading h2, .reading h3 {
  font-variant: small-caps;
  letter-spacing: 0.04em;
  color: var(--paper-accent);
}
.reading-body h2, .reading-body h3 { margin-top: var(--space-5); }
.reading-body > :first-child { margin-top: 0; }
.reading-body > :last-child { margin-bottom: 0; }
.reading pre { white-space: pre-wrap; overflow-wrap: anywhere; padding: var(--space-3); background: var(--paper-rim); }
.reading blockquote { margin-left: 0; padding-left: var(--space-4); border-left: 2px solid var(--paper-edge); }
.reading a { color: var(--paper-link); }
.reading .muted, .reading .row-meta { color: var(--paper-muted); }
.reading .tag-planned { color: var(--paper-tag-planned); }
.reading .tag-placeholder { color: var(--paper-muted); border-color: var(--paper-muted); }
.reading :focus-visible { outline-color: var(--paper-accent); }
.reading .project { background: transparent; border-color: var(--paper-muted); }

/* article head: the title block on the left, the narrator's picture on the right */
.article-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.reading .article-head {
  max-width: var(--measure);
  margin-left: auto;
  margin-right: auto;
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--paper-edge);
}
.article-head-text { flex: 1 1 auto; min-width: 0; }
.byline-avatar {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  border-radius: var(--radius);
  background: var(--border);
  border: 2px solid var(--voice);
}
.article-head .byline-avatar { width: 112px; height: 112px; }
.byline-text { margin: 0; min-width: 0; }
.byline-by {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.byline-name { font-weight: 700; color: var(--voice); }
.byline-epithet { color: var(--muted); }
.cast-epithet { color: var(--muted); margin: 0 0 var(--space-3); }
.cast-portrait {
  display: block;
  width: 160px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  margin: 0 0 var(--space-3);
  border-radius: var(--radius);
  background: var(--border);
  border: 2px solid var(--voice);
}
.voiced h2 { border-left: 4px solid var(--voice); padding-left: var(--space-3); }
.reading .byline-avatar { background: var(--avatar-wash); border-color: var(--voice); }
.reading .byline-by, .reading .byline-epithet { color: var(--paper-muted); }
.reading .byline-name { color: var(--voice); }
.reading.voiced h2 { border-left-color: var(--voice); }

/* scenes: text beside a figure that stays in view while the text scrolls */
.scene {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  max-width: var(--page);
  margin: 0 auto var(--space-6);
  padding: 0 var(--space-3);
}
.scene-text { min-width: 0; }
.scene-figure { min-width: 0; }
.scene-figure img {
  width: 100%;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

@media (min-width: 48rem) {
  .scene {
    grid-template-columns: 1fr 1.25fr;
    align-items: start;
    gap: var(--space-5);
  }
  .scene-left .scene-text { order: 2; }
  .scene-left .scene-figure { order: 1; }
  .scene-left { grid-template-columns: 1.25fr 1fr; }
  .scene-figure {
    position: sticky;
    top: var(--space-4);
  }
  .scene-figure img {
    max-height: calc(100vh - var(--footer-h) - var(--space-4) * 2);
  }
}

/* story: a run of beats; a cast character narrates beside a card that links on */
.story {
  max-width: var(--page);
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) 0;
}
.story-beat {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  align-items: center;
  margin: 0 0 var(--space-6);
}
.story-step { display: none; }
.wrap .story { padding-left: 0; padding-right: 0; }
.story-text { min-width: 0; max-width: 28rem; justify-self: center; }
.story-text::after { content: ""; display: block; clear: both; }
.story-icon {
  float: left;
  width: 112px;
  height: 112px;
  margin: 0 var(--space-3) var(--space-2) 0;
  border-radius: var(--radius);
  background: var(--border);
  border: 2px solid var(--voice);
}
.story-text h2 { display: flow-root; margin: 0; }
.story-role { margin: 0 0 var(--space-3); color: var(--muted); }
.story-card {
  position: relative;
  min-width: 0;
  width: 100%;
  max-width: 34rem;
  justify-self: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
/* a beat holding keyboard focus is always shown, staged or not */
.story-beat:focus-within {
  opacity: 1 !important;
  transform: none !important;
  pointer-events: auto !important;
}
.story-card:hover { border-color: var(--voice); }
.story-card:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
/* Keep animated artwork inside the native link, without a stacking overlay. */
.story-card-link { display: block; color: var(--text); text-decoration: none; }
.story-card-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
}
.story-card-heading { min-width: 0; }
.story-card-title { font-family: var(--font-serif); font-size: 1.15rem; margin: 0; }
.story-card-tagline { margin: 0; font-size: 0.85rem; color: var(--muted); }
.story-card-image {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: contain;
  background: var(--bg);
}
.story-card-body { margin: 0; padding: var(--space-3) var(--space-3) var(--space-2); }
.story-card-foot {
  padding: 0 var(--space-3) var(--space-3);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--link);
}

@media (min-width: 48rem) {
  .story-beat { grid-template-columns: 1fr 1fr; gap: var(--space-5); }
  .story-beat-left .story-text { order: 2; }
  .story-beat-left .story-card { order: 1; }
}

/* smooth jump links, and scroll reveal (scenes) hidden only when JavaScript runs; all only when motion is welcome */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .story-card { transition: transform 200ms ease-out, border-color 200ms ease-out; }
  .story-card:hover { transform: translateY(-4px); }
  html.js .scene-text,
  html.js .scene-figure {
    opacity: 0;
    transition: opacity 700ms ease-out, transform 700ms ease-out;
  }
  html.js .scene-text { transform: translateY(24px); }
  html.js .scene-right .scene-figure { transform: translateX(32px) scale(0.98); transition-delay: 120ms; }
  html.js .scene-left .scene-figure { transform: translateX(-32px) scale(0.98); transition-delay: 120ms; }
  html.js .scene-text.is-visible,
  html.js .scene-figure.is-visible,
  html.js .scene-right .scene-figure.is-visible,
  html.js .scene-left .scene-figure.is-visible {
    opacity: 1;
    transform: none;
  }
}

/* staged story: wide screens, JavaScript on, motion welcome. The stage stays pinned while the page scrolls past one sentinel per beat; the beats share one cell and one is active at a time. */
@media (min-width: 48rem) and (min-height: 40rem) and (prefers-reduced-motion: no-preference) {
  html.js .story.is-staged {
    --stage-h: calc(100vh - var(--footer-h) - var(--space-3) * 2);
    padding-top: 0;
  }
  html.js .story.is-staged .story-stage {
    position: sticky;
    top: var(--space-3);
    height: var(--stage-h);
    margin-bottom: calc(-1 * var(--stage-h));
    display: grid;
  }
  html.js .story.is-staged .story-beat {
    grid-area: 1 / 1;
    margin: 0;
    opacity: 0;
    pointer-events: none;
    transform: none;

  }
  html.js .story.is-staged .story-beat.is-active {
    opacity: 1;
    transform: none;
  }
  html.js .story.is-staged .story-beat.is-interactive { pointer-events: auto; }
  html.js .story.is-staged .story-step { display: block; height: var(--story-step); }
  html.js .story.is-staged .story-step:last-child { height: var(--stage-h); }
  html.js .story.is-staged .story-card-image { max-height: calc(var(--stage-h) - 11rem); }
}

@media (max-width: 30rem) {
  h1 { font-size: 1.8rem; }
  .reading { padding: var(--space-4) var(--space-3); border-radius: 0; }
  .hero-goblin { max-height: 30vh; }
  .brand-logo { width: 32px; height: 32px; }
  .article-head .byline-avatar { width: 72px; height: 72px; }
}

/* Keep the companion out of the reading area when there is no spare margin. */
@media (max-width: 80rem), (max-height: 40rem) {
  .goblin-corner {
    width: var(--goblin-compact);
    height: var(--goblin-compact);
    right: var(--space-2);
    bottom: calc((var(--footer-h) - var(--goblin-compact)) / 2);
    z-index: 60;
  }
}

@media print {
  .goblin-corner { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
  .goblin-corner .goblin-play { display: none !important; }
}

/* A speech bubble above Bigeye, in the spare outer margin. */
.tour-hint {
  position: fixed;
  right: var(--space-3);
  bottom: calc(var(--footer-h) + var(--space-2) + var(--goblin-size) + var(--space-3));
  z-index: 60;
  width: var(--tour-hint-width);
  padding: var(--space-3);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--link);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  white-space: normal;
}
.tour-hint::after {
  content: "";
  position: absolute;
  right: calc(var(--goblin-size) / 2 - var(--tour-hint-tail) / 2);
  bottom: calc(var(--tour-hint-tail) / -2 - 1px);
  width: var(--tour-hint-tail);
  height: var(--tour-hint-tail);
  background: var(--surface);
  border-right: 1px solid var(--link);
  border-bottom: 1px solid var(--link);
  transform: rotate(45deg);
}
.tour-hint[hidden] { display: none; }
.tour-hint button { display: block; margin-top: var(--space-2); font: inherit; color: var(--link); background: transparent; border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2); cursor: pointer; }
@media (max-width: 96rem), (max-height: 40rem), print {
  .tour-hint { display: none; }
}

/* Compact navigation indexes share the tour's dark cards and separate voices. */
.category-guide { max-width: var(--measure); margin: var(--space-5) 0; }
.destination-card { position: relative; padding: var(--space-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.destination-card h2, .destination-card h3 { margin-bottom: var(--space-2); }
.destination-card .row-title a::after, .destination-card .project-title a::after,
.reading .project-title a::after { content: ""; position: absolute; inset: 0; }
.destination-card:hover, .destination-card:focus-within { border-color: var(--focus); }
.destination-card:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.lore-grid > .project { display: block; padding: 0; border: 0; background: none; }
.lore-grid .row-meta { margin-top: var(--space-2); }
.reading .project { position: relative; }
.reading-body .project-title, .reading-body .row-title { margin: 0; }
.reading .cast-epithet { color: var(--paper-muted); }
.reading .cast-portrait { flex: 0 0 112px; width: 112px; height: 112px; }
.reading-diagram { margin: var(--space-4) 0; }
.reading-diagram figcaption { margin-top: var(--space-2); color: var(--paper-muted); font-size: 0.9rem; }
@media (min-width: 48rem) and (prefers-reduced-motion: no-preference) {
  html.js .navigation-entry { opacity: 0; transform: translateY(18px); transition: opacity 500ms ease-out, transform 500ms ease-out; }
  html.js .navigation-entry.is-visible, html.js .navigation-entry:focus-within { opacity: 1; transform: none; }
}
@media (max-width: 30rem) {
  .reading .cast-portrait { flex-basis: 72px; width: 72px; height: 72px; }
}

/* Room for diagrams and screenshots, while prose retains its 40rem measure. */
@media (min-width: 64rem) {
  .reading-body > p:has(> img:only-child),
  .reading-body > figure {
    width: calc(100% + 8rem);
    max-width: none;
    margin-left: -4rem;
  }
  .hero-goblin { flex-basis: 20rem; max-height: 40vh; }
  .hero .wrap { padding-top: var(--space-5); padding-bottom: var(--space-5); }
}

/* Local reading surfaces keep light-theme navigation legible over scenery. */
.crumbs, .story-text,
main > .wrap:has(> h1), .library-all, .notfound { background: var(--world-text-surface); }
.story-text { padding: var(--world-text-padding); border-radius: var(--radius); }
