/* ==========================================================================
   Andrew Triapitsyn — author homepage concept
   House style  = paper & ink (the author, every genre)
   Book "rooms" = each title brings its own palette (here: night & gold)
   ========================================================================== */

:root {
  /* House palette (author brand) */
  --paper: #f3eee4;
  --paper-2: #e9e2d3;
  --ink: #16130f;
  --ink-2: #3a342c;
  --muted: #5c554a;
  --rule: #cbbfa8;
  --accent: #7a2e23;          /* oxblood: author accent */
  --focus: #7a2e23;

  /* Book room: Immunity to Illusions */
  --night: #0d0c0a;
  --bronze: #241c15;
  --gold: #b99961;
  --gold-hi: #d8bd86;
  --parch: #e9dfca;
  --stone: #a59e90;

  /* Type */
  --f-display: "Cormorant Garamond", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --f-sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  /* Space */
  --gutter: clamp(16px, 5vw, 56px);
  --section: clamp(72px, 11vw, 148px);
  --header-h: 68px;

  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--f-sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; }
p { margin: 0 0 1em; }
cite { font-style: italic; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
ul, ol { margin: 0; padding: 0; list-style: none; }
main:focus { outline: none; }

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

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mono { font-family: var(--f-mono); font-size: .8125rem; letter-spacing: .06em; }
.wrap { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: var(--gutter); }

.skip-link {
  position: absolute; left: 12px; top: -100px; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 12px 18px; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.concept-bar {
  margin: 0; padding: 7px var(--gutter);
  background: var(--ink); color: var(--parch);
  font: 500 .75rem/1.4 var(--f-mono); letter-spacing: .08em; text-align: center; text-transform: uppercase;
}

/* ---------- Typography helpers ---------- */
.eyebrow {
  font: 500 .78rem/1.3 var(--f-mono);
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 1.25rem;
}
.eyebrow--gold { color: var(--gold); }
.section-title {
  font: 500 clamp(2.1rem, 4.6vw, 3.6rem)/1.04 var(--f-display);
  letter-spacing: -.01em; margin-bottom: 1.5rem; text-wrap: balance;
}
.section-lede { color: var(--muted); max-width: 46ch; font-size: 1.0625rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: .7em 1.4em;
  font: 500 .95rem/1.2 var(--f-sans); letter-spacing: .01em;
  text-decoration: none; border: 1px solid transparent; border-radius: 0;
  transition: background-color .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease);
  text-align: center;
}
.btn em { font-family: var(--f-display); font-size: 1.12em; font-weight: 600; }
.btn--small { min-height: 44px; padding: .5em 1.05em; font-size: .9rem; }
.btn--ink { background: var(--ink); color: var(--paper); }
.btn--ink:hover { background: var(--accent); }
.btn--line { border-color: var(--ink); color: var(--ink); }
.btn--line:hover { background: var(--ink); color: var(--paper); }
.btn--gold { background: var(--gold); color: var(--night); }
.btn--gold:hover { background: var(--gold-hi); }
.btn--line-gold { border-color: var(--gold); color: var(--gold-hi); }
.btn--line-gold:hover { background: rgba(185, 153, 97, .14); }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(243, 238, 228, .94);
  -webkit-backdrop-filter: saturate(1.2) blur(8px); backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease);
}
.site-header.is-scrolled { border-bottom-color: var(--rule); }
.site-header__inner {
  max-width: 1240px; margin: 0 auto; padding-inline: var(--gutter);
  height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; min-height: 44px; }
.brand__mark { width: 40px; height: 40px; color: var(--ink); flex: none; }
.brand__name { font: 600 1.32rem/1 var(--f-display); letter-spacing: .01em; white-space: nowrap; }

.site-nav__list { display: flex; align-items: center; gap: clamp(4px, 1.4vw, 18px); }
.site-nav__list a:not(.btn) {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px;
  font-size: .95rem; text-decoration: none; color: var(--ink-2);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0 1px; background-repeat: no-repeat; background-position: 8px calc(100% - 10px);
  transition: background-size .3s var(--ease), color .2s;
}
.site-nav__list a:not(.btn):hover,
.site-nav__list a[aria-current="true"] { color: var(--ink); background-size: calc(100% - 16px) 1px; }
.site-nav__cta { margin-left: 6px; }
.site-nav__toggle { display: none; }

