/* ============================================================
   styles.css — the vitrine.
   Obsidian glass instrumentation over a living scene.
   Fraunces for the specimen labels, Plex Mono for the readouts.
   ============================================================ */

:root {
  /* motion tokens — the only easings allowed in this codebase */
  --ease-signature: cubic-bezier(0.22, 1, 0.36, 1); /* expressive decel — reveals, entrances, page transitions */
  --ease-smooth:    cubic-bezier(0.4, 0.0, 0.2, 1);  /* restrained decel — UI state changes, micro-interactions */
  --ease-none:      none;                             /* instant — theme switches, visibility flips */
  --ease-loop:      linear;                           /* infinite loops only */

  /* palette — mirrors the WebGL grade so DOM and canvas feel like one room */
  --ink: #e8f2ee;
  --ink-dim: #7e948e;
  --ink-faint: #46584f;
  --glass: rgba(10, 16, 20, 0.55);
  --glass-edge: rgba(125, 251, 212, 0.14);
  --mint: #7dfbd4;
  --ember: #ffb26b;
  --orchid: #e07bd4;

  /* type scale — fluid, clamps keep it civil on both ends */
  --fs-species: clamp(1.6rem, 1rem + 2.4vw, 2.6rem);
  --fs-title: clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
  --fs-label: clamp(0.66rem, 0.6rem + 0.2vw, 0.75rem);
  --fs-mono: clamp(0.68rem, 0.62rem + 0.25vw, 0.78rem);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  background: #04060a; /* matches the WebGL night floor — no flash on load */
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none; /* the canvas owns its gestures */
}
#stage:active {
  cursor: grabbing;
}

/* ------------------------------------------------------------
   Nameplate — top-left museum label. Fades in like the lights
   coming up on an exhibit.
   ------------------------------------------------------------ */
.nameplate {
  position: fixed;
  top: clamp(1.2rem, 4vh, 2.5rem);
  left: clamp(1.2rem, 4vw, 3rem);
  pointer-events: none;
  animation: rise 1.4s var(--ease-signature) both;
  animation-delay: 0.3s;
}

.nameplate__kicker {
  font-size: var(--fs-label);
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.45rem;
}

.nameplate__species {
  font-family: 'Fraunces', serif;
  font-weight: 340;
  font-style: italic;
  font-size: var(--fs-species);
  line-height: 1.02;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-shadow: 0 0 32px rgba(125, 251, 212, 0.25);
}

.nameplate__seed {
  margin-top: 0.55rem;
  font-size: var(--fs-mono);
  color: var(--ink-dim);
  letter-spacing: 0.08em;
}

/* ------------------------------------------------------------
   Vitals — growth bar + mesh stats, bottom-left. Quiet.
   ------------------------------------------------------------ */
.vitals {
  position: fixed;
  bottom: clamp(1.2rem, 4vh, 2.5rem);
  left: clamp(1.2rem, 4vw, 3rem);
  width: min(240px, 40vw);
  pointer-events: none;
  animation: rise 1.4s var(--ease-signature) both;
  animation-delay: 0.55s;
}

.vitals__track {
  height: 2px;
  background: rgba(125, 251, 212, 0.12);
  border-radius: 1px;
  overflow: hidden;
}

.vitals__bar {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--mint), var(--ember));
  /* JS writes transform every frame — no transition needed or wanted */
}

.vitals__stats {
  margin-top: 0.6rem;
  font-size: var(--fs-mono);
  color: var(--ink-faint);
  letter-spacing: 0.05em;
}

/* ------------------------------------------------------------
   Control panel — the glass slab, right side. Backdrop blur,
   hairline mint edge, everything whispering instead of shouting.
   ------------------------------------------------------------ */
.panel {
  position: fixed;
  top: clamp(1.2rem, 4vh, 2.5rem);
  right: clamp(1.2rem, 4vw, 2.5rem);
  width: min(300px, calc(100vw - 2.4rem));
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid var(--glass-edge);
  border-radius: 18px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(232, 242, 238, 0.06);
  animation: rise 1.4s var(--ease-signature) both;
  animation-delay: 0.75s;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  scrollbar-width: none;
}
.panel::-webkit-scrollbar {
  display: none;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.3rem 0.9rem;
  border-bottom: 1px solid rgba(125, 251, 212, 0.08);
}

.panel__title {
  font-family: 'Fraunces', serif;
  font-weight: 420;
  font-size: var(--fs-title);
  letter-spacing: 0.06em;
  color: var(--ink);
}

/* collapse toggle — 44px hit area, tiny visible glyph */
.panel__collapse {
  width: 44px;
  height: 44px;
  margin: -10px -12px -10px 0;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  cursor: pointer;
}

