*, *::before, *::after { box-sizing: border-box; }

:root {
  --void: #03122a;
  --bone: #eef3f2;
  --vh: 100svh;
}

html { scroll-behavior: auto; }

body {
  margin: 0;
  background: var(--void);
  color: var(--bone);
  font: 400 1rem/1.5 ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  /* Sized from visualViewport in JS: the mobile URL bar resizing 100vh
     mid-scroll would otherwise jolt the canvas and the layout together. */
  height: var(--vh);
  display: block;
  z-index: 0;
}

#content { position: relative; z-index: 2; }

.chapter {
  min-height: 100svh;
  min-height: var(--vh);
  display: flex;
  align-items: flex-end;
  padding: clamp(1.5rem, 4vw, 4rem);
}

/* Stage 1 scaffolding only — replaced by the editorial layout in stage 2. */
.stage-marker {
  margin: 0;
  font: 500 0.75rem/1 ui-monospace, monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--bone) 55%, transparent);
}
.stage-marker span { margin-right: 0.75em; }

.fps {
  position: fixed;
  z-index: 10;
  top: 0.75rem; left: 0.75rem;
  padding: 0.35rem 0.6rem;
  font: 500 0.7rem/1.4 ui-monospace, monospace;
  letter-spacing: 0.08em;
  white-space: pre-line;   /* the triangle count sits on its own line */
  color: var(--bone);
  background: rgb(3 18 42 / 0.72);
  border: 1px solid rgb(238 243 242 / 0.18);
}

.is-still #content, .is-still .fps { display: none; }

/* Workbench: the grass comparisons as buttons. Opened with ?test or the t key,
   never shown otherwise, so it stays out of the piece. Same chrome as .fps —
   dark, thin-ruled, monospace — since both are instruments, not furniture. */
.testpanel {
  position: fixed;
  z-index: 10;
  right: 0.75rem; bottom: 0.75rem;
  width: min(19rem, calc(100vw - 1.5rem));
  max-height: calc(var(--vh) - 1.5rem);
  overflow-y: auto;
  padding: 0.7rem 0.8rem 0.8rem;
  font: 500 0.7rem/1.4 ui-monospace, monospace;
  letter-spacing: 0.06em;
  color: var(--bone);
  background: rgb(3 18 42 / 0.86);
  border: 1px solid rgb(238 243 242 / 0.18);
  backdrop-filter: blur(6px);
}
.testpanel[hidden] { display: none; }

.testpanel-head { display: flex; align-items: center; justify-content: space-between; }
.testpanel h2 {
  margin: 0;
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.testpanel h3 {
  margin: 0.9rem 0 0.4rem;
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: color-mix(in srgb, var(--bone) 45%, transparent);
}
.testpanel-row { display: flex; flex-wrap: wrap; gap: 0.3rem; }

/* A folded section. The summary is dressed as an h3 so the panel reads as one
   list of headings whether a section is open or shut, and the marker is the only
   thing saying this one has a body. Ruled above rather than below: that separates
   the three that fold from the three that always stand, and from each other,
   without leaving a trailing line under the last one. */
.testpanel-section {
  margin-top: 0.9rem;
  border-top: 1px solid rgb(238 243 242 / 0.12);
}
.testpanel-section > summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: color-mix(in srgb, var(--bone) 45%, transparent);
  cursor: pointer;
  /* Both halves of dropping the native marker: list-style is the modern spelling,
     the pseudo-element is what older WebKit reads. */
  list-style: none;
}
.testpanel-section > summary::-webkit-details-marker { display: none; }
/* Fixed width and no tracking of its own, so opening a section cannot shift its
   own label sideways. Escaped rather than typed, so the glyph does not depend on
   the stylesheet's encoding being guessed correctly. */
.testpanel-section > summary::before {
  content: '+';
  width: 0.8em;
  letter-spacing: 0;
}
.testpanel-section[open] > summary::before { content: "\2212"; }
.testpanel-section > summary:hover { color: var(--bone); }

/* A named block inside a folded section. Set at the planting groups' weight
   rather than the summary's, so Snap reads as a peer of Grass #1 and not as a
   second section heading — Advanced is a container that will hold more than
   Snap, and without this the ON/OFF pair and its Steps say nothing about what
   they quantise. */
.testpanel-sub {
  margin: 0 0 0.35rem;
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* A row of actions closing a stack of settings, rather than one more setting.
   Set at the gap that separates one planting group from the next, because that
   is the same distinction: what follows is a different kind of thing, not the
   next line of the same list. */
.testpanel-actions { margin-top: 0.6rem; }

.testpanel-btn {
  flex: 1 1 auto;
  padding: 0.35rem 0.5rem;
  font: inherit;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--bone) 60%, transparent);
  background: transparent;
  border: 1px solid rgb(238 243 242 / 0.18);
  cursor: pointer;
}
.testpanel-btn:hover { border-color: rgb(238 243 242 / 0.4); color: var(--bone); }
/* On is the shipped value, off is zero — the border carries the state so the
   two read apart at a glance while comparing frames. */
.testpanel-btn.is-on {
  color: var(--void);
  background: var(--bone);
  border-color: var(--bone);
}

/* A planting group: a name, its own terms, then the controls that rebuild it.
   Ruled off from the one above so three of them do not read as one long list. */
.testpanel-group + .testpanel-group {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgb(238 243 242 / 0.12);
}
.testpanel-group-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
}
.testpanel-check {
  margin: 0;
  accent-color: var(--bone);
  cursor: pointer;
}
/* A sub-heading that is not the first thing in its folded section. The first
   gets its air from the summary above it; a later one would otherwise sit
   straight on whatever the setting before it ended with. Ruled when it follows
   a group, for the same reason one group is ruled off from the next. */
.testpanel-stat + .testpanel-sub { margin-top: 1.1rem; }
.testpanel-group + .testpanel-sub {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgb(238 243 242 / 0.12);
}

/* Label on the left, value on the right — the value is what you read while
   dragging, so it wants to sit still rather than follow the handle. */
.testpanel-ctl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.4rem;
  color: color-mix(in srgb, var(--bone) 45%, transparent);
}
.testpanel-slider {
  width: 100%;
  margin: 0.25rem 0 0;
  accent-color: var(--bone);
  cursor: pointer;
}
.testpanel-btn-tight { flex: 0 0 auto; }

.testpanel-x {
  padding: 0 0.25rem;
  font: inherit;
  font-size: 1.1em;
  line-height: 1;
  color: color-mix(in srgb, var(--bone) 60%, transparent);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.testpanel-x:hover { color: var(--bone); }

.testpanel-stat {
  margin: 0.9rem 0 0;
  white-space: pre-line;
  color: color-mix(in srgb, var(--bone) 45%, transparent);
  letter-spacing: 0.04em;
}

/* What the workbench collapses to. Sits where the panel's own corner was, so
   closing and reopening does not move the target under the cursor. */
.testpanel-handle {
  position: fixed;
  z-index: 10;
  right: 0.75rem; bottom: 0.75rem;
  padding: 0.4rem 0.6rem;
  font: 500 0.7rem/1 ui-monospace, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--bone) 60%, transparent);
  background: rgb(3 18 42 / 0.72);
  border: 1px solid rgb(238 243 242 / 0.18);
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.testpanel-handle:hover { color: var(--void); background: var(--bone); border-color: var(--bone); }
.testpanel-handle[hidden] { display: none; }
