/* ============================================================
 * Glow Core CSS — topbar, settings panel, activatable focus/dwell.
 * Three visual modes: bright (default cream), soft (dim cream), cvi (black + yellow).
 * ============================================================ */

/* Self-hosted webfonts (OFL 1.1) — see /assets/fonts/LICENSING.md */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('/assets/fonts/fraunces-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 400 900;
  font-display: swap;
  src: url('/assets/fonts/fraunces-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('/assets/fonts/nunito.woff2') format('woff2');
}

:root {
  --navy: #1a1a3a;
  --cream: #faf3e7;
  --butter: #ffd24a;
  --coral: #ff6b6b;
  --mint: #5dd9b8;
  --lavender: #b8a4ff;
  --sky: #7cc7ff;
  --text: #1a1a3a;
  --text-soft: rgba(26, 26, 58, 0.65);
  --border: rgba(26, 26, 58, 0.12);
  --card: #fff;
  --focus: var(--butter);
  --bg: var(--cream);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Nunito', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Visual modes ---- */
body.glow-visual-soft { --bg: #f4ead7; --text: #2a2740; }
body.glow-visual-cvi {
  --bg: #000;
  --text: #ffeb3b;
  --card: #111;
  --border: rgba(255, 235, 59, 0.25);
  --text-soft: rgba(255, 235, 59, 0.7);
  --focus: #ffeb3b;
  --navy: #ffeb3b;
  --butter: #ffeb3b;
  --coral: #ff6b6b;
}
body.glow-visual-cvi .glow-topbar { background: #000; border-bottom: 2px solid #ffeb3b; }
body.glow-visual-cvi .glow-topbar .glow-title { color: #ffeb3b; }

/* ---- Topbar ---- */
.glow-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--navy);
  color: var(--cream);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}
.glow-back-btn, .glow-settings-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  color: var(--cream);
  border-radius: 50%;
  font-family: inherit;
  font-weight: 900;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  min-width: 48px;
  min-height: 48px;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}
.glow-back-btn:hover, .glow-settings-btn:hover {
  border-color: var(--butter);
  background: rgba(255, 255, 255, 0.16);
  transform: scale(1.05);
}
.glow-back-btn:active, .glow-settings-btn:active { transform: scale(0.95); }
.glow-settings-btn { font-size: 22px; }
body.glow-big-targets .glow-back-btn,
body.glow-big-targets .glow-settings-btn { width: 60px; height: 60px; min-width: 60px; min-height: 60px; font-size: 34px; }
body.glow-big-targets .glow-settings-btn { font-size: 26px; }

/* Dictation (voice / TTS) toggle — the prominent, always-visible control for the
   #1 ask: turn the spoken narration off. A pill so the "Dictation" label fits.
   Red = off, green = on. The icon and label also change with state, so the
   on/off cue is never color-only (colorblind-safe). */
.glow-voice-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  background: #e8584a;
  border: 2px solid #ff6b5c;
  color: #fff;
  border-radius: 100px;
  font-family: inherit;
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  min-height: 48px;
  padding: 0 16px;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.glow-voice-btn .glow-voice-icon { font-size: 20px; line-height: 1; }
.glow-voice-btn:hover { filter: brightness(1.06); transform: scale(1.04); }
.glow-voice-btn:active { transform: scale(0.96); }
/* "On" = dictation talks. Filled green so it reads as clearly active. */
.glow-voice-btn.is-on { background: #2fb567; border-color: #4cd183; color: #052b16; }
.glow-voice-btn.is-on:hover { filter: brightness(1.06); }
body.glow-big-targets .glow-voice-btn { min-height: 60px; min-width: 60px; font-size: 18px; padding: 0 20px; }
body.glow-big-targets .glow-voice-btn .glow-voice-icon { font-size: 24px; }
body.glow-visual-cvi .glow-voice-btn { background: #b3261a; border-color: #ff5a4a; color: #fff; }
body.glow-visual-cvi .glow-voice-btn.is-on { background: #16a34a; border-color: #3ef08a; color: #000; }

.glow-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 900;
  font-size: 22px;
  color: var(--butter);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile: shrink topbar so titles never push the HUD tall */
@media (max-width: 640px) {
  .glow-topbar { padding: 6px 10px; gap: 8px; }
  .glow-back-btn, .glow-settings-btn {
    width: 44px; height: 44px; min-width: 44px; min-height: 44px; font-size: 24px;
  }
  .glow-settings-btn { font-size: 20px; }
  .glow-voice-btn { min-height: 44px; font-size: 13px; padding: 0 12px; gap: 6px; }
  .glow-voice-btn .glow-voice-icon { font-size: 17px; }
  .glow-title { font-size: 15px; }
}
@media (max-width: 380px) {
  .glow-title { font-size: 0; }
}

/* ---- Activatable ---- */
.glow-activatable {
  position: relative;
  outline: none;
  /* Kill the 300ms tap delay on mobile + grey flash on tap. Every
     interactive element in every Glow game inherits this. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
.glow-activatable:focus-visible {
  outline: 3px dashed var(--focus);
  outline-offset: 8px;
}
.glow-dwell-ring {
  position: absolute;
  inset: -8px;
  border-radius: inherit;
  pointer-events: none;
  border: 4px solid transparent;
  border-top-color: var(--butter);
  animation: glow-dwell var(--dwell-time, 1000ms) linear forwards;
}
@keyframes glow-dwell {
  from { transform: rotate(0deg); }
  to { transform: rotate(720deg); }
}

/* ---- Settings panel ---- */
.glow-settings-panel {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
}
.glow-settings-panel.open { display: block; }
.glow-settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}
.glow-settings-card {
  position: absolute;
  top: 0;
  right: 0;
  width: min(440px, 100%);
  height: 100%;
  background: var(--bg);
  color: var(--text);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  animation: glow-slide-in 0.25s ease;
}
@keyframes glow-slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }

.glow-settings-head {
  display: flex;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 2px solid var(--border);
  background: var(--card);
}
.glow-settings-head h2 {
  flex: 1;
  margin: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 900;
  font-size: 24px;
  color: var(--navy);
}
.glow-settings-close {
  width: 44px;
  height: 44px;
  border-radius: 100px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--navy);
  font-size: 26px;
  font-weight: 700;
  cursor: pointer;
}
.glow-settings-close:hover { border-color: var(--coral); color: var(--coral); }
.glow-settings-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.glow-settings-section { margin-bottom: 22px; }
.glow-settings-section h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  margin: 0 0 10px;
}
.glow-settings-note {
  margin: -2px 0 10px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-soft);
}
.glow-settings-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.glow-settings-group button {
  background: var(--card);
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: 100px;
  padding: 10px 18px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  min-height: 44px;
}
.glow-settings-group button:hover { border-color: var(--navy); }
.glow-settings-group button.active {
  background: var(--navy);
  color: var(--cream);
  border-color: var(--navy);
}
body.glow-visual-cvi .glow-settings-group button.active {
  background: var(--butter);
  color: #000;
  border-color: var(--butter);
}

/* Dev environment banner — small corner chip, not a full-width bar.
   Lives in the bottom-left corner and is click-through so it never
   covers game controls, paint canvases, piano keys, or generator
   buttons. Only the "switch to live" link re-enables clicks. */
#glow-dev-banner {
  position: fixed;
  bottom: 10px; left: 10px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  background: linear-gradient(90deg, #ff6b6b, #ffd24a);
  color: #1a1a3a;
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 100px;
  box-shadow: 0 2px 6px rgba(26, 26, 58, 0.25);
  pointer-events: none; /* click-through; only .dlink re-enables */
  max-width: 280px;
  opacity: 0.92;
  transition: opacity 0.2s ease;
}
#glow-dev-banner:hover { opacity: 1; }
#glow-dev-banner .ddot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #1a1a3a;
  animation: glow-dev-pulse 1.4s ease-in-out infinite;
  flex: 0 0 8px;
}
@keyframes glow-dev-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.35); opacity: 0.6; }
}
#glow-dev-banner .dsep { opacity: 0.45; font-weight: 700; }
#glow-dev-banner .dlink {
  color: #1a1a3a;
  text-decoration: underline;
  font-style: italic;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: auto;
}
#glow-dev-banner .dlink:hover { color: #fff; }
/* Topbar border tint kept as a subtle dev marker. */
body.is-dev .glow-topbar { border-top: 4px solid #ff6b6b; }
/* On phones the chip stays small in the bottom-left corner. */
@media (max-width: 600px) {
  #glow-dev-banner { font-size: 10px; padding: 4px 8px 4px 6px; }
  #glow-dev-banner .dlink, #glow-dev-banner .dsep { display: none; }
}

/* Reduce-motion fallback */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
