/* ────────────────────────────────────────────────────────────────────────
   FRAGMENTUM ⋅ STYLE SYSTEM
   A research report rendered in HTML.
   ──────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght,SOFT,WONK@0,9..144,300..900,30..100,0..1;1,9..144,300..900,30..100,0..1&family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* INK ⋅ paper */
  --ink-0: #06080F;
  --ink-1: #0C1120;
  --ink-2: #111827;
  --ink-3: #1E2A45;
  --ink-4: #2D3A55;
  --paper:    #E8EDF5;
  --paper-2:  #B8C2D0;
  --paper-3:  #8892A4;
  --paper-4:  #4E617A;
  --paper-5:  #2D3A55;

  /* SIGNAL ⋅ a constrained, intentional palette */
  --duck:    #FFD93D;     /* primary accent, emphasis, mark, drop-cap */
  --duck-2:  #FFB700;
  --signal:  #00C9A7;     /* live, active, pass */
  --accent:  #00C9A7;     /* teal accent (alias of signal) */
  --primary: #5B7CF7;     /* cool secondary */
  --purple:  #A78BFA;
  --pink:    #F472B6;
  --cyan:    #38BDF8;
  --warn:    #F59E0B;
  --alert:   #F87171;

  /* TYPE */
  --display: 'Fraunces', 'Times New Roman', Georgia, serif;
  --body:    'IBM Plex Sans', system-ui, sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, 'Courier New', monospace;

  /* MEASURE */
  --measure: 64ch;
  --gutter:  2.5rem;
  --margin:  4rem;

  /* RHYTHM */
  --baseline: 1.5rem;
}

html {
  background: var(--ink-0);
  color: var(--paper);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  font-feature-settings: "ss01", "ss02", "kern", "liga";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(91,124,247,.08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(0,201,167,.06), transparent 60%),
    var(--ink-0);
  background-attachment: fixed;
}

::selection { background: var(--duck); color: var(--ink-0); }

/* ────────── TYPOGRAPHY ────────── */

.h-display {
  font-family: var(--display);
  font-weight: 400;
  font-variation-settings: "opsz" 144, "SOFT" 30, "WONK" 1;
  font-size: clamp(3.5rem, 9vw, 8.5rem);
  line-height: .92;
  letter-spacing: -0.035em;
  font-style: italic;
  color: var(--paper);
}

.h-display em {
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  color: var(--accent);
  -webkit-text-fill-color: var(--accent);
}

h1, .h1 {
  font-family: var(--display);
  font-weight: 400;
  font-variation-settings: "opsz" 144, "SOFT" 60, "WONK" 0;
  font-size: clamp(2.5rem, 5vw, 4.25rem);
  line-height: .98;
  letter-spacing: -0.025em;
  color: var(--paper);
}

h2, .h2 {
  font-family: var(--display);
  font-weight: 400;
  font-variation-settings: "opsz" 100, "SOFT" 50;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--paper);
}

h3 {
  font-family: var(--display);
  font-weight: 500;
  font-variation-settings: "opsz" 60, "SOFT" 40;
  font-size: 1.4rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h4 {
  font-family: var(--mono);
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-3);
}

p {
  font-size: 1.05rem;
  line-height: 1.65;
  max-width: var(--measure);
  color: var(--paper-2);
}

p + p { margin-top: 1.25rem; }

p.lede {
  font-family: var(--display);
  font-weight: 300;
  font-variation-settings: "opsz" 32, "SOFT" 50;
  font-size: clamp(1.3rem, 1.8vw, 1.65rem);
  line-height: 1.4;
  letter-spacing: -0.005em;
  color: var(--paper);
  font-style: italic;
}

/* Drop cap */
.drop-cap::first-letter {
  font-family: var(--display);
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  float: left;
  font-size: 4.6rem;
  line-height: .85;
  padding: .35rem .55rem .25rem 0;
  color: var(--primary);
}

/* Inline accents */
em { font-style: italic; color: var(--paper); }
strong { font-weight: 600; color: var(--paper); }
mark { background: rgba(255,217,61,.15); color: var(--duck); padding: 0 .2em; border-radius: 2px; }
code, .mono {
  font-family: var(--mono);
  font-size: .92em;
  font-weight: 500;
  color: var(--signal);
  background: rgba(0,201,167,.06);
  padding: .08em .35em;
  border-radius: 3px;
  letter-spacing: -0.01em;
}