@media (max-width: 860px) {
  .js .site-nav__toggle {
    display: inline-flex; align-items: center; gap: 10px;
    min-height: 44px; min-width: 44px; padding: 0 12px;
    background: none; border: 1px solid var(--ink); color: var(--ink);
    font: 500 .9rem/1 var(--f-sans); cursor: pointer;
  }
  .site-nav__toggle-icon, .site-nav__toggle-icon::before {
    display: block; width: 16px; height: 1.5px; background: currentColor; position: relative;
    transition: transform .25s var(--ease);
  }
  .site-nav__toggle-icon::before { content: ""; position: absolute; top: -5px; }
  .site-nav__toggle-icon { top: 2.5px; }
  .site-nav__toggle[aria-expanded="true"] .site-nav__toggle-icon { transform: rotate(45deg); top: 0; }
  .site-nav__toggle[aria-expanded="true"] .site-nav__toggle-icon::before { transform: rotate(-90deg); top: 0; }

  .js .site-nav__list {
    position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--paper); border-bottom: 1px solid var(--rule);
    padding: 8px var(--gutter) 20px;
    box-shadow: 0 18px 30px -24px rgba(22, 19, 15, .5);
  }
  .js .site-nav__list:not(.is-open) { display: none; }
  .js .site-nav__list a:not(.btn) { display: flex; width: 100%; min-height: 52px; font-size: 1.05rem; border-bottom: 1px solid var(--paper-2); padding: 0; background-position: 0 calc(100% - 12px); }
  .js .site-nav__cta { margin: 16px 0 0; }
  .js .site-nav__cta .btn { width: 100%; min-height: 48px; }

  /* No-JS fallback: links wrap under the brand */
  html:not(.js) .site-header__inner { height: auto; flex-wrap: wrap; padding-block: 8px; }
  html:not(.js) .site-nav__list { flex-wrap: wrap; }
}
@media (max-width: 400px) {
  .brand__name { font-size: 1.12rem; }
  .brand__mark { width: 34px; height: 34px; }
  .brand { gap: 9px; }
}

/* ---------- 1. Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, .82fr);
  min-height: min(calc(100svh - var(--header-h) - 30px), 900px);
}
.hero__author {
  display: flex; flex-direction: column; justify-content: center;
  padding: clamp(48px, 7vw, 96px) clamp(24px, 5vw, 72px) clamp(48px, 7vw, 96px) max(var(--gutter), calc((100vw - 1240px) / 2 + var(--gutter)));
  position: relative;
}
.hero__title {
  font: 500 clamp(3.4rem, 8.6vw, 8.4rem)/.86 var(--f-display);
  letter-spacing: -.025em; margin: 0 0 2.2rem;
}
.hero__title span { display: block; }
.hero__title span + span { padding-left: .42em; font-style: italic; font-weight: 500; }
.hero__lede { font-size: clamp(1.06rem, 1.35vw, 1.22rem); max-width: 40ch; color: var(--ink-2); margin-bottom: 2.2rem; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero__place {
  margin: 2.6rem 0 0; color: var(--muted); display: flex; align-items: center; gap: 14px;
}
.hero__place::before { content: ""; width: 40px; height: 1px; background: var(--rule); }

.hero__feature {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 38%, rgba(185, 153, 97, .16), transparent 60%),
    linear-gradient(180deg, var(--bronze), var(--night) 78%);
  background-color: var(--night);
  color: var(--parch);
  display: flex; align-items: center; justify-content: center;
  padding: clamp(40px, 5vw, 72px) clamp(24px, 4vw, 56px);
  --focus: var(--gold-hi);
}
.hero__feature::before { /* fine-line guilloche, original */
  content: ""; position: absolute; inset: -20%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400'%3E%3Cg fill='none' stroke='%23b99961' stroke-width='.5' opacity='.5'%3E%3Ccircle cx='200' cy='200' r='60'/%3E%3Ccircle cx='200' cy='200' r='90'/%3E%3Ccircle cx='200' cy='200' r='120'/%3E%3Ccircle cx='200' cy='200' r='150'/%3E%3Ccircle cx='200' cy='200' r='180' stroke-dasharray='2 6'/%3E%3Ccircle cx='200' cy='200' r='198'/%3E%3C/g%3E%3C/svg%3E") center / min(140%, 980px) no-repeat;
  opacity: .32; pointer-events: none;
}
.hero__feature-inner { position: relative; text-align: center; max-width: 360px; }
.hero__feature-label { color: var(--gold); margin-bottom: 1.6rem; font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; }
.cover-link { display: inline-block; text-decoration: none; }
.cover-link:hover .cover img { transform: translateY(-4px); }
.hero__feature-title { font: 600 1.6rem/1.1 var(--f-display); margin: 1.8rem 0 .4rem; color: var(--parch); }
.hero__feature-sub { font-size: .9rem; color: var(--stone); line-height: 1.45; margin: 0 auto; max-width: 30ch; }

