/* Slop Tank — Slopographic */

:root {
  --ink: #0a0a0a;
  --bone: #f1ede4;
  --bone-dim: rgba(241, 237, 228, 0.66);
  --bone-faint: rgba(241, 237, 228, 0.42);
  --line: rgba(241, 237, 228, 0.14);
  --slop: #d4ff3a;
  --slop-deep: #9fcc00;
  --glass: rgba(12, 12, 11, 0.62);
  --cond: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Inter Tight", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --gutter: max(16px, env(safe-area-inset-left));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
em { font-family: var(--serif); font-style: italic; font-weight: 400; }
kbd {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--bone-faint);
  text-transform: uppercase;
}
:focus-visible { outline: 2px solid var(--slop); outline-offset: 2px; }

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

.stage {
  position: fixed;
  inset: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
  background: var(--ink);
}
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.stage canvas[hidden] { display: none; }

/* ---------- overlay ---------- */

.ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.35s ease;
}
.ui > * { pointer-events: auto; }
.ui .title, .ui .hint, .ui .toast { pointer-events: none; }
body.ui-hidden .ui { opacity: 0; visibility: hidden; transition: opacity 0.35s ease, visibility 0s linear 0.35s; }

.brand {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--bone);
  text-decoration: none;
  font-family: var(--cond);
  font-stretch: 62%;
  font-weight: 800;
  font-size: 22px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
}
.wordmark:hover span { color: var(--slop); }
.mark { width: 20px; height: 20px; filter: drop-shadow(0 0 8px rgba(212, 255, 58, 0.35)); }
.mark path { fill: var(--slop); }
.mark .shine { fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; opacity: 0.8; }
.kicker {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bone-dim);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}
.kicker-no { color: var(--bone-faint); }
.tagline { margin: 2px 0 0; font-size: 16px; line-height: 1; color: var(--bone-faint); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8); }
.live {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--slop);
  box-shadow: 0 0 0 0 rgba(212, 255, 58, 0.6);
  animation: live 1.8s infinite;
}
body.paused .live { animation: none; background: var(--bone-faint); }
@keyframes live { 70% { box-shadow: 0 0 0 6px rgba(212, 255, 58, 0); } 100% { box-shadow: 0 0 0 0 rgba(212, 255, 58, 0); } }

/* big translucent title */
.title {
  position: absolute;
  left: 50%;
  top: 46%;
  width: min(94vw, 1200px);
  transform: translate(-50%, -50%);
  text-align: center;
  transition: opacity 1.4s ease, transform 1.8s cubic-bezier(.2, .7, .2, 1), filter 1.4s ease;
}
.title h1 {
  margin: 0;
  font-family: var(--cond);
  font-stretch: 62%;
  font-weight: 900;
  text-transform: uppercase;
  font-size: clamp(64px, 13vw, 230px);
  line-height: 0.84;
  letter-spacing: -0.01em;
  color: rgba(241, 237, 228, 0.16);
  -webkit-text-stroke: 1px rgba(241, 237, 228, 0.42);
  mix-blend-mode: screen;
}
.title-kicker, .title-sub { margin: 0; }
.title-kicker {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin-bottom: 14px;
}
.title-sub {
  margin-top: 16px;
  font-size: clamp(16px, 2.2vw, 24px);
  color: var(--bone-dim);
}
.title-sub em { color: var(--slop); }
.title.gone { opacity: 0; transform: translate(-50%, -54%) scale(1.04); filter: blur(6px); }

.hint {
  position: absolute;
  left: var(--gutter);
  bottom: max(16px, env(safe-area-inset-bottom));
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bone-faint);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}
.hint i { font-style: normal; opacity: 0.5; }

/* fallback note */
.fallback {
  position: absolute;
  top: max(84px, calc(env(safe-area-inset-top) + 72px));
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid rgba(212, 255, 58, 0.4);
  border-radius: 12px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 14px;
  color: var(--bone-dim);
  display: grid;
  gap: 4px;
}
.fallback[hidden] { display: none; }
.fallback strong {
  font-family: var(--cond);
  font-stretch: 62%;
  font-weight: 900;
  font-size: 26px;
  line-height: 1;
  text-transform: uppercase;
  color: var(--slop);
  letter-spacing: 0.01em;
}
.fallback em { color: var(--bone); }

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

.panel {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 304px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.panel-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
}
.panel-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.panel-state {
  position: relative;
  width: 12px; height: 12px;
}
.panel-state::before, .panel-state::after {
  content: "";
  position: absolute;
  left: 0; top: 5.5px;
  width: 12px; height: 1px;
  background: var(--bone-dim);
  transition: transform 0.25s ease;
}
.panel-state::after { transform: rotate(90deg); }
.panel-head[aria-expanded="true"] .panel-state::after { transform: rotate(0deg); }

