/* ------------------------------------------------------------------------
 * style.css — dark shell around the canvas.
 *
 * --accent is written by controls.js from the same hue the shader uses, so
 * the interface and the fluid never drift apart.
 * ---------------------------------------------------------------------- */

:root {
  --accent: #35d6e6;
  --bg: #04070a;

  --text: rgba(228, 240, 247, 0.94);
  --text-dim: rgba(214, 232, 242, 0.50);
  --text-faint: rgba(206, 228, 240, 0.28);
  --hairline: hsl(200 30% 70% / 0.09);

  --panel-w: 318px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ==================================================================== */
/*  Cold layered glass                                                   */
/*                                                                       */
/*  Three layers: a blurred, desaturated-then-resaturated backdrop with  */
/*  a fine grain over it, the content itself, and a set of inset         */
/*  highlights on top that read as a bevelled edge catching light.       */
/*  The noise is an inline SVG rather than a hosted texture so the page  */
/*  still works offline and straight off the filesystem.                 */
/* ==================================================================== */

.glass3d {
  --filter-glass3d: blur(32px) brightness(0.85) saturate(2.5);
  --color-glass3d: hsl(189 80% 10% / 0.2);
  --noise-glass3d: url("https://www.transparenttextures.com/patterns/egg-shell.png");

  position: relative;
  z-index: 4;
  box-shadow:
    0 0 0.75px hsl(205 20% 10% / 0.2),
    0.7px 0.8px 1.2px -0.4px hsl(205 20% 10% / 0.1),
    1.3px 1.5px 2.2px -0.8px hsl(205 20% 10% / 0.1),
    2.3px 2.6px 3.9px -1.2px hsl(205 20% 10% / 0.1),
    3.9px 4.4px 6.6px -1.7px hsl(205 20% 10% / 0.1),
    6.5px 7.2px 10.9px -2.1px hsl(205 20% 10% / 0.1),
    8px 9px 14px -2.5px hsl(205 20% 10% / 0.2);
}

/* Absolutely positioned, so these never become flex or grid items of the
   element they decorate. */
.glass3d::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  overflow: hidden;
  z-index: 3;

  -webkit-backdrop-filter: var(--filter-glass3d);
  backdrop-filter: var(--filter-glass3d);
  background-color: var(--color-glass3d);
  background-image: var(--noise-glass3d);
  background-size: 100px;
  background-repeat: repeat;
}

.glass3d::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  overflow: hidden;
  z-index: 5;

  box-shadow:
    inset 2px 2px 1px -3px hsl(205 20% 90% / 0.8),
    inset 4px 4px 2px -6px hsl(205 20% 90% / 0.3),
    inset 1.5px 1.5px 1.5px -0.75px hsl(205 20% 90% / 0.15),
    inset 1.5px 1.5px 0.25px hsl(205 20% 90% / 0.03),
    inset 0 0 0.25px 0.5px hsl(205 20% 90% / 0.03);
}

.glass3d > * {
  position: relative;
  z-index: 6;
}

/* At 0.2 alpha the glass carries almost no contrast of its own, so the
   legibility has to come from the type rather than from tinting the panel
   darker. A tight shadow in the panel's own hue keeps the glass exactly as
   specified while stopping the labels dissolving into bright fluid. */
#panel h1,
#panel .sub,
.group h2,
.row-head label,
.value,
.hint,
.stat .k,
.stat .v,
#hint {
  text-shadow:
    0 1px 3px hsl(196 70% 4% / 0.95),
    0 0 10px hsl(196 70% 4% / 0.8),
    0 0 22px hsl(196 70% 4% / 0.55);
}

/* ---------------------------------------------------------------- stage */

#stage { position: fixed; inset: 0; background: var(--bg); }
#stage.dead { filter: grayscale(1) brightness(0.4); }

#fluid {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;      /* stop the browser eating drags as scrolls */
  cursor: crosshair;
}

#hint {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  margin: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  pointer-events: none;
  animation: hint-fade 11s var(--ease) forwards;
}

#hint span { opacity: 0.4; }

#hint kbd {
  font: inherit;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-dim);
}

@keyframes hint-fade {
  0%, 65% { opacity: 1; }
  100%    { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #hint { animation: none; opacity: 0.5; }
}

/* --------------------------------------------------------------- toggle */

#panel-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 30;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 13px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition:
    color 0.25s var(--ease),
    border-color 0.25s var(--ease),
    transform 0.4s var(--spring),
    right 0.44s var(--ease);
}

