/* co-ambient-spectrum.css — the m·lab folio, re-skinned in the "Saint" cosmic
   theme (deep navy · teal · gold; Saint display / Rajdhani labels / Space
   Grotesk body). Saint + Bergamasco are display-only per house rules; body
   copy is Space Grotesk, labels are Rajdhani. */

@font-face {
  font-family: 'Saint';
  src: url('fonts/custom/saint.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:       #080f1a;
  --surface:  #0d1a2a;
  --panel:    rgba(13, 26, 42, 0.55);
  --teal:     #7dd3e8;
  --teal-dim: #3a8fa8;
  --gold:     #efd146;
  --silver:   #c8d8e8;
  --white:    #eef5fa;
  --muted:    #5a7a90;
  --line:     rgba(125, 211, 232, 0.16);
  --line-soft:rgba(125, 211, 232, 0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--silver);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 300;
  font-size: 16px;
  line-height: 1.75;
  overflow-x: hidden;
}

/* ── grid overlay ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(125,211,232,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125,211,232,.035) 1px, transparent 1px);
  background-size: 62px 62px;
  pointer-events: none;
  z-index: 1;
}

/* ── starfield canvas (drawn by JS) ── */
#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: block;
}

/* ── corner rune marks ── */
.corner { position: fixed; width: 34px; height: 34px; opacity: 0.35; z-index: 40; }
.corner::before, .corner::after { content: ''; position: absolute; background: var(--teal); }
.corner::before { width: 100%; height: 2px; top: 0; }
.corner::after  { width: 2px; height: 100%; top: 0; }
.corner.tl { top: 18px; left: 18px; }
.corner.tr { top: 18px; right: 18px; transform: scaleX(-1); }
.corner.bl { bottom: 18px; left: 18px; transform: scaleY(-1); }
.corner.br { bottom: 18px; right: 18px; transform: scale(-1); }
@keyframes flicker { 0%,100% { opacity: 0.30; } 50% { opacity: 0.5; } }
.corner { animation: flicker 3s ease-in-out infinite; }
.corner.tr { animation-delay: 0.8s; }
.corner.bl { animation-delay: 1.6s; }
.corner.br { animation-delay: 2.4s; }

/* ── header strip — folio identifier ── */
.folio-strip {
  position: fixed;
  top: 24px; left: 50%; transform: translateX(-50%);
  z-index: 50;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--teal-dim);
  white-space: nowrap;
  pointer-events: none;
}
.folio-strip .sep {
  display: inline-block;
  width: 16px; height: 1px;
  background: var(--teal-dim);
  vertical-align: middle;
  margin: 0 12px;
  opacity: 0.6;
}
.folio-strip .sw {
  display: inline-block;
  width: 6px; height: 6px;
  border: 1px solid var(--gold);
  transform: rotate(45deg);
  vertical-align: middle;
  margin: 0 8px;
}

/* ── circular seal, top-right ── */
.stamp {
  position: fixed;
  top: 84px; right: 52px;
  z-index: 6;
  width: 128px; height: 128px;
  transform: rotate(-9deg);
  pointer-events: none;
}
.stamp .ring, .stamp .ring2 {
  position: absolute; inset: 0;
  border: 1.5px solid var(--teal-dim);
  border-radius: 50%;
  opacity: 0.75;
  box-shadow: 0 0 22px rgba(125,211,232,.12);
}
.stamp .ring2 { inset: 8px; border-width: 1px; opacity: 0.5; }
.stamp .ink {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--teal-dim);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 500;
  font-size: 9px;
  letter-spacing: 0.22em;
  text-align: center;
  line-height: 1.35;
  text-transform: uppercase;
}
.stamp .ink b {
  display: block;
  font-family: 'Saint', Georgia, serif;
  font-size: 25px;
  letter-spacing: 0.05em;
  margin: 4px 0 6px;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(239,209,70,.3);
}

/* ── page container ── */
.page {
  position: relative;
  z-index: 4;
  max-width: 920px;
  margin: 96px auto 60px;
  padding: 52px 60px 68px;
  /* near-opaque reading surface: keeps the starfield in the margins but off
     the text, so the type sits on a clean ground (no blurred-grid banding) */
  background: linear-gradient(180deg, rgba(11,20,34,0.93) 0%, rgba(8,15,26,0.95) 100%);
  border: 1px solid var(--line);
  box-shadow:
    0 0 70px -12px rgba(125,211,232,.07),
    0 40px 120px -50px rgba(0,0,0,.85);
}

