/* R41 (G1): the gravity playground page. Colours come from the Remix tokens. */
/* Looks re-skin the stage only: its tokens are overridden, so the canvas (which reads
   them from the stage), the HUD and the frame all follow. Tron: cyan programs on a
   black grid; Clu: the orange of the other side. Dark in either site mode. */
.grav-stage[data-look=grid] { --bg: #02070c; --surface: #06141d; --ink: #e6fbff;
  --muted: #5fb9cc; --line: #19d7ff; --accent: #8ff3ff; --second: #ff8a1f;
  --soft: #08323f; border-color: #19d7ff; box-shadow: 0 0 18px #19d7ff55; }
.grav-stage[data-look=clu] { --bg: #0b0502; --surface: #1a0c04; --ink: #fff0dc;
  --muted: #c98550; --line: #ff7a14; --accent: #ffb347; --second: #ff3b1f;
  --soft: #3d1c08; border-color: #ff7a14; box-shadow: 0 0 18px #ff7a1455; }
.grav-page { padding-block: 24px 64px; }
.grav-page h1 { font-size: clamp(1.75rem, 3.5vw, 2.5rem); margin: 4px 0 8px; }
.grav-page .lead { max-width: 90ch; font-size: 1rem; margin-block: 0 4px; }
.grav-honest { color: var(--muted); max-width: 100ch; font-size: .8125rem; margin-block: 0 12px; }
.grav-stage { position: relative; width: 100%; aspect-ratio: 16 / 10; max-height: 76vh;
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  background: var(--bg); touch-action: none; user-select: none;
  -webkit-user-select: none; }
.grav-stage canvas { display: block; width: 100%; height: 100%; opacity: 1;
  image-rendering: auto; cursor: crosshair; }
.grav-stage canvas:focus-visible { outline-offset: -3px; }
.grav-hud { position: absolute; top: 10px; left: 14px; right: 14px; margin: 0;
  display: flex; flex-wrap: wrap; gap: 4px 18px; pointer-events: none;
  font: 600 .75rem/1.4 ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.grav-hud b { color: var(--ink); }
.grav-hud .bad b { color: var(--accent); }
.grav-hint { position: absolute; left: 14px; right: 14px; bottom: 10px;
  margin: 0; pointer-events: none; font-size: .8125rem; color: var(--muted); }
/* The how-to text only shows while a mouse is over the canvas, the keyboard has focus in it, or for a few seconds
   after a touch (a click's focus does not count); a status such as "Paused because motion is reduced" always shows. */
.grav-hint:not(.is-status) { opacity: 0; transition: opacity .2s; }
@media (hover: hover) { .grav-stage:hover .grav-hint { opacity: 1; } }
.grav-stage:has(canvas:focus-visible) .grav-hint, .grav-stage.show-hint .grav-hint { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .grav-hint { transition: none; } }
.grav-readout { margin: 14px 0 2px; min-height: 1.6em;
  font: 600 .9375rem/1.5 ui-monospace, Menlo, Consolas, monospace; }
.grav-note { max-width: 80ch; min-height: 1.6em; }
.grav-controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 18px; }  /* rows wrap inside the page, not past it */
.grav-row { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; }
.grav-group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.grav-group > span:first-child, .grav-field {
  font: 600 .75rem ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  margin-right: 4px; }
.grav-tools { display: contents; }
/* Each group's label sits on its own line and a slider fills the row beside its name, in the side panel and on a phone alike. */
.grav-group > span:first-child { flex-basis: 100%; }
.grav-field:has(> input[type=range]) { display: grid; grid-template-columns: 5em minmax(0, 1fr) auto; flex: 1 1 100%; }
.grav-row { gap: 12px 24px; }
.grav-field { display: inline-flex; flex-wrap: wrap; gap: 10px; align-items: center; max-width: 100%; }
.grav-field select { min-height: 40px; min-width: 0; max-width: 100%;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font: 500 .9375rem 'Segoe UI', Arial, sans-serif; letter-spacing: 0;
  text-transform: none; }
.grav-chip { display: inline-flex; gap: 6px; align-items: center;
  min-height: 36px; padding: 6px 13px; border: 1px solid var(--line);
  border-radius: 999px; background: transparent; color: var(--ink);
  font-size: .875rem; }
.grav-chip:hover { border-color: var(--accent); }
.grav-wide { display: none; }  /* Only where a wider column exists: see the 1000px block. */
.grav-chip[aria-pressed=true] { background: var(--accent);
  border-color: var(--accent); color: var(--button-ink); }
.grav-chip i { width: 10px; height: 10px; border-radius: 50%;
  background: var(--second); }
.grav-chip i:is([data-type=star], [data-type=hole]) { background: var(--accent); }
.grav-chip i:is([data-type=moon], [data-type=rock], [data-type=chibaku]) { background: var(--muted); }
.grav-chip i[data-type=comet] { background: var(--ink); }
.grav-chip i:is([data-type=neutron]) { background: var(--second); }
.grav-chip i[data-type=quasar] { background: var(--accent); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--accent); }
.grav-chip i:is([data-type=nova], [data-type=hyper]) { background: var(--accent); box-shadow: 0 0 6px 2px var(--accent); }
.grav-chip[aria-pressed=true] i { background: currentColor; }
.grav-story { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); }
.grav-story h2 { font-size: 1.75rem; margin-bottom: 8px; }
.grav-story p { color: var(--muted); max-width: 70ch; }
@media (pointer: coarse) {
  .grav-chip, .grav-field select { min-height: 44px; }
}
@media (max-width: 720px) {
  .grav-stage { aspect-ratio: 4 / 5; }
  .grav-hint { font-size: .75rem; }
  /* The five transport chips share one row where they fit and wrap where they don't. Play keeps
     Pause's width, so the label swap cannot reflow the row. */
  .grav-transport .grav-chip { flex: 1 1 auto; justify-content: center; padding-inline: 6px; }
  #gravity-play { min-width: 4em; }
}