#panel-toggle:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  transform: translateY(-1px) scale(1.04);
}

#panel-toggle:active { transform: scale(0.95); }

#panel-toggle svg {
  width: 19px; height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  transition: transform 0.5s var(--ease);
}

#panel-toggle:hover svg { transform: rotate(90deg); }
#panel-toggle svg circle { fill: currentColor; stroke: none; }

/* The toggle precedes the panel in the DOM, so this is driven by a class on
   <body> rather than a sibling selector. */
body.panel-open #panel-toggle { right: calc(var(--panel-w) + 18px); }

/* ---------------------------------------------------------------- panel */

#panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  width: var(--panel-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--hairline);
  transition: transform 0.46s var(--ease), opacity 0.3s var(--ease);
}

#panel.collapsed { transform: translateX(100%); opacity: 0; }

#panel header {
  padding: 20px 22px 15px;
  border-bottom: 1px solid var(--hairline);
  flex: none;
}

#panel h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

#panel h1 em {
  font-style: normal;
  font-weight: 300;
  color: var(--accent);
  text-shadow: 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent);
}

#panel .sub {
  margin: 6px 0 0;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--text-faint);
}

#panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0 10px;
  scrollbar-width: thin;
  scrollbar-color: hsl(197 30% 70% / 0.16) transparent;
}

#panel-body::-webkit-scrollbar { width: 9px; }
#panel-body::-webkit-scrollbar-track { background: transparent; }
#panel-body::-webkit-scrollbar-thumb {
  background: hsl(197 30% 70% / 0.14);
  border-radius: 9px;
  border: 3px solid transparent;
  background-clip: content-box;
  transition: background-color 0.2s;
}
#panel-body::-webkit-scrollbar-thumb:hover { background-color: hsl(197 40% 75% / 0.30); }

/* --------------------------------------------------------------- groups */

.group {
  padding: 15px 22px 8px;
  border-bottom: 1px solid var(--hairline);
  animation: group-in 0.5s var(--ease) backwards;
}

.group:nth-child(1) { animation-delay: 0.02s; }
.group:nth-child(2) { animation-delay: 0.06s; }
.group:nth-child(3) { animation-delay: 0.10s; }
.group:nth-child(4) { animation-delay: 0.14s; }
.group:nth-child(5) { animation-delay: 0.18s; }
.group:nth-child(6) { animation-delay: 0.22s; }
.group:nth-child(7) { animation-delay: 0.26s; }

@keyframes group-in {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .group { animation: none; }
}

.group:last-child { border-bottom: none; }

.group h2 {
  margin: 0 0 12px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.row {
  margin-bottom: 15px;
  transition: opacity 0.2s;
}

.row-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
}

.row-head label {
  flex: 1 1 auto;
  font-size: 12px;
  color: var(--text-dim);
  transition: color 0.2s var(--ease);
  cursor: default;
}

.row:hover .row-head label { color: var(--text); }

.value {
  font: 11px/1 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 46px;
  text-align: right;
  transition: color 0.2s, text-shadow 0.25s;
}

.row.live .value {
  color: var(--accent);
  text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 65%, transparent);
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    0 0 10px color-mix(in srgb, var(--accent) 80%, transparent),
    inset 0 0 0 1px hsl(0 0% 100% / 0.35);
}

.hint {
  margin: 6px 0 0;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--text-faint);
}

/* -------------------------------------------------------------- sliders */
/*  --fill is set from controls.js so the track shows the current value.   */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  display: block;
  --fill: 50%;
}

/* --- WebKit --- */
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background:
    linear-gradient(90deg,
      var(--accent) 0 var(--fill),
      hsl(200 25% 70% / 0.13) var(--fill) 100%);
  box-shadow: 0 0 12px -2px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: box-shadow 0.25s var(--ease);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow:
    0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent),
    0 0 12px color-mix(in srgb, var(--accent) 85%, transparent),
    inset 0 0 0 1px hsl(0 0% 100% / 0.45);
  transition:
    box-shadow 0.28s var(--ease),
    transform 0.28s var(--spring);
}

input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.18);
  box-shadow:
    0 0 0 6px color-mix(in srgb, var(--accent) 16%, transparent),
    0 0 18px color-mix(in srgb, var(--accent) 95%, transparent),
    inset 0 0 0 1px hsl(0 0% 100% / 0.6);
}

