/* =========================================================
   Terminal theme: green monospace on black.
   ========================================================= */

:root {
  --bg: #000000;
  --text: #33ff66;
  --bright: #7dffa0;
  --muted: #1f9e45;
  --line: rgba(51, 255, 102, 0.35);
  --panel: rgba(0, 0, 0, 0.6);

  /* Glass shapes */
  --glass-border: rgba(255, 255, 255, 0.92);
  --glass-fill-1: rgba(255, 255, 255, 0.16);
  --glass-fill-2: rgba(255, 255, 255, 0.03);
  --glass-highlight: rgba(255, 255, 255, 0.55);
  --glass-shadow: rgba(0, 0, 0, 0.45);

  --font: "JetBrains Mono", ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

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

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--bright); }
::selection { background: var(--text); color: var(--bg); }

/* ---------- Command-style buttons & links: "> label" ---------- */
.cmd {
  font: inherit;
  color: var(--text);
  background: none;
  border: 0;
  padding: 2px 0;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.cmd::before { content: "> "; color: var(--muted); }
.cmd:hover, .cmd:focus-visible, .cmd[aria-current="page"], .cmd[aria-pressed="true"] { color: var(--bright); text-decoration: underline; text-underline-offset: 4px; outline: none; }
.cmd:hover::before, .cmd:focus-visible::before { color: var(--bright); }
.cmd .state { color: var(--bright); }


.cmd-list { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin: 0; padding: 0; list-style: none; }
.cmd-row { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; padding: 0; list-style: none; }

/* =========================================================
   Page text (the content panel, and the standalone 404 page)
   ========================================================= */
h1, h2, h3 { color: var(--bright); font-weight: 700; }
h1 { font-size: clamp(1.55rem, 4.4vw, 2.2rem); line-height: 1.25; margin: 0 0 12px; }
h1::after { content: "_"; margin-left: 4px; animation: blink 1.1s steps(1) infinite; }
h1:focus { outline: none; }
h2 { font-size: 1.2rem; margin: 32px 0 10px; }
h2::before { content: "## "; color: var(--muted); }
p { max-width: 70ch; }
.lede { color: var(--muted); margin: 0 0 24px; }

@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { h1::after { animation: none; } }

.meta { color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 24px; font-size: 14px; }
.tag { text-transform: uppercase; letter-spacing: .08em; }
.tag::before { content: "["; }
.tag::after { content: "]"; }

/* Standalone pages (404.html) */
body.page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
body.page main { position: relative; z-index: 1; }

/* Content panel: the open page, in the middle of the screen */
.panel {
  position: fixed;
  z-index: 2;
  top: 12vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, calc(100vw - 640px));
  max-height: 76vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 8px 24px;
  animation: panel-in .25s ease-out;
}
.panel[hidden] { display: none; }
@keyframes panel-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { .panel { animation: none; } }


/* =========================================================
   Home page: full-screen physics playground
   ========================================================= */
body.home { height: 100%; overflow: hidden; overscroll-behavior: none; }

#playground { position: fixed; inset: 0; z-index: 1; touch-action: none; }

