/* The Price of a Nod — essay site styles */

:root {
  --paper: #f5f0e6;
  --paper-2: #ebe4d6;
  --ink: #1c1f24;
  --ink-2: #4a4f58;
  --muted: #7d8089;
  --rule: #d9d1c0;
  --teal: #1f7a8c;
  --teal-2: #2b96ab;
  --copper: #c0633a;
  --gold: #c9961a;
  --green: #3f8f5a;
  --card: #fffdf8;
  --shadow: 0 24px 60px rgba(40, 30, 10, 0.14);
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --display: "Instrument Serif", "Source Serif 4", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --measure: 66ch;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #0f1a1f;
  --paper-2: #14232a;
  --ink: #e8e3d8;
  --ink-2: #b7b1a4;
  --muted: #7f8a8f;
  --rule: #223640;
  --teal: #3fb3c8;
  --teal-2: #5ac7da;
  --copper: #e07a4b;
  --gold: #e0b03a;
  --green: #5fbf7c;
  --card: #132228;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: 1.1875rem; line-height: 1.65; font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased; transition: background-color 0.4s, color 0.4s;
}
::selection { background: var(--teal); color: #fff; }
a { color: var(--teal); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--teal) 40%, transparent); }
a:hover { border-bottom-color: var(--teal); }
img { max-width: 100%; height: auto; display: block; }

