/* ==========================================================================
   NOTEBOOK: house style
   Derived from /imperical: Frank Ruhl Libre, cream paper, near-black ink,
   a left index, a ruled divider, a central text column and a right margin.

   Two sides share one grammar:
     body[data-side="general"]   daylight: cream paper, black ink
     body[data-side="personal"]  white paper, dark green accents, its own single-column layout
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Frank+Ruhl+Libre:wght@300;400;500;700;900&display=swap');

:root {
  --paper:   #f3f2ed;          /* imperical page background */
  --sheet:   #ffffff;          /* imperical panels          */
  --ink:     rgb(9, 15, 11);   /* imperical nav / text      */
  --ink-2:   #3d403b;
  --ink-3:   #74766f;
  --rule:    #000000;
  --hair:    #d9d7cd;
  --accent:  #8e2a1f;          /* the rug's red field       */
  --tile:    #2f6b66;          /* the tiger's tile frieze   */
  --gilt:    #a5843a;          /* the frame                 */
  --wash:    #f8f6ef;
  --bar:     rgb(9, 15, 11);   /* imperical .nav-div        */
  --bar-ink: #f3f2ed;

  --serif: 'Frank Ruhl Libre', Georgia, 'Times New Roman', serif;
  --mono:  ui-monospace, 'Cascadia Mono', Consolas, monospace;

  /* border scale: every line on the site uses one of these */
  --line: 1px;          /* all rules, frames, dividers        */
  --line-mark: 2px;     /* current-item markers, accent bars  */
  --mat: 4px;           /* pale mat around pictures           */
  --rug-h: 10px;        /* the carpet band                    */

  --index-w: 260px;
  --margin-w: 250px;
  --measure: 680px;
}

/* Personal side: white is the main colour, dark green the accent */
body[data-side="personal"] {
  --paper:   #ffffff;
  --sheet:   #ffffff;
  --ink:     #10241a;
  --ink-2:   #3b4f44;
  --ink-3:   #6f8579;
  --rule:    #134a30;
  --hair:    #d8e4dc;
  --accent:  #134a30;
  --tile:    #134a30;
  --gilt:    #134a30;
  --wash:    #f2f7f4;
  --bar:     #134a30;
  --bar-ink: #ffffff;
}
body[data-side="personal"] .spine [role="tab"][aria-selected="true"] { border-bottom-color: var(--accent); }

* { box-sizing: border-box; font-family: var(--serif); }