input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.34);
  box-shadow:
    0 0 0 9px color-mix(in srgb, var(--accent) 22%, transparent),
    0 0 26px color-mix(in srgb, var(--accent) 100%, transparent),
    inset 0 0 0 1px hsl(0 0% 100% / 0.75);
}

input[type="range"]:hover::-webkit-slider-runnable-track {
  box-shadow: 0 0 18px -1px color-mix(in srgb, var(--accent) 70%, transparent);
}

/* --- Firefox --- */
input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 3px;
  background: hsl(200 25% 70% / 0.13);
}

input[type="range"]::-moz-range-progress {
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px -2px color-mix(in srgb, var(--accent) 60%, transparent);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    0 0 12px color-mix(in srgb, var(--accent) 85%, transparent),
    inset 0 0 0 1px hsl(0 0% 100% / 0.45);
  transition: transform 0.28s var(--spring), box-shadow 0.28s var(--ease);
}

input[type="range"]:hover::-moz-range-thumb { transform: scale(1.18); }
input[type="range"]:active::-moz-range-thumb { transform: scale(1.34); }

input[type="range"]:focus { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow:
    0 0 0 6px color-mix(in srgb, var(--accent) 26%, transparent),
    0 0 18px color-mix(in srgb, var(--accent) 95%, transparent);
}

/* -------------------------------------------------------------- toggles */

.row-toggle .row-head { margin-bottom: 0; }

.switch {
  position: relative;
  flex: none;
  width: 38px;
  height: 21px;
}

.switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: hsl(200 25% 70% / 0.12);
  box-shadow: inset 0 1px 2px hsl(200 40% 4% / 0.5);
  transition: background 0.32s var(--ease), box-shadow 0.32s var(--ease);
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: hsl(200 20% 88% / 0.55);
  transition:
    transform 0.36s var(--spring),
    background 0.3s var(--ease),
    box-shadow 0.3s var(--ease);
}

.switch input:checked + .track {
  background: color-mix(in srgb, var(--accent) 32%, transparent);
  box-shadow:
    inset 0 1px 2px hsl(200 40% 4% / 0.35),
    0 0 16px -2px color-mix(in srgb, var(--accent) 70%, transparent);
}

.switch input:checked + .track::after {
  transform: translateX(17px);
  background: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 90%, transparent);
}

.switch input:active + .track::after { width: 19px; }

.switch input:focus-visible + .track {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}

/* -------------------------------------------------------------- actions */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 18px;
}

.btn {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  padding: 8px 11px;
  font: inherit;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  background: hsl(200 25% 70% / 0.05);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    color 0.22s var(--ease),
    background 0.22s var(--ease),
    border-color 0.22s var(--ease),
    transform 0.3s var(--spring);
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 120%,
    color-mix(in srgb, var(--accent) 35%, transparent), transparent 70%);
  opacity: 0;
  transition: opacity 0.28s var(--ease);
}

.btn:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 34%, transparent);
  transform: translateY(-1px);
}

.btn:hover::before { opacity: 1; }
.btn:active { transform: translateY(0) scale(0.975); }

.btn.on {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  box-shadow: 0 0 18px -4px color-mix(in srgb, var(--accent) 75%, transparent);
}

/* ---------------------------------------------------------------- stats */

#stats {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 13px 22px 17px;
  border-top: 1px solid var(--hairline);
  background: hsl(200 50% 3% / 0.35);
}

.stat { display: flex; flex-direction: column; gap: 3px; padding: 3px 0; }
.stat.wide { grid-column: 1 / -1; }

.stat .k {
  font-size: 8.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stat .v {
  font: 12px/1.3 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

#stat-fps {
  color: var(--accent);
  font-size: 17px;
  text-shadow: 0 0 16px color-mix(in srgb, var(--accent) 70%, transparent);
}

.stat .mono {
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- fatal */

#fatal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: hsl(200 45% 3% / 0.92);
  padding: 24px;
}

#fatal[hidden] { display: none; }

.fatal-card {
  max-width: 440px;
  padding: 28px 30px;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: #080c11;
}

.fatal-card h2 { margin: 0 0 10px; font-size: 16px; font-weight: 600; }
.fatal-card p  { margin: 0 0 10px; color: var(--text-dim); font-size: 12.5px; }
.fatal-note    { color: var(--text-faint) !important; }

/* --------------------------------------------------------------- narrow */

@media (max-width: 720px) {
  :root { --panel-w: min(92vw, 330px); }
  #hint { font-size: 10px; bottom: 16px; }
}