.panel__collapse-glyph {
  width: 14px;
  height: 2px;
  background: var(--ink-dim);
  border-radius: 1px;
  position: relative;
  transition: transform 0.35s var(--ease-smooth), background-color 0.35s var(--ease-smooth);
}
.panel__collapse-glyph::after {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  border-radius: inherit;
  transform: rotate(90deg);
  transition: transform 0.35s var(--ease-smooth), opacity 0.35s var(--ease-smooth);
  opacity: 0; /* minus by default (open state) */
}
.panel.is-collapsed .panel__collapse-glyph::after {
  opacity: 1; /* plus when collapsed — "there's more in here" */
}
.panel__collapse:hover .panel__collapse-glyph {
  background: var(--mint);
}

.panel__body {
  padding: 1.1rem 1.3rem 1.3rem;
  display: grid;
  gap: 1.05rem;
  /* body folds away with the panel — grid-template-rows trick keeps it CSS-only */
}

.panel.is-collapsed .panel__body {
  display: none; /* visibility flip — no meaningful in-between, so no tween (--ease-none territory) */
}

/* ------------------------------------------------------------
   Sliders — label / track / live value on one quiet row each
   ------------------------------------------------------------ */
.ctl {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    'name value'
    'range range';
  align-items: center;
  gap: 0.45rem 0.6rem;
}

.ctl__name {
  grid-area: name;
  font-size: var(--fs-label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.ctl output {
  grid-area: value;
  font-size: var(--fs-mono);
  color: var(--mint);
  font-variant-numeric: tabular-nums;
}

.ctl input[type='range'] {
  grid-area: range;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 44px; /* full-height touch target; the visible track is drawn thin */
  background: transparent;
  cursor: pointer;
}

/* track */
.ctl input[type='range']::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(90deg, rgba(125, 251, 212, 0.4), rgba(224, 123, 212, 0.4));
  border-radius: 1px;
}
.ctl input[type='range']::-moz-range-track {
  height: 2px;
  background: linear-gradient(90deg, rgba(125, 251, 212, 0.4), rgba(224, 123, 212, 0.4));
  border-radius: 1px;
}

/* thumb — a small glowing seed */
.ctl input[type='range']::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--ink);
  border: 1px solid var(--mint);
  box-shadow: 0 0 12px rgba(125, 251, 212, 0.5);
  transition: transform 0.25s var(--ease-smooth), box-shadow 0.25s var(--ease-smooth);
}
.ctl input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  border: 1px solid var(--mint);
  box-shadow: 0 0 12px rgba(125, 251, 212, 0.5);
  transition: transform 0.25s var(--ease-smooth), box-shadow 0.25s var(--ease-smooth);
}
.ctl input[type='range']:hover::-webkit-slider-thumb,
.ctl input[type='range']:focus-visible::-webkit-slider-thumb {
  transform: scale(1.35);
  box-shadow: 0 0 20px rgba(125, 251, 212, 0.85);
}
.ctl input[type='range']:hover::-moz-range-thumb,
.ctl input[type='range']:focus-visible::-moz-range-thumb {
  transform: scale(1.35);
  box-shadow: 0 0 20px rgba(125, 251, 212, 0.85);
}
.ctl input[type='range']:focus-visible {
  outline: 1px solid var(--glass-edge);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.panel__actions {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.2rem;
}

.btn {
  min-height: 44px;
  border-radius: 11px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: var(--fs-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background-color 0.3s var(--ease-smooth),
    border-color 0.3s var(--ease-smooth),
    box-shadow 0.3s var(--ease-smooth),
    transform 0.3s var(--ease-smooth);
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 1px solid var(--mint);
  outline-offset: 3px;
}

.btn--primary {
  border: 1px solid rgba(125, 251, 212, 0.45);
  background: rgba(125, 251, 212, 0.1);
  color: var(--mint);
}
.btn--primary:hover {
  background: rgba(125, 251, 212, 0.2);
  box-shadow: 0 0 28px rgba(125, 251, 212, 0.22);
}

.btn--ghost {
  border: 1px solid rgba(224, 123, 212, 0.3);
  background: transparent;
  color: var(--orchid);
}
.btn--ghost:hover {
  border-color: rgba(224, 123, 212, 0.6);
  background: rgba(224, 123, 212, 0.08);
  box-shadow: 0 0 28px rgba(224, 123, 212, 0.18);
}

.panel__hint {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  text-align: center;
  line-height: 1.7;
}

/* ------------------------------------------------------------
   Entrance
   ------------------------------------------------------------ */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ------------------------------------------------------------
   Reduced motion — DOM side. (The canvas handles its own:
   app.js clamps wind and kills idle camera drift.)
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .nameplate,
  .vitals,
  .panel {
    animation: none;
  }
  .btn,
  .panel__collapse-glyph,
  .ctl input[type='range']::-webkit-slider-thumb {
    transition: none;
  }
}

/* ------------------------------------------------------------
   Small screens — panel docks to the bottom, nameplate shrinks
   ------------------------------------------------------------ */
@media (max-width: 640px) {
  .panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 46vh;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
  }

  .vitals {
    bottom: auto;
    top: clamp(5.4rem, 16vh, 7.5rem);
  }
}
