/* ── SONIC Web – shared styles ─────────────────────────────────────────────── */

:root {
  --bg: #0a0f0a;
  --surface: rgba(255,255,255,0.04);
  --border: rgba(255,255,255,0.08);
  --text: #f0f4f0;
  --text-muted: rgba(240,244,240,0.5);
  --green: #76b947;
  --green-dim: rgba(118,185,71,0.15);
  --green-glow: rgba(118,185,71,0.25);
  --radius: 10px;
  --glass-bg: rgba(10,15,10,0.75);
  --glass-border: rgba(255,255,255,0.09);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ────────────────────────────────────────────────────────────── */
h1,h2,h3,h4 { line-height: 1.2; }

/* ── Glass panel ───────────────────────────────────────────────────────────── */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
}

/* ── Demo layout ───────────────────────────────────────────────────────────── */
.demo-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #0a0f0a;
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Side panel ────────────────────────────────────────────────────────────── */
.side-panel {
  position: absolute;
  top: 1rem;
  bottom: 1rem;
  left: 1rem;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 10;
  pointer-events: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.side-panel::-webkit-scrollbar { width: 4px; }
.side-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.side-panel > * { pointer-events: auto; }

.panel-section {
  padding: 1rem 1.1rem;
}

.panel-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 0.7rem;
}

/* ── Project header ────────────────────────────────────────────────────────── */
.project-header { padding: 1rem 1.1rem 0.85rem; }
.project-header .logo {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}
.project-header .logo span { color: var(--green); }
.project-header .tagline {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ── Motion selector ───────────────────────────────────────────────────────── */
.motion-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.motion-list::-webkit-scrollbar { width: 4px; }
.motion-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.motion-item {
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  color: var(--text-muted);
  border: 1px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: none;
  text-align: left;
  width: 100%;
}
.motion-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.motion-item.active {
  background: var(--green-dim);
  border-color: rgba(118,185,71,0.3);
  color: #fff;
}

/* ── Generate motion panel ─────────────────────────────────────────────────── */
.generate-panel {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.prompt-input {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.prompt-input::placeholder { color: var(--text-muted); }
.prompt-input:focus { border-color: rgba(118,185,71,0.5); }
.generate-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.duration-input {
  width: 56px;
  padding: 0.3rem 0.45rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 0.78rem;
  font-family: inherit;
  outline: none;
  text-align: center;
  -moz-appearance: textfield;
}
.duration-input::-webkit-inner-spin-button,
.duration-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.duration-input:focus { border-color: rgba(118,185,71,0.5); }
.btn-generate {
  width: 100%;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(118,185,71,0.4);
  background: var(--green-dim);
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-generate:hover:not(:disabled) { background: rgba(118,185,71,0.25); }
.btn-generate:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-generate.generating {
  animation: pulse-border 1.5s ease-in-out infinite;
}
@keyframes pulse-border {
  0%,100% { border-color: rgba(118,185,71,0.4); }
  50% { border-color: rgba(118,185,71,0.8); }
}
.generate-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  min-height: 1em;
}

/* ── Generated motion indicator ───────────────────────────────────────────── */
.motion-item .gen-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 0.4rem;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ── Playback controls ─────────────────────────────────────────────────────── */
.controls {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.ctrl-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.ctrl-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 40px;
}
.ctrl-btns { display: flex; gap: 0.4rem; }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.icon-btn.active { background: var(--green-dim); border-color: rgba(118,185,71,0.4); color: var(--green); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn.text-btn { width: auto; padding: 0 0.75rem; font-size: 0.72rem; letter-spacing: 0.03em; }
.icon-btn.policy-loading { opacity: 0.45; cursor: wait; font-style: italic; }
.icon-btn.policy-ready {
  border-color: rgba(118,185,71,0.6);
  color: var(--green);
  animation: policy-nudge 2s ease-in-out infinite;
}
@keyframes policy-nudge {
  0%,100% { box-shadow: 0 0 0 0 rgba(118,185,71,0.45); }
  50%      { box-shadow: 0 0 0 5px rgba(118,185,71,0); }
}

/* ── Range slider ──────────────────────────────────────────────────────────── */
input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green);
  cursor: pointer;
  box-shadow: 0 0 6px var(--green-glow);
}
input[type=range]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green);
  border: none;
  cursor: pointer;
}

/* ── Status bar ────────────────────────────────────────────────────────────── */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: glow-pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
.status-dot.loading { background: #f0a500; }
.status-dot.error   { background: #e84040; animation: none; }
@keyframes glow-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(118,185,71,0.5); }
  50%      { box-shadow: 0 0 0 4px rgba(118,185,71,0); }
}

/* ── Top-right info panel ──────────────────────────────────────────────────── */
.info-panel {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  padding: 0.75rem 1rem;
  min-width: 170px;
}
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}
.info-row:last-child { margin-bottom: 0; }
.info-key { color: var(--text-muted); }
.info-val { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 0.8rem; }

/* ── Controls help (bottom center) ────────────────────────────────────────── */
.help-bar {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 0.5rem 1rem;
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  justify-content: center;
}
.help-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 0.45rem;
  border-radius: 5px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 0.65rem;
  font-weight: 600;
  min-width: 24px;
}

/* ── Loading overlay ───────────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.5s ease;
}
#loading-overlay.fade-out { opacity: 0; pointer-events: none; }
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(118,185,71,0.15);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1.2rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-logo { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.4rem; }
.loading-logo span { color: var(--green); }
#loading-status { font-size: 0.8rem; color: var(--text-muted); text-align: center; max-width: 280px; }

/* ── Toast notification ─────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 4.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  z-index: 20;
  background: rgba(10,15,10,0.92);
  border: 1px solid rgba(118,185,71,0.4);
  border-radius: 8px;
  padding: 0.55rem 1.2rem;
  font-size: 0.78rem;
  color: var(--green);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s, transform 0.35s;
  white-space: nowrap;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Back link ─────────────────────────────────────────────────────────────── */
.back-link {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  z-index: 10;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.back-link:hover { color: var(--text); background: rgba(255,255,255,0.05); }
