/* ==========================================================================
   PLATONIC GRIMOIRE — Dark Astral & Sacred Geometry Theme
   ========================================================================== */

:root {
  --bg-void: #05060c;
  --glass-bg: rgba(12, 15, 28, 0.72);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-highlight: rgba(255, 255, 255, 0.22);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-gold: #f59e0b;
  --accent-active: #ff5722;
  --font-display: 'Cinzel', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-void);
  color: var(--text-main);
  font-family: var(--font-sans);
}

#canvas-container {
  position: fixed;
  inset: 0;
  z-index: 1;
  cursor: grab;
}

#canvas-container:active {
  cursor: grabbing;
}

/* --- Top Bar --- */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.brand-sigil {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 30%, rgba(245, 158, 11, 0.35), rgba(15, 23, 42, 0.8));
  border: 1px solid rgba(245, 158, 11, 0.45);
  display: grid;
  place-items: center;
  font-size: 20px;
  color: #fbbf24;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: #f8fafc;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.top-actions {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.glass-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
}

.glass-btn:hover {
  border-color: var(--glass-highlight);
  background: rgba(25, 32, 56, 0.85);
  transform: translateY(-1px);
}

.glass-btn.primary-glow {
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.18);
}

/* --- Telemetry HUD (Bottom Left) --- */
.telemetry-hud {
  position: fixed;
  left: 24px;
  bottom: 108px;
  z-index: 9;
  max-width: 320px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  pointer-events: none;
  transition: border-color 0.3s ease;
}

.telemetry-badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.telemetry-main {
  font-size: 0.84rem;
  font-weight: 500;
  color: #f8fafc;
  line-height: 1.35;
}

.telemetry-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.charge-bar-wrap {
  margin-top: 8px;
  height: 4px;
  width: 100%;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.charge-bar-wrap.active {
  opacity: 1;
}

.charge-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #ef4444, #ffffff);
  transition: width 0.05s linear;
}

/* --- Right Grimoire Panel --- */
.grimoire-panel {
  position: fixed;
  top: 76px;
  right: 24px;
  bottom: 108px;
  width: 350px;
  max-width: calc(100vw - 48px);
  z-index: 10;
  border-radius: 18px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}

.grimoire-panel.collapsed {
  transform: translateX(calc(100% + 40px));
  opacity: 0;
  pointer-events: none;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(5, 8, 18, 0.5);
}

.tab-btn {
  flex: 1;
  padding: 13px 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  color: #fbbf24;
  border-bottom-color: #fbbf24;
  background: rgba(245, 158, 11, 0.06);
}

.tab-content {
  display: none;
  padding: 18px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.tab-content.active {
  display: block;
}

.solid-header {
  margin-bottom: 12px;
}

.element-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fbbf24;
  margin-bottom: 6px;
}

.solid-header h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.philosophy-quote {
  font-size: 0.84rem;
  line-height: 1.55;
  color: #cbd5e1;
  font-style: italic;
  padding-left: 12px;
  border-left: 2px solid rgba(245, 158, 11, 0.55);
  margin-bottom: 16px;
}

/* Euler Formula Box */
.euler-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
}

.euler-title {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
}

.euler-title span {
  font-family: var(--font-mono);
  color: #38bdf8;
}

.euler-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: center;
}

.euler-stat {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 54px;
}

.euler-stat.result {
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.stat-val {
  display: block;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.stat-lbl {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.euler-op {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.face-shape-note {
  margin-top: 9px;
  font-size: 0.74rem;
  color: #94a3b8;
  text-align: center;
}

/* Controls & Sliders */
.control-group {
  margin-bottom: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 500;
}

.control-val {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #fbbf24;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fbbf24;
  border: 2px solid #0f172a;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.7);
  cursor: pointer;
  transition: transform 0.15s ease;
}

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

.control-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-top: 7px;
}

.action-btn {
  margin-top: 10px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(234, 88, 12, 0.2));
  color: #fef3c7;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.35), rgba(234, 88, 12, 0.35));
  transform: translateY(-1px);
}

/* --- Spells Tab --- */
.panel-intro {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 14px;
}

.spells-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.spell-card {
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.09);
  padding: 12px 14px;
  transition: border-color 0.25s ease, background 0.25s ease;
}

.spell-card.active {
  border-color: rgba(192, 132, 252, 0.55);
  background: rgba(192, 132, 252, 0.07);
}

.spell-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.spell-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #f8fafc;
}

.spell-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 5px;
}

.spell-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.spell-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.spell-toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  cursor: pointer;
  transition: 0.25s;
}

.spell-toggle-slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.25s;
}

.spell-toggle input:checked + .spell-toggle-slider {
  background: #a855f7;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.6);
}

.spell-toggle input:checked + .spell-toggle-slider::before {
  transform: translateX(18px);
}

.spell-controls {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  display: none;
  flex-direction: column;
  gap: 10px;
}

.spell-card.active .spell-controls {
  display: flex;
}

/* --- Bottom Element Dock --- */
.element-dock {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.dock-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-2px);
}

.dock-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--accent);
  box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 35%, transparent);
}

.dock-symbol {
  font-size: 1.25rem;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 4px;
}

.dock-name {
  font-size: 0.78rem;
  font-weight: 600;
}

.dock-sub {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  opacity: 0.75;
  margin-top: 1px;
}

/* --- Toast --- */
.toast {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  z-index: 30;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(251, 191, 36, 0.5);
  color: #fef3c7;
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Responsive Mobile --- */
@media (max-width: 768px) {
  .brand-subtitle,
  .glass-btn .label {
    display: none;
  }

  .telemetry-hud {
    left: 12px;
    right: 12px;
    bottom: 94px;
    max-width: none;
    padding: 9px 12px;
  }

  .grimoire-panel {
    left: 12px;
    right: 12px;
    width: auto;
    top: 68px;
    bottom: 94px;
  }

  .element-dock {
    bottom: 12px;
    width: calc(100vw - 24px);
    justify-content: space-between;
    gap: 4px;
    padding: 6px;
  }

  .dock-item {
    min-width: 0;
    flex: 1;
    padding: 7px 4px;
  }
}
