/* FLUX // FIELD STUDIO — cyberpunk / neon minimal-dark */
:root {
  --bg: #0A0A0F;
  --ink: #E8E8E8;
  --dim: #7A7E8C;
  --cyan: #00F0FF;
  --magenta: #FF2E97;
  --panel: rgba(14, 15, 22, 0.72);
  --line: rgba(0, 240, 255, 0.14);
  --line-strong: rgba(0, 240, 255, 0.4);
  --glow: 0 0 18px rgba(0, 240, 255, 0.45);
  --radius: 10px;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  overflow: hidden;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: crosshair;
  touch-action: none; /* let the canvas own touch gestures (no scroll/zoom) */
}

/* focal-point influence ring (DOM overlay, not on the canvas) */
.ring {
  position: fixed; left: 0; top: 0; z-index: 6;
  border-radius: 50%; border: 1.5px solid var(--cyan);
  box-shadow: 0 0 18px rgba(0,240,255,0.45), inset 0 0 22px rgba(0,240,255,0.12);
  pointer-events: none; opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity 0.3s ease, border-color 0.2s, box-shadow 0.2s;
}
.ring.repel {
  border-color: var(--magenta);
  box-shadow: 0 0 18px rgba(255,46,151,0.45), inset 0 0 22px rgba(255,46,151,0.12);
}
.ring.show { opacity: 0.7; }

#stage.pulse { animation: huedrift 26s linear infinite; }
@keyframes huedrift { to { filter: hue-rotate(360deg); } }

/* Depth layers over the canvas: a soft vignette + faint film grain. */
.fx {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
}
.fx.vignette {
  background: radial-gradient(120% 120% at 50% 45%, transparent 55%, rgba(0,0,0,0.55) 100%);
}
.fx.grain {
  opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- top bar ---------- */
.hud-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(10,10,15,0.85), rgba(10,10,15,0));
  pointer-events: none;
  z-index: 10;
}
.hud-bar > * { pointer-events: auto; }

.brand { display: flex; align-items: baseline; gap: 8px; }
.brand .mark { color: var(--cyan); text-shadow: var(--glow); animation: spin 8s linear infinite; }
.brand .title { font-weight: 700; font-size: 18px; letter-spacing: 0.18em; }
.brand .sub { color: var(--dim); font-size: 11px; letter-spacing: 0.12em; }

.readout { display: flex; align-items: center; gap: 16px; }
.stat { display: flex; flex-direction: column; line-height: 1.1; text-align: right; }
.stat i { font-style: normal; color: var(--dim); font-size: 9px; letter-spacing: 0.2em; }
.stat b { font-weight: 700; font-size: 13px; color: var(--cyan); min-width: 60px; }
#polarity-tag { color: var(--magenta); }
#polarity-tag.pulse { animation: flash 0.5s ease; }

.ghost {
  background: transparent; border: 1px solid var(--line-strong);
  color: var(--ink); width: 30px; height: 30px; border-radius: 8px;
  cursor: pointer; font-size: 14px; transition: 0.15s;
}
.ghost:hover { background: var(--line); box-shadow: var(--glow); }

/* ---------- panel ---------- */
.panel {
  position: fixed;
  top: 64px; left: 16px;
  width: 268px;
  max-height: calc(100vh - 84px);
  overflow-y: auto;
  padding: 18px 16px;
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  z-index: 9;
  transition: transform 0.35s cubic-bezier(.5,.1,.2,1), opacity 0.35s;
  animation: slideIn 0.5s cubic-bezier(.2,.7,.2,1) backwards;
}
.panel-hidden .panel { transform: translateX(-110%); opacity: 0; }

.block { padding: 12px 0; border-bottom: 1px solid var(--line); }
.block:last-of-type { border-bottom: none; }
.block h2 {
  font-size: 10px; font-weight: 700; letter-spacing: 0.28em;
  color: var(--dim); margin-bottom: 12px;
}

.row { display: flex; gap: 8px; }
.row.wrap { flex-wrap: wrap; }

