/* ═══════════════════════════════════════════
   Dreamscape — CSS Theme
   ═══════════════════════════════════════════ */

:root {
  --void: #0f0a1a;
  --canvas-bg: #1a1025;
  --panel: #241535;
  --hover: #2e1f42;
  --lavender: #c4b5fd;
  --violet: #a78bfa;
  --moonlight: #93c5fd;
  --rose: #fda4af;
  --text-primary: rgba(255, 255, 255, 0.85);
  --text-secondary: rgba(255, 255, 255, 0.45);
  --text-accent: #c4b5fd;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --overlay-tint: rgba(255, 255, 255, 0.04);
  --overlay-hover: rgba(255, 255, 255, 0.08);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 400ms;
  --sidebar-width: 200px;
  --toolbar-width: 220px;
}

/* ═══ Light Theme ═══ */

[data-theme="light"] {
  --void: #f5f0f7;
  --canvas-bg: #ffffff;
  --panel: #ede8f2;
  --hover: #ddd6e8;
  --lavender: #7c3aed;
  --violet: #6d28d9;
  --moonlight: #3b82f6;
  --rose: #e11d48;
  --text-primary: rgba(30, 15, 50, 0.85);
  --text-secondary: rgba(30, 15, 50, 0.50);
  --text-accent: #7c3aed;
  --border: rgba(30, 15, 50, 0.08);
  --border-hover: rgba(30, 15, 50, 0.15);
  --overlay-tint: rgba(30, 15, 50, 0.03);
  --overlay-hover: rgba(30, 15, 50, 0.06);
}

/* ═══ Font Scaling ═══ */

[data-font-scale="small"] { font-size: 14px; }
[data-font-scale="large"] { font-size: 18px; }
[data-font-scale="xl"]    { font-size: 20px; }

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

html, body {
  height: 100%;
  font-family: 'Quicksand', sans-serif;
  font-weight: 400;
  background: var(--void);
  color: var(--text-primary);
  overflow: hidden;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}

/* ═══ Focus ═══ */

:focus-visible {
  outline: 2px solid rgba(196, 181, 253, 0.5);
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible {
  box-shadow: 0 0 0 2px var(--void), 0 0 0 4px rgba(196, 181, 253, 0.4);
  outline: none;
}

.tool-slider:focus-visible {
  outline: none;
  box-shadow: 0 0 8px rgba(196, 181, 253, 0.3);
}

/* ═══ Scrollbar ═══ */

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 181, 253, 0.15) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.2), rgba(147, 197, 253, 0.15));
  border-radius: 3px;
  transition: background 0.3s;
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.4), rgba(147, 197, 253, 0.3));
}
*::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.55), rgba(147, 197, 253, 0.4));
}

[data-theme="light"] * {
  scrollbar-color: rgba(109, 40, 217, 0.2) transparent;
}
[data-theme="light"] *::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(109, 40, 217, 0.2), rgba(59, 130, 246, 0.15));
}
[data-theme="light"] *::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(109, 40, 217, 0.35), rgba(59, 130, 246, 0.25));
}
[data-theme="light"] *::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, rgba(109, 40, 217, 0.5), rgba(59, 130, 246, 0.35));
}

/* ═══ Reduced Motion ═══ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
}

/* ═══ Accessibility Panel ═══ */

.a11y-wrapper {
  position: relative;
}

.a11y-btn {
  font-size: 0.7rem !important;
  letter-spacing: 0.5px;
  padding: 5px 10px !important;
}

.a11y-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 9999;
  min-width: 200px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border-hover);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.a11y-panel.open {
  display: block;
}

.a11y-group {
  margin-bottom: 10px;
}

.a11y-group:last-child {
  margin-bottom: 0;
}

.a11y-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: 0.3px;
}

.a11y-pills {
  display: flex;
  gap: 4px;
}

.a11y-pill {
  flex: 1;
  padding: 4px 8px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.a11y-pill:hover {
  background: var(--overlay-hover);
  color: var(--text-primary);
}

.a11y-pill.active {
  background: rgba(124, 58, 237, 0.15);
  color: var(--lavender);
  border-color: var(--lavender);
}

/* ── Reduce Motion Toggle ── */

.a11y-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.a11y-toggle-row .a11y-label {
  margin-bottom: 0;
}

.a11y-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.a11y-toggle-track {
  position: relative;
  width: 34px;
  height: 18px;
  background: var(--overlay-tint);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.a11y-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.a11y-checkbox:checked + .a11y-toggle-track {
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--lavender);
}

.a11y-checkbox:checked + .a11y-toggle-track .a11y-toggle-thumb {
  transform: translateX(16px);
  background: var(--lavender);
}

/* Keep canvas area dark even in light mode */
[data-theme="light"] .canvas-area {
  background: #1a1025;
}
