/* Palette-driven custom properties. dither-hero.js rewrites these on every
   palette change so the page chrome tracks the canvas. */
:root {
  --bg:     #080e1a;
  --dim:    #123a78;
  --accent: #50c3ff;
  --bright: #afe6ff;
  --fade:   400ms cubic-bezier(.4, 0, .2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  transition: background var(--fade);
}

body {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  color: var(--bright);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#hero-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* The canvas is the click target for the whole page. */
  cursor: crosshair;
  touch-action: none;
}

/* ---- Sites nav ------------------------------------------------------- */

.sites {
  position: fixed;
  z-index: 2;
  top: max(1.5rem, env(safe-area-inset-top));
  left: clamp(1.25rem, 4vw, 3rem);
  width: 19rem;
  max-width: calc(100vw - 2.5rem);
  border-radius: .75rem;
  border: 1px solid color-mix(in srgb, var(--bright) 18%, transparent);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(10px);
  font: 500 .8125rem/1 ui-monospace, Menlo, Consolas, "SFMono-Regular", monospace;
  overflow: hidden;
  transition: border-color var(--fade), background var(--fade);
}

.sites-toggle {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .7rem .85rem;
  border: 0;
  background: none;
  color: var(--bright);
  font: inherit;
  letter-spacing: .04em;
  cursor: pointer;
  transition: color var(--fade);
}

.caret {
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  opacity: .75;
  transition: transform 220ms cubic-bezier(.4, 0, .2, 1);
}

.sites.is-open .caret { transform: rotate(90deg); }

/* Collapsed by default. Animating grid-template-rows 0fr -> 1fr gives a real
   auto-height transition with no hardcoded max-height. It needs exactly ONE
   grid child, hence the wrapper — extra children land in implicit auto rows
   and stay visible while collapsed. */
.sites-drawer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 260ms cubic-bezier(.4, 0, .2, 1);
}

.sites.is-open .sites-drawer { grid-template-rows: 1fr; }

.sites-drawer > ul {
  min-height: 0;
  overflow: hidden;
  list-style: none;
  border-top: 1px solid color-mix(in srgb, var(--bright) 12%, transparent);
}

.sites-drawer a {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  padding: .6rem .85rem;
  color: var(--bright);
  text-decoration: none;
  transition: background 160ms ease, color var(--fade);
}

.sites-drawer a:hover,
.sites-drawer a:focus-visible {
  background: color-mix(in srgb, var(--bright) 12%, transparent);
  outline: none;
}

.tag { font-weight: 600; letter-spacing: .06em; }

.host {
  margin-left: auto;
  font-size: .6875rem;
  opacity: .45;
  letter-spacing: .02em;
}

/* ---- Palette control ------------------------------------------------ */

.palette-btn {
  position: fixed;
  z-index: 2;
  left: clamp(1.5rem, 6vw, 7rem);
  bottom: max(1.75rem, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  padding: .5rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--bright) 22%, transparent);
  background: color-mix(in srgb, var(--bg) 65%, transparent);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: border-color var(--fade), color var(--fade), background var(--fade);
}

.palette-btn:hover { border-color: color-mix(in srgb, var(--bright) 55%, transparent); }
.palette-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.swatches {
  display: flex;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--bright) 20%, transparent);
}

.swatches i {
  display: block;
  width: .55rem;
  height: 1.05rem;
  transition: background var(--fade);
}

/* ---- Debug FPS (press "f") ------------------------------------------ */

.fps {
  position: fixed;
  z-index: 3;
  right: 1rem;
  bottom: 1rem;
  padding: .3rem .55rem;
  border-radius: .35rem;
  font: 500 12px/1 ui-monospace, Menlo, Consolas, monospace;
  color: var(--bg);
  background: var(--bright);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; }
}
