/* ═══════════════════════════════════════════════════════════
   NEURA SYNC — Cosmic Consciousness Design System v3
   Deep · Immersive · Luminous
═══════════════════════════════════════════════════════════ */

:root {
  --brand:        #00D4FF;
  --brand-dark:   #0094C6;
  --brand-glow:   rgba(0,212,255,0.15);
  --brand-subtle: rgba(0,212,255,0.04);
  --accent:       #7C3AED;
  --accent-deep:  #6D28D9;
  --bg-deep:      #030712;
  --bg-card:      rgba(12,23,48,0.6);
  --bg-card-solid:#0C1730;
  --bg-nav:       rgba(7,16,34,0.85);
  --bg-topbar:    rgba(6,15,32,0.65);
  --border:       rgba(0,200,255,0.12);
  --border-solid: #0e2340;
  --text:         #E8F4FF;
  --text-muted:   #8FAFC8;
  --text-xmuted:  #6A8BA8;
  --shadow:       0 2px 16px rgba(0,0,0,0.3);
  --radius:       14px;
  --ease:         cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: 'Urbanist', 'Inter', system-ui, sans-serif;
  --font-body:    'Figtree', 'Inter', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text);
  overflow: hidden;
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── COSMIC BACKGROUND MESH ──────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(0,212,255,0.07) 0%, transparent 55%),
    radial-gradient(ellipse 50% 50% at 90% 10%, rgba(124,58,237,0.05) 0%, transparent 50%),
    radial-gradient(ellipse 70% 40% at 50% 95%, rgba(0,212,255,0.04) 0%, transparent 40%);
  pointer-events: none; z-index: 0;
  animation: subtlePulse 20s ease-in-out infinite alternate;
}

@keyframes subtlePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── SELECTION ────────────────────────────────────────────── */
::selection { background: rgba(0,212,255,0.25); color: #E8F4FF; }

/* ── PAGE LOAD ANIMATION ────────────────────────────────── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── GLOBAL HEADING FONT ────────────────────────────────── */
h1, h2, h3, h4,
.page-title, .course-title, .lesson-title-main,
.section-title, .hero-title, .section-name,
.profile-name, .card-title, .lb-name,
.ns-card-title, .section-card-title,
.outline-title, .rating-label, .comments-title { font-family: var(--font-display); }

/* ── TOPBAR ──────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 60px;
  background: var(--bg-topbar);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}

.topbar::after {
  content: '';
  position: absolute; bottom: -1px; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent 5%, var(--brand) 50%, transparent 95%);
  opacity: 0.3;
}

.topbar-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }

.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #0094C6, #00C8FF);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px var(--brand-glow), inset 0 1px 0 rgba(255,255,255,0.2);
  flex-shrink: 0;
  animation: logoPulse 4s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 2px 12px var(--brand-glow); }
  50% { box-shadow: 0 4px 20px rgba(0,212,255,0.25); }
}

.logo-icon svg { width: 20px; height: 20px; fill: none; stroke: white; stroke-width: 1.8; }

.logo-text {
  font-family: var(--font-display);
  font-size: 1.2rem; font-weight: 800; letter-spacing: 0.6px;
  background: linear-gradient(135deg, #00D4FF 0%, #00B8E6 40%, #7C3AED 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  animation: textShimmer 5s ease infinite;
}

@keyframes textShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.topbar-search { flex: 1; max-width: 320px; margin: 0 24px; position: relative; }

.topbar-search input {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-solid);
  border-radius: 10px;
  color: var(--text); font-size: 0.82rem; font-family: var(--font-body);
  padding: 8px 36px 8px 14px; outline: none;
  transition: all .3s var(--ease);
}

.topbar-search input:focus {
  border-color: var(--brand);
  background: rgba(255,255,255,0.06);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.08);
}

.topbar-search input::placeholder { color: var(--text-xmuted); }
.topbar-search svg { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; stroke: var(--text-muted); fill: none; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.topbar-btn {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-solid); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; text-decoration: none; color: var(--text-muted);
  transition: all .3s var(--ease);
}

.topbar-btn:hover {
  border-color: var(--brand); color: var(--brand);
  background: rgba(0,212,255,0.06);
  box-shadow: 0 2px 10px rgba(0,212,255,0.12);
}

.topbar-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--brand);
  background: linear-gradient(135deg, #0094C6, #00C8FF);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 0.75rem; font-weight: 700; color: white; cursor: pointer;
  box-shadow: 0 0 14px var(--brand-glow);
  transition: all .3s var(--ease);
}

.avatar:hover { transform: scale(1.1); box-shadow: 0 0 20px var(--brand-glow); }

/* ── LAYOUT ─────────────────────────────────────────────── */
.layout { display: flex; height: 100vh; padding-top: 60px; position: relative; z-index: 1; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: 210px; flex-shrink: 0;
  background: var(--bg-nav);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  padding: 16px 8px;
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
  animation: fadeSlideUp 0.4s var(--ease);
}

.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; text-decoration: none; color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.845rem; font-weight: 500;
  transition: all .25s var(--ease);
}

