/* =====================================================================
   styles.css — the render cube

   Design idea: a workbench at night. Warm graphite behind, so the
   printed PETG layers are the lightest thing on screen. Hairlines
   instead of boxes, numbers in monospace, and ONE accent colour — the
   green of an activity LED, the light a board shows while it works.
   Red-orange appears only for 230 V, and yellow only for DC: a colour
   on this page always means the same thing.

   Sections (same names as the data-sid in index.html):
     1. tokens, type, base
     2. stage      — canvas, poster, 3D labels
     3. header     — wordmark, language, chapter rail
     4. content    — chapters and running text
     5. panels     — parts list, assembly, control room
     6. footer + seal
     7. narrow     — phone and tablet
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. TOKENS, TYPE, BASE
   --------------------------------------------------------------------- */
/* Latin and Hebrew come from different files, split by unicode-range, so a
   Hebrew page never downloads the Latin faces until English is chosen.
   font-display: optional — a late font is skipped rather than swapped in,
   which would move the text (CLS). */
@font-face {
  font-family: 'Grotesk';
  src: url('assets/space-grotesk-var.woff2') format('woff2-variations');
  font-weight: 300 700; font-display: optional;
  unicode-range: U+0000-00FF, U+2010-205F, U+20AC, U+2122;
}
@font-face {
  font-family: 'Assistant';
  src: url('assets/assistant-var-hebrew.woff2') format('woff2');
  font-weight: 300 800; font-display: optional;
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Mono';
  src: url('assets/jetbrains-mono-var.woff2') format('woff2-variations');
  font-weight: 300 700; font-display: optional;
  unicode-range: U+0000-00FF, U+2010-205F, U+20AC;
}

:root {
  --ink: #0f0f0d;
  --ink-soft: #181815;
  --bone-100: #ece7dc;
  --bone-300: #bdb7aa;
  --bone-500: #8a8579;
  --line: rgba(214, 205, 186, 0.16);
  --line-strong: rgba(214, 205, 186, 0.34);
  --led: #b6e35a;
  --mains: #ff5a36;
  --sans: 'Grotesk', 'Assistant', 'Segoe UI', system-ui, sans-serif;
  /* Hebrew has no good monospace: in a mono slot it falls through to Assistant,
     digits and Latin stay in JetBrains Mono */
  --mono: 'Mono', 'Assistant', ui-monospace, 'Consolas', monospace;
  --column: min(35rem, 40vw);
  --edge: clamp(1.25rem, 4vw, 3.5rem);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--ink);
  color: var(--bone-300);
  font-family: var(--sans);
  font-size: clamp(0.98rem, 0.3vw + 0.9rem, 1.08rem);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  touch-action: pan-y pinch-zoom;
}
/* Hebrew sets a touch larger: the same size reads smaller than Latin. */
html[lang='he'] body { font-size: clamp(1.02rem, 0.3vw + 0.95rem, 1.13rem); }
/* letter-spacing is a Latin habit; it pulls Hebrew words apart */
html[lang='he'] :is(.kicker, .brand-note, #rail button, .ctl-name, .slider span, .step-count, .step-ref, .label) { letter-spacing: 0; }

/* The reading veil: fixed over the canvas so the text stays legible
   without a box round every paragraph. It sits on the reading side. */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  background: linear-gradient(90deg, rgba(15, 15, 13, 0.95) 0%, rgba(15, 15, 13, 0.85) 24%,
    rgba(15, 15, 13, 0.3) 44%, rgba(15, 15, 13, 0) 58%);
}
html[dir='rtl'] body::before {
  background: linear-gradient(270deg, rgba(15, 15, 13, 0.95) 0%, rgba(15, 15, 13, 0.85) 24%,
    rgba(15, 15, 13, 0.3) 44%, rgba(15, 15, 13, 0) 58%);
}

.skip {
  position: fixed; inset-inline-start: 0; top: 0; z-index: 100;
  transform: translateY(-120%);
  background: var(--led); color: var(--ink);
  padding: 0.6rem 1rem; font-weight: 600; text-decoration: none;
}
.skip:focus { transform: none; }
:focus-visible { outline: 2px solid var(--led); outline-offset: 3px; }

a { color: var(--bone-100); text-decoration-color: var(--line-strong); text-underline-offset: 0.2em; }
a:hover { color: var(--led); }

/* ---------------------------------------------------------------------
   2. STAGE — canvas, poster still and the labels pinned to the model
   --------------------------------------------------------------------- */
