/* ==========================================================================
   Dyslexia Kids Magic Toolkit & 3D Experiential Styles
   Vibrant, accessible, multi-sensory, and scientifically supportive.
   ========================================================================== */

/* 1. Dyslexia Color Overlays / Irlen Tints */
html.tint-cream, body.tint-cream {
  --paper: #fff6e5 !important;
  --soft: #fcedd0 !important;
  --tint: #fff9ee !important;
  background-color: #fff6e5 !important;
}

html.tint-mint, body.tint-mint {
  --paper: #edf7f2 !important;
  --soft: #d8efe3 !important;
  --tint: #f3faf6 !important;
  background-color: #edf7f2 !important;
}

html.tint-sky, body.tint-sky {
  --paper: #eef6fd !important;
  --soft: #d9ecfb !important;
  --tint: #f5faff !important;
  background-color: #eef6fd !important;
}

html.tint-rose, body.tint-rose {
  --paper: #fff0eb !important;
  --soft: #fde0d7 !important;
  --tint: #fff6f3 !important;
  background-color: #fff0eb !important;
}

html.tint-lilac, body.tint-lilac {
  --paper: #f7f0fc !important;
  --soft: #eedef7 !important;
  --tint: #faf6fe !important;
  background-color: #f7f0fc !important;
}

/* 2. Dyslexia High-Distinction Font Mode */
html.font-dyslexic body,
body.font-dyslexic {
  font-family: "Lexend", -apple-system, BlinkMacSystemFont, "Segoe UI", Comic Sans MS, cursive, sans-serif !important;
  letter-spacing: 0.04em !important;
  word-spacing: 0.1em !important;
  line-height: 1.82 !important;
}

html.font-dyslexic p,
html.font-dyslexic li,
html.font-dyslexic span,
html.font-dyslexic a {
  letter-spacing: 0.035em !important;
  word-spacing: 0.08em !important;
}

/* 3. Interactive Reading Ruler (Focus Guide) */
#readingRulerOverlay {
  position: fixed;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 9998;
  display: none;
  transition: opacity 0.15s ease;
}

#readingRulerOverlay.active {
  display: block;
}

.ruler-shade-top {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  background: rgba(18, 25, 34, 0.45);
  backdrop-filter: blur(1px);
}

.ruler-guide-window {
  position: absolute;
  left: 0;
  right: 0;
  height: 58px;
  background: rgba(255, 246, 170, 0.28);
  border-top: 3px solid #ff9d00;
  border-bottom: 3px solid #ff9d00;
  box-shadow: 0 0 25px rgba(255, 170, 0, 0.35), inset 0 0 10px rgba(255, 230, 100, 0.4);
}

.ruler-shade-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(18, 25, 34, 0.45);
  backdrop-filter: blur(1px);
}

/* 4. Header Sound & Magic Mode Buttons */
.sound-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 99px;
  background: #ffffff;
  border: 1.5px solid var(--line, #dfe7e4);
  color: var(--fill, #2f6f8f);
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 1px 3px rgba(23, 33, 43, 0.05);
}

.sound-toggle-btn:hover {
  background: #fff4dc;
  border-color: #f7c948;
  transform: scale(1.06);
}

.sound-toggle-btn.muted {
  color: #94a3b8;
  border-color: #cbd5e1;
}

.kids-magic-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  background: linear-gradient(135deg, #ff7e5f 0%, #feb47b 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  border: none;
  border-radius: 99px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(255, 126, 95, 0.35);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-decoration: none;
  white-space: nowrap;
}

.kids-magic-pill:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 5px 15px rgba(255, 126, 95, 0.45);
}

.kids-magic-pill .magic-sparkle {
  display: inline-block;
  animation: sparkleTwist 2.2s infinite ease-in-out;
}

@keyframes sparkleTwist {
  0%, 100% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(20deg) scale(1.25); }
}

/* 5. 3D Tactile Buttons & Interactive Cards */
.tactile-3d-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 12px 22px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  user-select: none;
  text-decoration: none;
}

.tactile-3d-btn.btn-cyan {
  background: #00b4d8;
  color: #ffffff;
  box-shadow: 0 5px 0 #0077b6, 0 10px 18px rgba(0, 180, 216, 0.3);
}

.tactile-3d-btn.btn-cyan:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #0077b6, 0 14px 22px rgba(0, 180, 216, 0.35);
}

.tactile-3d-btn.btn-cyan:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #0077b6, 0 4px 8px rgba(0, 180, 216, 0.3);
}

.tactile-3d-btn.btn-amber {
  background: #ffb703;
  color: #17212b;
  box-shadow: 0 5px 0 #fb8500, 0 10px 18px rgba(255, 183, 3, 0.35);
}

