/* BiliKids Writing Practice Stylesheet */
:root {
  --font-display: 'Fredoka One', 'Fredoka', cursive, sans-serif;
  --font-body: 'Nunito', 'Quicksand', sans-serif;
  --font-cursive: 'Caveat', 'Dancing Script', cursive;
  
  --bg-gradient: linear-gradient(135deg, #0c4a6e 0%, #0369a1 40%, #0284c7 100%);
  --panel-bg: rgba(255, 255, 255, 0.95);
  
  --color-primary: #0284c7;
  --color-accent: #f59e0b;
  --color-success: #10b981;
  --color-danger: #ef4444;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  color: #0f172a;
  min-height: 100vh;
  overflow-x: hidden;
}

/* App Outer Shell */
.writing-app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1300px;
  margin: 0 auto;
  padding: 10px 16px 24px;
}

/* Header & Suite Navigation */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 10px 18px;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.brand .logo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.logo-icon {
  font-size: 1.6rem;
}

.highlight {
  color: #38bdf8;
}

.badge-tag {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  font-size: 0.75rem;
  font-family: var(--font-body);
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 12px;
  color: #fff;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Suite Switcher */
.suite-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 6px;
  border-radius: 30px;
  flex-wrap: wrap;
}

.nav-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  color: #cbd5e1;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-pill:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  transform: translateY(-1px);
}

.nav-pill.active {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #fff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.pill-icon {
  font-size: 1.1rem;
}

/* Header Utilities */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stars-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(254, 240, 138, 0.2);
  border: 1px solid rgba(253, 224, 71, 0.4);
  padding: 6px 14px;
  border-radius: 20px;
  color: #fef08a;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.star-icon {
  font-size: 1.3rem;
  filter: drop-shadow(0 0 6px #fde047);
}

.icon-circle-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-circle-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.08);
}

/* Level & Style Selector Bar */
.level-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.level-tabs {
  display: flex;
  gap: 10px;
}

.lvl-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #fff;
}

.lvl-tab:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lvl-tab.active {
  background: #ffffff;
  color: #0369a1;
  border-color: #38bdf8;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.lvl-badge {
  font-size: 0.75rem;
  font-weight: 900;
  background: rgba(3, 105, 161, 0.15);
  padding: 2px 6px;
  border-radius: 8px;
  text-transform: uppercase;
}

.lvl-tab.active .lvl-badge {
  background: #0284c7;
  color: #fff;
}

.lvl-title {
  font-family: var(--font-display);
  font-size: 1rem;
}

/* Font Style Toggle (Script vs Cursive) */
.font-style-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  padding: 4px 8px;
  border-radius: 20px;
}

.toggle-desc {
  color: #cbd5e1;
  font-weight: 800;
  font-size: 0.85rem;
  margin-left: 4px;
}

.mode-btn {
  padding: 6px 14px;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: #e2e8f0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mode-btn.active {
  background: #38bdf8;
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.4);
}

/* Stage Layout */
.writing-stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Target Word Banner */
.word-card-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-bg);
  border-radius: 24px;
  padding: 14px 20px;
  border: 4px solid #ffffff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.word-nav-arrow {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: #f1f5f9;
  font-size: 1.3rem;
  color: #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.word-nav-arrow:hover {
  background: #0284c7;
  color: #fff;
  border-color: #0284c7;
  transform: scale(1.08);
}

.word-info {
  display: flex;
  align-items: center;
  gap: 20px;
}

.word-emoji {
  font-size: 3.8rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.12));
}

.word-text-wrapper {
  display: flex;
  flex-direction: column;
}

.target-word {
  font-family: var(--font-display);
  font-size: 3rem;
  letter-spacing: 4px;
  color: #0f172a;
  line-height: 1.1;
}

.target-word.cursive-mode {
  font-family: var(--font-cursive);
  font-size: 4rem;
  letter-spacing: 1px;
}

.word-sub-hint {
  font-weight: 700;
  font-size: 0.95rem;
  color: #64748b;
}

.speaker-bubble-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 20px;
  border: 2px solid #38bdf8;
  background: #e0f2fe;
  color: #0369a1;
  font-family: var(--font-display);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 10px rgba(56, 189, 248, 0.25);
}

.speaker-bubble-btn:hover {
  transform: translateY(-2px) scale(1.05);
  background: #bae6fd;
}

