/* ==================================================================
   Static article pages — lesson guides, lesson index, about.

   Hand-written and self-contained: these pages must render completely
   without the SPA bundle, so they share the brand palette but none of
   the app's CSS.
   ================================================================== */

:root {
  --bg: #071223;
  --bg-2: #0b1a2f;
  --panel: rgba(20, 40, 68, .55);
  --stroke: rgba(120, 165, 235, .18);
  --ink: #eaf3ff;
  --ink-2: #a9c0dd;
  --ink-3: #7d95b5;
  --teal: #22d3c5;
  --blue: #6ea8ff;
  --amber: #f0b53a;
  --radius: 14px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(70% 50% at 12% 0%, rgba(77, 124, 255, .16), transparent 70%),
    radial-gradient(50% 50% at 100% 100%, rgba(34, 211, 197, .08), transparent 70%),
    var(--bg);
  color: var(--ink);
  font: 400 17px/1.72 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--teal); }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--teal); color: #06283d; padding: .6rem 1rem; z-index: 20;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.2rem;
  padding: .85rem clamp(1rem, 4vw, 2.4rem);
  background: rgba(7, 18, 35, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--stroke);
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font: 700 1.05rem/1 ui-sans-serif, system-ui, sans-serif;
  color: var(--ink); text-decoration: none; letter-spacing: .01em;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(140deg, var(--teal), var(--blue));
  display: grid; place-items: center;
  color: #04121f; font: 800 14px/1 var(--mono);
}
.top nav { margin-inline-start: auto; display: flex; gap: 1.1rem; font-size: .92rem; }
.top nav a { color: var(--ink-2); text-decoration: none; }
.top nav a:hover { color: var(--ink); }
/* Below a phone width the four labels do not fit between the brand and the
   edge, and the simulator page is linked from every lesson page's CTA and
   from the footer, so the header keeps the three that do. */
@media (max-width: 560px) {
  .top nav .nav-sim { display: none; }
  .top nav { gap: .8rem; font-size: .86rem; }
}

/* ---------- layout ---------- */
.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 3rem) clamp(1rem, 4vw, 2.4rem) 4rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
}
@media (min-width: 1080px) {
  .has-aside .shell { grid-template-columns: minmax(0, 1fr) 290px; }
}

/* Measure first: long lines are hard to read, so the article column stays
   at roughly 70 characters even when the viewport is wider. */
.article { max-width: 46rem; }
/* Pages without a sidebar (index, About) centre their single column. */
.shell:has(> .article:only-child) > .article { margin-inline: auto; }
/* Pages without a sidebar (index, About) centre their single column. */
.shell:has(> .article:only-child) > .article { margin-inline: auto; }

.crumbs {
  font-size: .84rem; color: var(--ink-3);
  margin: 0 0 1.1rem;
  display: flex; flex-wrap: wrap; gap: .45rem; align-items: center;
}
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--teal); }
.crumbs span[aria-current] { color: var(--ink-2); }

.article h1 {
  font: 700 clamp(1.9rem, 4.6vw, 2.9rem)/1.12 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -.02em;
  margin: .2rem 0 .7rem;
}
.kicker {
  display: inline-flex; align-items: center; gap: .5rem;
  font: 600 .78rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--teal);
  margin: 0 0 .9rem;
}
.kicker .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); }

.standfirst {
  font-size: 1.16rem; line-height: 1.62; color: var(--ink);
  padding: 1rem 1.15rem;
  border-inline-start: 3px solid var(--teal);
  background: linear-gradient(100deg, rgba(34, 211, 197, .08), transparent 70%);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 0 0 1.6rem;
}

