/* WBF Academy — Custom CSS */

/* Alpine: hide x-cloak elements until Alpine initializes (prevents the
   hidden-shelf flash on my-courses.php and modal flashes elsewhere). */
[x-cloak] { display: none !important; }

/* ─── Custom properties ─────────────────────────────────────── */
:root {
  --color-bg:         #020617;
  --color-surface:    #0f172a;
  --color-surface-2:  #1e293b;
  --color-border:     #1e293b;
  --color-accent:     #7c3aed;
  --color-accent-lg:  #8b5cf6;
  --color-text:       #e2e8f0;
  --color-muted:      #64748b;
  --color-success:    #10b981;
  --color-warning:    #f59e0b;
  --color-danger:     #ef4444;
  --sidebar-w:        240px;
  --radius:           0.75rem;
  --transition:       150ms ease;
}

/* ─── Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--color-bg); color: var(--color-text); }

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb { background: var(--color-surface-2); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #334155; }

/* ─── Sidebar links ─────────────────────────────────────────── */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #94a3b8;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.sidebar-link:hover {
  background: rgba(139, 92, 246, 0.1);
  color: #a78bfa;
}
.sidebar-active {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}
.sidebar-danger { color: #f87171; }
.sidebar-danger:hover { background: rgba(239, 68, 68, 0.1); color: #fca5a5; }

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 500;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition), transform 60ms;
  text-decoration: none;
  border: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--color-accent); color: #fff; padding: 0.5rem 1rem; }