/* Cover treatment (authentic artwork, never cropped or recoloured) */
.cover { margin: 0; position: relative; }
.cover img {
  width: 100%; aspect-ratio: 539 / 862; object-fit: contain;
  box-shadow: 0 2px 0 rgba(255, 255, 255, .04), 0 30px 60px -18px rgba(0, 0, 0, .85), 0 12px 24px -12px rgba(0, 0, 0, .7);
  transition: transform .6s var(--ease);
}
.cover::after { /* gilt hairline frame, offset from the artwork */
  content: ""; position: absolute; inset: -12px; border: 1px solid rgba(185, 153, 97, .45); pointer-events: none;
}
.cover--hero { width: clamp(220px, 22vw, 330px); margin-inline: auto; }
.cover--feature { width: min(100%, 400px); }

/* ---------- Sections ---------- */
.section { padding-block: var(--section); }
.section-head { margin-bottom: clamp(40px, 6vw, 72px); max-width: 760px; }
.section-head--split { max-width: none; display: grid; grid-template-columns: 1.1fr .9fr; gap: 24px 64px; align-items: end; }
.section-head--split .section-title { margin-bottom: 0; }
.section-head--split .section-lede { margin: 0; }
.section-head--center { text-align: center; margin-inline: auto; }

/* ---------- 2. Author ---------- */
.author { border-top: 1px solid var(--rule); }
.author__grid { display: grid; grid-template-columns: minmax(180px, 280px) minmax(0, 1fr); gap: clamp(40px, 7vw, 112px); align-items: center; }
.author__mark { color: var(--ink); max-width: 280px; }
.author__mark svg { width: 100%; height: auto; }
.author__text { max-width: 640px; }
.author__text p:not(.eyebrow) { font-size: 1.1rem; color: var(--ink-2); }

/* ---------- 3. Writing / catalogue ---------- */
.writing { background: var(--paper-2); }
.shelves { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: clamp(32px, 5vw, 64px); align-items: start; }
.shelf { border-top: 2px solid var(--ink); padding-top: 22px; }
.shelf__head { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 18px; align-items: baseline; margin-bottom: 18px; }
.shelf__numeral { grid-row: span 2; font: 500 2.6rem/1 var(--f-display); color: var(--accent); min-width: 1.4ch; }
.shelf__title { font: 500 2rem/1.1 var(--f-display); }
.shelf__count { color: var(--muted); margin: 4px 0 0; }
.shelf__note { margin: 18px 0 0; font: italic 500 1.2rem/1.45 var(--f-display); color: var(--ink-2); }
.shelf--empty .shelf__note {
  margin-top: 0; padding: 26px 24px; border: 1px dashed var(--rule);
  font-size: 1.25rem;
}

/* Series: ready for announced series (heading + ordered books) */
.series + .series { margin-top: 28px; }
.series__head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: baseline; padding: 14px 0 12px; border-bottom: 1px solid var(--rule); }
.series__label { grid-column: 1; grid-row: 1; color: var(--accent); font-size: .72rem; text-transform: uppercase; }
.series__count { grid-column: 2; grid-row: 1; color: var(--muted); font-size: .72rem; }
.series__title { grid-column: 1 / -1; grid-row: 2; font: 600 1.45rem/1.2 var(--f-display); }
.series__books { counter-reset: book; }