html, body {
  margin: 0; padding: 0; border: 0;
  background: var(--paper);
  color: var(--ink);
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body { font-size: 18px; line-height: 1.65; font-weight: 400; transition: background-color .3s, color .3s; }

a { color: var(--ink); text-decoration: none; border-bottom: var(--line) solid var(--hair); }
a:hover { border-bottom-color: var(--accent); color: var(--accent); }

code, .mono { font-family: var(--mono); font-size: .86em; }

.label {
  font-size: 12px; letter-spacing: .18em; text-transform: uppercase;
  font-weight: 500; color: var(--ink-3);
}

/* ---------- the rug band ----------
   assets/rug-band.jpg: a 3787px slice down the length of the
   "Floral and Cloudband" Carpet (17th c.), Metropolitan Museum of Art,
   object 451184, DP310084, public domain (CC0), turned on its side. */
.rug {
  height: var(--rug-h); width: 100%;
  background: #8e2a1f url('../assets/rug-band.jpg') center / cover;
}

/* ==========================================================================
   THE SPINE: the bar that chooses a side (imperical .nav-div)
   ========================================================================== */
.spine {
  background: #ffffff; color: var(--ink); border-bottom: var(--line) solid var(--hair);   /* white on both sides */
  display: flex; justify-content: center; align-items: stretch;
  position: relative; z-index: 15;
}
.spine [role="tab"] {
  background: none; border: 0; cursor: pointer; color: inherit;
  font-size: 22px; font-weight: 300; padding: 14px 34px 12px; opacity: .55;
  display: flex; align-items: baseline; gap: 10px; letter-spacing: .02em;
  border-bottom: var(--line-mark) solid transparent;
}
.spine [role="tab"] .vol { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; }
.spine [role="tab"][aria-selected="true"] { opacity: 1; border-bottom-color: #8e2a1f; }
.spine [role="tab"]:hover { opacity: 1; }
.spine-tabs { display: flex; align-items: stretch; }
.spine .sep { width: var(--line); background: currentColor; opacity: .3; margin: 12px 0; }

/* Only the chosen side is shown */
.side[hidden] { display: none !important; }

/* ==========================================================================
   FRAME: index | divider | content | divider | margin
   ========================================================================== */
.main {
  display: grid;
  grid-template-columns: var(--index-w) 1px minmax(0, 1fr) 1px var(--margin-w);
  background: var(--sheet);
  min-height: 100vh;
}
.divider { background: var(--rule); width: var(--line); }

/* ---------- LEFT INDEX ---------- */
.index {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  scrollbar-width: none; padding: 26px 0 40px; background: var(--sheet);
}
.index-head { padding: 0 22px 14px; }
.index-head .who { font-size: 24px; font-weight: 300; line-height: 1.15; display: block; border: 0; }
.index-head .who:hover { color: var(--ink); }
.index-head .label { display: block; margin-top: 6px; }

.dash { background: var(--rule); height: var(--line); width: 100%; }
.dash.thin { background: var(--hair); }

.index-item {
  display: flex; align-items: baseline; gap: 10px; width: 100%;
  border: none; background: none; cursor: pointer; text-align: left;
  font-size: 19px; color: var(--ink); padding: 12px 22px; line-height: 1.25;
}
.index-item .num { font-size: 13px; color: var(--ink-3); min-width: 26px; letter-spacing: .05em; }
.index-item .caret { margin-left: auto; font-size: 12px; color: var(--ink-3); transition: transform .2s; }
.index-item[aria-expanded="true"] .caret { transform: rotate(90deg); }
.index-item:hover { color: var(--accent); }
.index-item.active .num { color: var(--accent); }

.sub { display: none; padding: 0 22px 14px 58px; }
.sub.open { display: grid; gap: 2px; }
.sub a { font-size: 15px; border: 0; color: var(--ink-2); padding: 2px 0; display: flex; gap: 8px; }
.sub a .n { color: var(--ink-3); font-size: 12px; min-width: 30px; padding-top: 2px; }
.sub a:hover { color: var(--accent); }

.index-foot { padding: 18px 22px 0; font-size: 14px; }
.index-foot a { color: var(--ink-2); }

/* ---------- RIGHT MARGIN ---------- */
.right {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: none;
  padding: 26px 22px 40px; background: var(--sheet); font-size: 15px; line-height: 1.5;
}
.right section + section { margin-top: 28px; padding-top: 18px; border-top: var(--line) solid var(--hair); }
.right h4 { margin: 0 0 10px; }
.right ul { list-style: none; margin: 0; padding: 0; }
.right li { padding: 3px 0; }
.toc-local a { border: 0; color: var(--ink-3); display: block; padding-left: 10px; border-left: var(--line-mark) solid transparent; }
.toc-local a.on { color: var(--ink); border-left-color: var(--accent); }
.now li { display: grid; grid-template-columns: 14px 1fr; gap: 6px; }
.now li::before { content: '▸'; color: var(--accent); font-size: 11px; padding-top: 3px; }
.now .meta { display: block; color: var(--ink-3); font-size: 13px; }
.key li { display: grid; grid-template-columns: 26px 1fr; }
.key .sym { color: var(--accent); }

/* ==========================================================================
   CONTENT COLUMN
   ========================================================================== */
.content { padding: 0 48px 80px; background: var(--sheet); }
.column { max-width: var(--measure); margin: 0 auto; }

.masthead { text-align: center; padding: 54px 0 34px; }
.masthead h1 {
  font-weight: 300; font-size: clamp(34px, 5vw, 54px); line-height: 1.08;
  margin: 18px 0 14px; letter-spacing: -.01em;
}
.masthead .subtitle { font-size: 20px; color: var(--ink-2); font-weight: 300; max-width: 560px; margin: 0 auto; }
.edition {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 22px; margin-top: 24px;
  font-size: 14px; color: var(--ink-3);
}
.edition span + span::before { content: '·'; margin-right: 22px; color: var(--ink-3); }

.section { padding-top: 46px; scroll-margin-top: 10px; }
.section > header { border-top: var(--line) solid var(--rule); padding-top: 12px; margin-bottom: 18px; }
.section > header .label { color: var(--accent); }
.section h2 { font-weight: 300; font-size: 34px; margin: 4px 0 0; line-height: 1.15; }
.section h3 { font-weight: 500; font-size: 21px; margin: 32px 0 8px; }
.lede { font-size: 20px; color: var(--ink-2); font-weight: 300; }
p { margin: 0 0 14px; hyphens: auto; }
.dropcap::first-letter {
  float: left; font-size: 68px; line-height: .82; padding: 6px 10px 0 0; color: var(--accent); font-weight: 400;
}

/* ---------- figures & plates ---------- */
figure { margin: 0; }
.plate img {
  display: block; width: 100%; height: auto; border: var(--line) solid var(--rule);
  outline: var(--mat) solid var(--wash); outline-offset: calc(-1 * var(--line));
}
figcaption { font-size: 14px; color: var(--ink-3); margin-top: 10px; line-height: 1.45; }
figcaption b { color: var(--ink); font-weight: 500; letter-spacing: .04em; }

/* ---------- decorative paintings (general side) ----------
   hero: the wide painting at the top of the column
   headpiece: a cropped band opening each section
   tailpiece: a small vignette closing each section
   margin-plate: a small framed painting in the index or margin */
.hero, .headpiece, .tailpiece, .margin-plate { margin: 0; }
.hero img, .headpiece img, .tailpiece img, .margin-plate img {
  display: block; width: 100%; height: auto;
  border: var(--line) solid var(--rule); outline: var(--mat) solid var(--wash); outline-offset: calc(-1 * var(--line));
}
.masthead:has(.hero) { padding-top: 34px; }
.hero img { aspect-ratio: 16 / 9; object-fit: cover; }
.headpiece { margin: 4px 0 26px; }
.headpiece img { aspect-ratio: 3 / 1; object-fit: cover; object-position: center 45%; }
.tailpiece { width: 220px; margin: 40px auto 0; }
.tailpiece::after { content: '❦'; display: block; text-align: center; color: var(--accent); font-size: 18px; margin-top: 10px; }
.index .margin-plate { padding: 26px 22px 0; }

.frontis { display: grid; grid-template-columns: 240px 1fr; gap: 36px; align-items: start; }

/* ---------- three readers ---------- */
.readers { display: grid; grid-template-columns: repeat(3, 1fr); border: var(--line) solid var(--rule); margin: 22px 0 6px; }
.readers > a { display: block; padding: 18px 18px 20px; border: 0; color: var(--ink); background: var(--sheet); }
.readers > a + a { border-left: var(--line) solid var(--rule); }
.readers > a:hover { background: var(--wash); color: var(--ink); }
.readers .q { font-size: 13px; color: var(--ink-3); letter-spacing: .14em; text-transform: uppercase; }
.readers .a { font-size: 21px; font-weight: 300; line-height: 1.2; margin: 8px 0; }
.readers .go { font-size: 14px; color: var(--accent); }

/* ---------- teaching environments ---------- */
.env { margin: 20px 0; padding: 14px 18px 4px; background: var(--wash); border-left: var(--line-mark) solid var(--ink); }
.env > .env-h { font-weight: 700; margin-right: 6px; }
.env > .env-h .t { font-weight: 400; color: var(--ink-2); }
.env.def { border-left-color: var(--accent); }
.env.thm { background: var(--sheet); border: var(--line) solid var(--rule); border-left-width: var(--line-mark); }
.env.ex  { border-left-color: var(--tile); }
.env.rem { border-left-color: var(--gilt); background: transparent; }
.env.exr { background: var(--sheet); border: var(--line) dashed var(--ink-3); border-left: var(--line-mark) solid var(--tile); }
.env p:last-child { margin-bottom: 10px; }
.env dl { margin: 4px 0 12px; display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.env dt { font-weight: 500; }
.env dd { margin: 0; }
details.sol { margin: 4px 0 12px; }
details.sol summary { cursor: pointer; color: var(--tile); font-size: 15px; letter-spacing: .06em; }
details.sol[open] summary { margin-bottom: 8px; }
.qed { float: right; }

.conventions { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.conventions .env { margin: 10px 0; font-size: 16px; }

.chip {
  display: inline-block; font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  border: var(--line) solid var(--hair); padding: 1px 8px; margin: 0 4px 4px 0; color: var(--ink-2); background: var(--sheet);
}

/* ---------- dependency map ---------- */
.map svg { width: 100%; height: auto; display: block; }
.map .node rect { fill: var(--sheet); stroke: var(--ink); stroke-width: 1; }
.map .node.root rect { stroke-width: 2; }
.map .node text { font-family: var(--serif); fill: var(--ink); font-size: 15px; }
.map .node .rn { fill: var(--accent); font-size: 12px; letter-spacing: .12em; }
.map .edge { stroke: var(--ink-3); stroke-width: 1.2; fill: none; }
.map .ah { fill: var(--ink-3); }
.map a { border: 0; }
.map a:hover rect { fill: var(--wash); stroke: var(--accent); }

/* ---------- table of contents ---------- */
.toc { list-style: none; margin: 0; padding: 0; }
.toc > li { border-top: var(--line) solid var(--hair); padding: 18px 0 16px; scroll-margin-top: 10px; }
.toc > li:last-child { border-bottom: var(--line) solid var(--hair); }
.toc .ch { display: grid; grid-template-columns: 54px 1fr; gap: 0 10px; align-items: baseline; }
.toc .rn { font-size: 15px; color: var(--accent); letter-spacing: .08em; }
.toc .ct { font-size: 23px; font-weight: 400; }
.toc .abs { margin: 6px 0 8px 64px; color: var(--ink-2); font-size: 16px; }
.toc .meta { margin-left: 64px; }
.toc ol.secs { margin: 8px 0 0 64px; padding: 0; list-style: none; columns: 2; column-gap: 28px; font-size: 15px; }
.toc ol.secs li { break-inside: avoid; padding: 1px 0; color: var(--ink-2); }
.toc ol.secs .n { color: var(--ink-3); display: inline-block; min-width: 34px; font-size: 13px; }

/* ---------- reading paths ---------- */
.paths { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 10px; }
.path { border-top: var(--line) solid var(--rule); padding-top: 10px; }
.path h4 { font-weight: 500; font-size: 18px; margin: 4px 0; }
.path .for { font-size: 14px; color: var(--ink-3); margin-bottom: 10px; }
.path ol { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.path li { counter-increment: step; position: relative; padding: 0 0 12px 30px; font-size: 15px; line-height: 1.4; }
.path li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 20px; height: 20px; border: var(--line) solid var(--ink); border-radius: 50%;
  font-size: 11px; display: grid; place-items: center; background: var(--sheet);
}
.path li:not(:last-child)::after { content: ''; position: absolute; left: 10px; top: 21px; bottom: 1px; width: var(--line); background: var(--hair); }
.path li span { display: block; color: var(--ink-3); font-size: 13px; }

/* ---------- laboratory ---------- */
.lab { border-top: var(--line) solid var(--rule); }
.proj { display: grid; grid-template-columns: 150px 1fr; gap: 20px; padding: 22px 0; border-bottom: var(--line) solid var(--hair); }
.proj .tag { font-size: 13px; color: var(--ink-3); }
.proj .tag b { display: block; color: var(--accent); font-weight: 500; letter-spacing: .1em; font-size: 12px; text-transform: uppercase; }
.proj h4 { font-size: 22px; font-weight: 400; margin: 0 0 6px; }
.proj dl { margin: 8px 0 0; display: grid; grid-template-columns: 90px 1fr; gap: 4px 14px; font-size: 15px; }
.proj dt { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); padding-top: 3px; }
.proj dd { margin: 0; }

/* ==========================================================================
   PERSONAL-SIDE FURNITURE
   ========================================================================== */

/* contents by form: Literature / Poetry / Art / Music */
.forms { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
.form { padding: 16px 0 10px; border-top: var(--line) solid var(--rule); scroll-margin-top: 10px; }
.form h3 { margin: 2px 0 10px !important; font-weight: 300 !important; font-size: 26px !important; }
.form ol { list-style: none; margin: 0; padding: 0; }
.form li { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 5px 0; border-bottom: var(--line) solid var(--hair); font-size: 16px; }
.form li i { color: var(--ink); }
.form li span { color: var(--ink-3); font-size: 13px; }

/* the gallery: empty framed plates waiting for work */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px 22px; }
.gallery .frame {
  aspect-ratio: 3 / 4; border: var(--line) solid var(--rule); outline: var(--mat) solid var(--wash); outline-offset: calc(-1 * var(--line));
  display: grid; place-items: center; color: var(--ink-3); font-size: 13px; letter-spacing: .18em;
  background:
    linear-gradient(135deg, transparent 49.6%, var(--hair) 49.8%, var(--hair) 50.2%, transparent 50.4%),
    linear-gradient(45deg,  transparent 49.6%, var(--hair) 49.8%, var(--hair) 50.2%, transparent 50.4%),
    var(--wash);
}
.gallery .frame.wide { aspect-ratio: 4 / 3; }
.gallery .frame.tall { grid-row: span 2; aspect-ratio: auto; }
.gallery .frame span { background: var(--wash); padding: 2px 8px; }

/* the specimen poem, with line numbers and glosses */
.verse { margin: 26px 0; padding: 26px 0; border-top: var(--line) solid var(--hair); border-bottom: var(--line) solid var(--hair); }
.verse .ttl { text-align: center; font-size: 24px; font-weight: 300; margin-bottom: 4px; }
.verse .by  { text-align: center; color: var(--ink-3); font-size: 14px; margin-bottom: 22px; letter-spacing: .1em; }
.verse ol { list-style: none; margin: 0 auto; padding: 0; max-width: 470px; counter-reset: ln; }
.verse li { counter-increment: ln; position: relative; line-height: 1.85; font-size: 18px; }
.verse li.stanza { margin-top: 1.1em; }
.verse li:nth-child(5n)::before {
  content: counter(ln); position: absolute; left: -46px; width: 30px; text-align: right; font-size: 12px; color: var(--ink-3);
}
.verse sup { color: var(--accent); font-size: 11px; margin-left: 2px; }
.glosses { counter-reset: none; margin: 0; padding: 0; list-style: none; font-size: 15px; }
.glosses li { display: grid; grid-template-columns: 60px 1fr; gap: 10px; padding: 6px 0; border-bottom: var(--line) solid var(--hair); }
.glosses li b { color: var(--accent); font-weight: 500; font-size: 13px; letter-spacing: .06em; }

/* ---------- about & colophon ---------- */
.about { display: grid; grid-template-columns: 1fr 200px; gap: 30px; align-items: start; }
.colophon { font-size: 14px; color: var(--ink-3); margin-top: 50px; padding-top: 14px; border-top: var(--line) solid var(--hair); }

footer.end {
  background: #ffffff; color: var(--ink-3); border-top: var(--line) solid var(--hair);   /* white on both sides */
  text-align: center; padding: 22px 16px; font-size: 13px; letter-spacing: .14em;
}
footer.end a { color: var(--ink-2); border-bottom: 0; }
footer.end a:hover { color: var(--accent); }

.menu-btn, .spine-end, .index-close, .scrim { display: none; }
.masthead:not(:has(*)) { padding: 0; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1180px) {
  .main { grid-template-columns: var(--index-w) 1px minmax(0, 1fr); }
  .main > .divider:nth-of-type(2), .right { display: none; }
}

/* ==========================================================================
   PERSONAL LAYOUT
   The General side reads like a textbook: index | text | margin.
   The Personal side reads like an exhibition catalogue: one centred column,
   the index turned into a horizontal menu, no margin, centred headings,
   tiles for the four forms and a masonry gallery.
   ========================================================================== */
#personal.main { grid-template-columns: 1fr; }
#personal > .divider, #personal > .right { display: none; }

#personal .index {
  position: sticky; top: 0; z-index: 10; height: auto; overflow: visible;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0 6px;
  padding: 0 16px; background: var(--sheet); border-bottom: var(--line) solid var(--hair);
}
#personal .index-head { padding: 14px 18px; }
#personal .index-head:not(:has(*)) { display: none; }
#personal .index .dash { display: none; }
#personal .index-item {
  width: auto; padding: 16px 16px 14px; font-size: 13px; letter-spacing: .2em; text-transform: uppercase;
  border-bottom: var(--line-mark) solid transparent;
}
#personal .index-item .num { display: none; }
#personal .index-item:hover, #personal .index-item.active { color: var(--accent); border-bottom-color: var(--accent); }
#personal .index-foot { display: contents; }
#personal .index-foot br { display: none; }
#personal .index-foot a {
  border: 0; padding: 16px 16px 14px; font-size: 13px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3);
}
#personal .index-foot a:hover { color: var(--accent); }