/* Heads-up display: sits above the shapes, but lets drags pass through empty space. */
.hud {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px 24px;
  padding: 24px;
  pointer-events: none;
}
.hud-top { top: 0; }
.controls { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.controls .cmd-row { justify-content: flex-end; }
.hud a, .hud button { pointer-events: auto; }
body.is-dragging .hud a, body.is-dragging .hud button { pointer-events: none; }

.intro h1 { font-size: 16.5px; margin: 0 0 10px; letter-spacing: .04em; }
.intro h1::after { content: none; }
.home-link { color: inherit; text-decoration: none; }
.home-link:hover, .home-link:focus-visible { text-decoration: underline; text-underline-offset: 4px; outline: none; }
.note { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- Glass shapes ---------- */
.shape {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 1.1em;
  color: var(--bright);
  text-align: center;
  text-decoration: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  will-change: transform;
  /* Glass: translucent gradient over a blurred copy of what's behind. */
  background: linear-gradient(145deg, var(--glass-fill-1), var(--glass-fill-2) 60%);
  backdrop-filter: blur(5px) saturate(170%);
  -webkit-backdrop-filter: blur(5px) saturate(170%);
  border: 3px solid var(--glass-border);
  /* Inner highlight + soft outer glow smooths the rotated edge. */
  box-shadow:
    inset 0 2px 3px var(--glass-highlight),
    inset 0 -10px 18px rgba(255, 255, 255, 0.05),
    0 0 1px var(--glass-border),
    0 10px 28px var(--glass-shadow);
  outline: 1px solid transparent; /* forces anti-aliased edges when rotated (Firefox) */
  backface-visibility: hidden;
  transition: background .15s;
}
.shape:hover, .shape:focus-visible { background: linear-gradient(145deg, var(--glass-fill-1), var(--glass-fill-1)); outline: none; }
.shape.grabbed { cursor: grabbing; }

.shape.circle { border-radius: 50%; }
.shape.square { border-radius: 0; }

/* Triangles can't use border; the edge is an SVG stroke inside a clip-path. */
.shape.triangle {
  border: 0;
  box-shadow: none;
  padding: 0;
  clip-path: polygon(75% 93.3%, 0% 50%, 75% 6.7%);
}
.shape.triangle svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.shape.triangle polygon { fill: none; stroke: var(--glass-border); stroke-width: 6; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

/* ---------- Sky box / dark room: WebGL ray-traced scene (js/realistic.js) replaces the glass look ---------- */
.realistic { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* Triangles are prisms in the 3D scene (no label), so their flat version just hides. */
:root.realistic-ready .shape.triangle { visibility: hidden; }
:root.realistic-ready .shape.circle,
:root.realistic-ready .shape.square {
  background: none;
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  text-shadow: 0 0 4px var(--bg), 0 0 10px var(--bg), 0 1px 2px var(--bg); /* readable over the render */
}

.shape-title { font-size: 1em; font-weight: 700; line-height: 1.25; } /* base size set per shape in home.js */
.shape-type { font-size: .65em; letter-spacing: .08em; text-transform: uppercase; color: var(--text); opacity: .75; }

/* ---------- Mobile layout: phones, tablets and narrow windows ("mobile" class, set in index.html) ----------
   The menu drops the "> " prompts and the "home" entry (the name goes home), and a page covers
   the whole screen with only the name above it. */
.mobile .cmd-list .cmd::before { content: none; }
.mobile .menu-home { display: none; }
.mobile .home-link { text-decoration: none; } /* (no underline, even after a tap) */
.mobile .hud { z-index: 3; }
.mobile body[data-view="page"] .hud nav,
.mobile body[data-view="page"] .controls { display: none; }
.mobile body[data-view="page"] .intro h1 { margin: 0; }
.mobile .panel {
  inset: 0;
  transform: none;
  width: auto;
  max-height: none;
  --bar: 64px; /* room for the name above the page */
  --side: 24px;
  padding: var(--bar) var(--side) 32px;
  background: var(--bg);
  border: 0;
  animation-name: fade-in;
}
/* The black bar behind the name belongs to the panel, so it fades in with the page, and the
   page text scrolls under it. */
.mobile .panel::before {
  content: "";
  display: block;
  position: sticky;
  top: calc(-1 * var(--bar)); /* (sticky offsets count from inside the panel's padding) */
  z-index: 1;
  height: var(--bar);
  margin: calc(-1 * var(--bar)) calc(-1 * var(--side)) 0;
  background: var(--bg);
}
@keyframes fade-in { from { opacity: 0; } }

@media (max-width: 600px) {
  .hud { padding: 16px; }
  .mobile .panel { --bar: 56px; --side: 16px; }
  .controls { align-items: flex-start; }
  .controls .cmd-row { justify-content: flex-start; }
}