.tactile-3d-btn.btn-amber:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #fb8500, 0 14px 22px rgba(255, 183, 3, 0.45);
}

.tactile-3d-btn.btn-amber:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #fb8500, 0 4px 8px rgba(255, 183, 3, 0.3);
}

.tactile-3d-btn.btn-coral {
  background: #ff6b6b;
  color: #ffffff;
  box-shadow: 0 5px 0 #d90429, 0 10px 18px rgba(255, 107, 107, 0.35);
}

.tactile-3d-btn.btn-coral:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #d90429, 0 14px 22px rgba(255, 107, 107, 0.4);
}

.tactile-3d-btn.btn-coral:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #d90429, 0 4px 8px rgba(255, 107, 107, 0.3);
}

/* 6. 3D Pen Playground Section */
.kids-3d-playground {
  background: radial-gradient(circle at 10% 20%, #f7fcff 0%, #fffbf2 85%);
  border: 2.5px solid #d4e8f3;
  border-radius: 28px;
  padding: 36px 32px;
  margin: 44px 0 52px;
  box-shadow: 0 16px 42px rgba(47, 111, 143, 0.08), 0 4px 10px rgba(0, 0, 0, 0.03);
  position: relative;
  overflow: hidden;
}

.playground-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #ffefe5;
  color: #e65100;
  border: 1.5px solid #ffcc80;
  border-radius: 99px;
  padding: 5px 14px;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.playground-title {
  font-size: clamp(1.8rem, 3.4vw, 2.4rem);
  font-weight: 850;
  color: #17212b;
  line-height: 1.22;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.playground-desc {
  font-size: 1.05rem;
  color: #526371;
  max-width: 62ch;
  line-height: 1.68;
  margin-bottom: 28px;
}

/* 3D Canvas Stage Container */
.stage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .stage-grid {
    grid-template-columns: 1fr;
  }
}

.canvas-3d-box {
  position: relative;
  background: linear-gradient(145deg, #1b2838 0%, #101924 100%);
  border-radius: 22px;
  border: 2px solid #2e435b;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.4), 0 10px 25px rgba(0, 0, 0, 0.15);
  min-height: 380px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.canvas-3d-box canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  cursor: grab;
}

.canvas-3d-box canvas:active {
  cursor: grabbing;
}

.canvas-overlay-ctrls {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.canvas-chip {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 750;
  pointer-events: auto;
}

.canvas-bottom-bar {
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  pointer-events: none;
  z-index: 10;
}

.pen-color-swatches {
  display: flex;
  gap: 7px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  padding: 5px 8px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  pointer-events: auto;
}

.swatch-btn {
  width: 24px;
  height: 24px;
  border-radius: 99px;
  border: 2px solid #ffffff;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.swatch-btn:hover {
  transform: scale(1.22);
}

.swatch-btn.active {
  transform: scale(1.25);
  box-shadow: 0 0 0 2px #ffc107, 0 0 10px #ffc107;
}

.pen-action-btns {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.pen-mini-btn {
  background: rgba(255, 255, 255, 0.92);
  color: #1e293b;
  border: none;
  font-weight: 750;
  font-size: 0.76rem;
  padding: 6px 12px;
  border-radius: 99px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: all 0.15s ease;
}

.pen-mini-btn:hover {
  background: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

/* Phonics Interactive Scanner Panel */
.scanner-interactive-card {
  background: #ffffff;
  border-radius: 22px;
  border: 2px solid #e2e8f0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 6px 20px rgba(0,0,0,0.03);
}

.scanner-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.scanner-sample-selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 16px;
}

.sample-chip-btn {
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.sample-chip-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.sample-chip-btn.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

/* Syllable Reading Stream */
.syllable-display-box {
  background: #fafaf9;
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  min-height: 110px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  position: relative;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.syllable-display-box.scanning {
  border-color: #0284c7;
  background: #f0f9ff;
}

.word-token {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 1.15rem;
  font-weight: 750;
  color: #1e293b;
  cursor: pointer;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.word-token:hover {
  transform: translateY(-2px) scale(1.05);
  border-color: #0284c7;
  color: #0284c7;
}

.word-token.highlighted {
  background: #ffea79 !important;
  color: #000000 !important;
  border-color: #f59e0b !important;
  transform: scale(1.12);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.45);
  z-index: 5;
}

.word-token.completed {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.syllable-divider {
  color: #94a3b8;
  font-weight: 400;
  margin: 0 1px;
}

/* Custom Text Entry Form */
.custom-input-wrap {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.custom-input-wrap input {
  flex: 1;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}

.custom-input-wrap input:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Phonics Syllable Exploder Area */
.phonics-breakdown-card {
  background: linear-gradient(135deg, #eef2ff 0%, #fdf4ff 100%);
  border-radius: 16px;
  border: 1.5px solid #c7d2fe;
  padding: 14px 18px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.phonics-pill-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.syllable-chip {
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.88rem;
  color: #4338ca;
  background: #ffffff;
  border: 1px solid #a5b4fc;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.syllable-chip:hover {
  transform: scale(1.1);
  background: #4338ca;
  color: #ffffff;
}

/* 7. Dyslexia Superpowers 3D Tilt Cards */
.superpowers-section {
  padding: 48px 0 32px;
}

.superpowers-header {
  text-align: center;
  max-width: 680px;
  margin: 0 auto 36px;
}

.superpowers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.tilt-power-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 26px 22px;
  border: 2px solid var(--line, #dfe7e4);
  box-shadow: 0 8px 24px rgba(23, 33, 43, 0.05);
  transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.tilt-power-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 16px 36px rgba(47, 111, 143, 0.15);
  border-color: #38bdf8;
}

.tilt-power-card .card-icon-3d {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  margin-bottom: 16px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
}

.tilt-power-card.card-blue .card-icon-3d {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  color: #ffffff;
}

.tilt-power-card.card-amber .card-icon-3d {
  background: linear-gradient(135deg, #fde047 0%, #eab308 100%);
  color: #1e293b;
}

.tilt-power-card.card-emerald .card-icon-3d {
  background: linear-gradient(135deg, #6ee7b7 0%, #10b981 100%);
  color: #ffffff;
}

.tilt-power-card.card-purple .card-icon-3d {
  background: linear-gradient(135deg, #c084fc 0%, #9333ea 100%);
  color: #ffffff;
}

.tilt-power-card h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #17212b;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.tilt-power-card p {
  color: #5a6875;
  font-size: 0.92rem;
  line-height: 1.62;
  margin-bottom: 14px;
}

.power-card-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 99px;
  background: #f1f5f9;
  color: #475569;
}

/* 8. Floating Kids' Magic Dock */
.kids-magic-dock {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.dock-trigger-btn {
  background: linear-gradient(135deg, #2f6f8f 0%, #1d4d65 100%);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 99px;
  padding: 10px 18px;
  font-weight: 800;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(47, 111, 143, 0.38), 0 2px 6px rgba(0,0,0,0.1);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dock-trigger-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 28px rgba(47, 111, 143, 0.48);
}

.dock-modal-panel {
  display: none;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 24px;
  width: 320px;
  padding: 22px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(0, 0, 0, 0.05);
  animation: dockSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.dock-modal-panel.open {
  display: block;
}

@keyframes dockSlideUp {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dock-panel-title {
  font-weight: 850;
  font-size: 1.05rem;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.dock-panel-title .close-dock-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 2px 6px;
  border-radius: 6px;
}

.dock-panel-title .close-dock-btn:hover {
  color: #0f172a;
  background: #f1f5f9;
}

.dock-section {
  margin-bottom: 18px;
}

.dock-section:last-child {
  margin-bottom: 0;
}

.dock-section-label {
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tint-swatch-row {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.tint-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: 99px;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 750;
}

.tint-circle-btn:hover {
  transform: scale(1.12);
}

.tint-circle-btn.active {
  border-color: #0284c7;
  transform: scale(1.14);
  box-shadow: 0 0 0 2px #bae6fd;
}

.dock-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
}

.dock-toggle-text {
  font-size: 0.88rem;
  font-weight: 700;
  color: #334155;
}

.dock-switch-btn {
  background: #e2e8f0;
  border: none;
  width: 44px;
  height: 24px;
  border-radius: 99px;
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.dock-switch-btn::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 99px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dock-switch-btn.active {
  background: #0284c7;
}

.dock-switch-btn.active::after {
  transform: translateX(20px);
}

/* Celebratory Confetti Mascot Toast */
.scanny-toast {
  position: fixed;
  bottom: 92px;
  right: 24px;
  background: #ffffff;
  border: 2px solid #f59e0b;
  border-radius: 18px;
  padding: 12px 18px;
  box-shadow: 0 12px 30px rgba(245, 158, 11, 0.25);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 9995;
  animation: toastBounceIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes toastBounceIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.scanny-avatar {
  font-size: 1.8rem;
  animation: mascotWiggle 1.8s infinite ease-in-out;
}

@keyframes mascotWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

.scanny-toast-text {
  font-size: 0.88rem;
  font-weight: 750;
  color: #1e293b;
  line-height: 1.35;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .magic-sparkle,
  .scanny-avatar,
  .tactile-3d-btn,
  .tilt-power-card,
  .dock-trigger-btn {
    animation: none !important;
    transition: none !important;
  }
}