.panel-body {
  padding: 2px 14px 14px;
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.panel-body[hidden] { display: none; }
.group { display: grid; gap: 8px; }
.label {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bone-faint);
}

.palettes { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.pal {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(241, 237, 228, 0.03);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bone-dim);
  text-align: left;
  line-height: 1.15;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.pal:hover { color: var(--bone); border-color: rgba(241, 237, 228, 0.3); }
.pal[aria-checked="true"] { color: var(--bone); border-color: var(--slop); background: rgba(212, 255, 58, 0.07); }
.pal:last-child:nth-child(odd) { grid-column: 1 / -1; }
.swatch {
  flex: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  box-shadow: inset -2px -3px 5px rgba(0, 0, 0, 0.35), inset 2px 2px 3px rgba(255, 255, 255, 0.55);
}

.sliders { gap: 4px; }
.slider {
  display: grid;
  grid-template-columns: 96px 1fr 24px;
  align-items: center;
  column-gap: 10px;
  cursor: pointer;
}
.slider output {
  order: 3;
  text-align: right;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
}
.slider input { order: 2; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --p: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--slop) var(--p), rgba(241, 237, 228, 0.16) var(--p));
}
input[type="range"]::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(241, 237, 228, 0.16); }
input[type="range"]::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--slop); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin-top: -6.5px;
  border-radius: 50%;
  border: 0;
  background: radial-gradient(circle at 35% 30%, #fff 0 12%, var(--slop) 40%, var(--slop-deep) 100%);
  box-shadow: 0 0 0 3px rgba(212, 255, 58, 0.15), 0 2px 6px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 0;
  background: radial-gradient(circle at 35% 30%, #fff 0 12%, var(--slop) 40%, var(--slop-deep) 100%);
  box-shadow: 0 0 0 3px rgba(212, 255, 58, 0.15), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.actions { grid-template-columns: repeat(3, 1fr); gap: 5px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-height: 32px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(241, 237, 228, 0.03);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--bone);
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.1s;
}
.btn:hover { border-color: rgba(241, 237, 228, 0.34); background: rgba(241, 237, 228, 0.07); }
.btn:active { transform: scale(0.97); }
.btn-pour {
  grid-column: 1 / -1;
  justify-content: center;
  gap: 10px;
  min-height: 38px;
  background: var(--slop);
  border-color: var(--slop);
  color: var(--ink);
  font-weight: 600;
}
.btn-pour kbd { color: rgba(10, 10, 10, 0.6); border-color: rgba(10, 10, 10, 0.25); }
.btn-pour:hover { background: #e2ff70; border-color: #e2ff70; }
.btn[aria-pressed="true"]:not(.btn-toggle) { border-color: var(--slop); color: var(--slop); }
.btn-toggle { grid-column: span 2; }
body.is-2d .btn-toggle { display: none; }
.btn-toggle::after {
  content: "";
  width: 22px; height: 12px;
  border-radius: 12px;
  background: rgba(241, 237, 228, 0.18);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background 0.2s;
  background-image: radial-gradient(circle at 6px 6px, var(--bone) 0 4px, transparent 4.5px);
}
.btn-toggle[aria-pressed="true"]::after {
  background-color: var(--slop-deep);
  background-image: radial-gradient(circle at 16px 6px, var(--ink) 0 4px, transparent 4.5px);
}

/* toast */
.toast {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast:empty { display: none; }

.show-ui {
  position: fixed;
  z-index: 3;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.35);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bone-faint);
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.show-ui:hover, .show-ui:focus-visible { opacity: 1; }
.show-ui[hidden] { display: none; }

.noscript {
  position: fixed;
  inset: auto 16px 50% 16px;
  z-index: 5;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--slop);
}

/* ---------- mobile ---------- */

@media (min-width: 900px) {
  /* keep the title clear of the control panel */
  .title { left: calc(50% - 150px); width: min(calc(100vw - 340px), 1100px); }
}

@media (max-width: 640px) {
  .hint { display: none; }
  .title h1 { font-size: 21vw; }
  .panel {
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
  }
  .panel-body { max-height: min(62vh, 480px); overflow-y: auto; overscroll-behavior: contain; }
  .palettes { grid-template-columns: 1fr 1fr; }
  .actions .btn kbd { display: none; }
  .actions .btn { justify-content: center; min-height: 38px; }
  .btn-toggle { gap: 10px; }
  .pal { min-height: 36px; }
  .slider { grid-template-columns: 96px 1fr 24px; min-height: 34px; }
  .tagline { display: none; }
  .toast { top: calc(max(16px, env(safe-area-inset-top)) + 64px); }
  .title { top: 40%; }
  .title-sub { font-size: 17px; }
  .fallback { top: max(88px, calc(env(safe-area-inset-top) + 76px)); font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .live { animation: none; }
  .title, .toast, .ui { transition: none; }
}
