/* ==========================================================================
   BARNES PROJECTS — essay.css
   Long-form layer for the BP-* / cyber-* essays. Loaded AFTER essay-base.css
   (the pre-"Wall" landing stylesheet, kept for the essays when index.css was
   rebuilt), which owns the theme tokens (--paper/--ink/--gold/--line), the
   topbar, the buttons and the .comms footer. Nothing here redefines a palette:
   every colour below resolves through essay-base.css, so the light/dark switch
   in essay.js (key: barnes-lcars-theme, shared with index.html) flips the
   essays exactly like the homepage.
   ========================================================================== */

/* two accents index.css has no need for: the warning callout and a paper
   tint for figures that must read as "inset" against --paper-2 blocks */
:root {
  --warn:      #C2554A;
  --warn-bg:   #251512;
  --warn-line: #4A2620;
}
body.light {
  --warn:      #A33A2C;
  --warn-bg:   #FBF1EE;
  --warn-line: #E8CFC8;
}

/* ---------------- utilities ---------------- */

/* for header cells that exist structurally but must stay visually empty */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------------- article shell ---------------- */

/* The measure is the point of the whole file: ~68ch of Inter is the band
   where a paragraph stays scannable. .essay-wide breaks out of it for
   tables and figures that genuinely need the room. */
.essay {
  --measure: 68ch;
  padding-block: clamp(40px, 6vw, 72px) clamp(56px, 8vw, 104px);
}

.essay-inner { max-width: 780px; margin-inline: auto; }

.essay-head { margin-bottom: clamp(36px, 5vw, 60px); }

.essay-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 22px;
}
.essay-meta .sep { color: var(--line-2); }

.essay-title {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: clamp(32px, 5.6vw, 56px);
  line-height: 1.08;
  letter-spacing: -.012em;
  margin: 0 0 14px;
}
/* the subordinate half of a compound title */
.essay-title .sub { font-style: italic; font-weight: 400; color: var(--ink-soft); }

.essay-standfirst {
  font-size: 1.12rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 58ch;
  margin: 0 0 30px;
}

.byline {
  display: flex; align-items: center; gap: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding-block: 16px;
}
.byline-mark {
  flex: none;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-display); font-size: 15px; font-weight: 600;
  color: var(--paper); background: var(--ink);
  border-radius: 2px;
}
.byline-name { font-weight: 500; line-height: 1.3; }
.byline-role { font-family: var(--f-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); margin-top: 2px; }

.essay-lead { display: block; width: 100%; border-radius: 3px; border: 1px solid var(--line); margin-bottom: 34px; }

/* ---------------- prose ---------------- */

.essay-body { font-size: 1.05rem; line-height: 1.78; }

.essay-body > p,
.essay-body > ul,
.essay-body > ol {
  max-width: var(--measure);
}

.essay-body p { margin: 0 0 1.35em; }
.essay-body strong { font-weight: 600; color: var(--ink); }
.essay-body em { font-style: italic; }

.essay-body a:not(.btn) {
  color: var(--ink);
  border-bottom: 1px solid var(--gold);
  transition: color .2s, border-color .2s;
}
.essay-body a:not(.btn):hover { color: var(--gold); }

