/* ================================================
   ProgMaster - Luminous Dark Design System
   ================================================ */

/* ================================================
   CSS Custom Properties
   ================================================ */
:root {
  /* Glass effect values */
  --glass-bg: rgba(30, 41, 59, 0.4);
  --glass-border: rgba(148, 163, 184, 0.1);
  --glass-blur: 12px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ================================================
   Prose / Markdown Content
   ================================================ */
.prose {
  max-width: none;
}

.prose pre {
  margin: 1.5em 0;
  border-radius: 0.5rem;
  background-color: #1e1e1e;
}

.prose code {
  font-size: 0.875em;
}

.prose :not(pre) > code {
  background-color: #f3f4f6;
  padding: 0.2em 0.4em;
  border-radius: 0.25rem;
  font-weight: 500;
}

.dark .prose :not(pre) > code {
  background-color: #374151;
}

/* Table styling */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
}

.prose th,
.prose td {
  border: 1px solid #e5e7eb;
  padding: 0.75rem 1rem;
  text-align: left;
}

.dark .prose th,
.dark .prose td {
  border-color: #374151;
}

.prose th {
  background-color: #f9fafb;
  font-weight: 600;
}

.dark .prose th {
  background-color: #1f2937;
}

/* Heading anchors */
.prose h1 .header-anchor,
.prose h2 .header-anchor,
.prose h3 .header-anchor,
.prose h4 .header-anchor,
.prose h5 .header-anchor,
.prose h6 .header-anchor {
  opacity: 0;
  margin-left: 0.5rem;
  color: #6b7280;
  text-decoration: none;
  transition: opacity 0.2s;
}

.prose h1:hover .header-anchor,
.prose h2:hover .header-anchor,
.prose h3:hover .header-anchor,
.prose h4:hover .header-anchor,
.prose h5:hover .header-anchor,
.prose h6:hover .header-anchor {
  opacity: 1;
}

/* ================================================
   Syntax Highlighting
   ================================================ */
.hljs {
  background: #0d1117 !important;
  color: #c9d1d9;
  padding: 1.5rem;
  border-radius: 0.5rem;
  overflow-x: auto;
}

/* ================================================
   Scrollbar
   ================================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.dark ::-webkit-scrollbar-track {
  background: #1e293b;
}

::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* ================================================
   Utility Classes
   ================================================ */

/* Line clamp */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Dark mode background adjustment */
.dark .bg-gray-750 {
  background-color: #1a2332;
}

/* Image zoom effect */
img.cursor-zoom-in {
  cursor: zoom-in;
  transition: transform 0.3s ease;
}

img.max-w-none {
  cursor: zoom-out;
}

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

/* Active TOC item */
nav a.active {
  color: #3b82f6;
  font-weight: 500;
}

/* File type badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
}

/* Loading spinner */
.spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Transition utilities */
.transition-all {
  transition: all 0.2s ease;
}

/* Focus visible */
:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* ================================================
   Gradient Mesh Background
   ================================================ */
.gradient-bg {
  background: #0f172a;
  position: relative;
}

.gradient-bg::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 40%, rgba(96, 165, 250, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 20%, rgba(192, 132, 252, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse 50% 60% at 60% 80%, rgba(52, 211, 153, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.gradient-bg > * {
  position: relative;
  z-index: 1;
}

/* ================================================
   Glass Card Components
   ================================================ */

/* Base glass card */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 0.75rem;
  transition: all var(--transition-base);
}

.glass-card:hover {
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(148, 163, 184, 0.2);
  transform: translateY(-2px);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(148, 163, 184, 0.1);
}

/* Glass card with gradient border glow on hover */
.glass-card-glow {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 0.75rem;
  position: relative;
  transition: all var(--transition-slow);
}

.glass-card-glow::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    135deg,
    transparent 0%,
    rgba(96, 165, 250, 0) 40%,
    rgba(96, 165, 250, 0) 60%,
    transparent 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--transition-base);
  pointer-events: none;
}

.glass-card-glow:hover::before {
  opacity: 1;
  background: linear-gradient(
    135deg,
    transparent 0%,
    rgba(96, 165, 250, 0.3) 40%,
    rgba(192, 132, 252, 0.3) 60%,
    transparent 100%
  );
}

.glass-card-glow:hover {
  transform: translateY(-4px);
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(148, 163, 184, 0.15);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(96, 165, 250, 0.05);
}

/* ================================================
   Card Hover Effect (upgraded)
   ================================================ */
.card-hover {
  transition: all var(--transition-slow);
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(148, 163, 184, 0.08);
}

/* ================================================
   Staggered Entrance Animation
   ================================================ */
.stagger-in {
  opacity: 0;
  transform: translateY(16px);
  animation: stagger-fade-in 0.5s ease-out forwards;
}

.stagger-in:nth-child(1) { animation-delay: 0.05s; }
.stagger-in:nth-child(2) { animation-delay: 0.1s; }
.stagger-in:nth-child(3) { animation-delay: 0.15s; }
.stagger-in:nth-child(4) { animation-delay: 0.2s; }
.stagger-in:nth-child(5) { animation-delay: 0.25s; }
.stagger-in:nth-child(6) { animation-delay: 0.3s; }
.stagger-in:nth-child(7) { animation-delay: 0.35s; }
.stagger-in:nth-child(8) { animation-delay: 0.4s; }
.stagger-in:nth-child(9) { animation-delay: 0.45s; }
.stagger-in:nth-child(10) { animation-delay: 0.5s; }