/* Above the text (z 15), under the header (z 20). No pointer events: the
   model is turned through window-level handlers (scene.js), so an
   invisible canvas never sits on top of a link or a slider. */
#stage { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
#poster {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transition: opacity 0.6s ease;
}
#poster.gone { opacity: 0; }
#scene {
  display: block; width: 100%; height: 100%;
  opacity: 0; transition: opacity 0.6s ease; touch-action: pan-y;
}
#scene.on { opacity: 1; }

/* Once the model is live the page shows the grab hand, except over text
   on a mouse: there a drag selects, it does not turn (scene.js). */
body:has(#scene.on) { cursor: grab; }
body:has(#scene.on) :is(a, button, label, select, summary) { cursor: pointer; }
body:has(#scene.on) input { cursor: auto; }
@media (pointer: fine) {
  body:has(#scene.on) :is(.chapter .text, .note, dl.readout, footer) { cursor: auto; }
}
body.dreht { cursor: grabbing; user-select: none; -webkit-user-select: none; }
input[type='range'] { touch-action: auto; }

#labels { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.label {
  position: absolute; top: 0; left: 0;
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.45; letter-spacing: 0.03em;
  color: var(--bone-100); white-space: nowrap;
  padding: 0.38rem 0.65rem;
  background: rgba(15, 15, 13, 0.78);
  border-inline-start: 1px solid var(--led);
  opacity: 0; transition: opacity 0.45s ease;
}
.label.on { opacity: 1; }
.label b { display: block; font-weight: 500; }
.label i { font-style: normal; color: var(--bone-500); font-size: 0.68rem; }

/* capture mode (?still): nothing but the canvas, for the poster still */
body.capture :is(header, main, footer, #labels, #poster, .skip, .wdm-seal),
body.capture::before { display: none !important; }
body.capture #scene { opacity: 1; }

/* ---------------------------------------------------------------------
   3. HEADER — wordmark on the reading side, language and rail opposite
   --------------------------------------------------------------------- */
header {
  position: fixed; z-index: 20; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: var(--edge); pointer-events: none;
}
/* opaque over the whole header and fading only below it, so a line of
   running text never shows through the wordmark */
header::before {
  content: ''; position: absolute; z-index: -1; inset: 0 0 auto 0;
  height: calc(100% + 1.6rem);
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink) calc(100% - 1.6rem), transparent 100%);
}
.brand { pointer-events: auto; }
.brand-name { display: block; font-weight: 600; color: var(--bone-100); font-size: 1.05rem; letter-spacing: -0.01em; }
.brand-note {
  display: block; margin-top: 0.1rem;
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.08em; color: var(--bone-500);
}
.header-side { pointer-events: auto; display: grid; gap: 0.7rem; justify-items: end; }
.lang {
  background: none; border: 1px solid var(--line-strong); cursor: pointer;
  padding: 0.38rem 0.75rem; min-height: 2.25rem;
  font-family: var(--sans); font-size: 0.8rem; color: var(--bone-100);
  transition: border-color 0.2s, color 0.2s;
}
.lang:hover { border-color: var(--led); color: var(--led); }

#rail { display: flex; align-items: center; gap: 1.1rem; }
/* not on the opening screen: there the cube and one sentence are the page */
body[data-chapter='ch-start'] #rail { visibility: hidden; }
#rail button {
  background: none; border: 0; cursor: pointer;
  padding: 0.2rem 0 0.32rem; border-bottom: 1px solid transparent;
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.04em;
  color: var(--bone-500); white-space: nowrap;
  transition: color 0.2s, border-color 0.25s;
}
#rail button:hover { color: var(--bone-300); }
#rail button[aria-current='true'] { color: var(--led); border-bottom-color: var(--led); }

/* ---------------------------------------------------------------------
   4. CONTENT — the chapters scroll, the model stays
   --------------------------------------------------------------------- */
main { position: relative; z-index: 10; pointer-events: none; }
.chapter {
  min-height: 118vh;
  display: flex; align-items: center;
  padding: 8rem var(--edge);
}
.chapter .text { width: var(--column); pointer-events: auto; }

.kicker {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em;
  color: var(--led); margin: 0 0 1rem;
}
h1, h2 {
  font-weight: 600; letter-spacing: -0.02em; line-height: 1.08;
  color: var(--bone-100); margin: 0 0 1.2rem; text-wrap: balance;
}
html[lang='he'] :is(h1, h2) { letter-spacing: 0; font-weight: 700; line-height: 1.12; }
h1 { font-size: clamp(2.5rem, 5.6vw, 4.3rem); }
h2 { font-size: clamp(1.95rem, 4vw, 3.05rem); }

.chapter p { margin: 0 0 1rem; max-width: 34rem; }
.lead { font-size: 1.12em; color: var(--bone-100); }
.note {
  font-family: var(--mono); font-size: 0.74rem; line-height: 1.75; letter-spacing: 0.01em;
  color: var(--bone-500);
  margin-top: 1.4rem; border-inline-start: 1px solid var(--line); padding-inline-start: 0.9rem;
}
html[lang='he'] .note { font-family: var(--sans); font-size: 0.86rem; letter-spacing: 0; }
.note-tight { margin-top: 0.2rem; }
.tally {
  font-family: var(--mono); font-size: 0.95rem; color: var(--led);
  font-variant-numeric: tabular-nums; min-height: 1.7em; margin-top: 1.6rem;
}

/* ---------------------------------------------------------------------
   5. PANELS — parts list, assembly step, control room
   --------------------------------------------------------------------- */
.panel { margin-top: 1.6rem; border-top: 1px solid var(--line); padding-top: 1.1rem; }

.btn {
  font-family: var(--sans); font-size: 0.86rem; color: var(--bone-100);
  background: none; border: 1px solid var(--line-strong);
  padding: 0.5rem 1rem; min-height: 2.5rem; cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn:hover { border-color: var(--led); color: var(--led); }
.btn-quiet { color: var(--bone-500); border-color: var(--line); }
.btn[disabled] { opacity: 0.35; cursor: default; }
.btn[disabled]:hover { border-color: var(--line); color: var(--bone-500); }

/* sliders: a hairline track and a round bone-coloured thumb */
input[type='range'] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 1.6rem; background: none; cursor: pointer; margin: 0;
}
input[type='range']::-webkit-slider-runnable-track { height: 1px; background: var(--line-strong); }
input[type='range']::-moz-range-track { height: 1px; background: var(--line-strong); }
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none; width: 0.95rem; height: 0.95rem; margin-top: -0.47rem;
  background: var(--bone-100); border: 0; border-radius: 50%;
}
input[type='range']::-moz-range-thumb { width: 0.95rem; height: 0.95rem; background: var(--bone-100); border: 0; border-radius: 50%; }
input[type='range']:hover::-webkit-slider-thumb { background: var(--led); }
input[type='range']:hover::-moz-range-thumb { background: var(--led); }