.book { border-bottom: 1px solid var(--rule); }
.book__link {
  display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 20px; align-items: center;
  padding: 18px 8px 18px 0; text-decoration: none; transition: background-color .25s var(--ease), padding .25s var(--ease);
}
.book__link:hover { background: rgba(255, 255, 255, .45); padding-left: 10px; }
.book__thumb { width: 76px; aspect-ratio: 539 / 862; object-fit: cover; box-shadow: 0 8px 16px -8px rgba(0, 0, 0, .6); }
.book__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.book__status { color: var(--accent); font-size: .72rem; text-transform: uppercase; }
.book__title { font: 600 1.55rem/1.1 var(--f-display); }
.book__title cite { font-style: italic; }
.book__sub { font-size: .92rem; color: var(--ink-2); line-height: 1.4; }
.book__meta { color: var(--muted); font-size: .74rem; }
.book__arrow { font-size: 1.4rem; color: var(--accent); transition: transform .25s var(--ease); padding-right: 6px; }
.book__link:hover .book__arrow { transform: translateX(4px); }

/* ---------- 4. Book room ---------- */
.book-room {
  position: relative; overflow: hidden; overflow: clip; /* clip keeps the sticky cover working */
  background:
    radial-gradient(80% 60% at 18% 30%, rgba(185, 153, 97, .14), transparent 60%),
    linear-gradient(180deg, var(--night), var(--bronze) 140%);
  background-color: var(--night);
  color: var(--parch);
  padding-block: var(--section);
  --focus: var(--gold-hi);
}
.book-room__filigree {
  position: absolute; right: -240px; top: 50%; width: 820px; height: 820px; transform: translateY(-50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 400'%3E%3Cg fill='none' stroke='%23b99961' stroke-width='.45'%3E%3Ccircle cx='200' cy='200' r='199'/%3E%3Ccircle cx='200' cy='200' r='170' stroke-dasharray='1 4'/%3E%3Ccircle cx='200' cy='200' r='140'/%3E%3Ccircle cx='200' cy='200' r='110'/%3E%3Ccircle cx='200' cy='200' r='80' stroke-dasharray='3 3'/%3E%3Cpath d='M200 1v398M1 200h398'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  opacity: .14; pointer-events: none;
}
.book-room__grid { position: relative; display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: clamp(48px, 8vw, 120px); align-items: start; }
.book-room__cover { position: sticky; top: calc(var(--header-h) + 48px); padding: 12px; }
.book-room__title { font: 600 clamp(2.6rem, 5.4vw, 4.6rem)/1 var(--f-display); color: var(--parch); margin-bottom: .6rem; }
.book-room__title cite { font-style: normal; }
.book-room__subtitle { font: italic 500 clamp(1.25rem, 2vw, 1.55rem)/1.3 var(--f-display); color: var(--gold-hi); max-width: 34ch; margin-bottom: 2.4rem; }
.book-room__text > p:not(.eyebrow):not(.book-room__subtitle) { color: #d6ccb7; max-width: 60ch; }
.pull { margin: 0 0 2rem; padding: 4px 0 4px 24px; border-left: 1px solid var(--gold); }
.pull p { font: 500 clamp(1.5rem, 2.6vw, 2.05rem)/1.2 var(--f-display); color: var(--parch); margin-bottom: .6rem; }
.pull footer { color: var(--stone); font-size: .72rem; text-transform: uppercase; }

.facts { margin: 2.6rem 0 2.6rem; border-top: 1px solid rgba(185, 153, 97, .35); }
.facts > div { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid rgba(185, 153, 97, .2); }
.facts dt { font: 500 .74rem/1.8 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.facts dd { margin: 0; color: var(--parch); }
.facts__note { color: var(--stone); font-size: .88em; }
.book-room__actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- 5. Inside + Inspect ---------- */
.territory {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--ink);
  margin-bottom: clamp(64px, 9vw, 120px);
}
.territory li { padding: 26px 28px 30px 0; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 8px; }
.territory li:not(:nth-child(3n + 1)) { padding-left: 28px; border-left: 1px solid var(--rule); }
.territory__k { font: italic 500 1.85rem/1.1 var(--f-display); color: var(--ink); }
.territory__v { color: var(--ink-2); max-width: 30ch; }

.inspect {
  background: var(--night); color: var(--parch);
  padding: clamp(28px, 5vw, 64px);
  display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(28px, 4vw, 48px);
  --focus: var(--gold-hi);
  position: relative;
}
.inspect::before { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(185, 153, 97, .28); pointer-events: none; }
.inspect .eyebrow { color: var(--gold); }
.inspect__title { font: 500 clamp(1.9rem, 3.4vw, 2.7rem)/1.08 var(--f-display); margin-bottom: 1.2rem; text-wrap: balance; }
.inspect__intro { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 8px 64px; align-items: end; }
.inspect__intro .eyebrow { grid-column: 1 / -1; margin-bottom: .2rem; }
.inspect__intro .inspect__title { margin: 0; }
.inspect__note { color: var(--stone); font-size: .95rem; margin: 0; max-width: 46ch; }

.inspect__stage {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); grid-template-areas: "controls controls" "figure captions";
  gap: 32px 56px; align-items: center;
}
.inspect__controls { grid-area: controls; border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.inspect__controls label { position: relative; flex: 1 1 0; min-width: 92px; }
.inspect__controls input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.inspect__controls span {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 10px;
  border: 1px solid rgba(185, 153, 97, .4); color: var(--parch);
  font: 500 .85rem/1 var(--f-sans); cursor: pointer;
  transition: background-color .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease);
}
.inspect__controls b { font: 500 .72rem/1 var(--f-mono); color: var(--gold); }
.inspect__controls label:hover span { border-color: var(--gold); }
.inspect__controls input:checked + span { background: var(--gold); color: var(--night); border-color: var(--gold); }
.inspect__controls input:checked + span b { color: var(--night); }
.inspect__controls input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 3px; }

