/* ============================================================
   ARTICLE — long-form layout, era nav rail, the Era block (v2)
   Adds: prefatory Era variant, historical figure framing,
   abbr + footnote treatment, 8-item rail, focus-safe scrolling.
   ============================================================ */

/* ---- Article header ---- */
.art-head {
  padding: var(--sp-7) 0 var(--sp-5);
}
.art-head .kicker {
  margin-bottom: var(--sp-4);
}
/* H1 is the LCP element: live text, large but not oversized */
.art-head h1 {
  font-size: var(--t-display);
  line-height: 1.02;
  max-width: 16ch;
  letter-spacing: -0.02em;
}
.art-head .standfirst {
  font-family: var(--font-serif);
  font-size: var(--t-body-lg);
  color: var(--ink-2);
  max-width: 58ch;
  margin-top: var(--sp-5);
  line-height: 1.5;
}
.art-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-5);
  align-items: center;
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: var(--hair) solid var(--rule);
  font-family: var(--font-sans);
  font-size: var(--t-small);
  color: var(--ink-3);
}
.art-meta .byline {
  color: var(--ink-2);
}
.art-meta .byline b {
  color: var(--ink);
  font-weight: 600;
}
.art-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-3);
}

/* ---- Two-column layout: rail + content ---- */
.art-layout {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  gap: clamp(2rem, 4vw, 5rem);
  align-items: start;
  padding-bottom: var(--sp-9);
}

/* ============================================================
   ERA NAV RAIL — real anchor links, reads as nav before JS
   ============================================================ */
