/* Two zones (Part I 8.1). The page is a notebook -- light ground, prose, real typography --
   with instrument screens embedded in it: dark, dense, live. That mirrors how the subject is
   actually practised, paper and oscilloscope, and it sidesteps both the wall-to-wall dark
   dashboard with one acid accent and the cream-and-terracotta essay. */

:root {
  --paper: #f7f5f1;
  --paper-ink: #1c1a18;
  --paper-dim: #5d5852;
  --rule: #ddd8d0;
  --instrument: #12151a;   /* genuinely blue-shifted dark, not tinted near-black */
  --instrument-ink: #e8e6e3;
  --instrument-dim: #8a8f98;
  --accent: #3e6fd9;       /* the one non-derived colour; human interactions only */
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--paper-ink);
  font-family: Spectral, Georgia, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.65;
  font-variant-numeric: tabular-nums;
}

#loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--instrument); color: var(--instrument-dim);
  font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 13px; z-index: 10;
}

main { display: block; }

.prose {
  max-width: 62ch;           /* Part I 8.3 */
  margin: 0 auto;
  padding: 3.4rem 1.25rem;
}

h1 {
  font-size: 2.6rem; font-weight: 600; line-height: 1.1;
  margin: 0 0 1.4rem; letter-spacing: -0.015em;
}
h2 {
  font-size: 1.35rem; font-weight: 600; line-height: 1.25;
  margin: 2.6rem 0 0.9rem;
}
p { margin: 0 0 1.15rem; }
.lede { font-size: 1.15rem; }
i { font-style: italic; }

/* Numerics, gates and parameters get the engineering monospace. */
.m, code {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.86em;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* ---- instrument zone ---- */

.instrument {
  background: var(--instrument);
  color: var(--instrument-ink);
  padding: 1rem 1.25rem 1.25rem;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.hero { padding-top: 1.25rem; }

.hero-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 0.75rem;
  max-width: 1080px;
  margin: 0 auto;
}
.hero-grid canvas { height: 260px; }

.hero-caption {
  max-width: 1080px; margin: 0.6rem auto 0;
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  color: var(--instrument-dim); font-size: 12px;
}
.hero-caption b { color: var(--instrument-ink); font-weight: 500; }
.dim { color: var(--instrument-dim); }

canvas {
  width: 100%;
  max-width: 100%;
  height: 190px;
  display: block;
  background: var(--instrument);
}

/* Flex items default to min-width:auto, which refuses to shrink below their content. A
   single long unbreakable-looking caption then widens the whole document and the prose,
   centred in that wider body, gets clipped at 360px. Letting these shrink is the fix; the
   text wraps normally once it is allowed to. */
.hero-caption > *, .controls > *, .readouts > * { min-width: 0; }

.panel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  max-width: 1080px;
  margin: 0 auto;
}
.panel-grid.single { grid-template-columns: 1fr; }
.panel-grid.pair { grid-template-columns: 1.15fr 1fr; }
.panel-grid.pair canvas { height: 300px; }
.panel-grid.single canvas { height: 300px; }

.controls, .readouts {
  max-width: 1080px; margin: 0 auto 0.75rem;
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.1rem; align-items: center;
}
.readouts { color: var(--instrument-dim); margin-bottom: 1rem; }
.readouts b { color: var(--instrument-ink); font-weight: 500; margin-left: 0.3rem; }

label { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--instrument-dim); }
label b { color: var(--instrument-ink); font-weight: 500; min-width: 1.2em; }
.check { gap: 0.35rem; }

input[type=range] { width: 84px; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
input[type=number], select {
  background: #1b1f26; color: var(--instrument-ink); border: 1px solid #2a2f38;
  border-radius: 3px; padding: 3px 5px; font: inherit; width: 5.5em;
}
select { width: auto; }

button {
  background: #1b1f26; color: var(--instrument-ink);
  border: 1px solid #333a45; border-radius: 3px;
  padding: 4px 12px; font: inherit; cursor: pointer;
}
button:hover { border-color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

footer {
  background: var(--paper);
  border-top: 1px solid var(--rule);
  padding: 1.6rem 1.25rem 3rem;
  color: var(--paper-dim);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.7;
}
footer p { max-width: 1080px; margin: 0 auto; }

/* Responsive to 360px. The spectrum panel is the one that must survive; the others stack. */
@media (max-width: 900px) {
  .panel-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid.pair { grid-template-columns: 1fr; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-grid canvas { height: 200px; }
}
@media (max-width: 560px) {
  body { font-size: 17px; }
  .hero-caption { gap: 0.2rem 1rem; }
  .hero-caption .dim { flex-basis: 100%; }
  h1 { font-size: 2rem; }
  .panel-grid { grid-template-columns: 1fr; }
  .prose { padding: 2.4rem 1rem; }
  .instrument { padding: 0.85rem 0.85rem 1rem; }
  input[type=range] { width: 68px; }
}

/* The hero is the only motion nobody asked for, so it is the first thing to go. */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
