/* hoodie_groupies — specimen archive
   palette: light-blue (#6ec6ff) signature accent, clown-nose pink as a
   micro-accent, warm neutrals so the dark ground feels of the same world
   as the characters. */

:root {
  --bg: #0a0908;          /* warm near-black */
  --panel: #100e0b;
  --panel-2: #16120d;
  --line: #241f18;
  --line-hi: #3a332a;
  --text: #ece6da;        /* warm off-white */
  --dim: #8b8275;
  --dimmer: #574f45;
  --accent: #6ec6ff;        /* light blue — primary accent */
  --accent-dim: rgba(110, 198, 255, 0.42);
  --accent-glow: rgba(110, 198, 255, 0.20);
  --pink: #ff5c7a;        /* the clown nose — secondary accent */
  --pink-glow: rgba(255, 92, 122, 0.14);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --pad-x: clamp(16px, 5vw, 40px);
}

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

::selection { background: var(--accent); color: #000; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* --- atmosphere: stage glow + grain + vignette + scanlines ----------------- */
/* all of it sits UNDER the content — atmosphere on the void, never on the art */

/* breathing colour pools behind the specimen, borrowed from the art */
body::before {
  content: "";
  position: fixed;
  z-index: 0;
  left: 50%;
  top: 40%;
  width: min(130vw, 1150px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  background:
    radial-gradient(38% 38% at 44% 42%, var(--accent-glow), transparent 70%),
    radial-gradient(32% 32% at 62% 60%, var(--pink-glow), transparent 70%);
  filter: blur(34px);
  opacity: 0.55;
  animation: breathe 10s ease-in-out infinite;
}

/* faint CRT scanlines over the void */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px);
  opacity: 0.35;
}

@keyframes breathe {
  0%, 100% { opacity: 0.42; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.62; transform: translate(-50%, -52%) scale(1.06); }
}

.atmo { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

.atmo::before {
  /* film grain */
  content: "";
  position: absolute;
  inset: -100px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.05;
  animation: grain 0.9s steps(4) infinite;
}

.atmo::after {
  /* vignette */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 92% 78% at 50% 42%, transparent 52%, rgba(0, 0, 0, 0.74) 100%);
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-38px, 22px); }
  50% { transform: translate(22px, -30px); }
  75% { transform: translate(-14px, -12px); }
  100% { transform: translate(30px, 18px); }
}

/* --- layout ---------------------------------------------------------------- */

.page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(22px, 4vh, 34px);
  padding: max(40px, env(safe-area-inset-top)) var(--pad-x)
           max(48px, env(safe-area-inset-bottom)) var(--pad-x);
}

/* --- specimen frame -------------------------------------------------------- */

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 3vh, 22px);
  width: 100%;
}

.specimen {
  position: relative;
  width: 100%;
  max-width: 540px;
  padding: 16px;
}

/* corner ticks */
.specimen::before,
.specimen::after,
.canvas-frame::before,
.canvas-frame::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  border: 1px solid var(--line-hi);
  z-index: 2;
  transition: border-color 0.3s ease;
}

.specimen::before { top: 0; left: 0; border-right: none; border-bottom: none; }
.specimen::after { top: 0; right: 0; border-left: none; border-bottom: none; }
.canvas-frame::before { bottom: -15px; left: -15px; border-right: none; border-top: none; }
.canvas-frame::after { bottom: -15px; right: -15px; border-left: none; border-top: none; }

.specimen:hover::before,
.specimen:hover::after,
.specimen:hover .canvas-frame::before,
.specimen:hover .canvas-frame::after { border-color: var(--accent-dim); }

.canvas-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: visible;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.9),
              0 0 60px -20px var(--accent-glow);
}

.canvas-clip { position: relative; overflow: hidden; width: 100%; height: 100%; }

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* lock-in pulse: frame + corner ticks flash the accent and fade — artwork untouched */
.specimen.lock .canvas-frame { animation: lock-frame 0.6s ease-out; }

.specimen.lock::before,
.specimen.lock::after,
.specimen.lock .canvas-frame::before,
.specimen.lock .canvas-frame::after { animation: lock-ticks 0.6s ease-out; }

.specimen.lock .frame-label.br span { animation: lock-id 0.6s steps(3); }

@keyframes lock-frame {
  0% { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 42px -6px var(--accent); }
  100% { border-color: var(--line); box-shadow: 0 30px 80px -30px rgba(0,0,0,0.9), 0 0 60px -20px var(--accent-glow); }
}

@keyframes lock-ticks {
  0% { border-color: var(--accent); }
  100% { border-color: var(--line-hi); }
}

@keyframes lock-id {
  0%, 40% { color: #000; background: var(--accent); }
  100% { color: var(--accent); background: transparent; }
}

/* frame labels */
.frame-label {
  position: absolute;
  z-index: 3;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--dimmer);
  text-transform: uppercase;
  user-select: none;
}

.frame-label.tl { top: -6px; left: 16px; background: var(--bg); padding: 0 6px; }
.frame-label.br { bottom: -6px; right: 16px; background: var(--bg); padding: 0 6px; color: var(--dim); }
.frame-label.br span { color: var(--accent); }

/* --- buttons --------------------------------------------------------------- */

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 540px;
}

.btn {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line-hi);
  padding: 15px 26px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
  transition: border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease, background 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
  /* iOS: kill the long-press text selection + callout while holding to roll */
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  border-color: var(--accent-dim);
  box-shadow: 0 0 18px -6px var(--accent-dim), inset 0 0 14px -10px var(--accent-dim);
}