.nav-link:hover {
  background: rgba(0,212,255,0.06); color: var(--text);
  transform: translateX(3px);
}

.nav-link.active {
  background: linear-gradient(90deg, rgba(0,212,255,0.1) 0%, rgba(0,212,255,0.02) 100%);
  color: var(--brand);
  box-shadow: inset 3px 0 0 var(--brand);
}

.nav-link svg { width: 17px; height: 17px; stroke: currentColor; fill: none; flex-shrink: 0; transition: filter .3s; }
.nav-link.active svg { filter: drop-shadow(0 0 4px rgba(0,212,255,0.4)); }

/* ── MAIN ─────────────────────────────────────────────────── */
.main {
  flex: 1; overflow-y: auto; padding: 28px 36px;
  animation: fadeSlideUp 0.5s var(--ease);
}

/* ── CARDS ───────────────────────────────────────────────── */
.ns-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: all .3s var(--ease);
}

.ns-card:hover { border-color: rgba(0,212,255,0.25); }

.ns-card-header { padding: 20px 24px 14px; border-bottom: 1px solid var(--border); }
.ns-card-body { padding: 20px 24px; }
.ns-card-title { font-size: 0.95rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.ns-card-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ── BADGE / XP ──────────────────────────────────────────── */
.xp-badge {
  background: linear-gradient(135deg, rgba(0,212,255,0.12), rgba(0,212,255,0.06));
  border: 1px solid rgba(0,212,255,0.2); border-radius: 20px;
  padding: 3px 10px; font-size: 0.78rem; font-weight: 700; color: var(--brand);
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--font-display);
}