/* progress + topbar */
.progress { position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 50; pointer-events: none; }
.progress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--copper)); transition: width 0.1s linear; }
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.06em; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.topbar .brand { color: var(--ink-2); border: 1px solid var(--rule); text-transform: uppercase; padding: 10px 14px; border-radius: 999px; background: color-mix(in srgb, var(--paper) 78%, transparent); backdrop-filter: blur(10px); }
.topbar .brand:hover { color: var(--teal); }
.theme-toggle { appearance: none; border: 1px solid var(--rule); background: color-mix(in srgb, var(--paper) 78%, transparent); backdrop-filter: blur(10px); color: var(--ink); border-radius: 999px; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

/* hero: split, paper-first */
.hero { width: min(1180px, 100% - 40px); margin: 0 auto; padding: 120px 0 40px; display: grid; gap: 40px; align-items: center; }
@media (min-width: 960px) { .hero { grid-template-columns: 1.05fr 1fr; min-height: 92svh; padding-top: 90px; } }
.hero-text .eyebrow { font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--teal); margin: 0 0 20px; display: flex; align-items: center; gap: 12px; }
.hero-text .eyebrow::before { content: ""; width: 32px; height: 1px; background: currentColor; }
.hero h1 { font-family: var(--display); font-weight: 400; font-size: clamp(3rem, 7.6vw, 6.4rem); line-height: 0.96; letter-spacing: -0.015em; margin: 0 0 22px; }
.hero h1 em { font-style: italic; color: var(--copper); }
.hero .dek { font-size: clamp(1.1rem, 1.9vw, 1.4rem); line-height: 1.45; color: var(--ink-2); max-width: 38ch; margin: 0 0 28px; font-style: italic; }
.byline { font-family: var(--sans); font-size: 0.82rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.byline strong { color: var(--ink); font-weight: 600; }
.byline .dot { opacity: 0.4; }
.hero-art { position: relative; }
.hero-art img { border-radius: 14px; box-shadow: var(--shadow); }
.hero-art::after { content: ""; position: absolute; inset: 10px -10px -10px 10px; border: 1px solid var(--rule); border-radius: 14px; z-index: -1; }

/* signal line: an ACK pulse travelling between the two columns */
.signal { position: relative; height: 2px; margin: 10px auto 0; width: min(1180px, 100% - 40px); background: repeating-linear-gradient(90deg, var(--rule) 0 6px, transparent 6px 12px); }
.signal::after { content: ""; position: absolute; top: -4px; left: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 14px var(--teal); animation: ack 5s ease-in-out infinite; }
@keyframes ack { 0% { left: 0; background: var(--copper); box-shadow: 0 0 14px var(--copper); } 48% { left: calc(100% - 10px); background: var(--copper); box-shadow: 0 0 14px var(--copper); } 52% { left: calc(100% - 10px); background: var(--teal); box-shadow: 0 0 14px var(--teal); } 100% { left: 0; background: var(--teal); box-shadow: 0 0 14px var(--teal); } }

/* layout */
.layout { width: min(1180px, 100% - 40px); margin: 0 auto; display: grid; grid-template-columns: 1fr; gap: 0 60px; padding: 40px 0 80px; }
@media (min-width: 1100px) { .layout { grid-template-columns: 220px minmax(0, 1fr); } }
.toc { display: none; }
@media (min-width: 1100px) { .toc { display: block; position: sticky; top: 90px; align-self: start; font-family: var(--sans); font-size: 0.8rem; line-height: 1.4; } }
.toc h2 { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; font-weight: 500; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc li a { display: block; padding: 7px 0 7px 16px; border: 0; color: var(--ink-2); margin-left: -1px; border-left: 2px solid transparent; }
.toc li a.active { color: var(--teal); border-left-color: var(--teal); }
.toc .num { font-family: var(--mono); color: var(--muted); margin-right: 6px; }

/* essay */
.essay { max-width: var(--measure); }
.essay section { padding: 36px 0 20px; }
.essay section + section { border-top: 1px solid var(--rule); }
.essay h2 { font-family: var(--display); font-weight: 400; font-size: clamp(1.9rem, 3.6vw, 2.7rem); line-height: 1.1; margin: 0 0 26px; scroll-margin-top: 80px; }
.essay h2 .num { display: block; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--copper); margin-bottom: 12px; }
.essay p { margin: 0 0 1.25em; }
.essay p strong { font-weight: 600; }
.essay ul { padding-left: 1.2em; margin: 0 0 1.4em; }
.essay li { margin: 0 0 0.6em; }
.essay li::marker { color: var(--copper); }
.essay code { font-family: var(--mono); font-size: 0.85em; background: var(--paper-2); padding: 0.1em 0.4em; border-radius: 4px; }
.essay section > p.lede::first-letter { font-family: var(--display); float: left; font-size: 4.4em; line-height: 0.8; padding: 0.06em 0.12em 0 0; color: var(--teal); }
.pull { margin: 44px 0 44px -8px; padding: 6px 0 6px 26px; border-left: 3px solid var(--copper); font-family: var(--display); font-style: italic; font-size: clamp(1.4rem, 2.6vw, 1.9rem); line-height: 1.3; }
@media (min-width: 1100px) { .pull { margin-left: -40px; } }
figure.art { margin: 48px 0; }
figure.art img { border-radius: 12px; box-shadow: var(--shadow); }
figure.art figcaption, .fig-caption { font-family: var(--sans); font-size: 0.78rem; color: var(--muted); margin-top: 12px; line-height: 1.5; }
@media (min-width: 1100px) { figure.art.wide { margin-left: -120px; margin-right: -120px; } }

/* protocol tags */
.tag { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; padding: 3px 8px; border-radius: 4px; color: #fff; display: inline-block; vertical-align: middle; }
.tag-purr { background: var(--teal); }
.tag-pop { background: var(--copper); }
.tag-flash { background: var(--green); }
.tag-none { background: var(--muted); }

/* codebook figure */
.codebook { margin: 40px 0; border: 1px solid var(--rule); border-radius: 14px; background: var(--card); box-shadow: var(--shadow); overflow: hidden; font-family: var(--sans); }
.codebook h3 { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); margin: 0; padding: 16px 22px; border-bottom: 1px solid var(--rule); }
.codebook table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.codebook th { text-align: left; font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-weight: 500; padding: 12px 22px; }
.codebook td { padding: 14px 22px; border-top: 1px solid var(--rule); vertical-align: middle; }
.codebook td.arrow { color: var(--muted); font-family: var(--mono); width: 60px; text-align: center; }
.codebook tr.miss td { background: color-mix(in srgb, var(--copper) 9%, transparent); }
.codebook .rx { font-family: var(--mono); font-size: 0.72rem; color: var(--copper); letter-spacing: 0.08em; }
.codebook .note { padding: 14px 22px; font-size: 0.82rem; color: var(--muted); border-top: 1px solid var(--rule); font-family: var(--sans); }

/* channel simulator */
.sim { margin: 48px 0 56px; border: 1px solid var(--rule); border-radius: 16px; background: var(--card); box-shadow: var(--shadow); overflow: hidden; font-family: var(--sans); }
@media (min-width: 1100px) { .sim { margin-left: -60px; margin-right: -60px; } }
.sim-head { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; flex-wrap: wrap; padding: 22px 26px 12px; }
.sim-head h3 { font-family: var(--display); font-weight: 400; font-size: 1.5rem; margin: 0; }
.sim-head h3 em { color: var(--copper); }
.sim-head .hint { font-size: 0.76rem; color: var(--muted); }
.sim-status { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 0 26px 16px; }
.battery { display: flex; align-items: center; gap: 12px; font-size: 0.76rem; color: var(--muted); font-family: var(--mono); letter-spacing: 0.06em; text-transform: uppercase; }
.battery-bar { flex: 1; height: 12px; border: 1px solid var(--rule); border-radius: 6px; padding: 2px; max-width: 320px; }
.battery-fill { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width 0.4s, background 0.4s; }
.battery.low .battery-fill { background: var(--copper); }
.channel { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--rule); color: var(--muted); }
.channel.open { color: var(--green); border-color: var(--green); }
.channel.weak { color: var(--gold); border-color: var(--gold); }
.channel.dead { color: var(--copper); border-color: var(--copper); }
.sim-log { padding: 8px 26px 12px; display: flex; flex-direction: column; gap: 12px; min-height: 180px; max-height: 420px; overflow-y: auto; scroll-behavior: smooth; }
.msg { max-width: 78%; padding: 12px 16px; border-radius: 16px; font-family: var(--serif); font-size: 1.02rem; line-height: 1.45; position: relative; animation: pop-in 0.3s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.them { align-self: flex-start; background: var(--paper-2); border-bottom-left-radius: 4px; }
.msg.you { align-self: flex-end; background: color-mix(in srgb, var(--teal) 14%, transparent); border-bottom-right-radius: 4px; }
.msg.sys { align-self: center; background: transparent; font-family: var(--mono); font-size: 0.72rem; color: var(--muted); letter-spacing: 0.06em; text-align: center; max-width: 100%; }
.msg .tag { margin-top: 8px; display: inline-block; }
.msg .cost { font-family: var(--mono); font-size: 0.66rem; color: var(--muted); margin-left: 8px; }
.sim-choices { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 26px 22px; border-top: 1px solid var(--rule); }
.choice { appearance: none; cursor: pointer; font-family: var(--serif); font-size: 0.98rem; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--rule); background: transparent; color: var(--ink); display: inline-flex; align-items: center; gap: 10px; transition: border-color 0.2s, background-color 0.2s; }
.choice:hover:not(:disabled) { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 8%, transparent); }
.choice:disabled { opacity: 0.45; cursor: not-allowed; }
.choice .price { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em; color: var(--muted); }
.choice.flash { border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.choice.repair { border-color: color-mix(in srgb, var(--gold) 60%, transparent); }
.sim-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 0 26px 20px; font-size: 0.78rem; color: var(--muted); }
.sim-foot .start { display: flex; gap: 8px; align-items: center; }
.sim-foot button { appearance: none; cursor: pointer; font-family: var(--sans); font-size: 0.74rem; font-weight: 600; letter-spacing: 0.04em; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--rule); background: transparent; color: var(--ink-2); }
.sim-foot button[aria-pressed="true"] { color: var(--teal); border-color: var(--teal); }
.sim-verdict { padding: 16px 26px 22px; font-family: var(--serif); font-size: 1.02rem; border-top: 1px solid var(--rule); background: color-mix(in srgb, var(--gold) 8%, transparent); }
.sim-verdict[hidden] { display: none; }

/* sources, colophon */
.sources { font-size: 0.95rem; color: var(--ink-2); }
.sources li { margin-bottom: 0.5em; }
.colophon { border-top: 1px solid var(--rule); margin-top: 20px; padding: 48px 0 60px; font-family: var(--sans); font-size: 0.85rem; line-height: 1.6; color: var(--ink-2); }
.colophon .inner { width: min(1180px, 100% - 40px); margin: 0 auto; display: grid; gap: 28px; }
@media (min-width: 900px) { .colophon .inner { grid-template-columns: 1.2fr 1fr 1fr; } }
.colophon h3 { font-family: var(--display); font-weight: 400; font-size: 1.25rem; color: var(--ink); margin: 0 0 10px; }
.colophon p { margin: 0 0 10px; }
.colophon .mark { font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.2em; color: var(--teal); margin-bottom: 14px; }
.colophon .fine { font-size: 0.75rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { .signal::after { animation: none; } html { scroll-behavior: auto; } .msg { animation: none; } }
