/* Essay reading apparatus — ivory prose set directly on the cosmic ground.
   Consumed by every essays/<slug>.html. The page supplies content only;
   layout, apparatus, figures, and set-text quotation styling live here. */

body.essay {
  /* Clearance for the permanent lectern strip at the foot of the viewport. */
  padding-bottom: 200px;
}

.essay-room {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  padding:
    clamp(96px, 13vh, 138px)
    clamp(16px, 3vw, 40px)
    clamp(48px, 9vh, 120px);
}

.room-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, var(--measure-essay));
  gap: clamp(24px, 3.4vw, 48px);
  width: min(100%, calc(240px + var(--measure-essay) + 48px));
  margin-inline: auto;
  align-items: start;
}

/* ---- The prose column ---- */

.essay-column {
  grid-column: 2;
  max-width: var(--measure-essay);
  color: rgba(242, 231, 203, .88);
  font-size: var(--fs-base);
  line-height: 1.74;
}

.essay-column .essay-header {
  min-height: auto;
  padding: 0 0 var(--sp-4);
}

.essay-column .page-dek {
  color: rgba(242, 231, 203, .82);
  opacity: 1;
}

.essay-meta {
  margin: .6rem 0 0;
  color: var(--ivory-faint);
  font: 600 var(--fs-xs)/1.5 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
}

.essay-column section {
  margin-block: var(--sp-4);
  scroll-margin-top: 6rem;
}

.essay-column h2 {
  margin: var(--sp-6) 0 1rem;
  color: rgba(242, 231, 203, .65);
  font: 800 .76rem/1.25 var(--sans);
  letter-spacing: .17em;
  text-transform: uppercase;
}

.essay-column h3 {
  margin: var(--sp-4) 0 .8rem;
  color: rgba(242, 231, 203, .72);
  font: 700 .7rem/1.3 var(--sans);
  letter-spacing: .15em;
  text-transform: uppercase;
}

.essay-column p {
  margin: 0 0 1.08rem;
}

.essay-column em { font-style: italic; }

/* ---- Set text: epigraphs and kernel quotations.
   Kernel quotation law: indented, hairline-ruled above and below,
   byte-identical to source, never paraphrased. ---- */

.set-text {
  margin: var(--sp-4) 0;
  padding: 1.1rem 0 1.1rem 1.6rem;
  border-top: 1px solid rgba(242, 231, 203, .16);
  border-bottom: 1px solid rgba(242, 231, 203, .16);
  color: rgba(242, 231, 203, .8);
  font-style: italic;
}

.set-text p { margin: 0 0 .5rem; }
.set-text p:last-child { margin: 0; }

.set-text .attribution {
  display: block;
  margin-top: .55rem;
  color: var(--ivory-faint);
  font: 600 var(--fs-xs)/1.4 var(--sans);
  font-style: normal;
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* ---- Figures: images set like plates in a folio —
   hairline-framed, captioned, numbered. ---- */

.essay-figure {
  margin: var(--sp-6) 0;
}

.essay-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(242, 231, 203, .14);
  /* Sit the image into the ground: no bright halo, edges recede. */
  box-shadow: 0 0 0 6px rgba(22, 15, 12, .6), 0 18px 48px rgba(0, 0, 0, .5);
}

.essay-figure figcaption {
  margin-top: .8rem;
  color: var(--ivory-dim);
  font: 500 var(--fs-s)/1.55 var(--serif);
  font-style: italic;
}

.essay-figure figcaption .fig-kicker {
  display: block;
  margin-bottom: .2rem;
  color: var(--ivory-faint);
  font: 700 .66rem/1.3 var(--sans);
  font-style: normal;
  letter-spacing: .16em;
  text-transform: uppercase;
}

/* The headpiece: an essay's frontispiece image under its title, unframed
   wider treatment — vignetted into the dark rather than boxed. */
.essay-headpiece {
  margin: var(--sp-4) 0 var(--sp-6);
}