.chip {
  flex: 1 1 auto;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 0.1em;
  padding: 8px 6px; border-radius: 7px; cursor: pointer;
  transition: 0.15s;
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip.active {
  color: var(--bg); background: var(--cyan); border-color: var(--cyan);
  box-shadow: var(--glow); font-weight: 700;
}

.chip.surprise { border-color: rgba(255,46,151,0.5); color: var(--ink); }
.chip.surprise:hover { background: rgba(255,46,151,0.14); border-color: var(--magenta); box-shadow: 0 0 14px rgba(255,46,151,0.4); }

.swatch {
  flex: 1; height: 30px; border-radius: 7px; cursor: pointer;
  border: 2px solid transparent; transition: 0.15s; position: relative;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.active { border-color: var(--ink); box-shadow: 0 0 12px rgba(255,255,255,0.4); }

.ctrl { display: block; margin-bottom: 14px; }
.ctrl span {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--ink); margin-bottom: 6px;
}
.ctrl span b { color: var(--cyan); font-weight: 500; }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 3px; border-radius: 3px;
  background: var(--line-strong); outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--cyan); box-shadow: var(--glow); border: none; cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--cyan); box-shadow: var(--glow); border: none; cursor: pointer;
}

.hint { font-size: 10px; color: var(--dim); margin-top: 8px; line-height: 1.5; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.05em;
  padding: 10px 6px; border-radius: 7px; cursor: pointer; transition: 0.15s;
}
.btn:hover { background: var(--line); box-shadow: var(--glow); }
.btn.active { background: var(--magenta); border-color: var(--magenta); color: #fff; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.recording { background: #FF2E2E; border-color: #FF2E2E; color: #fff; animation: recpulse 1.1s ease-in-out infinite; }
@keyframes recpulse { 0%,100% { box-shadow: 0 0 0 rgba(255,46,46,0.7); } 50% { box-shadow: 0 0 18px rgba(255,46,46,0.9); } }
.btn.accent { grid-column: 1 / -1; background: var(--cyan); color: var(--bg); border-color: var(--cyan); font-weight: 700; }
.btn.accent:hover { box-shadow: 0 0 22px rgba(0,240,255,0.6); }

.panel-foot {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 9px; color: var(--dim); line-height: 1.6; letter-spacing: 0.05em;
}

/* ---------- animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flash { 0% { transform: scale(1.3); color: var(--cyan); } 100% { transform: scale(1); } }
@keyframes slideIn { from { transform: translateX(-30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* intro overlay */
.intro {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(10,10,15,0.4), rgba(10,10,15,0.85));
  backdrop-filter: blur(3px);
  transition: opacity 0.6s ease;
}
.intro.hidden { opacity: 0; pointer-events: none; }
.intro-card {
  width: min(440px, 88vw);
  padding: 34px 32px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 0 60px rgba(0,240,255,0.15);
  text-align: left;
  animation: slideIn 0.6s cubic-bezier(.2,.7,.2,1) both;
}
.intro-mark { color: var(--cyan); text-shadow: var(--glow); font-size: 22px; display: inline-block; animation: spin 8s linear infinite; }
.intro-card h1 { font-size: 30px; font-weight: 700; letter-spacing: 0.14em; margin: 10px 0 4px; }
.intro-card h1 small { color: var(--dim); font-size: 12px; font-weight: 500; letter-spacing: 0.12em; }
.intro-card p { color: var(--ink); font-size: 13px; margin-bottom: 18px; }
.intro-card ul { list-style: none; margin: 0 0 22px; padding: 0; }
.intro-card li { font-size: 12px; color: var(--dim); padding: 7px 0; border-bottom: 1px solid var(--line); }
.intro-card li b { color: var(--cyan); font-weight: 500; }
.intro-card kbd {
  background: rgba(0,240,255,0.12); border: 1px solid var(--line-strong);
  border-radius: 4px; padding: 1px 6px; color: var(--ink); font-size: 11px;
}
.intro-card .btn { width: 100%; padding: 13px; font-size: 13px; letter-spacing: 0.1em; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(14,15,22,0.92); border: 1px solid var(--line-strong);
  color: var(--ink); font-size: 11px; letter-spacing: 0.14em;
  padding: 11px 20px; border-radius: 8px; backdrop-filter: blur(10px);
  box-shadow: var(--glow); opacity: 0; pointer-events: none; z-index: 20;
  transition: opacity 0.3s, transform 0.3s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); animation: toastOut 0.4s ease 2.2s forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(-50%) translateY(20px); } }

/* scrollbar */
.panel::-webkit-scrollbar { width: 6px; }
.panel::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

/* Accessibility: tone down decorative motion (the field itself is the content). */
@media (prefers-reduced-motion: reduce) {
  .brand .mark, .intro-mark { animation: none; }
  #stage.pulse { animation: none; }
  .panel, .intro-card { animation-duration: 0.01ms; }
}

@media (max-width: 600px) {
  .panel { width: calc(100vw - 32px); top: 60px; }
  .brand .sub { display: none; }
  .intro-card { padding: 26px 22px; }
  .intro-card h1 { font-size: 25px; }
}