.rail {
  position: sticky;
  top: calc(var(--mast-h) + 1.25rem);
  align-self: start;
}
.rail-title {
  font-family: var(--font-sans);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--sp-4);
}
.rail-list {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}
.rail-list::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--rule);
}
.rail-group-label {
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding: 0 0 var(--sp-2) var(--sp-5);
  margin-top: var(--sp-4);
}
.rail-group-label:first-child {
  margin-top: 0;
}
.rail-item {
  position: relative;
  padding: 0 0 0 var(--sp-5);
  margin-bottom: var(--sp-3);
}
.rail-item a {
  display: block;
  text-decoration: none;
  color: var(--ink-3);
  transition: color 0.15s;
  padding: 2px 0;
}
.rail-item a:hover {
  color: var(--ink-2);
}
.rail-dot {
  position: absolute;
  left: 0;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--rule-2);
  transition: all 0.2s;
}
.rail-yr {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  color: var(--ink-3);
  display: block;
}
.rail-lib {
  font-family: var(--font-sans);
  font-size: var(--t-small);
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink-2);
}
.rail-item.active .rail-dot {
  background: var(--e);
  border-color: var(--e);
  transform: scale(1.15);
  box-shadow: 0 0 0 4px var(--e-tint);
}
.rail-item.active a {
  color: var(--ink);
}
.rail-item.active .rail-lib {
  font-weight: 600;
  color: var(--ink);
}
.rail-item.is-pre .rail-lib {
  font-style: italic;
}
.rail-progress {
  margin-top: var(--sp-5);
  padding-top: var(--sp-5);
  border-top: var(--hair) solid var(--rule);
  font-family: var(--font-sans);
  font-size: var(--t-micro);
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---- Mobile era strip ---- */
.strip {
  display: none;
}

/* ---- Body prose ---- */
.art-body {
  min-width: 0;
}
.prose {
  font-family: var(--font-serif);
}
.prose-intro p {
  font-size: var(--t-body);
  max-width: var(--measure);
  margin-top: var(--sp-5);
}
.prose-intro .drop::first-letter {
  font-size: 3.6em;
  line-height: 0.8;
  float: left;
  font-weight: 500;
  padding: 0.04em 0.12em 0 0;
  color: var(--accent-ink);
}

/* ---- abbreviations + footnotes ---- */
abbr[title] {
  text-decoration: none;
  border-bottom: 1px dotted var(--ink-3);
  cursor: help;
  font-variant: all-small-caps;
  letter-spacing: 0.03em;
  font-feature-settings: 'c2sc', 'smcp';
}
.fn-ref {
  font-family: var(--font-sans);
  font-size: 0.62em;
  font-weight: 600;
  vertical-align: super;
  line-height: 0;
  color: var(--accent-ink);
  text-decoration: none;
  padding: 0 0.1em;
  margin-left: 0.5px;
}
.fn-ref::before {
  content: '[';
}
.fn-ref::after {
  content: ']';
}
.fn-ref:hover {
  background: var(--accent-soft);
  border-radius: 2px;
}
.footnotes {
  margin-top: var(--sp-8);
  padding-top: var(--sp-5);
  border-top: var(--hair) solid var(--rule);
  max-width: var(--measure);
}
.footnotes .label {
  color: var(--ink-3);
  margin-bottom: var(--sp-4);
  display: block;
}
.footnotes ol {
  padding-left: 1.4em;
  margin: 0;
  display: grid;
  gap: var(--sp-3);
}
.footnotes li {
  font-family: var(--font-sans);
  font-size: var(--t-small);
  color: var(--ink-2);
  line-height: 1.55;
}
.footnotes li::marker {
  color: var(--accent-ink);
  font-weight: 600;
}
.footnotes a {
  word-break: break-word;
}

/* ============================================================
   THE ERA BLOCK  (standard)
   ============================================================ */
.era {
  margin: var(--sp-9) 0;
  scroll-margin-top: calc(var(--mast-h) + 1.5rem);
}

.era-head {
  border-top: 2px solid var(--e);
  padding-top: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.era-meta-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.era-num {
  font-family: var(--font-mono);
  font-size: var(--t-small);
  color: var(--e-ink);
  font-weight: 500;
}
.era-tag {
  font-family: var(--font-sans);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--e-ink);
  background: var(--e-tint);
  padding: 4px 9px;
  border-radius: 100px;
}
.era-anchor {
  margin-left: auto;
  font-family: var(--font-sans);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-decoration: none;
  border: var(--hair) solid var(--rule-2);
  border-radius: 100px;
  padding: 4px 9px;
  line-height: 1;
  display: inline-flex;
  gap: 5px;
  align-items: center;
  cursor: pointer;
  background: none;
}
.era-anchor:hover {
  color: var(--accent-ink);
  border-color: var(--accent);
}
/* H2 era heading — year + library + component, must wrap gracefully */
.era-lib {
  display: block;
  font-family: var(--font-serif);
  font-size: var(--t-h2);
  color: var(--ink);
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -0.015em;
  text-wrap: balance;
  max-width: 18ch;
}
.era-lib .era-lib-yr {
  color: var(--e-ink);
}
.era-lede {
  font-family: var(--font-serif);
  font-size: 1.18rem;
  color: var(--ink-2);
  max-width: 60ch;
  margin-top: var(--sp-4);
  line-height: 1.5;
}

/* demo stage */
.era-demo {
  border: var(--hair) solid var(--rule-2);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: var(--sp-5) 0 var(--sp-6);
  box-shadow: var(--shadow-demo);
  background: var(--paper-demo);
}
.era-demo-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: var(--hair) solid var(--rule);
  background: var(--paper-2);
}
.era-demo-bar .dot-row {
  display: flex;
  gap: 5px;
}
.era-demo-bar .dot-row i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rule-2);
  display: block;
}
.era-demo-bar .demo-label {
  font-family: var(--font-sans);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.era-demo-bar .demo-live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--e-ink);
}
.era-demo-bar .demo-live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--e);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in oklab, var(--e) 60%, transparent);
  }
  70% {
    box-shadow: 0 0 0 6px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}
.era-demo iframe {
  width: 100%;
  height: 480px;
  border: 0;
  display: block;
}

/* commentary + sticky code */
.era-body-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.04fr);
  gap: clamp(1.5rem, 3vw, 3rem);
  align-items: start;
}
.era-commentary {
  min-width: 0;
}
.era-commentary p {
  font-family: var(--font-serif);
  font-size: var(--t-body);
  max-width: var(--measure-narrow);
  margin-bottom: var(--sp-4);
  color: var(--ink);
}
.era-commentary h4 {
  font-family: var(--font-sans);
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: var(--sp-6) 0 var(--sp-3);
}
.era-commentary .pull {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.35rem;
  line-height: 1.4;
  color: var(--e-ink);
  border-left: 2px solid var(--e);
  padding-left: var(--sp-4);
  margin: var(--sp-5) 0;
  max-width: 40ch;
}
.era-commentary code,
.prose code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: var(--paper-sunk);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.era-seg {
  display: none;
}
/* sticky code panel — top offset clears the masthead so focused prose is never hidden */
.era-code {
  position: sticky;
  top: calc(var(--mast-h) + 1.25rem);
  align-self: start;
}