.grav-goals ul { list-style: none; padding: 0; margin: 0.5rem 0; display: grid; gap: 0.25rem; }
.grav-goals li { color: var(--muted, inherit); }
.grav-goals li.done { color: inherit; font-weight: 600; }
.grav-chip i[data-type=worm] { background: transparent; border: 2px dashed var(--second); }
.grav-chip i[data-type=micro] { width: 6px; height: 6px; background: #000; border: 1px solid var(--second); box-shadow: 0 0 6px 1px var(--second); }
.grav-stage[data-look] .grav-hud, .grav-stage[data-look] .grav-hint {
  text-shadow: 0 0 4px var(--bg), 0 0 9px var(--bg); }
.grav-more { margin-top: 4px; }
/* Both disclosures read as buttons before hover: bordered pill, chevron, and a label that names the action. */
.grav-more > summary, .grav-goals > summary { cursor: pointer; width: fit-content; max-width: 100%;
  min-height: 40px; display: flex; align-items: center; gap: 10px; padding: 6px 16px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink);
  font-size: .9375rem; font-weight: 600; }
.grav-more > summary:hover, .grav-goals > summary:hover { border-color: var(--accent); }
.grav-more > summary::after, .grav-goals > summary::after, .grav-keyboard > summary::after { content: ""; flex: none; width: .5em; height: .5em;
  border: solid currentColor; border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); }
.grav-more[open] > summary::after, .grav-goals[open] > summary::after, .grav-keyboard[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.grav-more > summary small { display: block; font-weight: 400; color: var(--muted); }
.when-open, [open] > summary > .when-closed { display: none; }
[open] > summary > .when-open { display: inline; }
.grav-more[open] > summary, .grav-goals[open] > summary { margin-bottom: 8px; }
.grav-goals { margin-top: 12px; }
.grav-tip { margin: 0; color: var(--ink); }
.grav-need { color: var(--muted); font-size: .8125rem; }
.grav-more .grav-row { margin-block: 10px; }
.grav-labs { margin-top: 20px; display: grid; gap: 8px; }
.grav-labs h2 { font-size: 1.5rem; margin: 0; }
.grav-labs > p { margin: 0; }
.grav-labs .caption a { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }  /* inline: a 44px-tall box would double-space every line of the sentence */
.grav-keyboard { max-width: 70ch; color: var(--muted); }
.grav-keyboard > summary { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.grav-keyboard p { margin: 4px 0 0; }
.grav-experiments { margin-top: 20px; display: grid; gap: 12px; }
.grav-experiments h2 { font-size: 1.5rem; margin: 0; }
.grav-experiments article { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 14px 18px; max-width: 70ch; }
.grav-experiments h3 { margin: 0 0 6px; font-size: 1.0625rem; }
.grav-experiments article p { margin: 4px 0; color: var(--muted); }

/* Laptop and wider: scene on the left, controls beside it, so changing a control keeps the result in view.
   The panel scrolls inside its own box, never past the canvas. */
@media (min-width: 1000px) {
  /* Wide view (the button) gives the demo the whole window; the help sits below the canvas on purpose. */
  .grav-page.is-wide.shell { width: calc(100% - 2 * var(--site-gutter)); max-width: 2200px; }
  .grav-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: 24px; align-items: start; }
  .grav-workspace .grav-stage { max-height: calc(100vh - 120px); min-height: 420px; }
  .grav-workspace .grav-stage { min-width: 360px; max-width: 100%; }
  .grav-workspace .grav-controls { margin-top: 0; max-height: calc(100vh - 24px); overflow-y: auto; padding: 4px 8px 4px 2px; }
  .grav-workspace .grav-experiments { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
  .grav-experiments h2 { grid-column: 1 / -1; }
  .grav-experiments article { max-width: none; }
}

/* Wide view only changes anything once the window is wider than the 1240px site column. */
@media (min-width: 1320px) { .grav-wide { display: inline-flex; } }
/* A dragged width does not outlive the layouts that offer the handle. */
@media (max-width: 999px) { .grav-stage { width: 100% !important; } }
body:has(.grav-page.is-wide) > header { padding-inline: var(--site-gutter); }
/* A mouse can drag the canvas's corner to size it; touch and the Wide view button cover the rest. */
@media (min-width: 1000px) and (pointer: fine) { .grav-workspace .grav-stage { resize: horizontal; } }