@keyframes stagger-fade-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ================================================
   Stat Card Components
   ================================================ */
.stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  text-align: center;
  transition: border-color var(--transition-base);
}

.stat-card:hover {
  border-color: rgba(148, 163, 184, 0.25);
}

.stat-value {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 2rem;
  line-height: 1;
  background: linear-gradient(135deg, var(--color-from, #60a5fa), var(--color-to, #c084fc));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ================================================
   Category Tabs (/learn page)
   ================================================ */

.category-tab {
  position: relative;
  cursor: pointer;
  outline: none;
  min-width: 180px;
}

.category-tab:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 4px;
  border-radius: 0.5rem;
}

/* Inactive state */
.category-tab {
  background: rgba(30, 41, 59, 0.4);
  backdrop-filter: blur(12px);
}

/* Active state */
.category-tab[aria-selected="true"].tab-active {
  background: rgba(51, 65, 85, 0.6);
  transform: translateY(-2px);
}

/* Color-specific active glow (purple) */
.category-tab[aria-selected="true"][data-color="purple"] {
  border-color: rgba(192, 132, 252, 0.6);
  box-shadow: 0 8px 24px rgba(192, 132, 252, 0.2);
}

/* Orange */
.category-tab[aria-selected="true"][data-color="orange"] {
  border-color: rgba(251, 146, 60, 0.6);
  box-shadow: 0 8px 24px rgba(251, 146, 60, 0.2);
}

/* Rose */
.category-tab[aria-selected="true"][data-color="rose"] {
  border-color: rgba(251, 113, 133, 0.6);
  box-shadow: 0 8px 24px rgba(251, 113, 133, 0.2);
}

/* Emerald */
.category-tab[aria-selected="true"][data-color="emerald"] {
  border-color: rgba(52, 211, 153, 0.6);
  box-shadow: 0 8px 24px rgba(52, 211, 153, 0.2);
}

/* Violet */
.category-tab[aria-selected="true"][data-color="violet"] {
  border-color: rgba(167, 139, 250, 0.6);
  box-shadow: 0 8px 24px rgba(167, 139, 250, 0.2);
}

/* Tab panel transitions */
.category-panel {
  animation: fade-in-up 0.3s ease-out;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive: Stack tabs on mobile */
@media (max-width: 768px) {
  .category-tab {
    min-width: 140px;
    padding: 0.75rem 1rem;
  }

  .category-tab .text-3xl {
    font-size: 2rem; /* Smaller icons */
  }
}

@media (max-width: 640px) {
  /* Full width tabs on small mobile */
  .category-tab {
    width: 100%;
    justify-content: center;
  }
}

/* ================================================
   Print Styles
   ================================================ */
@media print {
  nav,
  aside,
  footer,
  .no-print {
    display: none !important;
  }

  .prose {
    max-width: 100% !important;
  }

  body {
    background: white !important;
    color: black !important;
  }
}

/* ================================================
   Language Switcher - CSS-only dropdown
   ================================================ */
.lang-switcher {
  padding-bottom: 0.5rem;
  margin-bottom: -0.5rem;
}

.lang-switcher .lang-dropdown {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  pointer-events: none;
}

.lang-switcher .lang-dropdown::before {
  content: '';
  position: absolute;
  top: -1rem;
  left: -1rem;
  right: -1rem;
  height: 1.5rem;
}

.lang-switcher:hover .lang-dropdown,
.lang-switcher:focus-within .lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.lang-switcher:hover svg,
.lang-switcher:focus-within svg {
  transform: rotate(180deg);
}

/* ================================================
   Quiz Modal Styles
   ================================================ */

.modal-backdrop {
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(2rem);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track {
  background: rgb(15 23 42);
}

.modal-content::-webkit-scrollbar-thumb {
  background: rgb(51 65 85);
  border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: rgb(71 85 105);
}

/* ================================================
   Collapsible Animations
   ================================================ */

.module-content,
#practice-test-content {
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chevron-icon {
  transition: transform 0.2s ease-in-out;
}

/* ================================================
   Range Slider Styling
   ================================================ */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: #3b82f6;
  cursor: pointer;
  border-radius: 50%;
  border: 2px solid #1e293b;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: #2563eb;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #3b82f6;
  cursor: pointer;
  border-radius: 50%;
  border: 2px solid #1e293b;
}

input[type="range"]:focus {
  outline: none;
}

/* ================================================
   Mobile Responsive
   ================================================ */

@media (max-width: 768px) {
  .modal-content {
    max-height: 95vh;
    border-radius: 1rem;
  }

  .quiz-modal-body {
    padding: 1rem;
  }

  .quiz-question {
    padding: 1rem;
  }
}

/* ================================================
   Loading Animation
   ================================================ */

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ================================================
   Accessibility: Reduced Motion
   ================================================ */
@media (prefers-reduced-motion: reduce) {
  .stagger-in {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .glass-card:hover,
  .glass-card-glow:hover {
    transform: none;
  }

  .card-hover:hover {
    transform: none;
  }

  html {
    scroll-behavior: auto;
  }
}
