/* magicbar.org — direction C, "Instrument manual" */

:root {
  --paper: #e7e4dc;
  --ink: #161513;
  --muted: #5b574f;
  --rule: #b9b4a8;
  --accent: #ffaa3c; /* the clock's warm white-orange */
  --wrap: 1180px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.55 Archivo, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--ink); }
a:hover { color: #8a3d12; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 40px; }
.x { font-stretch: 125%; text-wrap: balance; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 36px; }

/* Condensed uppercase labels: section numbers, figure captions, nav, tags */
.label {
  font-stretch: 75%;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .07em;
  text-transform: uppercase;
}

/* Header */
.site-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 16px; padding: 24px 0; border-bottom: 2px solid var(--ink);
}
.brand { display: flex; align-items: baseline; gap: 16px; }
.brand a { font-size: 24px; font-weight: 900; font-stretch: 125%; letter-spacing: -.01em; text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: 28px; }
.site-nav a { text-decoration: none; }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; min-height: 52px; padding: 0 26px;
  font-stretch: 75%; font-weight: 800; font-size: 16px; letter-spacing: .06em; text-transform: uppercase;
  text-decoration: none; border: 2px solid var(--ink);
}
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { background: #2e2b27; color: var(--paper); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn-accent:hover { color: var(--ink); filter: brightness(1.06); }

/* Hero */
.hero { padding: 64px 0 72px; display: flex; flex-direction: column; gap: 40px; }
.hero-top {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr));
  gap: 40px; align-items: end;
}
.hero h1 { margin: 0; font-size: clamp(52px, 7.4vw, 104px); line-height: .9; font-weight: 900; letter-spacing: -.03em; }
.hero-side { display: flex; flex-direction: column; gap: 24px; }
.hero-side p { margin: 0; max-width: 28em; }

.figure { margin: 0; background: var(--accent); padding: clamp(24px, 5vw, 64px); display: flex; flex-direction: column; gap: 20px; }
.figure figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }

/* Numbered sections */
.sec {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  gap: 24px 48px; padding: 64px 0; border-top: 2px solid var(--ink);
}
.sec-head { display: flex; flex-direction: column; gap: 8px; }
.sec-head h2 { margin: 0; font-size: 32px; font-weight: 800; font-stretch: 125%; line-height: 1; }

.table-row {
  display: grid; grid-template-columns: minmax(0, 160px) minmax(0, 1fr) auto;
  gap: 24px; padding: 16px 0; border-bottom: 1px solid var(--rule); align-items: baseline;
}
.table-row strong { font-size: 20px; font-stretch: 125%; }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 40px; }
.cols > div { display: flex; flex-direction: column; gap: 12px; }
.cols p { margin: 0; }

.ways { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); border-left: 1px solid var(--ink); }
.ways > div { padding: 0 24px; border-right: 1px solid var(--ink); display: flex; flex-direction: column; gap: 10px; }
.ways .big { font-size: 56px; font-weight: 900; font-stretch: 125%; line-height: 1; }

pre {
  margin: 0; padding: 16px; background: var(--ink); color: var(--paper);
  font: 14px/1.6 "IBM Plex Mono", ui-monospace, monospace; white-space: pre-wrap; overflow-x: auto;
}

/* Footer */
.site-footer {
  border-top: 2px solid var(--ink); padding: 28px 0 48px;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px;
}

/* Manual (docs) */
.docs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 48px; padding: 56px 0 80px; }
.docs-nav ol { list-style: none; margin: 12px 0 0; padding: 0; border-top: 2px solid var(--ink); }
.docs-nav li a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 12px 0;
  border-bottom: 1px solid var(--rule); text-decoration: none;
}
.docs-nav a[aria-current="page"] { font-weight: 800; }

.prose { max-width: 40em; counter-reset: sec; }
.prose h1 { margin: 0 0 24px; font-size: clamp(40px, 5vw, 64px); line-height: .95; font-weight: 900; font-stretch: 125%; letter-spacing: -.02em; }
.prose h2 {
  margin: 48px 0 12px; padding-top: 20px; border-top: 2px solid var(--ink);
  font-size: 28px; font-weight: 800; font-stretch: 125%; line-height: 1.05;
}
/* Every h2 in the manual gets an automatic "§ 01" number */
.prose h2::before {
  counter-increment: sec; content: "§ " counter(sec, decimal-leading-zero);
  display: block; margin-bottom: 6px; color: var(--muted);
  font-size: 13px; font-weight: 700; font-stretch: 75%; letter-spacing: .07em;
}
.prose code { font: .9em "IBM Plex Mono", monospace; background: rgba(22, 21, 19, .08); padding: .1em .3em; }
.prose pre code { background: none; padding: 0; color: inherit; }
.prose led-panel { margin: 24px 0; }

@media (max-width: 760px) {
  .wrap { padding: 0 20px; }
  .sec, .docs { grid-template-columns: minmax(0, 1fr); }
  .table-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .ways { border-left: 0; }
  .ways > div { border-right: 0; border-top: 1px solid var(--ink); padding: 16px 0; }
}

/* LED panel: 53 × 11 dots. Fast on, slow off = the afterglow. */
led-panel { display: block; }
.led-frame {
  background: #0f0d0b; border-radius: 14px;
  padding: 3.4% 3.8%; box-shadow: inset 0 0 0 1px #2a241e;
}
.led-grid { display: grid; grid-template-columns: repeat(53, minmax(0, 1fr)); }
.led-px {
  aspect-ratio: 1; margin: 17%; border-radius: 50%; background: #2a231c;
  transition: background-color 1.9s cubic-bezier(.12, .6, .25, 1), box-shadow 1.9s cubic-bezier(.12, .6, .25, 1);
}
.led-px.on {
  background: var(--accent);
  box-shadow: 0 0 6px 1px color-mix(in srgb, var(--accent) 55%, transparent);
  transition-duration: .06s;
}
.led-px.dim { background: color-mix(in srgb, var(--accent) 30%, #2a231c); transition-duration: .4s; }

@media (prefers-reduced-motion: reduce) {
  .led-px { transition: none; }
}

/* The real panel (interactive): the board's code does its own fades, and its
   buttons sit beside the frame, as on the board. */
led-panel.live .led-px { transition: none; }
led-panel.live {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center; gap: clamp(10px, 2vw, 20px);
}
led-panel:focus-visible { outline: 3px solid var(--ink); outline-offset: 6px; }
.led-buttons { display: flex; flex-direction: column; gap: 6px; }
.led-buttons button {
  display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  color: #d8d2c6; background: #1e1a16; border: 1px solid #3a322a; border-radius: 6px;
  cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
}
.led-buttons svg { width: 16px; height: 16px; }
.led-buttons button:hover { border-color: #5a4c3e; }
.led-buttons button.held { background: var(--accent); color: var(--ink); border-color: var(--accent); }