.essay-body h2 {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: clamp(25px, 3.4vw, 34px);
  line-height: 1.15;
  letter-spacing: -.008em;
  margin: clamp(52px, 7vw, 76px) 0 20px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
/* an h2 that only closes the piece (References, Addendum) carries less weight */
.essay-body h2.minor { font-size: clamp(20px, 2.4vw, 25px); }

.essay-body h3 {
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 40px 0 14px;
}

.essay-body ul, .essay-body ol { margin: 0 0 1.35em; padding-left: 22px; }
.essay-body li { margin-bottom: .6em; }
.essay-body ul li::marker { color: var(--gold); }
.essay-body ol li::marker { font-family: var(--f-mono); font-size: .85em; color: var(--gold); }

.essay-body hr { border: 0; border-top: 1px solid var(--line); margin: clamp(48px, 6vw, 72px) 0; }

.essay-body .pullquote { margin: clamp(36px, 5vw, 52px) 0; max-width: var(--measure); font-size: 1.4rem; }

/* a definition-style list: mono term on the left, prose on the right */
.termlist { list-style: none; margin: 0 0 1.6em; padding: 0; max-width: none; }
.termlist li {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 18px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.termlist li:last-child { border-bottom: 1px solid var(--line); }
.termlist .term {
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold);
  padding-top: 4px;
}

/* ---------------- callouts ---------------- */

.callout {
  border: 1px solid var(--line);
  border-left: 2px solid var(--gold);
  border-radius: 3px;
  background: var(--paper-2);
  padding: clamp(20px, 3vw, 28px) clamp(22px, 3vw, 30px);
  margin: clamp(30px, 4vw, 42px) 0;
  max-width: var(--measure);
}
.callout-label {
  font-family: var(--f-mono);
  font-size: 10px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 12px;
}
.callout > p { margin: 0 0 .9em; }
.callout > p:last-child { margin-bottom: 0; }
/* the opening thesis of every post — carried at display weight */
.callout.abstract > p { font-family: var(--f-display); font-size: 1.22rem; line-height: 1.55; color: var(--ink); }

.callout.warn { border-color: var(--warn-line); border-left-color: var(--warn); background: var(--warn-bg); }
.callout.warn .callout-label { color: var(--warn); }

.callout ul, .callout ol { margin: 0; padding-left: 20px; }

/* dash-led list — used inside callouts and statements, so it is not scoped
   to either of them */
.essay-body ul.bare { list-style: none; padding-left: 0; }
.essay-body ul.bare li { padding-left: 20px; position: relative; }
.essay-body ul.bare li::before { content: "—"; position: absolute; left: 0; color: var(--gold); }

/* full-measure centred emphasis block */
.statement {
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--paper-2);
  padding: clamp(28px, 4vw, 44px);
  margin: clamp(38px, 5vw, 56px) 0;
  text-align: center;
}
.statement h3 {
  font-family: var(--f-display) !important;
  font-size: clamp(20px, 2.6vw, 26px) !important;
  font-weight: 500 !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  color: var(--ink) !important;
  margin: 0 0 16px !important;
}
.statement p { margin: 0 auto 14px; max-width: 54ch; }
.statement p:last-child { margin-bottom: 0; }
.statement .lead { font-family: var(--f-display); font-style: italic; font-size: 1.2rem; color: var(--ink); }

/* numbered-step callout */
.steps { list-style: none; margin: clamp(30px, 4vw, 42px) 0; padding: 0; counter-reset: step; max-width: none; }
.steps li {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 20px;
  align-items: start;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  counter-increment: step;
}
.steps li:last-child { border-bottom: 1px solid var(--line); }
.steps li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--f-display);
  font-size: 2rem;
  line-height: 1;
  color: var(--gold);
}
.steps .step-lead { display: block; font-weight: 600; margin-bottom: 5px; }

/* ---------------- code / notation blocks ---------------- */

.codeblock {
  font-family: var(--f-mono);
  font-size: .84rem;
  line-height: 1.75;
  white-space: pre;
  overflow-x: auto;
  color: var(--ink);
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-left: 2px solid var(--gold);
  border-radius: 3px;
  padding: 20px 22px;
  margin: clamp(28px, 4vw, 40px) 0;
  tab-size: 2;
}
.codeblock .c { color: var(--ink-faint); }
.codeblock .k { color: var(--gold); }

/* ---------------- paired cards ---------------- */

.cardpair { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: clamp(30px, 4vw, 42px) 0; }
.mini-card { border: 1px solid var(--line); border-radius: 3px; background: var(--paper-2); padding: 24px; }
.mini-card h4 { font-family: var(--f-display); font-size: 1.25rem; font-weight: 500; margin: 0 0 10px; }
.mini-card .mini-kind { font-family: var(--f-mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); margin: 0 0 6px; }
.mini-card p { margin: 0; color: var(--ink-soft); font-size: .96rem; }
@media (max-width: 640px) { .cardpair { grid-template-columns: 1fr; } }