.slider { display: grid; gap: 0.2rem; margin-top: 1.4rem; max-width: 18rem; }
.slider span, .ctl-name {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; color: var(--bone-500);
}

/* --- parts list ------------------------------------------------------- */
#part-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.4rem; }
#part-list button {
  text-align: start; width: 100%; min-height: 2.25rem;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 0.4rem 0; cursor: pointer;
  font-family: var(--sans); font-size: 0.86rem; color: var(--bone-300);
  transition: color 0.18s, border-color 0.18s;
}
#part-list button:hover { color: var(--bone-100); border-color: var(--line-strong); }
#part-list button[aria-selected='true'] { color: var(--led); border-color: var(--led); }

.panel-info { border-top-color: var(--led); }
.panel-info h3 { margin: 0 0 0.2rem; font-size: 1.2rem; font-weight: 600; color: var(--bone-100); }
.panel-info .kind { font-family: var(--mono); font-size: 0.72rem; color: var(--led); margin: 0 0 0.7rem; }
html[lang='he'] .panel-info .kind { font-family: var(--sans); font-size: 0.82rem; }
.panel-info button { margin-top: 0.6rem; }

/* --- assembly step ---------------------------------------------------- */
.step-count { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; color: var(--bone-500); margin: 0 0 0.4rem; }
.step-name { font-size: 1.25rem; color: var(--bone-100); margin: 0 0 0.4rem; font-weight: 600; }
.step-text { min-height: 5.4em; }
.step-ref { font-family: var(--mono); font-size: 0.72rem; color: var(--led); }
.step-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.4rem 0 1rem; }
.progress { height: 1px; background: var(--line); }
/* scaleX, not width: a transform never triggers layout */
#progress-bar { height: 1px; background: var(--led); transform-origin: left; transform: scaleX(0); transition: transform 0.4s ease; }
html[dir='rtl'] #progress-bar { transform-origin: right; }

