/* ══════════════════════════════════════════════════════════════════════
   LAMBU THEME SYSTEM — SHARED STYLES
   Universal Light & Dark Mode Tokens and Switch Component
   ══════════════════════════════════════════════════════════════════════ */

:root {
  /* Core Semantic Theme Tokens (Dark Mode Default) */
  --theme-bg: #141313;
  --theme-surface: #1c1b1b;
  --theme-surface-subtle: #232326;
  --theme-border: rgba(255, 255, 255, 0.12);
  --theme-text-primary: #ffffff;
  --theme-text-secondary: #a0a0ab;
  --theme-input-bg: #1c1b1b;
  --theme-input-border: rgba(255, 255, 255, 0.15);
  --theme-input-text: #ffffff;
  --theme-input-placeholder: #7a7a85;
  --theme-back-icon: #ffffff;
  --theme-back-icon-hover: #ffffff;

  /* Theme Switch Tokens (Morph Button) */
  --theme-btn-bg: rgba(255, 255, 255, 0.07);
  --theme-btn-hover-bg: rgba(255, 255, 255, 0.12);
  --theme-btn-border: rgba(255, 255, 255, 0.14);
  --theme-btn-icon: #ffffff;
  color-scheme: dark;
}

[data-theme="light"] {
  /* Core Semantic Theme Tokens (Light Mode) */
  --theme-bg: #f4f5f8;
  --theme-surface: #ffffff;
  --theme-surface-subtle: #eaedf2;
  --theme-border: rgba(0, 0, 0, 0.12);
  --theme-text-primary: #111215;
  --theme-text-secondary: #5e606a;
  --theme-input-bg: #ffffff;
  --theme-input-border: rgba(0, 0, 0, 0.12);
  --theme-input-text: #111215;
  --theme-input-placeholder: #8e909c;
  --theme-back-icon: #5e606a;
  --theme-back-icon-hover: #111215;

  /* Theme Switch Tokens (Morph Button) */
  --theme-btn-bg: rgba(0, 0, 0, 0.04);
  --theme-btn-hover-bg: rgba(0, 0, 0, 0.08);
  --theme-btn-border: rgba(0, 0, 0, 0.12);
  --theme-btn-icon: #ff9500;
  color-scheme: light;
}

/* Universal Back Button Theme Styling */
.back-icon {
  fill: var(--theme-back-icon);
  transition: fill 0.2s ease, transform 0.1s ease-in;
}

.back-icon:hover {
  fill: var(--theme-back-icon-hover);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Tap-and-Morph Theme Toggle Component (No Slide, Buttery Micro-Interaction)
   ───────────────────────────────────────────────────────────────────────────── */
.theme-switch-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--theme-btn-bg);
  border: 1px solid var(--theme-btn-border);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  cursor: pointer;
  outline: none;
  color: var(--theme-btn-icon);
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.12s cubic-bezier(0, 0, 0.2, 1), box-shadow 0.25s ease;
  flex-shrink: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.theme-switch-btn:hover {
  background-color: var(--theme-btn-hover-bg);
}

.theme-switch-btn:active {
  transform: scale(0.92);
}

/* Compact Variation for Headers & Tight Toolbars */
.theme-switch-btn.compact {
  width: 36px;
  height: 36px;
}

/* Morphing SVG Icon */
.theme-morph-svg {
  width: 21px;
  height: 21px;
  overflow: visible;
  display: block;
  pointer-events: none;
  transform-origin: center center;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-switch-btn.compact .theme-morph-svg {
  width: 19px;
  height: 19px;
}

.theme-morph-svg .sun-core {
  transform-origin: center center;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-morph-svg .sun-beams {
  transform-origin: center center;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
}

.theme-morph-svg mask circle {
  transform-origin: center center;
  transition: transform 0.45s cubic-bezier(0.25, 1, 0.5, 1);
}

/* ── Dark Mode State: Crescent Moon (Tilted 40deg, rays collapse, core expands) ── */
[data-theme="dark"] .theme-morph-svg {
  transform: rotate(40deg);
}

[data-theme="dark"] .theme-morph-svg .sun-core {
  transform: scale(1.75);
}

[data-theme="dark"] .theme-morph-svg .sun-beams {
  transform: rotate(-35deg) scale(0.2);
  opacity: 0;
}

[data-theme="dark"] .theme-morph-svg mask circle {
  transform: translateX(-7px);
}

@supports (cx: 1px) {
  .theme-morph-svg mask circle {
    transition: transform 0.45s cubic-bezier(0.25, 1, 0.5, 1), cx 0.45s cubic-bezier(0.25, 1, 0.5, 1);
  }
  [data-theme="dark"] .theme-morph-svg mask circle {
    transform: translateX(0);
    cx: 17px;
  }
}

/* ── Light Mode State: Radiant Sun (Upright 0deg, rays expand, core contracts) ── */
[data-theme="light"] .theme-morph-svg {
  transform: rotate(0deg);
}

[data-theme="light"] .theme-morph-svg .sun-core {
  transform: scale(1);
}

[data-theme="light"] .theme-morph-svg .sun-beams {
  transform: rotate(0deg) scale(1);
  opacity: 1;
}

[data-theme="light"] .theme-morph-svg mask circle {
  transform: translateX(0);
}

@supports (cx: 1px) {
  [data-theme="light"] .theme-morph-svg mask circle {
    cx: 24px;
  }
}

/* Backward compatibility safeguard: suppress legacy knob / separate icons if rendered */
.theme-switch-knob,
.theme-switch-btn .theme-icon {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .theme-switch-btn,
  .theme-morph-svg,
  .theme-morph-svg .sun-core,
  .theme-morph-svg .sun-beams,
  .theme-morph-svg mask circle {
    transition-duration: 0.01ms !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   SEAMLESS NATIVE-LIKE PAGE TRANSITIONS & INSTANT TACTILE TOUCH
   ══════════════════════════════════════════════════════════════════════ */

/* Native Cross-Document View Transitions (Fast, seamless, GPU-accelerated) */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: 150ms cubic-bezier(0.4, 0, 1, 1) both lambu-vt-fade-out;
}
::view-transition-new(root) {
  animation: 190ms cubic-bezier(0, 0, 0.2, 1) both lambu-vt-fade-in;
}

@keyframes lambu-vt-fade-out {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.994); }
}

@keyframes lambu-vt-fade-in {
  from { opacity: 0; transform: scale(1.006); }
  to { opacity: 1; transform: scale(1); }
}

/* 0ms Tactile Press (Instant confirmation on mobile touch) */
.quiz-card,
.box,
.back-btn-wrapper a,
.nav-item {
  -webkit-tap-highlight-color: transparent !important;
  touch-action: manipulation;
}

.quiz-card:active,
.quiz-card.is-pressed,
.box:active,
.box.is-pressed {
  transform: scale(0.974) !important;
  filter: brightness(0.94);
  transition: transform 0.05s cubic-bezier(0, 0, 0.2, 1), filter 0.05s ease !important;
}

/* Slim top progress indicator for slow network connections */
#lambu-nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2.5px;
  width: 0;
  background: linear-gradient(90deg, #8b5cf6, #ec4899, #38bdf8);
  z-index: 999999;
  opacity: 0;
  pointer-events: none;
  transition: width 0.3s cubic-bezier(0.1, 0.8, 0.3, 1), opacity 0.15s ease;
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.7);
}
#lambu-nav-progress.active {
  opacity: 1;
}
