/* Eureka · a reading page. site.css carries the letters, the colours, the widths, the header and the footer; this file lays out the page itself.
   Three columns, always the same: the chapters of the document, the page, the sections of this page. Their widths are fixed per screen width, so no page moves them. */
:root { --head-h: 101px; --doc-pad: 18px; }
@media (min-width: 1100px) { :root { --head-h: var(--top-h); --doc-pad: 32px; } }
@media (min-width: 1280px) { :root { --doc-pad: 40px; } }
@media (min-width: 1600px) { :root { --doc-pad: 44px; } }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--head-h) + 16px); }

/* the phone's bar under the header: the page, the section you are reading, and a tap opens the list */
.pagebar { display: flex; align-items: center; gap: 8px; width: 100%; height: 44px; padding: 0 var(--pad); border: 0; border-top: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; }
.pb-label { flex: 0 1 auto; min-width: 0; max-width: 55%; font: 600 14px/1.2 var(--font-display); color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-now { flex: 1 1 0; min-width: 0; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-now:not(:empty)::before { content: '· '; color: var(--ink-3); }
.pagebar svg { flex: none; width: 18px; height: 18px; color: var(--ink-3); transition: transform .2s; }
.toc-open .pagebar svg { transform: rotate(180deg); }

/* ---------- layout: chapters | page | sections of the page ---------- */
.reader { position: relative; z-index: 1; display: block; margin: 0 auto; padding: calc(var(--head-h) + 16px) var(--pad) 72px; }
.doc { min-width: 0; max-width: 860px; margin: 0 auto; }
.rail { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.rail .eyebrow { padding-left: 14px; }
.chapters-rail { display: none; }

/* the two columns are one idea: the same list, the same mark. Left is where you are in the document, right is where you are in this page. */
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 7px 12px; border-radius: 10px; border-left: 2px solid transparent; font-size: 14px; line-height: 1.35; color: var(--ink-2); text-decoration: none; overflow-wrap: anywhere; }
.toc .t3 a { margin-left: 14px; font-size: 13.5px; }
.toc a:hover { color: var(--ink); background: var(--line); }
.toc a.on { color: var(--ink); background: var(--glass-2); border-left-color: var(--accent); font-weight: 600; }
.toc .top a { color: var(--ink); }
.toc .none { padding: 7px 14px; font-size: 13px; color: var(--ink-3); }
/* a section that holds sub-sections: its chevron folds them; the mark of the section being read shows on the parent while its children are folded */
.toc li.fold { position: relative; }
.toc li.fold > a { padding-right: 38px; }
.toc li.fold.has-on > a { border-left-color: var(--accent); color: var(--ink); }
.toc .fold-btn { position: absolute; top: 2px; right: 2px; width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--ink-3); cursor: pointer; }
.toc .fold-btn:hover { color: var(--ink); background: var(--line); }
.toc .fold-btn svg { width: 16px; height: 16px; transition: transform .15s; }
.toc .fold-btn[aria-expanded="false"] svg { transform: rotate(-90deg); }
/* the list scrolls inside its box (.toc-scroll). Where it is longer than the box, the edge that hides more fades out and carries a chevron that scrolls it. */
@property --fade-up { syntax: '<length>'; inherits: false; initial-value: 0px; }
@property --fade-down { syntax: '<length>'; inherits: false; initial-value: 0px; }
.rail.toc { --pt: 0px; --pb: 0px; display: flex; flex-direction: column; overflow: hidden; padding-top: var(--pt); padding-bottom: var(--pb); }
.toc-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; transition: --fade-up .18s, --fade-down .18s;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 var(--fade-up), #000 calc(100% - var(--fade-down)), transparent); mask-image: linear-gradient(to bottom, transparent, #000 var(--fade-up), #000 calc(100% - var(--fade-down)), transparent); }
.toc-scroll.more-up { --fade-up: 40px; }
.toc-scroll.more-down { --fade-down: 40px; }
.toc-cue { position: absolute; left: 0; right: 0; z-index: 3; height: 24px; display: grid; place-items: center; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .18s, visibility .18s; }
.toc-cue.show { opacity: 1; visibility: visible; }
.toc-cue.up { top: calc(var(--pt) + 2px); }
.toc-cue.down { bottom: calc(var(--pb) + 2px); }
.toc-cue button { width: 40px; height: 24px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); cursor: pointer; pointer-events: auto; }
.toc-cue button:hover { color: var(--ink); background: var(--line); }
.toc-cue button svg { width: 18px; height: 18px; }
.toc-cue.up button svg { transform: rotate(180deg); }
.rail .tree a { font-size: 14px; }
.rail .tree ol ol a { font-size: 13.5px; }