.essay-headpiece img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-mask-image: radial-gradient(ellipse 92% 88% at 50% 46%, #000 58%, transparent 99%);
  mask-image: radial-gradient(ellipse 92% 88% at 50% 46%, #000 58%, transparent 99%);
}

/* ---- Term markers: glossary-bound words. essay.js binds these to the
   lectern with definitions parsed from glossary.html. ---- */

.essay-column .term-marker {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0 .03em .04em;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: inherit;
  text-decoration-line: underline;
  text-decoration-color: rgba(242, 231, 203, .44);
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
  cursor: pointer;
  transition: color .34s var(--ease), text-decoration-color .34s var(--ease);
}

.essay-column .term-marker:hover,
.essay-column .term-marker:focus-visible {
  color: var(--ivory);
  text-decoration-color: rgba(242, 231, 203, .72);
}

.essay-column .term-marker:focus-visible {
  outline: 0;
  border-bottom: 1px solid rgba(242, 231, 203, .82);
}

/* Definition content shown in the lectern strip (dark ground). */
.lectern__body .anchor-link {
  display: inline-block;
  min-height: 24px;
  margin-top: .4rem;
  color: rgba(242, 231, 203, .72);
  font: 600 var(--fs-xs)/1.4 var(--sans);
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid rgba(242, 231, 203, .38);
  transition: color .24s var(--ease), border-color .24s var(--ease);
}

.lectern__body .anchor-link:hover,
.lectern__body .anchor-link:focus-visible {
  color: var(--ivory);
  border-color: rgba(242, 231, 203, .7);
}

/* ---- Footnotes: superscript anchors in the prose, a Notes list at the
   essay's foot with return links. ---- */

.essay-column sup.fn {
  font-size: .68em;
  line-height: 0;
}

.essay-column sup.fn a {
  color: rgba(242, 231, 203, .66);
  text-decoration: none;
  padding: 0 .08em;
  border-bottom: 1px solid rgba(242, 231, 203, .40);
  transition: color .24s var(--ease), border-color .24s var(--ease);
}

.essay-column sup.fn a:hover,
.essay-column sup.fn a:focus-visible {
  color: var(--ivory);
  border-color: rgba(242, 231, 203, .7);
  outline: 0;
}

.footnotes ol {
  margin: 0;
  padding-left: 1.4rem;
  display: grid;
  gap: .55rem;
}

.footnotes li {
  color: var(--ivory-dim);
  font-size: var(--fs-s);
  line-height: 1.6;
  scroll-margin-top: 6rem;
}

.footnotes .fn-back {
  margin-left: .35em;
  color: rgba(242, 231, 203, .5);
  text-decoration: none;
  transition: color .24s var(--ease);
}

.footnotes .fn-back:hover,
.footnotes .fn-back:focus-visible {
  color: var(--ivory);
  outline: 0;
}

/* ---- Footer: the turn to the next essay ---- */

.essay-footer {
  margin-top: var(--sp-6);
  padding-top: 1.2rem;
  border-top: 1px solid rgba(242, 231, 203, .14);
}

.next-label {
  margin: 0 0 .6rem;
  color: var(--ivory-faint);
  font: 800 .66rem/1.3 var(--sans);
  letter-spacing: .16em;
  text-transform: uppercase;
}

.reading-links {
  display: grid;
  gap: .45rem;
}

.reading-links a {
  min-height: 44px;
  color: rgba(242, 231, 203, .72);
  font: 600 .94rem/1.35 var(--serif);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  transition: color .28s var(--ease);
}

.reading-links a:hover { color: var(--ivory); }

.reading-links a:focus-visible {
  outline: 0;
  color: var(--ivory);
  border-bottom: 1px solid var(--ivory);
}

.rub-end {
  display: block;
  width: 28px;
  height: 28px;
  margin: 2rem auto 0;
  color: rgba(242, 231, 203, .5);
}

/* ---- Margin apparatus: kicker, section nav, progress hairline ---- */

.margin-apparatus {
  position: sticky;
  grid-column: 1;
  grid-row: 1;
  top: clamp(22px, 5vh, 56px);
  min-height: 62vh;
  padding-top: .4rem;
  color: var(--ivory-dim);
}

.progress-track {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 1px;
  background: rgba(242, 231, 203, .13);
}

.progress-rule {
  position: absolute;
  left: 0; top: 0;
  width: 1px;
  height: calc(var(--read-progress, 0) * 100%);
  background: rgba(242, 231, 203, .82);
}

.margin-inner { padding-left: 1.35rem; }

.margin-kicker {
  margin: 0 0 1rem;
  color: rgba(242, 231, 203, .52);
  font: 800 .62rem/1.45 var(--sans);
  letter-spacing: .18em;
  text-transform: uppercase;
}

.wave-note {
  max-width: 11rem;
  margin: 0 0 1.2rem;
  color: rgba(242, 231, 203, .52);
  font: 500 .76rem/1.55 var(--sans);
}

.margin-apparatus nav[aria-label="Section anchors"] {
  display: grid;
  gap: .55rem;
  margin-bottom: 1.5rem;
}

.margin-apparatus nav[aria-label="Section anchors"] a {
  width: fit-content;
  min-height: 32px;
  color: rgba(242, 231, 203, .62);
  font: 600 .72rem/1.25 var(--sans);
  letter-spacing: .05em;
  text-decoration: none;
  transition: color .28s var(--ease);
}

.margin-apparatus nav[aria-label="Section anchors"] a:hover,
.margin-apparatus nav[aria-label="Section anchors"] a[aria-current="location"] {
  color: var(--ivory);
}

.margin-apparatus nav[aria-label="Section anchors"] a:focus-visible {
  outline: 0;
  color: var(--ivory);
  border-bottom: 1px solid var(--ivory);
}

.apparatus-turn {
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid rgba(242, 231, 203, .12);
}

.apparatus-turn .reading-links { gap: .25rem; }

.apparatus-turn .reading-links a {
  min-height: 34px;
  color: rgba(242, 231, 203, .62);
  font: 600 var(--fs-xs)/1.35 var(--sans);
}

/* ---- Responsive ---- */

@media (max-width: 820px) {
  html { scroll-behavior: auto; }

  body.essay { padding-bottom: 260px; }

  .essay-room {
    padding: clamp(112px, 20vh, 136px) clamp(14px, 4vw, 22px) 44px;
  }

  .room-layout {
    grid-template-columns: 1fr;
    width: 100%;
    margin: 0;
  }

  .essay-column {
    grid-column: 1;
    grid-row: 1;
    font-size: 1.055rem;
    line-height: 1.7;
  }

  .margin-apparatus {
    position: static;
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
    margin: 0 0 18px;
    padding: 0 0 0 1rem;
    border-left: 1px solid rgba(242, 231, 203, .2);
    display: block;
  }

  .margin-apparatus .progress-track {
    position: fixed;
    left: auto; right: 0; top: 0; bottom: auto;
    z-index: 10;
    width: 1px;
    /* Stop clear of the fixed lectern strip (min-height 112px). */
    height: calc(100svh - 112px);
    background: rgba(242, 231, 203, .12);
  }

  .margin-apparatus .progress-rule {
    position: fixed;
    left: auto; right: 0; top: 0;
    z-index: 11;
    width: 1px;
  }

  .margin-inner { padding-left: 0; }

  .margin-apparatus nav[aria-label="Section anchors"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .25rem .6rem;
    margin-bottom: 1rem;
  }

  .margin-apparatus nav[aria-label="Section anchors"] a { min-height: 36px; }

  .apparatus-turn { display: none; }

  .wave-note { max-width: none; margin-bottom: 1.1rem; }
}

@media (max-width: 430px) {
  .margin-apparatus nav[aria-label="Section anchors"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .essay-column .term-marker,
  .reading-links a,
  .margin-apparatus a {
    transition-duration: .01ms !important;
  }
}

/* ---- Zoomable figures: baked raster tables too dense to read at the
   reading column's width, let alone at 390px. Click/tap (or Enter) opens
   the image at natural size inside a fullscreen scrollable dialog — panning
   and native pinch-zoom stand in for chrome; there is no button. See
   essay.js for the dialog wiring. ---- */

.essay-figure--zoomable img {
  cursor: zoom-in;
}

.essay-figure--zoomable img:focus-visible {
  outline: 1px solid var(--ivory);
  outline-offset: 3px;
}

.figure-zoom-dialog {
  padding: 0;
  margin: 0;
  border: none;
  max-width: none;
  max-height: none;
  width: 100vw;
  height: 100vh;
  background: rgba(22, 15, 12, .97);
  overflow: auto;
  cursor: zoom-out;
}

.figure-zoom-dialog::backdrop {
  background: rgba(22, 15, 12, .97);
}

.figure-zoom-dialog img {
  display: block;
  margin: auto;
  /* Natural size — the whole point is legibility beyond the reading
     column's width; the dialog scrolls and pinch-zooms rather than the
     image shrinking to fit. */
  width: auto;
  height: auto;
  max-width: none;
  border: 1px solid rgba(242, 231, 203, .5);
}

/* In-body cross-links between essays (restored from the published posts). */
.essay-column a.xref {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(242, 231, 203, .44);
  transition: border-color .28s var(--ease);
}

.essay-column a.xref:hover,
.essay-column a.xref:focus-visible {
  border-bottom-color: rgba(242, 231, 203, .68);
  outline: 0;
}