.article h2 {
  font: 700 clamp(1.25rem, 2.6vw, 1.5rem)/1.3 ui-sans-serif, system-ui, sans-serif;
  margin: 2.6rem 0 .8rem;
  padding-top: .2rem;
  letter-spacing: -.01em;
}
.article h3 {
  font: 650 1.06rem/1.4 ui-sans-serif, system-ui, sans-serif;
  margin: 1.7rem 0 .4rem;
  color: #dbe9fb;
}
.article p { margin: 0 0 1rem; color: #cfdff3; }
.article ul, .article ol { margin: 0 0 1.2rem; padding-inline-start: 1.3rem; color: #cfdff3; }
.article li { margin: .35rem 0; }
.article code {
  font: 500 .88em/1.4 var(--mono);
  background: rgba(110, 168, 255, .13);
  color: #bfe0ff;
  padding: .12em .38em;
  border-radius: 5px;
}
.article strong { color: #fff; }

/* ---------- call to action ---------- */
.cta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1.1rem;
  margin: 1.6rem 0 .4rem;
  padding: .95rem 1.1rem;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: .95rem;
}
.cta p { margin: 0; color: var(--ink-2); flex: 1 1 16rem; }
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .62rem 1.05rem;
  border-radius: 10px;
  background: linear-gradient(120deg, var(--teal), #48b7ff);
  color: #04202c; font-weight: 700; font-size: .92rem;
  text-decoration: none;
  border: 0;
  white-space: nowrap;
}
.btn:hover { color: #04202c; filter: brightness(1.06); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 0 1.4rem; border-radius: var(--radius); border: 1px solid var(--stroke); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
caption { caption-side: bottom; padding: .6rem 0; color: var(--ink-3); font-size: .82rem; text-align: start; }
th, td { text-align: start; vertical-align: top; padding: .68rem .85rem; border-bottom: 1px solid var(--stroke); }
th {
  font: 600 .78rem/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3);
  background: rgba(10, 25, 45, .7);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) { background: rgba(120, 165, 235, .04); }
td:first-child { color: #fff; font-weight: 600; white-space: nowrap; }
.pin { font-family: var(--mono); font-size: .86rem; color: var(--amber); }

/* ---------- code ---------- */
.code-block {
  margin: 0 0 1.4rem;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: #050f1e;
  overflow: hidden;
}
.code-block header {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .85rem;
  border-bottom: 1px solid var(--stroke);
  background: rgba(20, 40, 68, .5);
  font: 600 .74rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3);
}
.code-block .led { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.code-block pre { margin: 0; padding: 1rem 1.1rem; overflow-x: auto; }
.code-block code {
  font: 400 .885rem/1.68 var(--mono);
  background: none; padding: 0; color: #d6e6fa;
  white-space: pre;
}
.code-block .cm { color: #6d8bab; }

/* ---------- faq ---------- */
.faq { margin: 0 0 1.5rem; display: grid; gap: .55rem; }
.faq details {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--panel);
  padding: .1rem .95rem;
}
.faq summary {
  cursor: pointer;
  padding: .78rem 0;
  font-weight: 600;
  color: #fff;
  list-style: none;
  display: flex; gap: .7rem; align-items: baseline;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+"; color: var(--teal); font-family: var(--mono); }
.faq details[open] summary::before { content: "−"; }
.faq p { margin: 0 0 .9rem; color: var(--ink-2); font-size: .97rem; }

/* ---------- book list ---------- */
.book-ed { display: block; font-weight: 400; font-size: .78rem; color: var(--ink-2); margin-top: .15rem; }

/* ---------- pager ---------- */
.pager {
  display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin: 2.4rem 0 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--stroke);
}
.pager a {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: .85rem 1rem;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  text-decoration: none;
  background: var(--panel);
}
.pager a:hover { border-color: rgba(34, 211, 197, .5); }
.pager .dir { display: block; font: 600 .72rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: .45rem; }
.pager .name { color: #fff; font-weight: 600; font-size: .97rem; }
.pager .next { text-align: end; }

/* ---------- aside ---------- */
.aside { font-size: .9rem; }
.aside h2 {
  font: 600 .76rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 .9rem;
}
.aside ol { list-style: none; margin: 0 0 1.6rem; padding: 0; counter-reset: lesson; }
.aside ol li { counter-increment: lesson; margin: 0; }
.aside ol a {
  display: flex; gap: .6rem; align-items: baseline;
  padding: .5rem .55rem;
  border-radius: 9px;
  color: var(--ink-2);
  text-decoration: none;
  line-height: 1.35;
}
.aside ol a::before {
  content: counter(lesson, decimal-leading-zero);
  font: 600 .72rem/1 var(--mono);
  color: var(--ink-3);
  min-width: 1.4rem;
}
.aside ol a:hover { background: rgba(120, 165, 235, .09); color: #fff; }
.aside ol a[aria-current] { background: rgba(34, 211, 197, .12); color: #fff; }
.aside ol a[aria-current]::before { color: var(--teal); }

.side-card {
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--panel);
  padding: .95rem 1rem;
  margin-bottom: 1.2rem;
}
.side-card p { margin: 0 0 .7rem; color: var(--ink-2); font-size: .88rem; }
.side-card p:last-child { margin-bottom: 0; }

/* ---------- index / cards ---------- */
.cards { display: grid; gap: .9rem; margin: 1.6rem 0 0; padding: 0; list-style: none; }
@media (min-width: 760px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cards li {
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1rem 1.1rem;
}
.cards a { color: #fff; text-decoration: none; font-weight: 650; font-size: 1.02rem; }
.cards a:hover { color: var(--teal); }
.cards .num { font: 600 .72rem/1 var(--mono); color: var(--teal); letter-spacing: .08em; display: block; margin-bottom: .5rem; }
.cards p { margin: .45rem 0 0; color: var(--ink-2); font-size: .9rem; line-height: 1.55; }
/* The card carries the same one-sentence definition that opens the
   lesson, so the hub page is quotable without a click. */
.cards .blurb { color: var(--ink-3); }
.cards .def { color: #d6e4f7; font-size: .9rem; }

/* ---------- wiring map figure ---------- */
.wiring-figure {
  margin: 0 0 1.8rem;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  overflow: hidden;
  background: #08162b;
}
.wiring-figure img { display: block; width: 100%; height: auto; }
.wiring-figure figcaption {
  padding: .7rem .95rem;
  border-top: 1px solid var(--stroke);
  color: var(--ink-3);
  font: 500 .82rem/1.55 var(--mono);
}

/* Real captures of the simulator reuse the wiring-image frame, lifted a
   little so a photograph of the app is not read as another diagram, and
   set in the body face because the caption is prose, not pin names. */
.wiring-figure.shot {
  margin: 1.9rem 0 2.1rem;
  box-shadow: 0 30px 70px -46px rgba(0, 0, 0, .95);
}
.wiring-figure.shot figcaption { font-family: inherit; font-weight: 400; font-size: .86rem; line-height: 1.6; color: var(--ink-2); }

/* ---------- sources ---------- */
.sources-note { color: var(--ink-3); font-size: .92rem; }
.sources {
  list-style: none;
  margin: 0 0 1.6rem;
  padding: 0;
  display: grid;
  gap: .45rem;
}
.sources li {
  position: relative;
  padding-inline-start: 1.15rem;
  font-size: .93rem;
  line-height: 1.5;
}
.sources li::before {
  content: "↗";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  color: var(--teal);
  font-family: var(--mono);
  font-size: .85rem;
}

/* ---------- related lessons ---------- */
.related {
  margin: 2.2rem 0 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--stroke);
}
.related ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .7rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.related a {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  height: 100%;
  padding: .8rem .9rem;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--panel);
  text-decoration: none;
}
.related a:hover { border-color: rgba(34, 211, 197, .5); }
.rel-kw { font: 600 .7rem/1.2 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--teal); }
.rel-title { color: #fff; font-weight: 600; font-size: .93rem; line-height: 1.35; }

/* ---------- author card ---------- */
.author-card {
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1.1rem 1.2rem;
  margin: 0 0 2rem;
}
.author-head { display: flex; align-items: center; gap: .8rem; margin-bottom: .8rem; }
.author-mark {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--teal), var(--blue));
  color: #04121f; font: 800 15px/1 var(--mono);
}
.author-name { margin: 0; color: #fff; font-weight: 700; }
.author-name span { color: var(--ink-3); font-weight: 500; font-size: .82rem; }
.author-meta { margin: .15rem 0 0; color: var(--ink-3); font: 500 .78rem/1.4 var(--mono); }
.author-card p:not(.author-name):not(.author-meta) { color: var(--ink-2); font-size: .95rem; }
.author-links { margin: 0; font-size: .88rem; }

/* ---------- footer ---------- */
.foot {
  border-top: 1px solid var(--stroke);
  background: rgba(4, 12, 24, .7);
  padding: 2.2rem clamp(1rem, 4vw, 2.4rem) 3rem;
  font-size: .88rem;
  color: var(--ink-3);
}
.foot-inner { max-width: 1180px; margin: 0 auto; display: grid; gap: 1.2rem; }
@media (min-width: 760px) { .foot-inner { grid-template-columns: 2fr 1fr 1fr; } }
.foot h2 { font: 600 .74rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 .7rem; }
.foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .38rem; }
.foot a { color: var(--ink-2); text-decoration: none; }
.foot a:hover { color: var(--teal); }
.foot p { margin: 0 0 .5rem; }
.stamp { font: 500 .8rem/1.6 var(--mono); color: var(--ink-3); }

@media (max-width: 560px) {
  .top { gap: .55rem; padding-inline: 1rem; }
  .brand { font-size: .95rem; white-space: nowrap; }
  .brand-mark { width: 22px; height: 22px; font-size: 12px; }
  .top nav { gap: .8rem; font-size: .85rem; }
  .top nav a { white-space: nowrap; }
  .standfirst { font-size: 1.05rem; }
}

@media (max-width: 560px) {
  .top { gap: .55rem; padding-inline: 1rem; }
  .brand { font-size: .95rem; white-space: nowrap; }
  .brand-mark { width: 22px; height: 22px; font-size: 12px; }
  .top nav { gap: .8rem; font-size: .85rem; }
  .top nav a { white-space: nowrap; }
  .standfirst { font-size: 1.05rem; }
}

@media print {
  .top, .aside, .cta, .pager, .foot { display: none; }
  body { background: #fff; color: #111; }
  .article p, .article li { color: #222; }
}
