/* ==========================================================================
   GRAVITY — style.css
   Dark-mode-first design system for the toy. Everything is CSS-variable
   driven so the palette / spacing can be retuned from one place.
   ========================================================================== */

:root {
  /* ---- palette (dark mode default) ---- */
  --bg: #08080c;
  --bg-elevated: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.09);
  --text: #f3f2fa;
  --text-dim: rgba(243, 242, 250, 0.55);
  --accent-cyan: #4dfcff;
  --accent-magenta: #ff4fd8;
  --accent-amber: #ffc857;

  /* ---- type ---- */
  --font-display: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  /* ---- misc ---- */
  --radius: 16px;
  --transition: 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light mode is intentionally out of scope for v1 — this is a dark toy —
   but we still respect prefers-color-scheme for the rare light-forced OS
   by nudging surfaces slightly, without breaking the neon aesthetic. */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #0b0b10; /* keep it dark deliberately; see README */
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  overflow: hidden; /* the canvas is the whole viewport */
  -webkit-font-smoothing: antialiased;
}

/* ---- canvas fills the screen and sits behind the UI ---- */
#canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* we handle touch gestures ourselves */
  cursor: crosshair;
}

/* Soft ambient gradient breathing behind everything for depth */
.bg-glow {
  position: fixed;
  inset: -10%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(38% 30% at 18% 20%, rgba(77, 252, 255, 0.10), transparent 60%),
    radial-gradient(42% 34% at 85% 78%, rgba(255, 79, 216, 0.09), transparent 60%),
    radial-gradient(30% 24% at 75% 15%, rgba(255, 200, 87, 0.06), transparent 60%);
  animation: drift 22s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(2%, -2%, 0) scale(1.06); }
}

/* ==========================================================================
   UI overlay — everything here is pointer-events:none by default so the
   canvas underneath receives all drag/click gestures; individual
   interactive elements opt back in.
   ========================================================================== */

.ui {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(18px, 4vw, 44px);
  pointer-events: none;
}

.hero {
  animation: fadeInDown 900ms var(--transition) both;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 4.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  background: linear-gradient(120deg, var(--accent-cyan), var(--accent-magenta) 55%, var(--accent-amber));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: hueTravel 8s linear infinite;
}

.tagline {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: clamp(0.85rem, 1.6vw, 1rem);
  font-weight: 400;
  letter-spacing: 0.01em;
}

@keyframes hueTravel {
  to { background-position: 200% center; }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- hint bar (bottom-ish, above panel) ---- */
.hint {
  align-self: flex-start;
  margin: auto 0 14px;
  animation: fadeIn 900ms var(--transition) 200ms both;
}

.hint p {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

.key {
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
  font-weight: 500;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---- control panel (glassmorphic) ---- */
.panel {
  pointer-events: auto;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: rgba(20, 20, 28, 0.55);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  min-width: min(340px, 92vw);
  animation: fadeInUp 900ms var(--transition) 120ms both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-row {
  display: grid;
  grid-template-columns: 72px 1fr 40px;
  align-items: center;
  gap: 10px;
}

.panel-row label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.value-badge {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-align: right;
  color: var(--accent-cyan);
}

/* range input, styled minimal + neon thumb */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(77, 252, 255, 0.7);
  transition: transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(77, 252, 255, 0.7);
}

.buttons {
  grid-template-columns: none;
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.22);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(120deg, rgba(77, 252, 255, 0.18), rgba(255, 79, 216, 0.18));
  border-color: rgba(255, 255, 255, 0.18);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background var(--transition), box-shadow var(--transition);
}

#soundToggle[aria-pressed="true"] .dot {
  background: var(--accent-amber);
  box-shadow: 0 0 8px rgba(255, 200, 87, 0.9);
}

/* ---- footer credit ---- */
.credit {
  align-self: flex-end;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  animation: fadeIn 900ms var(--transition) 300ms both;
}

.sep {
  margin: 0 6px;
  opacity: 0.5;
}

/* ==========================================================================
   Responsive tweaks
   ========================================================================== */

@media (max-width: 640px) {
  .ui {
    padding: 16px;
  }

  .hint {
    display: none; /* too cramped on small screens, mobile hint lives in tagline */
  }

  .panel {
    width: 100%;
    min-width: 0;
  }

  .credit {
    align-self: center;
    text-align: center;
  }
}

@media (max-height: 560px) {
  .hint {
    display: none;
  }
}

/* Respect reduced motion preferences: keep interactivity, drop decorative
   animation loops that never settle. */
@media (prefers-reduced-motion: reduce) {
  .bg-glow,
  .hero h1 {
    animation: none;
  }
  .hero,
  .hint,
  .panel,
  .credit {
    animation-duration: 1ms;
  }
}