#personal .content { padding: 0 32px 100px; }
#personal .column { max-width: 760px; }
#personal .masthead { padding: 80px 0 30px; }
#personal .masthead h1 { font-size: clamp(40px, 7vw, 72px); }

#personal .section { padding-top: 80px; }
#personal .section > header { border-top: 0; padding-top: 0; margin-bottom: 30px; text-align: center; }
#personal .section > header::before {
  content: ''; display: block; width: 40px; height: var(--line-mark); background: var(--accent); margin: 0 auto 22px;
}
#personal .section h2 { font-size: 44px; letter-spacing: .01em; }

#personal .forms { grid-template-columns: 1fr 1fr; gap: 18px; }
#personal .form {
  border: var(--line) solid var(--hair); border-top: var(--line-mark) solid var(--accent); padding: 22px 24px 18px; background: var(--sheet);
}
#personal .form h3 { text-align: center; font-size: 30px !important; margin: 0 0 12px !important; }
#personal .form li { border-bottom-color: var(--hair); }

#personal .gallery { display: block; columns: 3 220px; column-gap: 20px; }
#personal .gallery > * { break-inside: avoid; margin: 0 0 20px; }



/* ==========================================================================
   3D MODELS (js/stl-viewer.js)
   <figure class="model"><stl-viewer src="…stl"></stl-viewer><figcaption>…</figcaption></figure>
   ========================================================================== */