/* --- control room ----------------------------------------------------- */
.panel-console { display: grid; gap: 1.05rem; }
.ctl { display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 1rem; align-items: baseline; }
.ctl input[type='range'] { grid-column: 1 / -1; }
.ctl-val { font-family: var(--mono); font-size: 0.85rem; color: var(--bone-100); font-variant-numeric: tabular-nums; }
.ctl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.ctl-row .ctl { grid-template-columns: 1fr; }
.ctl select, .ctl input[type='number'] {
  font: inherit; font-family: var(--mono); font-size: 0.9rem;
  color: var(--bone-100); background: var(--ink-soft);
  border: 1px solid var(--line-strong); padding: 0.4rem 0.55rem; min-height: 2.5rem; width: 100%;
}
.ctl-board { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.45rem; }
.ctl-board legend { width: 100%; margin-bottom: 0.35rem; padding: 0; }
.ctl-board label { position: relative; }
.ctl-board input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ctl-board span {
  display: inline-block; padding: 0.45rem 0.8rem; min-height: 2.4rem;
  border: 1px solid var(--line-strong); font-size: 0.84rem; color: var(--bone-300);
  transition: border-color 0.2s, color 0.2s;
}
.ctl-board input:checked + span { border-color: var(--led); color: var(--led); }
.ctl-board input:focus-visible + span { outline: 2px solid var(--led); outline-offset: 2px; }

.readout {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.9rem 1.2rem;
  margin: 0.3rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line);
}
.readout div { display: grid; gap: 0.1rem; }
.readout dt { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.04em; color: var(--bone-500); }
html[lang='he'] .readout dt { font-family: var(--sans); font-size: 0.78rem; }
.readout dd {
  margin: 0; font-family: var(--mono); font-size: 1.3rem; color: var(--bone-100);
  font-variant-numeric: tabular-nums;
}
.readout dd small { font-size: 0.66rem; color: var(--bone-500); }
.status {
  font-size: 0.9rem; line-height: 1.6; margin: 0;
  border-inline-start: 2px solid var(--led); padding-inline-start: 0.8rem; color: var(--bone-300);
}

.chapter-sources { min-height: auto; padding-bottom: 4rem; }
.chapter-sources .text { width: min(44rem, 92vw); }
.chapter-sources p { max-width: 44rem; font-size: 0.94rem; }

/* ---------------------------------------------------------------------
   6. FOOTER + SEAL
   --------------------------------------------------------------------- */
footer {
  position: relative; z-index: 10;
  padding: 2rem var(--edge) 2.5rem; border-top: 1px solid var(--line);
  font-size: 0.84rem; color: var(--bone-500);
  background: rgba(15, 15, 13, 0.86);
}
footer p { margin: 0; }
/* The studio seal sits in normal flow after the footer. Without its own
   stacking context its difference-blend would mix with the fixed canvas
   behind it and show up in the wrong place. */
.wdm-seal { position: relative; z-index: 10; background: var(--ink); isolation: isolate; }

/* ---------------------------------------------------------------------
   7. NARROW — phone and tablet: the model above, the text below
   --------------------------------------------------------------------- */
@media (max-width: 900px) {
  :root { --column: 100%; }
  body::before, html[dir='rtl'] body::before {
    background: linear-gradient(180deg, rgba(15, 15, 13, 0.7) 0%, rgba(15, 15, 13, 0.12) 13%,
      rgba(15, 15, 13, 0.15) 36%, rgba(15, 15, 13, 0.88) 48%, rgba(15, 15, 13, 0.97) 60%);
  }
  .chapter { min-height: 100vh; padding: 46vh var(--edge) 5rem; align-items: flex-start; }
  #ch-start { padding-top: 56vh; }
  header { flex-direction: column; gap: 0.7rem; }
  .header-side {
    position: absolute; top: var(--edge); inset-inline-end: var(--edge);
    justify-items: end;
  }
  #rail {
    position: fixed; top: 4.4rem; left: 0; right: 0;
    padding: 0 var(--edge); gap: 0.95rem;
    overflow-x: auto; scrollbar-width: none;
  }
  #rail::-webkit-scrollbar { display: none; }
  #rail button { flex: 0 0 auto; font-size: 0.7rem; min-height: 2.25rem; }
  .label { font-size: 0.66rem; white-space: normal; max-width: 60vw; }
  #part-list { grid-template-columns: 1fr; }
  .readout { grid-template-columns: 1fr 1fr; }
  .chapter-sources { padding-bottom: 6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