/* ---------------- tables ---------------- */

/* the wrapper, not the table, is what scrolls — a bare table would push the
   whole page sideways on a phone */
.table-wrap { overflow-x: auto; margin: clamp(30px, 4vw, 42px) 0; border: 1px solid var(--line); border-radius: 3px; }
.table-wrap table { margin: 0; border: 0; }

.ctable {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  line-height: 1.55;
}
.ctable th {
  font-family: var(--f-mono);
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--paper-3);
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-2);
  /* deliberately wrapping: a nowrap header forces a wide matrix table into a
     horizontal scroll even when the viewport has room for it */
  line-height: 1.5;
}
.ctable td {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  vertical-align: top;
  color: var(--ink-soft);
}
.ctable tbody tr:first-child td { border-top: 0; }
.ctable td strong { color: var(--ink); font-weight: 600; }
.ctable td:first-child { color: var(--ink); }

/* a row header inside the body (matrix tables) */
.ctable tbody th {
  background: var(--paper-2);
  border-top: 1px solid var(--line);
  border-bottom: 0;
  vertical-align: top;
}
/* the cell the surrounding prose is actually pointing at */
.ctable td.hot { background: var(--ink); color: var(--paper); }
.ctable td.hot strong { color: var(--gold); }
.ctable td.mute { color: var(--ink-faint); }

/* ---------------- rule-topped card grid ---------------- */

.cardgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 26px 32px;
  margin: clamp(30px, 4vw, 42px) 0;
}
.rule-card { border-top: 1px solid var(--line-2); padding-top: 16px; }
.rule-card h4 { font-family: var(--f-display); font-size: 1.15rem; font-weight: 500; margin: 0 0 8px; }
.rule-card p { margin: 0; font-size: .93rem; color: var(--ink-soft); }

/* ---------------- figures ---------------- */

.fig {
  margin: clamp(38px, 5vw, 56px) 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper-2);
  padding: clamp(20px, 3vw, 32px);
}
.fig > svg, .fig > img { display: block; width: 100%; height: auto; margin-inline: auto; max-width: 720px; }
/* SVGs draw with currentColor, so they follow the theme for free */
.fig > svg { color: var(--ink); }
.fig figcaption {
  font-family: var(--f-mono);
  font-size: 11px; line-height: 1.6; letter-spacing: .06em;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.fig .accent { color: var(--gold); }
.fig .faint { opacity: .55; }

/* diagram primitives shared by the essay figures. CSS beats an SVG
   presentation attribute, so setting the family here also normalises the
   older figures that carry a font-family="…" attribute of their own. */
.fig svg text { fill: currentColor; font-family: var(--f-mono); }
.fig svg .ring { stroke: currentColor; fill: none; stroke-width: 2; }
.fig svg .ring-fill { fill: currentColor; stroke: none; opacity: .06; }
.fig svg .label-tiny { font-size: 9px; opacity: .55; }
.fig svg .gold { fill: var(--gold); }
.fig svg .gold-stroke { stroke: var(--gold); }

/* ---------------- references ---------------- */

.refs { list-style: none; margin: 0; padding: 0; max-width: var(--measure); }
.refs li {
  font-family: var(--f-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-soft);
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.refs li:first-child { border-top: 0; }
.refs em { font-style: italic; color: var(--ink); }

/* ---------------- foot navigation ---------------- */

.essay-nav {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  margin-top: clamp(48px, 6vw, 72px);
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

/* ---------------- responsive ---------------- */

@media (max-width: 700px) {
  .essay-body { font-size: 1rem; }
  .termlist li, .steps li { grid-template-columns: 1fr; gap: 8px; }
  .steps li::before { font-size: 1.5rem; }
  .statement { padding: 26px 20px; }
}

/* ---------------- print ---------------- */

@media print {
  .topbar, .essay-nav, .comms { display: none !important; }
  .essay { padding-block: 0; }
  .essay-body h2 { break-after: avoid; }
  .callout, .fig, .table-wrap, .statement { break-inside: avoid; }
  .essay-body { font-size: 11pt; }
}