/* ── ICON BOXES ──────────────────────────────────────────── */
.icon-box {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: transform .2s var(--ease);
}
.icon-box svg { width: 17px; height: 17px; stroke: currentColor; fill: none; }
.icon-box.cyan   { background: rgba(0,212,255,0.08);  color: var(--brand); }
.icon-box.violet { background: rgba(124,58,237,0.08); color: #7C3AED; }
.icon-box.sky    { background: rgba(14,165,233,0.08);  color: #0EA5E9; }
.icon-box.green  { background: rgba(16,185,129,0.08);  color: #059669; }
.icon-box.indigo { background: rgba(99,102,241,0.08);  color: #6366F1; }

/* ── FORM STYLES ────────────────────────────────────────── */
.form-label { display: block; font-size: 0.82rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }

.form-input, .form-select, .form-textarea {
  width: 100%; background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-solid);
  border-radius: 10px; color: var(--text); font-size: 0.85rem; font-family: var(--font-body);
  padding: 9px 13px; outline: none;
  transition: all .3s var(--ease);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.08);
  background: rgba(255,255,255,0.06);
}

.form-input::placeholder, .form-textarea::placeholder { color: var(--text-xmuted); }
.form-select { appearance: none; cursor: pointer; }
.form-select option { background: #0C1730; color: var(--text); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-group { display: flex; flex-direction: column; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 9px 18px; border-radius: 10px;
  font-size: 0.85rem; font-weight: 600; border: none; cursor: pointer;
  text-decoration: none; font-family: var(--font-display);
  transition: all .3s var(--ease);
}

.btn-primary {
  background: linear-gradient(135deg, #0094C6, #00C8FF);
  color: #030712;
  box-shadow: 0 2px 10px rgba(0,212,255,0.2);
}

.btn-primary:hover {
  box-shadow: 0 4px 22px rgba(0,212,255,0.35);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
}

.btn-ghost:hover {
  border-color: rgba(255,255,255,0.25); color: var(--text);
  background: rgba(0,212,255,0.04);
}

/* ── DIVIDER ─────────────────────────────────────────────── */
hr.ns { border: none; border-top: 1px solid var(--border-solid); margin: 24px 0; }

/* ── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-solid);
  margin-bottom: 28px;
}

.page-super {
  font-family: var(--font-display);
  font-size: 0.75rem; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--brand); margin-bottom: 4px;
  opacity: 0.8;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.5rem; font-weight: 700; letter-spacing: -0.4px;
}

/* ── SCROLLBAR ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--brand-dark), var(--brand));
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: var(--brand); }

/* ── XP TOAST ────────────────────────────────────────────── */
.xp-toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  background: rgba(12,23,48,0.95);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 12px; padding: 12px 18px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; gap: 10px;
  min-width: 200px;
  transform: translateY(20px); opacity: 0;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
  pointer-events: none;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.xp-toast.visible { transform: translateY(0); opacity: 1; pointer-events: auto; }
.xp-toast-icon { flex-shrink: 0; }
.xp-toast-icon svg { width: 16px; height: 16px; stroke: var(--brand); fill: none; }
.xp-toast-text { display: flex; flex-direction: column; gap: 2px; }
.xp-toast-points { font-size: 0.88rem; font-weight: 700; color: var(--brand); }
.xp-toast-reason { font-size: 0.78rem; color: var(--text-muted); }

/* ── TOPBAR XP BADGE ─────────────────────────────────────── */
.topbar-xp {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(0,212,255,0.06);
  border: 1px solid rgba(0,212,255,0.15);
  border-radius: 20px;
  padding: 4px 12px 4px 8px;
  font-size: 0.75rem; font-weight: 700;
  color: var(--brand);
  cursor: default;
  transition: transform 0.2s var(--ease);
}
.topbar-xp svg { width: 13px; height: 13px; stroke: var(--brand); fill: none; }
@keyframes xpBump {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.topbar-xp.bumping { animation: xpBump 0.4s var(--ease); }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Body text >= 14px: Phase 17 sets html { font-size: 18px } globally, satisfying this requirement */

  /* ── Overflow and scroll failsafe ── */
  html, body { overflow-x: hidden; max-width: 100vw; overflow-y: auto; }
  body { touch-action: manipulation; }

  /* ── Sidebar → Fixed bottom tab bar ── */
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; height: 64px;
    flex-direction: row; justify-content: space-around; align-items: center;
    padding: 4px 0 env(safe-area-inset-bottom, 0);
    border-right: none; border-top: 1px solid var(--border);
    background: rgba(7,16,34,0.92);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    z-index: 200; gap: 0; overflow: visible;
    display: flex;
  }
  .nav-link {
    flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 6px 4px; font-size: 0.6rem;
    min-width: 44px; min-height: 44px;
    border-radius: 8px; transform: none;
  }
  .nav-link:hover { transform: none; }
  .nav-link.active { box-shadow: none; background: rgba(0,212,255,0.1); }
  .nav-link svg { width: 22px; height: 22px; }

  /* ── Topbar mobile ── */
  .topbar { padding: 0 12px; height: 52px; }
  .topbar-search { display: none; }
  .logo-text { font-size: 1rem; }
  .logo-icon { width: 32px; height: 32px; border-radius: 8px; }
  .logo-icon svg { width: 16px; height: 16px; }

  /* ── XP badge — hidden on mobile ── */
  .topbar-xp { display: none; }

  /* ── Main content safe area (64px bottom bar + 18px breathing room) ── */
  .main { padding: 12px 14px 82px 14px; overflow-y: auto; }
  .layout { overflow: visible; }

  /* ── Touch targets ── */
  .topbar-btn { min-width: 44px; min-height: 44px; }
  .avatar { min-width: 44px; min-height: 44px; }

  /* ── Cards and typography ── */
  .ns-card-header { padding: 14px 16px 10px; }
  .ns-card-body { padding: 14px 16px; }

  /* ── XP toast — positioned above bottom bar ── */
  .xp-toast { right: auto; left: 50%; transform: translateX(-50%) translateY(20px); bottom: 80px; }
  .xp-toast.visible { transform: translateX(-50%) translateY(0); }

  /* ── Table overflow failsafe ── */
  table { display: block; overflow-x: auto; max-width: 100%; }
}

/* ── AUDIO PRACTICE PLAYER ─────────────────────────────── */
.audio-practice-player {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.audio-practice-heading {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--brand);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.audio-practice-element {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  outline: none;
}

/* Webkit (Chrome, Safari, Edge) audio controls styling */
.audio-practice-element::-webkit-media-controls-panel {
  background: var(--bg-deep);
  border-radius: 8px;
}

.audio-practice-element::-webkit-media-controls-current-time-display,
.audio-practice-element::-webkit-media-controls-time-remaining-display {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .audio-practice-player {
    padding: 12px;
    margin-bottom: 16px;
    border-radius: 10px;
  }

  .audio-practice-heading {
    font-size: 0.85rem;
    margin-bottom: 8px;
  }

  .audio-practice-element {
    height: 40px;
  }
}

/* ── UTILITY KEYFRAMES ───────────────────────────────────── */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(0,212,255,0.12); }
  50% { box-shadow: 0 4px 16px rgba(0,212,255,0.25); }
}

@keyframes borderGlow {
  0%, 100% { border-color: rgba(0,212,255,0.1); }
  50% { border-color: rgba(0,212,255,0.25); }
}

@media (prefers-reduced-motion: reduce) {
  .xp-toast { transition: none; }
  .topbar-xp.bumping { animation: none; }
}