/* Handwriting Workspace (Lined Paper + Canvas) */
.handwriting-workspace {
  background: var(--panel-bg);
  border-radius: 28px;
  padding: 18px 24px;
  border: 4px solid #ffffff;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.canvas-outer-frame {
  position: relative;
  width: 100%;
  height: 340px;
  background: #fffdf5; /* Warm creamy paper tone */
  border: 3px solid #cbd5e1;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.06);
  touch-action: none; /* Crucial for drawing on mobile/touch */
}

/* Kindergarten Handwriting Ruled Lines */
.paper-rules {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  padding: 20px 0;
}

.rule-line {
  width: 100%;
}

.rule-line.headline {
  border-top: 2px solid #93c5fd;
}

.rule-line.midline {
  border-top: 2px dashed #f87171;
}

.rule-line.baseline {
  border-top: 3px solid #60a5fa;
}

.rule-line.descender {
  border-top: 2px solid #cbd5e1;
}

/* Dashed Guideline Path Overlay (Opacified tracing guide) */
.dashed-guide-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0.30; /* Opacified tracing guide */
  transition: opacity 0.3s ease;
}

.dashed-guide-overlay.hidden {
  opacity: 0 !important;
}

.dashed-guide-overlay.prominent {
  opacity: 0.45 !important;
}

.guide-text {
  font-size: 9.5rem;
  font-weight: 900;
  color: transparent;
  -webkit-text-stroke: 3px #475569;
  text-shadow: 0 0 1px #475569;
  stroke-dasharray: 8, 8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  transform: translateY(-8px);
}

.letter-char {
  display: inline-block;
  transition: all 0.25s ease;
}

.letter-char.missing-hint {
  -webkit-text-stroke: 4px #ef4444 !important;
  animation: pulseLetterHint 0.8s infinite alternate;
}

@keyframes pulseLetterHint {
  from { transform: scale(1); filter: drop-shadow(0 0 6px #ef4444); }
  to { transform: scale(1.15); filter: drop-shadow(0 0 16px #ef4444); }
}

.guide-text.script-guide {
  font-family: var(--font-display);
}

.guide-text.cursive-guide {
  font-family: var(--font-cursive);
  font-size: 13rem;
  letter-spacing: 4px;
  transform: translateY(-24px);
}

/* Active Canvas */
#writingCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  z-index: 2;
}

/* Feedback Banner in Canvas */
.feedback-banner {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  padding: 6px 18px;
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  pointer-events: none;
  z-index: 3;
  transition: all 0.3s ease;
}

.feedback-banner.success {
  background: #10b981;
  color: #fff;
  transform: translateX(-50%) scale(1.08);
}

.feedback-banner.error {
  background: #ef4444;
  color: #fff;
  animation: shakeError 0.4s ease;
}

@keyframes shakeError {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(-55%); }
  75% { transform: translateX(-45%); }
}

/* Toolbar */
.writing-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.tool-group {
  display: flex;
  gap: 8px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 16px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  font-family: var(--font-display);
  font-size: 1rem;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tool-btn:hover {
  transform: translateY(-2px);
  border-color: #94a3b8;
}

.tool-btn.active {
  background: #0284c7;
  color: #fff;
  border-color: #0284c7;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.tool-btn.guide-btn.active {
  background: #8b5cf6;
  border-color: #8b5cf6;
  color: #fff;
}

.tool-btn.check-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  padding: 10px 24px;
  font-size: 1.1rem;
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

.tool-btn.check-btn:hover {
  transform: translateY(-2px) scale(1.06);
}

/* Color Swatches */
.color-palette {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.color-dot:hover {
  transform: scale(1.2);
}

.color-dot.active {
  transform: scale(1.25);
  box-shadow: 0 0 0 3px #0284c7;
}

/* Quick Word Ribbon */
.word-ribbon-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.5);
  padding: 10px 18px;
  border-radius: 20px;
  overflow-x: auto;
}

.ribbon-label {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: #38bdf8;
  white-space: nowrap;
}

.word-ribbon {
  display: flex;
  gap: 8px;
}

.ribbon-chip {
  padding: 6px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.ribbon-chip:hover {
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.ribbon-chip.active {
  background: #38bdf8;
  color: #0f172a;
  font-weight: 800;
  border-color: #38bdf8;
}

/* Fullscreen Confetti Canvas */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

/* Responsive */
@media (max-width: 800px) {
  .word-info {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }
  
  .target-word {
    font-size: 2.2rem;
  }
  
  .guide-text {
    font-size: 5rem;
    letter-spacing: 12px;
  }
  
  .guide-text.cursive-guide {
    font-size: 7rem;
  }
  
  .writing-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .tool-group, .color-palette {
    justify-content: center;
  }
}