.code-panel {
  border: var(--hair) solid var(--rule-2);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--paper);
}
.code-tabs {
  display: flex;
  align-items: stretch;
  background: var(--paper-2);
  border-bottom: var(--hair) solid var(--rule);
}
.code-tab {
  font-family: var(--font-sans);
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--ink-3);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  line-height: 1;
}
.code-tab:hover {
  color: var(--ink-2);
}
.code-tab[aria-selected='true'] {
  color: var(--ink);
  border-bottom-color: var(--e);
}
.code-copy {
  margin-left: auto;
  align-self: center;
  margin-right: var(--sp-2);
  font-family: var(--font-sans);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: none;
  border: var(--hair) solid var(--rule-2);
  border-radius: 100px;
  padding: 4px 10px;
  cursor: pointer;
  line-height: 1;
}
.code-copy:hover {
  color: var(--accent-ink);
  border-color: var(--accent);
}
.code-body {
  position: relative;
}
.code-body pre {
  margin: 0;
  padding: var(--sp-4) var(--sp-5);
  overflow: auto;
  max-height: 440px;
  background: var(--paper-sunk);
}
.code-body pre[hidden] {
  display: none;
}
.code-body code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre;
  tab-size: 2;
  display: block;
}
.code-cap {
  font-family: var(--font-sans);
  font-size: var(--t-micro);
  color: var(--ink-3);
  padding: var(--sp-3) var(--sp-4);
  border-top: var(--hair) solid var(--rule);
  background: var(--paper-2);
  line-height: 1.5;
}

/* code tokens */
.tok-c {
  color: var(--ink-3);
  font-style: italic;
}
.tok-s {
  color: var(--accent-ink);
}
.tok-k {
  color: var(--ink);
  font-weight: 600;
}
.tok-f {
  color: var(--e-ink);
}
.tok-n {
  color: var(--ink-2);
}
.tok-p {
  color: var(--ink-3);
}

/* between-era transition note */
.interlude {
  max-width: var(--measure);
  margin: var(--sp-8) auto;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--ink-1);
  font-style: italic;
  text-align: center;
}
.interlude::before,
.interlude::after {
  content: '❉';
  color: var(--e, var(--accent));
  margin: 0 0.6em;
  font-style: normal;
  opacity: 0.6;
}

/* ============================================================
   PREFATORY ERA VARIANT  (.era.is-pre)
   Quieter rhythm: dashed top rule, "context" treatment, no sticky,
   single narrower column. Signals "context, not implementation."
   ============================================================ */
.era.is-pre {
  margin: var(--sp-8) 0;
  padding-left: var(--sp-5);
  border-left: 2px dotted var(--e);
}
.era.is-pre .era-head {
  border-top: 1px dashed var(--e);
  padding-top: var(--sp-3);
}
.era.is-pre .era-lib {
  font-size: var(--t-h3);
}
.era.is-pre .era-lede {
  font-size: 1.08rem;
}
/* prefatory body is a single quieter column; code (if any) is NOT sticky */
.era.is-pre .era-body-grid {
  grid-template-columns: 1fr;
  gap: var(--sp-5);
  max-width: var(--measure);
}
.era.is-pre .era-code {
  position: static;
}
.era.is-pre .era-commentary p {
  max-width: var(--measure);
}
/* tiny demo + tiny code for the alert era */
.era.is-pre .era-demo.is-tiny iframe {
  height: 240px;
}
.era.is-pre .code-body pre {
  max-height: none;
}

/* ============================================================
   HISTORICAL FIGURE FRAMING  (Era 0 — period recreations)
   ============================================================ */
.fig-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
  margin: var(--sp-5) 0 var(--sp-6);
}
@media (max-width: 600px) {
  .fig-grid {
    grid-template-columns: 1fr;
  }
}
figure.fig {
  margin: 0;
}
.fig-frame {
  border: var(--hair) solid var(--rule-2);
  background: var(--paper-2);
  padding: var(--sp-6) var(--sp-5);
  display: grid;
  place-items: center;
  min-height: 220px;
  border-radius: var(--radius);
}
.fig figcaption {
  margin-top: var(--sp-3);
}
.fig-cap {
  font-family: var(--font-sans);
  font-size: var(--t-small);
  color: var(--ink-2);
  line-height: 1.45;
}
.fig-attr {
  font-family: var(--font-sans);
  font-size: var(--t-micro);
  color: var(--ink-3);
  margin-top: 3px;
  display: block;
}