stl-viewer { display: block; max-width: 100%; --model-color: #e9e5dc; }
/* The frame's size comes only from its width and aspect ratio. The canvas is
   pinned inside it, so the 3D drawing can never push the page taller. */
.stl-stage {
  position: relative; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; contain: layout paint;
  background: radial-gradient(circle at 50% 38%, #ffffff 0%, var(--wash) 75%);
  border: var(--line) solid var(--hair);
}
@supports not (aspect-ratio: 1 / 1) {
  .stl-stage::before { content: ''; display: block; padding-top: 75%; }
  .sculptures .stl-stage::before { padding-top: 100%; }
}
.stl-stage canvas {
  position: absolute; inset: 0; display: block; width: 100% !important; height: 100% !important;
  touch-action: pan-y;               /* a vertical swipe still scrolls the page on phones */
  cursor: grab; opacity: 0; transition: opacity .4s;
}
.stl-stage canvas.grabbing { cursor: grabbing; }
.stl-stage.ready canvas { opacity: 1; }
.stl-status {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px;
  color: var(--ink-3); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; pointer-events: none; text-align: center; padding: 16px;
}
.stl-stage.ready .stl-status { display: none; }
.stl-progress { display: block; width: 120px; height: var(--line); background: var(--hair); }
.stl-progress b { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.stl-stage.failed .stl-progress { display: none; }
/* small icon controls tucked into the frame's corner; faint until you reach for them */
.stl-tools {
  position: absolute; right: 8px; bottom: 8px; display: flex; gap: 2px;
  opacity: .35; transition: opacity .2s;
}
.stl-stage:hover .stl-tools, .stl-tools:focus-within, .stl-tools .on { opacity: 1; }
.stl-stage:not(.ready) .stl-tools { display: none; }
.stl-tools button {
  width: 26px; height: 26px; display: grid; place-items: center; padding: 0; cursor: pointer;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink-2);
}
.stl-tools button:hover, .stl-tools button.on { background: rgba(255,255,255,.85); color: var(--accent); }
.stl-tools svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }

/* the lighting panel */
.stl-light {
  position: absolute; right: 8px; bottom: 40px; width: 200px; margin: 0;
  display: grid; gap: 6px; padding: 10px 12px 10px;
  background: rgba(255,255,255,.94); border: var(--line) solid var(--hair);
  font-size: 11px; color: var(--ink-2); box-shadow: 0 6px 24px rgba(0,0,0,.06);
}
.stl-light[hidden] { display: none; }
.stl-light label { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 8px; }
.stl-light input[type=range] { width: 100%; accent-color: var(--accent); height: 14px; margin: 0; }
.stl-light input[type=color] { width: 100%; height: 18px; padding: 0; border: var(--line) solid var(--hair); background: none; }
.stl-presets { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 2px; }
.stl-presets button, .stl-light-reset {
  border: var(--line) solid var(--hair); background: #fff; color: var(--ink-2); cursor: pointer;
  font-size: 10px; letter-spacing: .04em; padding: 2px 6px;
}
.stl-presets button:hover, .stl-light-reset:hover { border-color: var(--accent); color: var(--accent); }
.stl-light-reset { justify-self: start; margin-top: 2px; }
/* full screen, or "expanded" to fill the window where full screen isn't allowed (iPhone) */
stl-viewer:fullscreen, stl-viewer.stl-expanded {
  background: #ffffff; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
stl-viewer.stl-expanded { position: fixed; inset: 0; z-index: 1000; }
stl-viewer:fullscreen .stl-stage, stl-viewer.stl-expanded .stl-stage { aspect-ratio: auto; flex: 1; height: auto; }
stl-viewer:fullscreen .stl-stage::before, stl-viewer.stl-expanded .stl-stage::before { display: none; }
stl-viewer:fullscreen canvas, stl-viewer.stl-expanded canvas { touch-action: none; }
html.stl-lock, html.stl-lock body { overflow: hidden; }

/* touch screens have no hover: keep the corner icons readable and easy to hit */
@media (hover: none) {
  .stl-tools { opacity: .8; }
  .stl-tools button { width: 34px; height: 34px; background: rgba(255,255,255,.7); }
  .stl-tools svg { width: 16px; height: 16px; }
  .stl-light { bottom: 50px; }
}
@media (max-width: 520px) {
  .stl-light { left: 8px; right: 8px; width: auto; max-height: calc(100% - 66px); overflow: auto; }
}

/* before the script runs (and inside the editor): a labelled placeholder */
stl-viewer:not(:defined) {
  display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--wash);
  border: var(--line) dashed var(--ink-3); color: var(--ink-3); font-size: 12px; letter-spacing: .12em; text-align: center; padding: 16px;
}
stl-viewer:not(:defined)::before { content: '3D model \2014  ' attr(src); }

figure.model { margin: 22px 0; }
.sculptures figure.model { margin: 0; }
figure.model figcaption { text-align: center; }

/* the Sculptures section: models side by side, square stages */
.sculptures { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 28px 24px; }
.sculptures .stl-stage, .sculptures stl-viewer:not(:defined) { aspect-ratio: 1 / 1; }
.sculptures figcaption { font-size: 16px; color: var(--ink); letter-spacing: .02em; margin-top: 12px; }

/* ==========================================================================
   PHONES (820px and narrower)
   One sticky bar on top: index button | General / Personal | (balance).
   General: the index slides in from the left over a dimmed page.
   Personal: its menu sits under the bar as a swipeable row.
   ========================================================================== */
@media (max-width: 820px) {
  :root { --bar-h: 50px; }
  body { font-size: 17px; line-height: 1.6; }

  /* the bar */
  .spine {
    position: sticky; top: 0; z-index: 40; height: var(--bar-h);
    display: grid; grid-template-columns: var(--bar-h) 1fr var(--bar-h); align-items: stretch;
  }
  .spine-tabs { justify-content: center; }
  .spine [role="tab"] { font-size: 16px; padding: 0 18px; align-items: center; }
  .spine .sep { margin: 14px 0; }
  .spine-end { display: block; }
  .menu-btn {
    display: grid; place-items: center; width: var(--bar-h); height: var(--bar-h); padding: 0;
    border: 0; background: none; color: var(--ink); cursor: pointer;
  }
  .menu-btn span, .menu-btn span::before, .menu-btn span::after {
    display: block; width: 18px; height: var(--line); background: currentColor; position: relative; content: '';
  }
  .menu-btn span::before { position: absolute; top: -6px; }
  .menu-btn span::after { position: absolute; top: 6px; }
  body[data-side="personal"] .menu-btn { visibility: hidden; }

  /* one column */
  .main { grid-template-columns: 1fr; min-height: 0; }
  .main > .divider, .right { display: none; }
  .content { padding: 0 20px 56px; }
  .column { max-width: none; }

  /* General: the index drawer */
  #general .index {
    position: fixed; top: 0; bottom: 0; left: 0; height: auto; width: min(84vw, 320px); z-index: 60;
    padding: 18px 0 32px; transform: translateX(-104%); transition: transform .25s ease;
    border-right: var(--line) solid var(--hair); overflow-y: auto;
  }
  #general .index.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.12); }
  .index-close {
    display: block; position: absolute; top: 8px; right: 8px; width: 40px; height: 40px;
    border: 0; background: none; font-size: 26px; line-height: 1; color: var(--ink-2); cursor: pointer;
  }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 55; background: rgba(9, 15, 11, .32);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .scrim.on { opacity: 1; pointer-events: auto; }
  html.drawer-open, html.drawer-open body { overflow: hidden; }

  /* General: text and blocks */
  .section { padding-top: 36px; scroll-margin-top: calc(var(--bar-h) + 10px); }
  .section > header { margin-bottom: 14px; }
  .section h2 { font-size: 28px; }
  .section h3 { font-size: 19px; margin-top: 24px; }
  .lede { font-size: 18px; }
  .masthead { padding: 32px 0 20px; }
  .masthead:not(:has(*)) { padding: 0; }
  .masthead h1 { font-size: 34px; }
  .masthead .subtitle { font-size: 17px; }
  .frontis, .about, .conventions, .paths, .readers { grid-template-columns: 1fr; }
  .readers > a + a { border-left: 0; border-top: var(--line) solid var(--rule); }
  .frontis .plate { max-width: 300px; margin: 0 auto; }
  .about .plate { max-width: 240px; }
  .proj { grid-template-columns: 1fr; gap: 6px; }
  .toc > li { scroll-margin-top: calc(var(--bar-h) + 10px); }
  .toc .ch { grid-template-columns: 40px 1fr; }
  .toc .abs, .toc .meta, .toc ol.secs { margin-left: 0; }
  .toc ol.secs { columns: 1; }
  .env { padding: 12px 14px 4px; }
  .verse ol { padding-left: 28px; }
  .verse li:nth-child(5n)::before { left: -30px; }
  figure.plate[style*="float"] { float: none !important; width: auto !important; margin: 20px 0 !important; }

  /* Personal: the menu row under the bar */
  #personal .index {
    position: sticky; top: var(--bar-h); z-index: 30; height: auto; width: auto; transform: none;
    flex-wrap: nowrap; justify-content: flex-start; gap: 0; padding: 0 10px;
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 28px), transparent);
            mask-image: linear-gradient(to right, transparent 0, #000 14px, #000 calc(100% - 28px), transparent);
  }
  #personal .index::-webkit-scrollbar { display: none; }
  #personal .index-item, #personal .index-foot a {
    flex: none; white-space: nowrap; scroll-snap-align: start;
    padding: 14px 11px 12px; font-size: 11px; letter-spacing: .16em;
  }
  #personal .content { padding: 0 20px 56px; }
  #personal .masthead { padding: 36px 0 8px; }
  #personal .masthead:not(:has(*)) { padding: 0; }
  #personal .section { padding-top: 48px; scroll-margin-top: calc(var(--bar-h) + 52px); }
  #personal .form { scroll-margin-top: calc(var(--bar-h) + 52px); }
  #personal .section > header { margin-bottom: 20px; }
  #personal .section > header::before { margin-bottom: 16px; }
  #personal .section h2 { font-size: 30px; }
  #personal .forms { grid-template-columns: 1fr 1fr; gap: 10px; }
  #personal .form { padding: 14px 12px 10px; }
  #personal .form h3 { font-size: 20px !important; margin-bottom: 6px !important; }
  #personal .form li { font-size: 14px; }
  #personal .gallery { columns: 2 140px; column-gap: 12px; }
  #personal .gallery > * { margin-bottom: 12px; }
  .sculptures { grid-template-columns: 1fr; gap: 32px; }

  footer.end { padding: 18px 16px 22px; }
}