a { color: var(--primary); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; transition: color .12s; }
a:hover { color: #7B9FFF; text-decoration-thickness: 2px; }

hr {
  border: none;
  border-top: 1px solid var(--ink-3);
  margin: 3rem 0;
}

hr.thick { border-top: 2px solid var(--paper-5); }
hr.dashed { border-top: 1px dashed var(--ink-3); }
hr.double { border: none; height: 5px; border-top: 1px solid var(--ink-3); border-bottom: 1px solid var(--ink-3); }

/* ────────── PAGE FRAME ────────── */

.frame {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--margin);
}

@media (max-width: 900px) { .frame { padding: 0 1.5rem; } }

/* The masthead, every page wears this hat */
.masthead {
  border-bottom: 2px solid var(--paper-5);
  padding: 1.5rem 0 .9rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2rem;
  align-items: end;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--paper-3);
}

.masthead .brand {
  display: flex;
  align-items: center;
  gap: .8rem;
  font-family: var(--display);
  font-style: italic;
  font-variation-settings: "opsz" 60, "SOFT" 80, "WONK" 1;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  text-transform: none;
  color: var(--paper);
  text-decoration: none;
}

.masthead .brand img { width: 36px; height: 36px; border-radius: 8px; }

.masthead .colophon { text-align: center; line-height: 1.4; }
.masthead .issue    { text-align: right; line-height: 1.4; }

.masthead .colophon span,
.masthead .issue span { color: var(--paper); }

/* Chapter strip, running header */
.chapter-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 2rem;
  align-items: center;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-4);
  padding: .8rem 0;
  border-bottom: 1px solid var(--ink-3);
}

.chapter-strip .nav-list {
  display: flex;
  gap: 1.5rem;
  justify-content: flex-end;
  list-style: none;
}

.chapter-strip a {
  color: var(--paper-3);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: color .15s, border-color .15s;
}

.chapter-strip a:hover { color: var(--primary); border-color: var(--primary); }
.chapter-strip a.current { color: var(--accent); border-color: var(--accent); }

.chapter-strip .center {
  font-family: var(--display);
  font-style: italic;
  font-variation-settings: "opsz" 40, "SOFT" 60;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  color: var(--paper);
  text-transform: none;
}

/* Section markers ⋅ §0.0 numbering throughout */
.sec-num {
  font-family: var(--mono);
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-4);
  display: block;
  margin-bottom: .5rem;
}

.sec-num.duck { color: var(--primary); }

/* ────────── LAYOUT GRIDS ────────── */

/* Editorial grid: marginalia rail + main body */
.editorial {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  gap: 3rem;
  margin: 6rem 0;
}

.editorial .marg {
  font-family: var(--mono);
  font-size: .72rem;
  line-height: 1.55;
  color: var(--paper-3);
  letter-spacing: 0.04em;
  border-right: 1px solid var(--ink-3);
  padding-right: 1.5rem;
  text-align: right;
}

.editorial .marg .label {
  display: block;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-4);
  margin-bottom: .3rem;
}

.editorial .marg .label.duck { color: var(--primary); }

@media (max-width: 900px) {
  .editorial { grid-template-columns: 1fr; gap: 1.5rem; }
  .editorial .marg { border-right: none; border-left: 2px solid var(--primary); padding: 0 0 0 1rem; text-align: left; }
}

/* Asymmetric two-column */
.split {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 4rem;
  align-items: start;
}
@media (max-width: 900px) { .split { grid-template-columns: 1fr; gap: 2rem; } }

/* 12-col flex */
.cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.cols-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
@media (max-width: 900px) { .cols-3, .cols-4 { grid-template-columns: 1fr; } }

/* ────────── COMPONENTS ────────── */

/* Tag / badge */
.tag {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: .25rem .55rem;
  border: 1px solid currentColor;
  border-radius: 2px;
  color: var(--paper-3);
}

.tag.duck   { color: var(--accent); }
.tag.signal { color: var(--signal); }
.tag.warn   { color: var(--warn); }
.tag.alert  { color: var(--alert); }

.tag::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.tag.no-dot::before { display: none; }

/* Buttons, text-link first, ornament second */
.btn {
  display: inline-flex;
  align-items: baseline;
  gap: .6rem;
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  padding: .9rem 1.4rem;
  border: 1px solid var(--paper-4);
  color: var(--paper);
  background: transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}

.btn:hover { background: var(--primary); color: var(--paper); border-color: var(--primary); text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(91,124,247,.35); }