.btn-primary:hover { background: var(--color-accent-lg); }
.btn-secondary { background: var(--color-surface-2); color: #cbd5e1; padding: 0.5rem 1rem; }
.btn-secondary:hover { background: #334155; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn:disabled, .btn[data-loading="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ─── Inputs ────────────────────────────────────────────────── */
.input {
  background: var(--color-surface-2);
  border: 1px solid #334155;
  color: #f1f5f9;
  border-radius: 0.5rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input::placeholder { color: #475569; }
.input:focus {
  border-color: var(--color-accent-lg);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3);
}
.input-error { border-color: var(--color-danger) !important; }
.field-error { font-size: 0.75rem; color: #f87171; margin-top: 0.25rem; }

/* ─── Labels ────────────────────────────────────────────────── */
label { font-size: 0.875rem; font-weight: 500; color: #cbd5e1; }

/* ─── Code / syntax highlighting ────────────────────────────── */
pre, code {
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
}
pre {
  background: #0d1117;
  border: 1px solid #1e293b;
  border-radius: 0.625rem;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  color: #c9d1d9;
}
.code-kw  { color: #ff7b72; }   /* keyword */
.code-fn  { color: #d2a8ff; }   /* function/type */
.code-str { color: #a5d6ff; }   /* string */
.code-cm  { color: #8b949e; }   /* comment */
.code-num { color: #f0883e; }   /* number */
.code-op  { color: #79c0ff; }   /* operator/punct */
.code-var { color: #ffa657; }   /* variable */

/* ─── Quiz options ──────────────────────────────────────────── */
.quiz-option {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  border-radius: 0.625rem;
  border: 1px solid #1e293b;
  background: #0f172a;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  font-size: 0.9375rem;
  color: #e2e8f0;
}
.quiz-option:hover { border-color: #7c3aed; background: rgba(124, 58, 237, 0.07); }
.quiz-option.selected { border-color: #7c3aed; background: rgba(124, 58, 237, 0.15); }
.quiz-option.correct  { border-color: #10b981; background: rgba(16, 185, 129, 0.1); }
.quiz-option.incorrect { border-color: #ef4444; background: rgba(239, 68, 68, 0.1); }

/* ─── Progress bar ──────────────────────────────────────────── */
.progress-bar { height: 6px; border-radius: 999px; background: #1e293b; overflow: hidden; }
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7c3aed, #6366f1);
  transition: width 0.4s ease;
  animation: progress-glow 2s ease-in-out infinite alternate;
}

/* Course hero: left→right fade that follows the active theme's page bg
   (dark #020617, light #f8fafc) so text stays legible in both modes. */
.hero-fade {
  background: linear-gradient(
    to right,
    var(--color-bg) 0%,
    color-mix(in srgb, var(--color-bg) 80%, transparent) 50%,
    transparent 85%
  );
}
@keyframes progress-glow {
  from { box-shadow: none; }
  to   { box-shadow: 0 0 8px rgba(139, 92, 246, 0.6); }
}

/* ─── Skeleton loading ──────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #2d3f55 50%, #1e293b 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 0.375rem;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Streak flame animation ────────────────────────────────── */
.flame {
  display: inline-block;
  animation: flame-flicker 0.8s ease-in-out infinite alternate;
  transform-origin: bottom center;
}
@keyframes flame-flicker {
  0%   { transform: scaleY(1) rotate(-2deg); filter: brightness(1); }
  50%  { transform: scaleY(1.08) rotate(0deg); filter: brightness(1.15); }
  100% { transform: scaleY(0.95) rotate(2deg); filter: brightness(0.9); }
}

/* ─── Toast notifications ───────────────────────────────────── */
.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.625rem;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  pointer-events: auto;
  animation: toast-in 0.25s ease forwards;
  max-width: 20rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(1rem); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-out { animation: toast-out 0.2s ease forwards; }
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(1rem); }
}
.toast-success { background: #052e16; border-color: rgba(16,185,129,0.3); color: #6ee7b7; }
.toast-error   { background: #2d0a0a; border-color: rgba(239,68,68,0.3);  color: #fca5a5; }
.toast-warning { background: #1c1000; border-color: rgba(245,158,11,0.3); color: #fde68a; }
.toast-info    { background: #0a192f; border-color: rgba(99,102,241,0.3); color: #a5b4fc; }

/* ─── Badge pill ────────────────────────────────────────────── */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  text-transform: uppercase;
}

/* ─── Gradient text ─────────────────────────────────────────── */
.text-gradient {
  background: linear-gradient(135deg, #a78bfa 0%, #818cf8 50%, #67e8f9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Glassmorphism ─────────────────────────────────────────── */
.glass {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

/* ─── Gradient border card ──────────────────────────────────── */
.card-glow {
  position: relative;
}
.card-glow::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--radius) + 1px);
  background: linear-gradient(135deg, rgba(124,58,237,0.4), rgba(99,102,241,0.2), transparent 60%);
  z-index: -1;
}

/* ─── Hero background animation ─────────────────────────────── */
.hero-grid {
  background-image:
    linear-gradient(rgba(124, 58, 237, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 58, 237, 0.06) 1px, transparent 1px);
  background-size: 60px 60px;
}
.hero-glow {
  background: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(124, 58, 237, 0.25), transparent);
}

/* ─── Floating animation ─────────────────────────────────────── */
.float {
  animation: float 4s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

/* ─── Fade-in on scroll (CSS only fallback) ──────────────────── */
.fade-up {
  animation: fade-up 0.6s ease both;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }

/* ─── Pulse dot ─────────────────────────────────────────────── */
.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  animation: pulse-dot 2s ease infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(1.4); }
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 767px) {
  .input { font-size: 1rem; }   /* prevent iOS zoom */
}

/* Instant feedback while the language switch reloads the page. */
.lang-switching { cursor: progress; }
.lang-switching::before {
  content: "";
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 30%;
  background: linear-gradient(90deg, transparent, #8b5cf6, transparent);
  animation: lang-loading 0.9s linear infinite;
  z-index: 9999;
  pointer-events: none;
}
@keyframes lang-loading {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ════════════════════════════════════════════════════════════════
   LIGHT THEME
   Dark is the default and untouched (Tailwind config stays default hex,
   so dark can never break). Light is opt-in via html.light and built
   entirely from explicit overrides of the exact slate utility tokens the
   site uses — specificity (html.light .x) beats the bare utility, so this
   is deterministic with no CDN-variable dependency.
   ════════════════════════════════════════════════════════════════ */

/* Semantic vars that the component classes below read */
html.light {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-2: #eef2f7;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-muted: #64748b;
}

/* Backgrounds (surfaces) */
html.light .bg-slate-950 { background-color: #f8fafc; }
html.light .bg-slate-900 { background-color: #ffffff; }
html.light .bg-slate-800 { background-color: #e2e8f0; }
html.light .bg-slate-700 { background-color: #cbd5e1; }
html.light .bg-slate-900\/95 { background-color: rgba(255,255,255,0.95); }
html.light .bg-slate-900\/80 { background-color: rgba(255,255,255,0.85); }
html.light .bg-slate-900\/60 { background-color: rgba(255,255,255,0.70); }
html.light .bg-slate-900\/50 { background-color: rgba(255,255,255,0.60); }
html.light .bg-slate-900\/40 { background-color: rgba(255,255,255,0.50); }
html.light .bg-slate-800\/80 { background-color: rgba(226,232,240,0.80); }
html.light .bg-slate-800\/60 { background-color: rgba(226,232,240,0.60); }
html.light .bg-slate-800\/50 { background-color: rgba(226,232,240,0.50); }
html.light .bg-slate-700\/60 { background-color: rgba(203,213,225,0.60); }

/* Text (dark on light). text-slate-900 is already dark — left as is. */
html.light .text-slate-100 { color: #0f172a; }
html.light .text-slate-200 { color: #1e293b; }
html.light .text-slate-300 { color: #334155; }
html.light .text-slate-400 { color: #475569; }
html.light .text-slate-500 { color: #64748b; }
html.light .text-slate-600 { color: #94a3b8; }
html.light .text-slate-700 { color: #475569; }

/* Borders */
html.light .border-slate-800 { border-color: #e2e8f0; }
html.light .border-slate-700 { border-color: #cbd5e1; }
html.light .border-slate-600 { border-color: #cbd5e1; }
html.light .border-slate-800\/60 { border-color: rgba(226,232,240,0.60); }
html.light .border-slate-800\/50 { border-color: rgba(226,232,240,0.50); }

/* Dividers */
html.light .divide-slate-800 > :not([hidden]) ~ :not([hidden]),
html.light .divide-slate-700 > :not([hidden]) ~ :not([hidden]) { border-color: #e2e8f0; }

/* Gradient fades to the page background */
html.light .from-slate-950 { --tw-gradient-from: #f8fafc var(--tw-gradient-from-position); }
html.light .to-slate-950 { --tw-gradient-to: #f8fafc var(--tw-gradient-to-position); }
html.light .to-slate-950\/50 { --tw-gradient-to: rgb(248 250 252 / 0.5) var(--tw-gradient-to-position); }

/* Component classes with literal dark values */
html.light .sidebar-link { color: #475569; }
html.light .sidebar-link:hover,
html.light .sidebar-active { color: #6d28d9; }
html.light .input { color: #0f172a; border-color: #cbd5e1; }
html.light .input::placeholder { color: #94a3b8; }
html.light label { color: #334155; }
html.light .btn-secondary { color: #334155; }
html.light .quiz-option { color: #0f172a; border-color: #e2e8f0; background: #ffffff; }
html.light .glass { background: rgba(255,255,255,0.7); border-color: rgba(15,23,42,0.08); }
html.light ::-webkit-scrollbar-thumb { background: #cbd5e1; }

/* text-white: flip to a dark heading colour, but keep white on solid accent
   buttons and dark scrims. !important so it reliably beats the utility no
   matter how/when the CDN injects its stylesheet. */
html.light .text-white { color: #0f172a !important; }
html.light [class~="bg-violet-500"].text-white,
html.light [class~="bg-violet-600"].text-white,
html.light [class~="bg-violet-700"].text-white,
html.light [class~="bg-indigo-500"].text-white,
html.light [class~="bg-indigo-600"].text-white,
html.light [class~="bg-emerald-500"].text-white,
html.light [class~="bg-emerald-600"].text-white,
html.light [class~="bg-amber-500"].text-white,
html.light [class~="bg-orange-400"].text-white,
html.light [class~="bg-orange-500"].text-white,
html.light [class~="bg-red-500"].text-white,
html.light [class~="bg-red-600"].text-white,
html.light [class~="bg-green-600"].text-white,
html.light [class~="bg-rose-500"].text-white,
html.light [class*="bg-black/"].text-white { color: #fff !important; }

/* White overlays designed for dark surfaces → tint dark on light bg */
html.light .bg-white\/5  { background-color: rgba(15,23,42,0.04); }
html.light .bg-white\/10 { background-color: rgba(15,23,42,0.06); }
html.light .bg-white\/20 { background-color: rgba(15,23,42,0.10); }
html.light .border-white\/20 { border-color: rgba(15,23,42,0.12); }
html.light .text-white\/5 { color: rgba(15,23,42,0.05); }

/* Always-dark surfaces (inline gradient cards: My Courses card, certification
   exam card). Their background never switches with the theme, so the literal
   white utilities inside them must not switch either. Higher specificity than
   the html.light remaps above. */
html.light .theme-dark-card .text-white,
html.light .theme-dark-card.text-white { color: #ffffff !important; }
html.light .theme-dark-card .bg-white\/5  { background-color: rgba(255,255,255,0.05); }
html.light .theme-dark-card .bg-white\/10 { background-color: rgba(255,255,255,0.10); }
html.light .theme-dark-card .bg-white\/20 { background-color: rgba(255,255,255,0.20); }
html.light .theme-dark-card .border-white\/20 { border-color: rgba(255,255,255,0.20); }