/* the constellation (sky.js): under the list of sections, down to the bottom of the screen, so it stays in view while reading. Phones and tablets do not show it. */
.sky-box { display: none; }
.side-right { display: contents; }

@media (min-width: 1100px) {
  .reader { width: 100%; max-width: var(--site-w); display: grid; grid-template-columns: var(--w-left) minmax(0, 1fr) var(--w-right); column-gap: var(--gap); align-items: start; }
  .doc { max-width: none; margin: 0; }
  .chapters-rail { display: block; }
  .rail { position: sticky; top: calc(var(--head-h) + 16px); max-height: calc(100vh - var(--head-h) - 32px); overflow: auto; padding-bottom: 20px; }
  .pagebar { display: none; }
  /* the box is fixed to the bottom of the column and its size does not depend on the list above it, so nothing moves while reading */
  .side-right { display: block; --box-h: min(60%, 560px); position: sticky; top: calc(var(--head-h) + 16px); height: calc(100vh - var(--head-h) - 32px); }
  .side-right .toc { position: relative; top: auto; max-height: calc(100% - var(--box-h) - 14px); }
  .sky-box { display: block; position: absolute; left: 0; right: calc(-1 * var(--pad)); bottom: 0; height: var(--box-h); -webkit-mask-image: radial-gradient(ellipse 52% 52% at 50% 50%, #000 58%, transparent 100%); mask-image: radial-gradient(ellipse 52% 52% at 50% 50%, #000 58%, transparent 100%); }
  .sky-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
}

/* ---------- the page: a sheet of paper ---------- */
.doc { background: var(--glass-solid); border: 1px solid var(--line); border-radius: 22px; padding: 46px var(--doc-pad) 40px; box-shadow: var(--shadow); }
.doc-head { padding-bottom: 28px; margin-bottom: 34px; border-bottom: 1px solid var(--line); display: grid; gap: 16px; }
.crumb { font: 500 12.5px/1.2 var(--font-body); color: var(--ink-3); }
.crumb a { color: var(--ink-2); text-decoration: none; }
.crumb a:hover { color: var(--ink); text-decoration: underline; }
.doc-head h1 { margin: 0; font: 600 clamp(34px, 4.2vw, 56px)/1.06 var(--font-display); letter-spacing: -0.04em; overflow-wrap: anywhere; text-wrap: balance; scroll-margin-top: calc(var(--head-h) + 16px); }
.doc-meta { display: flex; gap: 6px 18px; flex-wrap: wrap; font: 500 12px/1.4 var(--font-mono); color: var(--ink-3); }

.prose { font-size: 17.5px; line-height: 1.72; color: var(--ink); }
.prose p { margin: 0 0 1.15em; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose h2, .prose h3 { font-family: var(--font-display); font-weight: 600; margin: 2.1em 0 .6em; scroll-margin-top: calc(var(--head-h) + 16px); position: relative; display: flex; gap: 14px; align-items: baseline; line-height: 1.2; overflow-wrap: anywhere; }
.prose h2 { font-size: clamp(24px, 2.2vw, 30px); letter-spacing: -0.025em; }
.prose h3 { font-size: clamp(20px, 1.8vw, 24px); letter-spacing: -0.02em; margin-top: 1.8em; }
.prose h2:first-child { margin-top: 0; }
.prose .h-num { font: 500 12px/1 var(--font-mono); color: var(--accent); flex: none; transform: translateY(-3px); }
.prose .anchor { position: absolute; left: -26px; top: 50%; transform: translateY(-50%); width: 22px; font: 500 15px/1 var(--font-mono); color: var(--ink-3); text-decoration: none; opacity: 0; transition: opacity .15s; text-align: center; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .anchor:focus-visible { opacity: 1; }
.prose strong { font-weight: 600; }
.prose ul, .prose ol { margin: 0 0 1.25em; padding-left: 1.4em; }
.prose li { margin: .35em 0; padding-left: .2em; }
.prose li::marker { color: var(--accent); }
.prose li > ul, .prose li > ol { margin: .3em 0 .3em; }
.prose code { font: 400 .88em var(--font-mono); background: var(--glass-2); border: 1px solid var(--line); border-radius: 5px; padding: .08em .35em; }

/* the contents page */

/* the thread of Lucía: a note set apart, not shouting */
.callout { margin: 1.8em 0 1.9em; padding: 18px 22px 6px 24px; border-radius: 4px 16px 16px 4px; background: var(--tint); border-left: 3px solid var(--accent); font-size: 17px; line-height: 1.68; }
.callout-title { display: flex; align-items: center; gap: 10px; margin: 0 0 .7em !important; font: 500 12px/1 var(--font-mono) !important; letter-spacing: .13em; text-transform: uppercase; color: var(--accent); }
.callout-title::before { content: ''; width: 13px; height: 9px; border-radius: 50%; background: var(--accent); transform: rotate(-20deg); flex: none; }
.callout > :last-child { margin-bottom: 1em; }

/* the founder's own words: a voice, not a note; no box, a large opening mark and the light of the accent on the left */
.callout-quote { position: relative; background: none; border-left: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 0; padding: 4px 0 2px 46px; font: italic 400 20px/1.62 var(--font-display); color: var(--ink); }
.callout-quote::before { content: '“'; position: absolute; left: 8px; top: -6px; font: 700 52px/1 var(--font-display); color: var(--accent); opacity: .35; pointer-events: none; }
.callout-quote .callout-title { font-style: normal !important; margin-bottom: .9em !important; }
.callout-quote .callout-title::before { display: none; }
@media (max-width: 720px) { .callout-quote { font-size: 18px; padding-left: 38px; } .callout-quote::before { font-size: 44px; left: 4px; } }

/* «Eureka in numbers»: each row of a [!numbers] table is a card with its number large */
.stats { margin: 2.2em 0 2.4em; }
.stats-title { margin: 0 0 14px !important; font: 500 12px/1 var(--font-mono); letter-spacing: .13em; text-transform: uppercase; color: var(--accent); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.stat { padding: 18px 18px 16px; border-radius: 16px; background: var(--glass); border: 1px solid var(--glass-edge); box-shadow: var(--shadow); }
.stat p { margin: 0 !important; }
.stat-n { font: 600 40px/1.05 var(--font-display); letter-spacing: -.02em; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-u { margin-top: 6px !important; font: 600 15.5px/1.35 var(--font-display); color: var(--ink); }
.stat-m { margin-top: 8px !important; font-size: 14.5px; line-height: 1.5; color: color-mix(in srgb, var(--ink) 72%, transparent); }
@media (max-width: 720px) { .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; } .stat { padding: 14px 14px 12px; } .stat-n { font-size: 30px; } .stat-u { font-size: 14.5px; } .stat-m { font-size: 13.5px; } }

/* ---------- pieces: as wide as the column ---------- */
.piece { margin: 2em 0 2.2em; }
.piece .zoom, .piece .shot { display: block; width: 100%; padding: 8px; margin: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--glass-2); text-align: inherit; }
.piece .zoom { cursor: zoom-in; }
.piece img, .piece video { width: 100%; height: auto; border-radius: 12px; background: var(--bg-2); }
.piece .shot { position: relative; }
.piece .shot video { background: #04060c; }
/* the Listen button, with its little equaliser; an audio gets the same button in a row of its own */
.mini-listen { display: inline-flex; align-items: center; gap: 10px; height: 38px; padding: 0 16px; border-radius: 999px; cursor: pointer; flex: none;
  font: 600 14px/1 var(--font-body); border: 1px solid rgba(255, 255, 255, .16); background: rgba(7, 11, 22, .78); color: #edf1f8; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: border-color .2s, background-color .2s, color .2s; }
.mini-listen .eq { height: 13px; color: #f4c46a; }
.mini-listen .eq i { width: 2px; }
.mini-listen:hover { border-color: #f4c46a; }
.mini-listen.on { background: #f4c46a; color: #04060c; }
.mini-listen.on .eq { color: #04060c; }
.shot .mini-listen { position: absolute; right: 14px; bottom: 14px; }
.listen-row { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.listen-bar { flex: 1; height: 3px; border-radius: 2px; background: var(--line-2); overflow: hidden; }
.listen-bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }
.piece audio { width: 100%; margin-top: 12px; }
.piece figcaption { margin: 12px 8px 0; font-size: 14px; line-height: 1.5; color: var(--ink-3); }
.piece-diagram .zoom { padding: 18px 16px; overflow-x: auto; background: var(--glass); }
.diagram svg { display: block; width: 100%; height: auto; margin: 0 auto; }
.enlarge { display: none; }
.diagram-night { display: none; }
:root[data-theme="dark"] .diagram-day { display: none; }
:root[data-theme="dark"] .diagram-night { display: block; }
.missing { padding: 14px; border: 1px dashed var(--line-2); border-radius: 10px; color: var(--ink-3); font: 500 13px/1.4 var(--font-mono); white-space: pre-wrap; }
.table-wrap { margin: 2em 0 2.2em; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--glass); -webkit-overflow-scrolling: touch; }
.piece .table-wrap { margin: 0; }
.table-wrap table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 15.5px; line-height: 1.5; }
.table-wrap th { text-align: left; font: 500 11.5px/1.3 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); background: var(--glass-2); padding: 12px 16px; white-space: nowrap; }
.table-wrap td { padding: 12px 16px; vertical-align: top; border-top: 1px solid var(--line); color: var(--ink-2); }
.table-wrap td:first-child { color: var(--ink); font-weight: 560; }

/* ---------- previous and next ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }
.pager a { display: block; padding: 18px 20px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass); text-decoration: none; }
.pager a:hover { border-color: var(--accent); }
.pager .next { text-align: right; grid-column: 2; }
.pager small { display: block; margin-bottom: 8px; font: 500 11px/1 var(--font-mono); color: var(--ink-3); }
.pager b { font: 600 16px/1.3 var(--font-display); overflow-wrap: anywhere; }

/* ---------- enlarged picture ---------- */
.lightbox { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-rows: minmax(0, 1fr) auto; padding: 56px 20px 20px; background: color-mix(in srgb, var(--bg) 97%, transparent); backdrop-filter: blur(8px); cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lb-stage { min-height: 0; display: flex; overflow: auto; touch-action: pan-x pan-y pinch-zoom; }
.lb-stage > * { margin: auto; flex: none; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 150px); width: auto; height: auto; border-radius: 10px; box-shadow: var(--shadow); }
.lb-stage .diagram { width: min(1400px, 100%); }
.lb-stage .diagram svg { max-height: calc(100vh - 140px); }
.lb-caption { margin: 14px auto 0; max-width: 900px; text-align: center; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.lb-close { position: absolute; top: 12px; right: 16px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--solid); font-size: 26px; line-height: 1; cursor: pointer; }
body.lb-open { overflow: hidden; }

/* ---------- phone and tablet: the sections of the page become a bar that opens ---------- */
@media (max-width: 1099px) {
  .reader { z-index: auto; }
  .shade { display: none; position: fixed; inset: var(--head-h) 0 0 0; z-index: 44; background: rgba(0, 0, 0, 0.4); }
  .toc-open .shade { display: block; }
  .toc { position: fixed; z-index: 45; top: var(--head-h); left: var(--pad); right: var(--pad); max-height: min(60vh, 460px); padding-left: 10px; padding-right: 10px; background: var(--solid); box-shadow: var(--shadow); border: 1px solid var(--line-2); border-top: 0; border-radius: 0 0 16px 16px;
    opacity: 0; visibility: hidden; transform: translateY(-8px); transition: opacity .2s, transform .2s, visibility .2s; }
  .toc-open .toc { opacity: 1; visibility: visible; transform: none; }
  .rail.toc { --pt: 18px; --pb: 14px; }
  .toc a { padding: 10px 12px; font-size: 15.5px; }
  .toc li.fold > a { padding-right: 46px; }
  .toc .fold-btn { top: 4px; width: 38px; height: 38px; }
  .toc .t3 a { font-size: 14.5px; }
  .prose .anchor { display: none; }
  .piece-diagram .zoom { padding: 12px 10px; }
  .piece-diagram .diagram svg { min-width: 620px; }
  .enlarge { display: block; margin: 8px 8px 0; font: 500 11.5px/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
  .lb-stage .diagram svg { max-height: none; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .reader { padding-left: 10px; padding-right: 10px; }
  .doc { padding: 32px var(--doc-pad) 28px; border-radius: 18px; }
  .prose { font-size: 17px; line-height: 1.7; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: auto; }
  .callout { padding: 16px 16px 4px 18px; }
  .table-wrap th, .table-wrap td { padding: 10px 12px; }
  .piece .zoom, .piece .shot { padding: 5px; border-radius: 14px; }
  .piece img, .piece video { border-radius: 10px; }
}