/* ── eyebrow ── */
.eyebrow {
  text-align: center;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--teal-dim);
  margin-bottom: 24px;
}
.eyebrow .dot { color: var(--gold); margin: 0 6px; }
.eyebrow b { color: var(--silver); font-weight: 600; }
.eyebrow a {
  color: var(--teal);
  text-decoration: none;
  border-bottom: 1px solid var(--teal-dim);
}
.eyebrow a:hover { color: var(--white); border-color: var(--teal); }

/* ── title block ── */
.title-block {
  text-align: center;
  padding: 6px 0 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.title-genus {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--teal-dim);
  margin-bottom: 14px;
}
.title-main {
  font-family: 'Saint', Georgia, serif;
  font-size: clamp(2.8rem, 8vw, 5.6rem);
  line-height: 0.98;
  letter-spacing: 0.04em;
  color: var(--teal);
  text-transform: uppercase;
  margin: 8px 0 10px;
  text-shadow: 0 0 60px rgba(125,211,232,.28), 0 0 120px rgba(125,211,232,.12);
  animation: pulse-glow 4s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%,100% { text-shadow: 0 0 60px rgba(125,211,232,.25), 0 0 120px rgba(125,211,232,.10); }
  50%     { text-shadow: 0 0 84px rgba(125,211,232,.42), 0 0 160px rgba(125,211,232,.18); }
}
.title-main .amp { color: var(--gold); }
.title-tag {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 300;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 640px;
  margin: 16px auto 0;
  line-height: 1.55;
}
.title-meta {
  margin-top: 20px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--teal-dim);
}
.title-meta .pipe { color: var(--gold); margin: 0 8px; }

/* ── two-column layout ── */
.layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 44px;
  margin-top: 40px;
}

/* ── sidebar (TOC + meta) ── */
.toc {
  position: sticky;
  top: 88px;
  align-self: start;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 16px 0 18px;
}
.toc h3 {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--teal-dim);
  margin-bottom: 12px;
}
.toc ol { list-style: none; counter-reset: tocc; font-size: 14px; }
.toc li {
  counter-increment: tocc;
  padding: 4px 0;
  border-bottom: 1px dotted var(--line-soft);
}
.toc li:last-child { border-bottom: none; }
.toc li::before {
  content: "§ " counter(tocc, decimal-leading-zero) "  ";
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.06em;
}
.toc a { color: var(--silver); text-decoration: none; }
.toc a:hover { color: var(--teal); }

.toc-meta {
  margin-top: 24px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.9;
}
.toc-meta .k { color: var(--teal); margin-right: 8px; }
.toc-meta .row { display: block; }

.toc-mascot {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.toc-mascot .seal {
  width: 58px; height: 58px;
  border: 1.5px solid var(--teal-dim);
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--teal);
  font-size: 24px;
  transform: rotate(-6deg);
  text-shadow: 0 0 20px rgba(125,211,232,.5);
}
.toc-mascot .seal-label {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 500;
  font-size: 9px;
  letter-spacing: 0.32em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ── article body ── */
article > section { margin-bottom: 48px; scroll-margin-top: 64px; }

article h2 {
  font-family: 'Saint', Georgia, serif;
  font-size: 2rem;
  color: var(--teal);
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 18px;
  counter-increment: section;
  text-shadow: 0 0 30px rgba(125,211,232,.18);
}
article h2::before {
  content: "§ " counter(section, decimal-leading-zero) " · ";
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.18em;
  color: var(--gold);
  vertical-align: middle;
}
article h3 {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--silver);
  margin: 24px 0 8px;
}
article { counter-reset: section; }
article p { margin-bottom: 15px; text-align: justify; hyphens: auto; }
article p + p { text-indent: 1.4em; }

/* drop-letter on the first paragraph only */
article section#idea p:first-of-type::first-letter {
  font-family: 'Saint', Georgia, serif;
  font-size: 4.4em;
  line-height: 0.86;
  float: left;
  padding: 8px 12px 0 0;
  color: var(--gold);
  text-shadow: 0 0 34px rgba(239,209,70,.35);
}

article a {
  color: var(--teal);
  text-decoration: none;
  border-bottom: 1px solid var(--teal-dim);
}
article a:hover { border-color: var(--teal); color: var(--white); }
article em { font-style: italic; color: var(--white); }
article strong { font-weight: 500; color: var(--white); }