.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: #7B9FFF; color: #fff; border-color: #7B9FFF; box-shadow: 0 10px 30px rgba(91,124,247,.5); }

.btn.accent { background: var(--accent); color: var(--ink-0); border-color: var(--accent); }
.btn.accent:hover { background: #00e0ba; color: var(--ink-0); border-color: #00e0ba; box-shadow: 0 10px 30px rgba(0,201,167,.4); }

.btn .arrow { font-family: var(--mono); font-size: 1em; transform: translateY(1px); }

/* Hairline horizontal "divider with eyebrow" */
.section-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem;
  align-items: end;
  border-bottom: 1px solid var(--ink-3);
  padding-bottom: 1rem;
  margin-bottom: 2.5rem;
}
.section-head .num { font-family: var(--mono); font-size: .78rem; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--paper-4); }
.section-head .name { font-family: var(--display); font-style: italic; font-variation-settings: "opsz" 60, "SOFT" 60, "WONK" 1; font-size: 1.6rem; color: var(--paper); }

/* Index table, for tables of contents and data */
.idx-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: .9rem;
}

.idx-table th, .idx-table td {
  text-align: left;
  padding: .9rem 1rem .9rem 0;
  border-bottom: 1px solid var(--ink-3);
  vertical-align: top;
}

.idx-table th {
  font-size: .68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-4);
  font-weight: 600;
  border-bottom: 1px solid var(--paper-5);
  padding-bottom: .5rem;
}

.idx-table tr:hover td { color: var(--paper); }
.idx-table .num { color: var(--paper-4); width: 4rem; }
.idx-table .ref { color: var(--paper-3); width: 8rem; text-align: right; padding-right: 0; }
.idx-table .ref a { color: var(--primary); text-decoration: none; border-bottom: 1px dotted var(--paper-5); }
.idx-table .ref a:hover { color: #7B9FFF; border-color: var(--primary); }

.idx-table .lede-cell { font-family: var(--display); font-style: italic; font-variation-settings: "opsz" 32, "SOFT" 60; font-size: 1.05rem; color: var(--paper); }

/* Code/terminal block, used for ASCII diagrams and pseudocode */
.figure {
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.55;
  color: var(--paper-2);
  background: var(--ink-1);
  border: 1px solid var(--ink-3);
  border-left: 2px solid var(--primary);
  padding: 1.5rem 1.8rem;
  white-space: pre;
  overflow-x: auto;
  letter-spacing: -0.005em;
}

.figure .c-duck   { color: var(--duck); }
.figure .c-signal { color: var(--signal); }
.figure .c-blue   { color: var(--primary); }
.figure .c-purple { color: var(--purple); }
.figure .c-pink   { color: var(--pink); }
.figure .c-cyan   { color: var(--cyan); }
.figure .c-dim    { color: var(--paper-4); }
.figure .c-paper  { color: var(--paper); }

.figure .comment { color: var(--paper-4); font-style: italic; }

.fig-caption {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper-4);
  margin-top: .8rem;
  padding-left: .2rem;
}

.fig-caption span { color: var(--accent); }

/* Footnote system */
sup.fn {
  font-family: var(--mono);
  font-size: .65em;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  padding: 0 1px;
  vertical-align: super;
  line-height: 0;
}
sup.fn a { color: inherit; text-decoration: none; }
sup.fn a:hover { color: var(--duck); }
.footnotes ol li a { color: var(--primary); text-decoration: none; border-bottom: 1px dotted var(--paper-5); }
.footnotes ol li a:hover { color: var(--duck); border-color: var(--duck); }

.footnotes {
  border-top: 1px solid var(--paper-5);
  padding-top: 1.5rem;
  margin-top: 4rem;
}

.footnotes ol {
  list-style: none;
  counter-reset: fn-counter;
  display: grid;
  gap: .9rem;
}

.footnotes ol li {
  counter-increment: fn-counter;
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.55;
  color: var(--paper-3);
  padding-left: 2.5rem;
  position: relative;
}

.footnotes ol li::before {
  content: "[" counter(fn-counter) "]";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 600;
}

/* Pull quote, editorial drama */
.pullquote {
  font-family: var(--display);
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--paper);
  padding: 3rem 0;
  border-top: 1px solid var(--paper-5);
  border-bottom: 1px solid var(--paper-5);
  margin: 4rem 0;
  position: relative;
}