.inspect__figure { grid-area: figure; color: var(--stone); }
.inspect__figure svg { width: 100%; height: auto; overflow: visible; }
.ring rect, .ring circle { fill: none; stroke: currentColor; stroke-width: 1; }
.ring .ring__fill { stroke: none; fill: url(#hatch); opacity: .0; }
.ring text { font: 500 15px var(--f-mono); letter-spacing: .16em; fill: currentColor; stroke: none; }
.ring .ring__core { fill: currentColor; }
.ring { color: var(--stone); opacity: .55; transition: opacity .45s var(--ease), color .45s var(--ease); }
.ring rect, .ring circle { transition: stroke-width .45s var(--ease); }

.inspect__captions { grid-area: captions; min-height: 12rem; }
.caption { display: none; }
.caption__step { color: var(--gold); text-transform: uppercase; font-size: .72rem; margin-bottom: .9rem; }
.caption__what { font: 500 clamp(1.3rem, 2vw, 1.6rem)/1.25 var(--f-display); color: var(--parch); }
.caption__ask { color: #d6ccb7; border-top: 1px solid rgba(185, 153, 97, .3); padding-top: 1rem; margin: 1.2rem 0 0; }
.caption__ask .mono { display: block; color: var(--gold); font-size: .7rem; text-transform: uppercase; margin-bottom: .3rem; }

/* State: CSS :has() drives it with no JS; JS mirrors to [data-layer] as a fallback */
.inspect__stage:has(input[value="1"]:checked) .caption--1, .inspect__stage[data-layer="1"] .caption--1,
.inspect__stage:has(input[value="2"]:checked) .caption--2, .inspect__stage[data-layer="2"] .caption--2,
.inspect__stage:has(input[value="3"]:checked) .caption--3, .inspect__stage[data-layer="3"] .caption--3,
.inspect__stage:has(input[value="4"]:checked) .caption--4, .inspect__stage[data-layer="4"] .caption--4,
.inspect__stage:has(input[value="5"]:checked) .caption--5, .inspect__stage[data-layer="5"] .caption--5 { display: block; animation: caption-in .5s var(--ease); }

/* Active layer = gold; outer (already inspected) layers recede */
.inspect__stage:has(input[value="1"]:checked) .ring--1, .inspect__stage[data-layer="1"] .ring--1,
.inspect__stage:has(input[value="2"]:checked) .ring--2, .inspect__stage[data-layer="2"] .ring--2,
.inspect__stage:has(input[value="3"]:checked) .ring--3, .inspect__stage[data-layer="3"] .ring--3,
.inspect__stage:has(input[value="4"]:checked) .ring--4, .inspect__stage[data-layer="4"] .ring--4,
.inspect__stage:has(input[value="5"]:checked) .ring--5, .inspect__stage[data-layer="5"] .ring--5 { color: var(--gold-hi); opacity: 1; }

.inspect__stage:has(input[value="1"]:checked) .ring--1 rect, .inspect__stage[data-layer="1"] .ring--1 rect,
.inspect__stage:has(input[value="2"]:checked) .ring--2 rect, .inspect__stage[data-layer="2"] .ring--2 rect,
.inspect__stage:has(input[value="3"]:checked) .ring--3 rect, .inspect__stage[data-layer="3"] .ring--3 rect,
.inspect__stage:has(input[value="4"]:checked) .ring--4 rect, .inspect__stage[data-layer="4"] .ring--4 rect,
.inspect__stage:has(input[value="5"]:checked) .ring--5 circle, .inspect__stage[data-layer="5"] .ring--5 circle { stroke-width: 2; }
.inspect__stage:has(input[value="3"]:checked) .ring--3 .ring__fill, .inspect__stage[data-layer="3"] .ring--3 .ring__fill { opacity: .22; }

.inspect__stage:has(input[value="2"]:checked) .ring--1, .inspect__stage[data-layer="2"] .ring--1,
.inspect__stage:has(input[value="3"]:checked) :is(.ring--1, .ring--2), .inspect__stage[data-layer="3"] :is(.ring--1, .ring--2),
.inspect__stage:has(input[value="4"]:checked) :is(.ring--1, .ring--2, .ring--3), .inspect__stage[data-layer="4"] :is(.ring--1, .ring--2, .ring--3),
.inspect__stage:has(input[value="5"]:checked) :is(.ring--1, .ring--2, .ring--3, .ring--4), .inspect__stage[data-layer="5"] :is(.ring--1, .ring--2, .ring--3, .ring--4) { opacity: .2; }

@keyframes caption-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 6. Sources ---------- */
.sources { border-top: 1px solid var(--rule); }
.sources__grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: clamp(40px, 8vw, 120px); align-items: center; }
.sources__text p:not(.eyebrow) { color: var(--ink-2); max-width: 54ch; margin-bottom: 2rem; font-size: 1.1rem; }
.ledger { border-top: 1px solid var(--ink); }
.ledger li { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 18px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--rule); }
.ledger__n { font: 500 3.4rem/1 var(--f-display); color: var(--accent); font-variant-numeric: lining-nums; }
.ledger__l { color: var(--ink-2); }

/* ---------- 7. Continue ---------- */
.continue { background: var(--paper-2); }
.continue .section-title { max-width: 22ch; margin-inline: auto; }
.paths { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--ink); }
.path { padding: 28px 28px 32px 0; display: flex; flex-direction: column; }
.path + .path { padding-left: 28px; border-left: 1px solid var(--rule); }
.path__k { color: var(--accent); text-transform: uppercase; font-size: .72rem; margin-bottom: 1rem; }
.path__title { font: 600 1.6rem/1.15 var(--f-display); margin-bottom: .7rem; }
.path p:not(.path__k) { color: var(--ink-2); font-size: .98rem; }
.path__link {
  margin-top: auto; display: inline-flex; align-items: center; gap: .4em; min-height: 44px;
  font-weight: 500; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px;
  text-decoration-color: var(--accent); overflow-wrap: anywhere;
}
.path__link:hover { color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: var(--parch); padding: 64px 0 48px; --focus: var(--gold-hi); }
.site-footer__inner { display: grid; grid-template-columns: 1fr auto; gap: 8px 32px; align-items: end; }
.site-footer__name { font: 500 2.2rem/1 var(--f-display); margin: 0; }
.site-footer .mono { color: var(--stone); margin: 0; grid-column: 1; }
.site-footer nav { grid-column: 2; grid-row: 1 / span 2; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.site-footer__links a { display: inline-flex; min-height: 44px; align-items: center; text-decoration: none; color: var(--parch); }
.site-footer__links a:hover { color: var(--gold-hi); text-decoration: underline; text-underline-offset: 4px; }
.site-footer__small { grid-column: 1 / -1; margin: 32px 0 0; padding-top: 24px; border-top: 1px solid #3a342c; color: var(--stone); font-size: .82rem; }

/* ---------- Reveal motion (only when JS is running and motion is allowed) ---------- */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .9s var(--ease), transform .9s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }
.js .hero .reveal { transition-duration: 1.1s; }
.js .hero__feature .cover { opacity: 0; transform: translateY(18px) scale(.985); transition: opacity 1.3s var(--ease) .25s, transform 1.3s var(--ease) .25s; }
.js .is-loaded .hero__feature .cover { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal, .js .hero__feature .cover { opacity: 1 !important; transform: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .territory { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .territory li:not(:nth-child(3n + 1)) { padding-left: 0; border-left: 0; }
  .territory li:nth-child(even) { padding-left: 28px; border-left: 1px solid var(--rule); }
  .paths { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .path, .path + .path { padding: 28px 28px 32px 0; border-left: 0; border-bottom: 1px solid var(--rule); }
  .path:nth-child(even) { padding-left: 28px; border-left: 1px solid var(--rule); }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero__author { padding: 56px var(--gutter) 56px; }
  .hero__feature { padding: 56px var(--gutter) 64px; }
  .author__grid { grid-template-columns: 1fr; }
  .section-head--split { grid-template-columns: 1fr; }
  .book-room__grid { grid-template-columns: 1fr; }
  .book-room__cover { position: static; max-width: 340px; margin-inline: auto; }
  .sources__grid { grid-template-columns: 1fr; }
  .inspect__stage { grid-template-columns: 1fr; grid-template-areas: "controls" "figure" "captions"; }
  .inspect__captions { min-height: 0; }
  .inspect__intro { grid-template-columns: 1fr; }
  .author__mark { max-width: 132px; }
}

@media (max-width: 640px) {
  body { font-size: 1rem; }
  .hero__title { font-size: clamp(3.1rem, 16vw, 4.6rem); margin-bottom: 1.6rem; }
  .hero__title span + span { padding-left: .28em; }
  .hero__author { padding: 36px var(--gutter) 40px; }
  .hero__lede { margin-bottom: 1.6rem; }
  .hero__actions .btn { flex: 1 1 100%; }
  .hero__place { display: none; }
  .hero__feature { padding: 30px var(--gutter) 34px; justify-content: flex-start; }
  .hero__feature-inner {
    display: grid; grid-template-columns: 104px minmax(0, 1fr); grid-template-areas: "cover label" "cover title" "cover sub";
    column-gap: 24px; align-content: center; text-align: left; max-width: none; width: 100%;
  }
  .hero__feature-label { grid-area: label; margin: 0 0 .5rem; font-size: .68rem; letter-spacing: .08em; }
  .hero__feature .cover-link { grid-area: cover; align-self: center; }
  .hero__feature-title { grid-area: title; margin: 0 0 .35rem; font-size: 1.45rem; }
  .hero__feature-sub { grid-area: sub; margin: 0; font-size: .84rem; max-width: none; }
  .cover--hero { width: 104px; }
  .cover--hero::after { inset: -6px; }
  .ring text { font-size: 21px; letter-spacing: .1em; }
  .territory { grid-template-columns: 1fr; }
  .territory li, .territory li:nth-child(even) { padding: 22px 0 24px; border-left: 0; }
  .paths { grid-template-columns: 1fr; }
  .path, .path + .path, .path:nth-child(even) { padding: 24px 0 26px; border-left: 0; }
  .book__link { grid-template-columns: 60px minmax(0, 1fr); gap: 16px; }
  .book__thumb { width: 60px; }
  .book__arrow { display: none; }
  .book__title { font-size: 1.4rem; }
  .facts > div { grid-template-columns: 1fr; gap: 2px; }
  .inspect { padding: 28px 20px 32px; }
  .inspect::before { inset: 6px; }
  .inspect__controls label { min-width: calc(50% - 3px); } /* 2 + 2 + 1 grid; the last layer spans the row */
  .ledger__n { font-size: 2.8rem; }
  .ledger li { grid-template-columns: 4.2rem minmax(0, 1fr); }
  .site-footer__inner { grid-template-columns: 1fr; }
  .site-footer nav { grid-column: 1; grid-row: auto; margin-top: 16px; }
  .book-room__actions .btn { flex: 1 1 100%; }
}

@media (max-width: 360px) {
  .shelf__title { font-size: 1.75rem; }
}

@media print {
  .concept-bar, .site-header, .inspect__controls { display: none; }
  .js .reveal { opacity: 1; transform: none; }
}