/* ── definition / theorem / remark boxes ──
   house rule: no half-painted single-edge borders. Full hairline border on
   all four sides + subtle accent tint; the bucket colour lives in the label. */
.box {
  margin: 20px 0 24px;
  padding: 18px 22px 16px;
  background: rgba(125, 211, 232, 0.05);
  border: 1px solid rgba(125, 211, 232, 0.22);
}
.box .box-label {
  display: inline-block;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 10px;
}
.box .box-num { color: var(--muted); margin-left: 8px; }
.box p { text-indent: 0 !important; }

.box.thm {
  background: rgba(239, 209, 70, 0.06);
  border-color: rgba(239, 209, 70, 0.28);
}
.box.thm .box-label { color: var(--gold); }

.box.rmk {
  background: rgba(200, 216, 232, 0.04);
  border-color: rgba(200, 216, 232, 0.16);
  font-style: italic;
}
.box.rmk .box-label { color: var(--silver); font-style: normal; }

/* MathJax on a dark ground */
.MathJax, .MathJax_Display, .MathJax_Preview { color: var(--white) !important; }
.MathJax_Display { margin: 16px 0 !important; }

/* ── diagram ── */
.diagram { margin: 26px auto; text-align: center; }
.diagram svg { max-width: 100%; height: auto; }
.diagram .caption {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 12px;
}
.diagram .caption .num { color: var(--gold); }

/* ── examples list ── */
.examples { list-style: none; counter-reset: ex; margin: 10px 0 0; }
.examples li {
  counter-increment: ex;
  position: relative;
  padding: 12px 0 12px 58px;
  border-bottom: 1px dotted var(--line-soft);
}
.examples li:last-child { border-bottom: none; }
.examples li::before {
  content: counter(ex, decimal-leading-zero);
  position: absolute;
  left: 0; top: 14px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--gold);
  width: 44px;
  border-right: 1px solid var(--teal-dim);
  padding-right: 8px;
  text-align: right;
}
.examples li b {
  display: block;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 1rem;
  color: var(--teal);
  margin-bottom: 4px;
}

/* ── related list ── */
.related { margin-left: 1.4em; margin-top: 8px; }
.related li { margin-bottom: 4px; }

/* ── references ── */
.refs { list-style: none; counter-reset: ref; font-size: 14px; line-height: 1.6; }
.refs li { counter-increment: ref; padding: 7px 0 7px 40px; position: relative; }
.refs li::before {
  content: "[" counter(ref) "]";
  position: absolute;
  left: 0; top: 7px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 12px;
  color: var(--gold);
}

/* ── colophon ── */
.colophon {
  margin-top: 56px;
  padding: 26px 28px;
  border: 1px dashed var(--teal-dim);
  background:
    repeating-linear-gradient(45deg, transparent 0 8px, rgba(125,211,232,.03) 8px 9px);
  text-align: center;
}
.colophon .col-eyebrow {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}
.colophon p {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 300;
  font-style: italic;
  color: var(--silver);
  line-height: 1.7;
  text-indent: 0;
  text-align: center;
}
.colophon a {
  color: var(--teal);
  border-bottom: 1px solid var(--teal-dim);
  text-decoration: none;
  font-style: normal;
}
.colophon a:hover { color: var(--white); border-color: var(--teal); }
.colophon .col-line { width: 60px; height: 1px; background: var(--teal-dim); margin: 14px auto; opacity: 0.6; }
.colophon .col-ps {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 300;
  font-style: normal;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 4px;
}
.colophon .col-ps .ps-k {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--gold);
  margin-right: 6px;
}

/* ── end rule ── */
.end-rule {
  text-align: center;
  margin-top: 32px;
  color: var(--teal-dim);
  font-size: 16px;
  letter-spacing: 0.6em;
}

/* ── smaller screens ── */
@media (max-width: 820px) {
  .stamp { width: 92px; height: 92px; top: 56px; right: 22px; }
  .stamp .ink b { font-size: 16px; }
  .page { margin: 76px 12px 30px; padding: 34px 20px 48px; }
  .layout { grid-template-columns: 1fr; gap: 26px; }
  .toc { position: static; }
  article section#idea p:first-of-type::first-letter { font-size: 3.4em; }
}