.pullquote::before {
  content: "“";
  position: absolute;
  left: -1.4rem;
  top: 1.5rem;
  color: var(--duck);
  font-size: 1.3em;
  line-height: 1;
}

.pullquote .attr {
  display: block;
  font-family: var(--mono);
  font-style: normal;
  font-variation-settings: normal;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-4);
  margin-top: 1.5rem;
}

/* Stat block, metrics with character */
.stat {
  border-top: 1px solid var(--paper-5);
  padding-top: 1.2rem;
}

.stat .num {
  font-family: var(--display);
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 30, "WONK" 1;
  font-size: clamp(3rem, 6vw, 5rem);
  line-height: .92;
  letter-spacing: -0.04em;
  color: var(--primary);
  -webkit-text-fill-color: var(--primary);
  display: block;
}

.stat .label {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper-3);
  margin-top: .8rem;
  display: block;
}

.stat .src {
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--paper-4);
  margin-top: .4rem;
  font-style: italic;
}

/* Inline tools list, for the protocol page */
.tool-row {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  gap: 1.2rem;
  padding: .9rem 0;
  border-bottom: 1px solid var(--ink-3);
  align-items: baseline;
}

.tool-row .idx { font-family: var(--mono); font-size: .72rem; color: var(--paper-4); letter-spacing: 0.1em; }
.tool-row .name { font-family: var(--mono); font-weight: 600; color: var(--paper); }
.tool-row .desc { font-family: var(--display); font-style: italic; font-variation-settings: "opsz" 32, "SOFT" 60; color: var(--paper-2); font-size: 1.02rem; line-height: 1.4; }
.tool-row .meta { font-family: var(--mono); font-size: .68rem; letter-spacing: 0.12em; color: var(--paper-4); text-transform: uppercase; }
.tool-row .meta.tfa { color: var(--accent); }

.tool-row.cat-disc  .name { color: var(--primary); }
.tool-row.cat-life  .name { color: var(--signal); }
.tool-row.cat-auth  .name { color: var(--purple); }
.tool-row.cat-pub   .name { color: var(--pink); }
.tool-row.cat-mgmt  .name { color: var(--cyan); }

@media (max-width: 700px) {
  .tool-row { grid-template-columns: 1fr; gap: .3rem; }
}

/* Footer */
.colophon-foot {
  margin-top: 8rem;
  padding: 3rem 0 2rem;
  border-top: 2px solid var(--paper-5);
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: 0.1em;
  color: var(--paper-3);
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 3rem;
  text-transform: uppercase;
}

.colophon-foot .name {
  font-family: var(--display);
  font-style: italic;
  font-variation-settings: "opsz" 60, "SOFT" 80, "WONK" 1;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--paper);
  text-transform: none;
  margin-bottom: .5rem;
  display: block;
}

.colophon-foot a { color: var(--paper-3); text-decoration: none; border-bottom: 1px dotted var(--paper-5); }
.colophon-foot a:hover { color: var(--primary); border-color: var(--primary); }

.colophon-foot ul { list-style: none; display: grid; gap: .5rem; }

@media (max-width: 800px) {
  .colophon-foot { grid-template-columns: 1fr; gap: 2rem; }
}

/* Reveal animation, staggered, restrained */
.reveal { opacity: 0; transform: translateY(8px); animation: reveal .9s cubic-bezier(.2,.6,.2,1) forwards; }
.reveal[data-d="0"] { animation-delay: 0s; }
.reveal[data-d="1"] { animation-delay: .12s; }
.reveal[data-d="2"] { animation-delay: .24s; }
.reveal[data-d="3"] { animation-delay: .36s; }
.reveal[data-d="4"] { animation-delay: .48s; }
.reveal[data-d="5"] { animation-delay: .6s; }
.reveal[data-d="6"] { animation-delay: .72s; }

@keyframes reveal {
  to { opacity: 1; transform: translateY(0); }
}

/* Cursor-blink for terminal */
.blink::after {
  content: "▋";
  display: inline-block;
  margin-left: 2px;
  color: var(--accent);
  animation: blink 1.05s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Page-specific helpers */
.kicker {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.subtitle {
  font-family: var(--display);
  font-style: italic;
  font-variation-settings: "opsz" 32, "SOFT" 60;
  color: var(--paper-2);
  font-size: 1.4rem;
  line-height: 1.4;
  margin-top: 1rem;
}

/* Responsive masthead */
@media (max-width: 800px) {
  .masthead { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .masthead .colophon { display: none; }
}