.btn:active {
  background: var(--text);
  color: #000;
  border-color: var(--text);
  transition-duration: 0s;
}

.btn-primary {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.btn-primary:hover {
  border-color: var(--accent);
  box-shadow: 0 0 24px -6px var(--accent-glow), inset 0 0 16px -10px var(--accent-dim);
}

.btn-primary:active { background: var(--accent); border-color: var(--accent); color: #000; }

/* keyboard hints — sit on their own line below the buttons */
.hints {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--dimmer);
  text-transform: uppercase;
}

.hints span { display: inline-flex; align-items: baseline; gap: 7px; }

.hints kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  border: 1px solid var(--line);
  padding: 2px 6px;
  letter-spacing: 0.1em;
}

.combo-count {
  font-size: clamp(11px, 3vw, 12.5px);
  color: var(--dimmer);
  letter-spacing: 0.12em;
  text-align: center;
}

.combo-count b { color: var(--dim); font-weight: 400; }

/* --- toast ----------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translate(-50%, 60px);
  max-width: 90vw;
  background: var(--panel);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 13px 20px;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.25s ease;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- entrance -------------------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: reveal 0.6s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
  animation-delay: var(--d, 0s);
}

@keyframes reveal { to { opacity: 1; transform: translateY(0); } }

/* --- responsive: phones ---------------------------------------------------- */

@media (max-width: 520px) {
  .actions { flex-direction: column; }
  .btn { width: 100%; padding: 16px 20px; }
  /* stacked = touch-first; the keyboard-only hints just add noise */
  .hints { display: none; }
}

/* touch devices: no lingering hover glow, drop keyboard-only hints */
@media (hover: none) {
  .btn:hover { border-color: var(--line-hi); box-shadow: none; }
  .btn-primary:hover { border-color: var(--accent-dim); }
  .hints { display: none; }
}

/* short landscape phones: tighten so it still fits without scrolling */
@media (max-height: 560px) and (orientation: landscape) {
  .page { justify-content: flex-start; gap: 14px; }
  .specimen { width: min(46vh, 340px); }
}

/* respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  body::before, .atmo::before { animation: none; }
  .reveal { animation: none; opacity: 1; transform: none; }
}

/* --- admin ----------------------------------------------------------------- */

.admin-layout {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(340px, 620px) minmax(320px, 420px);
  gap: 40px;
  align-items: start;
  justify-content: center;
  padding: max(44px, env(safe-area-inset-top)) var(--pad-x)
           max(48px, env(safe-area-inset-bottom)) var(--pad-x);
}

@media (max-width: 880px) {
  .admin-layout { grid-template-columns: 1fr; justify-items: center; gap: 28px; }
}

.admin-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 44px;
}

@media (max-width: 880px) { .admin-left { position: static; width: 100%; align-items: center; } }

.admin-left .specimen { width: min(88vw, 620px); }

.admin-title {
  font-size: clamp(14px, 4vw, 16px);
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--dim);
}

.admin-title b { color: var(--text); font-weight: 500; }
.admin-title em { color: var(--accent); font-style: normal; }

.admin-title a {
  color: var(--dimmer);
  text-decoration: none;
  font-size: 11px;
  margin-left: 14px;
  letter-spacing: 0.08em;
  transition: color 0.2s ease;
}

.admin-title a:hover { color: var(--accent); }

.admin-right { display: flex; flex-direction: column; gap: 22px; width: 100%; max-width: 620px; }

.panel {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: clamp(18px, 4vw, 24px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel h2 {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--dimmer);
  text-transform: lowercase;
}

.panel h2::before { content: "## "; color: var(--accent-dim); }

.fx-note { font-size: 11.5px; color: var(--dimmer); line-height: 1.7; letter-spacing: 0.04em; }
.fx-note::before { content: "// "; }

/* trait selectors */

.trait-select {
  display: grid;
  grid-template-columns: 34px 84px 1fr auto;
  align-items: center;
  gap: 10px;
}

@media (max-width: 400px) {
  .trait-select { grid-template-columns: 28px 62px 1fr auto; gap: 7px; }
}

.trait-select .lock {
  font-family: var(--mono);
  font-size: 12.5px;
  background: none;
  border: none;
  color: var(--dimmer);
  cursor: pointer;
  padding: 2px 0;
  letter-spacing: 0;
  transition: color 0.2s ease;
}

.trait-select .lock:hover { color: var(--dim); }
.trait-select .lock.locked { color: var(--accent); }

.trait-select label {
  font-size: 12.5px;
  color: var(--dim);
  letter-spacing: 0.1em;
}

.trait-select select {
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 9px 11px;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.2s ease;
  appearance: none;
}

.trait-select select:hover, .trait-select select:focus { border-color: var(--line-hi); outline: none; }

.step-btns { display: flex; gap: 5px; }

.step-btns button {
  font-family: var(--mono);
  width: 30px;
  height: 34px;
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 13px;
  touch-action: manipulation;
  transition: all 0.15s ease;
}

.step-btns button:hover { color: var(--accent); border-color: var(--accent-dim); }
.step-btns button:active { background: var(--accent); color: #000; }

/* sliders */

.slider-row { display: flex; flex-direction: column; gap: 9px; }

.slider-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--dim);
}

.slider-head .val { font-variant-numeric: tabular-nums; color: var(--accent); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: linear-gradient(to right, var(--accent) var(--fill, 0%), var(--line) var(--fill, 0%));
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 19px;
  background: var(--text);
  border: 1px solid #000;
  transition: background 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover,
input[type="range"]:active::-webkit-slider-thumb { background: var(--accent); }
