/* ═══════════════════════════════════════════
   THEME — Semantic colour tokens
   ═══════════════════════════════════════════ */
:root {
  --surface: #ffffff;
  --surface-raised: #f8fafc;
  --surface-sunken: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  --brand-50: #eef2ff;
  --brand-600: #4f46e5;
  --accent-success: #22c55e;
  --accent-error: #f87171;
  --accent-warning: #f59e0b;
}

.dark {
  --surface: #110e1a;
  --surface-raised: #1a1630;
  --surface-sunken: #0a0812;
  --border: #2a2545;
  --border-strong: #3d3660;
  --text-primary: #f0ecf9;
  --text-secondary: #a09cb0;
  --text-muted: #5a5470;
  --text-inverse: #110e1a;
  --brand-50: #1e1b4b;
  --brand-600: #a78bfa;
  --accent-success: #4ade80;
  --accent-error: #f87171;
  --accent-warning: #fbbf24;
}

/* ══════════════════════════════════════════════════
   CLAYMORPHISM DESIGN SYSTEM
   ══════════════════════════════════════════════════ */

/* ── Clay Colour Tokens ── */
:root {
    --clay-bg: #F4F1FA;
    --clay-card: rgba(255, 255, 255, 0.75);
    --clay-card-solid: #FFFFFF;
    --clay-text: #332F3A;
    --clay-text-muted: #635F69;
    --clay-primary: #7C3AED;
    --clay-primary-light: #A78BFA;
    --clay-secondary: #10B981;
    --clay-secondary-light: #34D399;
    --clay-accent: #F59E0B;
    --clay-accent2: #EC4899;
    --clay-border: rgba(255, 255, 255, 0.5);
    --clay-shadow: 8px 8px 16px rgba(124, 58, 237, 0.08), -4px -4px 12px rgba(255, 255, 255, 0.8), inset 0 2px 0 rgba(255, 255, 255, 0.6);
    --clay-shadow-sm: 4px 4px 8px rgba(124, 58, 237, 0.06), -2px -2px 6px rgba(255, 255, 255, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    --clay-shadow-hover: 10px 10px 20px rgba(124, 58, 237, 0.12), -6px -6px 16px rgba(255, 255, 255, 0.9), inset 0 2px 0 rgba(255, 255, 255, 0.7);
    --clay-radius-outer: 24px;
    --clay-radius-card: 20px;
    --clay-radius-button: 14px;
    --clay-radius-badge: 12px;
    --clay-radius-input: 12px;
}

.dark {
    --clay-bg: #13101f;
    --clay-card: rgba(26, 22, 48, 0.85);
    --clay-card-solid: #1a1640;
    --clay-text: #EDE9F6;
    --clay-text-muted: #A8A2B5;
    --clay-primary: #A78BFA;
    --clay-primary-light: #C4B5FD;
    --clay-secondary: #34D399;
    --clay-secondary-light: #6EE7B7;
    --clay-accent: #FBBF24;
    --clay-accent2: #F472B6;
    --clay-border: rgba(167, 139, 250, 0.12);
    --clay-shadow: 8px 8px 16px rgba(0, 0, 0, 0.4), -4px -4px 12px rgba(167, 139, 250, 0.04), inset 0 2px 0 rgba(255, 255, 255, 0.05);
    --clay-shadow-sm: 4px 4px 8px rgba(0, 0, 0, 0.3), -2px -2px 6px rgba(167, 139, 250, 0.03), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    --clay-shadow-hover: 10px 10px 20px rgba(0, 0, 0, 0.5), -6px -6px 16px rgba(167, 139, 250, 0.06), inset 0 2px 0 rgba(255, 255, 255, 0.06);
}

/* ── Clay Utility Classes ── */
.clay-card {
    background: var(--clay-card);
    border: 1px solid var(--clay-border);
    border-radius: var(--clay-radius-card);
    box-shadow: var(--clay-shadow);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.clay-card:hover {
    box-shadow: var(--clay-shadow-hover);
}

.clay-card-sm {
    background: var(--clay-card);
    border: 1px solid var(--clay-border);
    border-radius: var(--clay-radius-badge);
    box-shadow: var(--clay-shadow-sm);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.clay-btn-primary {
    background: linear-gradient(135deg, var(--clay-primary-light), var(--clay-primary));
    color: white;
    border: none;
    border-radius: var(--clay-radius-button);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
.clay-btn-primary:hover {
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.35);
    transform: translateY(-1px);
}
.clay-btn-primary:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

.clay-btn-secondary {
    background: var(--clay-card);
    border: 1.5px solid var(--clay-border);
    border-radius: var(--clay-radius-button);
    font-weight: 600;
    box-shadow: var(--clay-shadow-sm);
    backdrop-filter: blur(4px);
    color: var(--clay-text);
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
.clay-btn-secondary:hover {
    box-shadow: var(--clay-shadow);
    transform: translateY(-1px);
}
.clay-btn-secondary:active {
    transform: scale(0.95);
}

.clay-input {
    border-radius: var(--clay-radius-input);
    border: 1.5px solid var(--clay-border);
    background: var(--clay-card);
    box-shadow: inset 2px 2px 4px rgba(124, 58, 237, 0.04);
    backdrop-filter: blur(4px);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.clay-input:focus {
    border-color: var(--clay-primary);
    box-shadow: inset 2px 2px 4px rgba(124, 58, 237, 0.04), 0 0 0 3px rgba(124, 58, 237, 0.12);
}

/* Python Lab — Custom styles */

/* Smooth scrolling */
html { scroll-behavior: smooth; }

/* Code editor styling */
.cm-editor {
    font-size: 14px;
    border-radius: 0.5rem;
    overflow: hidden;
}
.cm-editor .cm-scroller {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    line-height: 1.6;
}

/* Output panel */
.output-panel {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.output-panel .error {
    color: #f87171;
}

.output-panel .success {
    color: #22c55e;
}

/* Exercise cards */
.exercise-card {
    transition: all 0.2s ease;
}

.exercise-card:hover {
    transform: translateY(-2px);
}

/* PRIMM stage badges */
.primm-badge {
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: var(--clay-radius-badge);
    white-space: nowrap;
    flex-shrink: 0;
    color: white;
}

.primm-predict { background: linear-gradient(135deg, #60A5FA, #3B82F6); }
.primm-run { background: linear-gradient(135deg, #34D399, #10B981); }
.primm-investigate { background: linear-gradient(135deg, #FBBF24, #F59E0B); color: #1e293b; }
.primm-modify { background: linear-gradient(135deg, #A78BFA, #7C3AED); }
.primm-make { background: linear-gradient(135deg, #F472B6, #EC4899); }

/* Completed exercise checkmark */
.exercise-complete {
    position: relative;
}

.exercise-complete::after {
    content: '';
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 1.25rem;
    height: 1.25rem;
    background: #22c55e;
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white' width='14' height='14'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 14px;
}

/* Pulse animation for loading */
@keyframes pulse-dot {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

.loading-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6366f1;
    animation: pulse-dot 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

/* Locked topic card */
.topic-locked {
  opacity: 0.6;
  filter: grayscale(30%);
  pointer-events: none;
  position: relative;
}

.topic-locked::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: inherit;
}

/* Topic unlock animation */
.topic-unlocking {
  animation: topic-unlock 0.6s ease-out forwards;
}

@keyframes topic-unlock {
  0% { opacity: 0.6; filter: grayscale(30%); }
  50% { transform: scale(1.02); }
  100% { opacity: 1; filter: grayscale(0%); transform: scale(1); }
}

/* ── Topic Grid ── */
.topic-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 640px) {
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .topic-grid { grid-template-columns: repeat(3, 1fr); }
}

/* "Up Next" badge on recommended topic */
.topic-up-next {
  border-color: var(--brand-600) !important;
  box-shadow: 0 0 0 1px var(--brand-600), 0 4px 12px rgba(99, 102, 241, 0.15);
}
.up-next-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  background: var(--brand-600);
  color: var(--text-inverse);
}

/* PRIMM type chips */
.primm-chip {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.primm-chip-predict { background: #3b82f6; }
.primm-chip-run { background: #22c55e; }
.primm-chip-investigate { background: #f59e0b; }
.primm-chip-modify { background: #8b5cf6; }
.primm-chip-make { background: #ec4899; }

/* Exercise step indicator */
.step-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.step-dot {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  transition: all 0.2s ease;
}
.step-dot:hover {
  border-color: var(--brand-600);
}
.step-dot.step-current {
  background: var(--brand-600);
  border-color: var(--brand-600);
}
.step-dot.step-complete {
  background: var(--accent-success);
  border-color: var(--accent-success);
}

/* Quick Practice card */
.quick-practice-card {
  background: linear-gradient(135deg, var(--brand-50), var(--surface-raised));
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  transition: all 0.2s ease;
}
.quick-practice-card:hover {
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

/* ── Glossary Panel ── */
.glossary-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0);
  transition: background 0.3s ease;
  pointer-events: none;
}
.glossary-overlay.glossary-open {
  background: rgba(0, 0, 0, 0.3);
  pointer-events: auto;
}
.glossary-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 85vw;
  z-index: 9001;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  padding: 1.5rem;
}
.glossary-open .glossary-panel {
  transform: translateX(0);
}
.glossary-term {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.glossary-term:last-child {
  border-bottom: none;
}
.glossary-term-name {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand-600);
}
.glossary-term-def {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  line-height: 1.5;
}

/* Worked Example in hints */
.worked-example {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.worked-example-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-warning);
  margin-bottom: 0.5rem;
}
.worked-example-code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
}

/* Topic Complete modal */
.topic-complete-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  transition: background 0.4s ease;
}
.topic-complete-overlay.visible {
  background: rgba(0, 0, 0, 0.5);
}
.topic-complete-modal {
  text-align: center;
  background: var(--surface);
  border-radius: 1.5rem;
  padding: 2.5rem 3rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  transform: scale(0.5);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 400px;
  width: 90%;
}
.topic-complete-overlay.visible .topic-complete-modal {
  transform: scale(1);
  opacity: 1;
}

/* Subtle dot-grid background for main views */
.bg-dotgrid {
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Reduced motion — Accessibility */
@media (prefers-reduced-motion: reduce) {
  .loading-dot,
  .topic-unlocking {
    animation: none !important;
  }
  .exercise-card,
  .topic-unlocking {
    transition-duration: 0.01s !important;
  }
}

/* ── Parsons Problems ── */
.parsons-list { display: flex; flex-direction: column; gap: 0.5rem; }
.parsons-block {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.625rem 1rem; border-radius: 0.5rem;
    background: #f1f5f9; border: 2px solid #e2e8f0;
    cursor: grab; font-family: 'JetBrains Mono', monospace; font-size: 14px;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
    user-select: none;
}
.dark .parsons-block { background: #1e293b; border-color: #334155; color: #e2e8f0; }
.parsons-block:hover { border-color: #818cf8; }
.parsons-block.dragging { opacity: 0.5; transform: scale(0.98); }
.parsons-handle { color: #94a3b8; font-size: 16px; cursor: grab; }
.parsons-correct { border-color: #22c55e !important; background: #f0fdf4 !important; }
.parsons-incorrect { border-color: #ef4444 !important; background: #fef2f2 !important; }
.dark .parsons-correct { background: #052e16 !important; }
.dark .parsons-incorrect { background: #450a0a !important; }

/* ── Quick-Fire ── */
.qf-timer-wrap {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 1rem;
}
.qf-timer-bar {
    flex: 1; height: 8px; border-radius: 4px;
    background: #6366f1; transition: width 1s linear;
}
.qf-timer-danger { background: #ef4444 !important; }
.qf-timer-text { font-weight: 700; font-size: 0.875rem; min-width: 2.5rem; }
.qf-score { font-weight: 600; margin-bottom: 1rem; font-size: 1rem; }
.qf-question-area { min-height: 200px; }
.qf-question-num { font-size: 0.75rem; color: #64748b; margin-bottom: 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; }
.qf-question-text { font-size: 1.125rem; font-weight: 600; margin-bottom: 1.25rem; line-height: 1.5; }
.qf-options { display: flex; flex-direction: column; gap: 0.5rem; }
.qf-option {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem; border-radius: 0.5rem;
    background: #f8fafc; border: 2px solid #e2e8f0;
    cursor: pointer; font-size: 0.95rem; text-align: left;
    transition: border-color 0.2s, background 0.2s;
}
.dark .qf-option { background: #1e293b; border-color: #334155; color: #e2e8f0; }
.qf-option:hover:not(:disabled) { border-color: #818cf8; background: #eef2ff; }
.dark .qf-option:hover:not(:disabled) { background: #1e1b4b; }
.qf-option-label { font-weight: 700; color: #6366f1; min-width: 1.5rem; }
.qf-option:disabled { cursor: default; opacity: 0.7; }
.qf-correct { border-color: #22c55e !important; background: #f0fdf4 !important; }
.qf-wrong { border-color: #ef4444 !important; background: #fef2f2 !important; }
.dark .qf-correct { background: #052e16 !important; }
.dark .qf-wrong { background: #450a0a !important; }
.qf-result { text-align: center; padding: 2rem; }
.qf-result-score { font-size: 3rem; font-weight: 800; color: #6366f1; }
.qf-result-pct { font-size: 1.25rem; color: #64748b; margin: 0.5rem 0; }
.qf-result-msg { font-size: 1.5rem; font-weight: 700; margin-top: 0.5rem; }

/* ── Emoji + Glow Topic Card Images ── */
.topic-card-image {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.1), rgba(124, 58, 237, 0.05));
    overflow: hidden;
}

.emoji-icon {
    font-size: 56px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 2;
}

.icon-glow {
    position: absolute;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    filter: blur(30px);
    opacity: 0.25;
}

/* ── Gold Accent Headings ── */
.gold-heading {
    color: #fbbf24;
}

/* ── Polish Utilities ── */

/* Radial glow behind hero elements */
.hero-glow {
    position: relative;
}
.hero-glow::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 300px;
    background: radial-gradient(ellipse at center, rgba(124, 58, 237, 0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

/* Subtle glow behind form cards */
.form-glow {
    position: relative;
}
.form-glow::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 250px;
    background: radial-gradient(ellipse at center, rgba(124, 58, 237, 0.1) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

/* Header shadow (replaces border) */
.header-shadow {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Smooth card hover lift */
.hover-lift {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}
.hover-lift:hover {
    transform: translateY(-4px);
}

/* CTA button hover */
.cta-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.cta-hover:hover {
    transform: scale(1.02);
}

/* ── Motion One — initial hidden states ── */
.motion-fade {
    opacity: 0;
    transform: translateY(20px);
}
.motion-scale {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
}
.motion-slide-left {
    opacity: 0;
    transform: translateX(-20px);
}
@media (prefers-reduced-motion: reduce) {
    .motion-fade,
    .motion-scale,
    .motion-slide-left {
        opacity: 1;
        transform: none;
    }
}

/* ══════════════════════════════════════════════════
   SNEK MASCOT & VISUAL ENGAGEMENT
   ══════════════════════════════════════════════════ */

/* ── Snek Mascot Container ── */
#snek-mascot {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 80px;
    height: 80px;
    z-index: 40;
    opacity: 0.6;
    transition: opacity 0.3s, transform 0.3s;
    cursor: default;
    pointer-events: none;
}
#snek-mascot:hover,
#snek-mascot.snek-reacting {
    opacity: 1;
}

/* Snek expression groups — hide all, show active */
#snek-mascot .snek-expr { display: none; }
#snek-mascot.snek-neutral .expr-neutral,
#snek-mascot.snek-happy .expr-happy,
#snek-mascot.snek-thinking .expr-thinking,
#snek-mascot.snek-sleeping .expr-sleeping,
#snek-mascot.snek-celebrating .expr-celebrating,
#snek-mascot.snek-surprised .expr-surprised { display: block; }

/* Snek idle sway */
@keyframes snekSway {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}
#snek-mascot svg {
    animation: snekSway 3s ease-in-out infinite;
}

/* Snek tongue flick */
@keyframes snekTongue {
    0%, 90%, 100% { opacity: 0; transform: scaleX(0.3); }
    93%, 97% { opacity: 1; transform: scaleX(1); }
}
#snek-mascot .snek-tongue {
    animation: snekTongue 5s ease-in-out infinite;
    transform-origin: left center;
}

/* Sleeping zzz */
@keyframes snekZzz {
    0%, 100% { opacity: 0; transform: translateY(0) scale(0.8); }
    50% { opacity: 1; transform: translateY(-10px) scale(1); }
}
#snek-mascot.snek-sleeping .snek-zzz {
    animation: snekZzz 2s ease-in-out infinite;
}

/* Celebrating bounce */
@keyframes snekBounce {
    0%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
    60% { transform: translateY(-4px); }
}
#snek-mascot.snek-celebrating svg {
    animation: snekBounce 0.6s ease-in-out 3;
}
#snek-mascot.snek-happy svg {
    animation: snekBounce 0.5s ease-in-out 2;
}

/* ── Large Snek (Home Page) ── */
#snek-home {
    width: 160px;
    height: 160px;
    display: inline-block;
    vertical-align: middle;
}
#snek-home svg {
    animation: snekSway 3s ease-in-out infinite;
}
#snek-home .snek-tongue {
    animation: snekTongue 5s ease-in-out infinite;
    transform-origin: left center;
}

/* ── Typing Effect ── */
.snek-typing::after {
    content: "▎";
    animation: cursorBlink 0.6s steps(1) infinite;
    color: #6366f1;
    font-weight: 700;
}
@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ── Snek Speech Bubble ── */
.snek-speech {
    font-size: 0.8rem;
    font-weight: 500;
    color: #475569;
    text-align: center;
    max-width: 180px;
    position: fixed;
    bottom: 7rem;
    right: 1rem;
    z-index: 41;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: auto;
    cursor: pointer;
}
.dark .snek-speech {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}
.snek-speech.visible {
    opacity: 1;
    transform: translateY(0);
}
.snek-speech::after {
    content: "";
    position: absolute;
    bottom: -6px;
    right: 30px;
    width: 12px;
    height: 12px;
    background: inherit;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    transform: rotate(45deg);
}
.dark .snek-speech::after {
    border-color: #334155;
}

/* ── Page Transitions ── */
main {
    animation: pageIn 0.2s ease-out;
}
@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Enhanced Hover Effects ── */

/* Topic cards — enhanced lift and glow */
.topic-grid > div {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.25s ease;
}
.topic-grid > div:hover {
    transform: translateY(-6px) scale(1.01);
    box-shadow: var(--clay-shadow-hover);
}

/* Exercise links — slide right on hover */
.topic-grid a[href*="exercise.html"] {
    transition: transform 0.2s, background-color 0.2s;
}
.topic-grid a[href*="exercise.html"]:hover {
    transform: translateX(4px);
}

/* Buttons — press effect */
button, .btn, [role="button"] {
    transition: transform 0.1s;
}
button:active, .btn:active, [role="button"]:active {
    transform: scale(0.95);
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Floating Code Symbols ── */
.floating-symbols {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}
.floating-symbol {
    position: absolute;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    color: #6366f1;
    opacity: 0.04;
    animation: symbolDrift linear infinite;
    user-select: none;
}
.dark .floating-symbol {
    color: #818cf8;
    opacity: 0.03;
}
@keyframes symbolDrift {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(30px, -40px) rotate(5deg); }
    50% { transform: translate(-20px, -80px) rotate(-3deg); }
    75% { transform: translate(40px, -40px) rotate(4deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* ── Loading Screen with Snek ── */
#snek-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
}
#snek-loading svg {
    width: 64px;
    height: 64px;
    animation: snekSway 2s ease-in-out infinite;
}
#snek-loading-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
}
.dark #snek-loading-text {
    color: #94a3b8;
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    main { animation: none; }
    #snek-mascot svg,
    #snek-home svg { animation: none; }
    #snek-mascot .snek-tongue { animation: none; opacity: 0; }
    #snek-home .snek-tongue { animation: none; opacity: 0; }
    #snek-mascot.snek-sleeping .snek-zzz { animation: none; }
    #snek-mascot.snek-celebrating svg { animation: none; }
    #snek-mascot.snek-happy svg { animation: none; }
    .snek-typing::after { animation: none; }
    .floating-symbol { animation: none; }
    #snek-loading svg { animation: none; }
    .topic-grid > div:hover { transform: none; }
    .topic-grid a[href*="exercise.html"]:hover { transform: none; }
    button:active, .btn:active { transform: none; }
}