/* --- System 7 alert recreation --- */
.sys7 {
  width: 230px;
  font-family: 'Geneva', 'Helvetica Neue', system-ui, sans-serif;
  color: #000;
  background: #fff;
  border: 2px solid #000;
  border-radius: 4px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.4);
}
.sys7-bar {
  height: 14px;
  border-bottom: 1px solid #000;
  background: repeating-linear-gradient(#000 0 1px, #fff 1px 2px);
  margin: 2px;
}
.sys7-body {
  display: flex;
  gap: 10px;
  padding: 12px 12px 6px;
  align-items: flex-start;
}
.sys7-ico {
  width: 30px;
  height: 30px;
  border: 2px solid #000;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 20px;
  flex: none;
}
.sys7-msg {
  font-size: 11px;
  line-height: 1.35;
}
.sys7-btns {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 4px 12px 12px;
}
.sys7-btn {
  font-size: 11px;
  padding: 2px 12px;
  border: 1px solid #000;
  border-radius: 8px;
  background: #fff;
}
.sys7-btn.def {
  border-width: 3px;
  font-weight: 700;
}

/* --- Windows 3.1 recreation --- */
.win31 {
  width: 234px;
  font-family: 'MS Sans Serif', 'Tahoma', system-ui, sans-serif;
  color: #000;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
}
.win31-bar {
  background: #000080;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 5px;
  margin: 2px;
  display: flex;
  align-items: center;
}
.win31-body {
  display: flex;
  gap: 10px;
  padding: 12px 12px 8px;
  align-items: flex-start;
}
.win31-ico {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #000;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  color: #000080;
  background: #fff;
  flex: none;
}
.win31-msg {
  font-size: 11px;
  line-height: 1.4;
}
.win31-btns {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 4px 12px 14px;
}
.win31-btn {
  font-size: 11px;
  padding: 3px 14px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #808080 #808080 #fff;
}
.win31-btn.def {
  outline: 1px dotted #000;
  outline-offset: 2px;
}

/* coda */
.art-coda {
  margin-top: var(--sp-9);
  border-top: 2px solid var(--accent);
  padding-top: var(--sp-6);
}
.art-coda h2 {
  font-family: var(--font-serif);
  font-size: var(--t-h2);
  font-weight: 500;
  margin-bottom: var(--sp-4);
  max-width: 20ch;
}

/* ---- Responsive ---- */
@media (max-width: 920px) {
  .art-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .rail {
    display: none;
  }
  .strip {
    display: block;
    position: sticky;
    top: var(--mast-h);
    z-index: 40;
    margin: 0 calc(-1 * var(--shell-pad));
    padding: var(--sp-3) var(--shell-pad);
    background: var(--paper);
    border-bottom: var(--hair) solid var(--rule);
  }
  .strip-list {
    display: flex;
    gap: var(--sp-2);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .strip-list::-webkit-scrollbar {
    display: none;
  }
  .strip-item {
    font-family: var(--font-sans);
    font-size: var(--t-micro);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-3);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 100px;
    border: var(--hair) solid var(--rule);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .strip-item .sdot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--e);
  }
  .strip-item.is-pre .sdot {
    background: transparent;
    border: 1.5px dotted var(--e);
  }
  .strip-item.active {
    color: var(--ink);
    border-color: var(--e);
    background: var(--e-tint);
  }

  .era-body-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .era-code {
    position: static;
  }
  .era-seg {
    display: flex;
    gap: 0;
    margin: var(--sp-4) 0;
    border: var(--hair) solid var(--rule-2);
    border-radius: 100px;
    padding: 3px;
    background: var(--paper-2);
    width: fit-content;
  }
  .era-seg button {
    font-family: var(--font-sans);
    font-size: var(--t-small);
    font-weight: 600;
    padding: 7px 16px;
    border: 0;
    background: none;
    color: var(--ink-3);
    border-radius: 100px;
    cursor: pointer;
  }
  .era-seg button[aria-selected='true'] {
    background: var(--ink);
    color: var(--paper);
  }
  .era[data-panel='code'] .era-commentary {
    display: none;
  }
  .era[data-panel='notes'] .era-code {
    display: none;
  }
  .era.is-pre .era-seg {
    display: none;
  } /* prefatory: no toggle, just stack */
  .era-commentary p {
    max-width: none;
  }
  .code-body pre {
    max-height: none;
  }
}

@media (max-width: 520px) {
  .art-head h1 {
    font-size: clamp(2.4rem, 11vw, 3rem);
  }
  .era-anchor {
    margin-left: 0;
  }
  .era-lib {
    max-width: none;
  }
}
