/* ============================================================
   EDUVILLE 2.0 — MAIN.CSS
   Core design system: tokens, typography, utilities, animations
   ============================================================ */

/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */

:root {
  /* Backgrounds */
  --bg-primary:      #0d1117;
  --bg-secondary:    #161b22;
  --bg-tertiary:     #21262d;
  --bg-overlay:      #30363d;

  /* Text */
  --text-primary:    #e6edf3;
  --text-secondary:  #8b949e;
  --text-bright:     #ffffff;
  --text-dim:        #6e7681;

  /* Brand */
  --edu-blue:        #1E3A8A;
  --edu-blue-light:  #58a6ff;
  --edu-blue-dark:   #0F1E4A;
  --gold:            #FBBF24;
  --gold-dark:       #D4AF37;

  /* Accents */
  --accent-green:    #238636;
  --accent-green-h:  #2ea043;
  --accent-purple:   #a371f7;
  --accent-red:      #da3633;
  --accent-yellow:   #d29922;

  /* Tags */
  --tag-blue-bg:     #dbeafe;
  --tag-blue-text:   #1e3a8a;
  --tag-purple-bg:   #e9d5ff;
  --tag-purple-text: #6b21a8;
  --tag-green-bg:    #d1fae5;
  --tag-green-text:  #065f46;
  --tag-orange-bg:   #fed7aa;
  --tag-orange-text: #9a3412;
  --tag-gold-bg:     #fef3c7;
  --tag-gold-text:   #92400e;

  /* Borders */
  --border-default:  #30363d;
  --border-muted:    #21262d;
  --border-strong:   #484f58;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg:  0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-xl:  0 24px 48px rgba(0, 0, 0, 0.6);

  /* Radii */
  --r-xs:  4px;
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;
  --r-full: 999px;

  /* Spacing */
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-5:  1.25rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;

  /* Fonts */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
  --font-feat-head: 'ss01', 'ss03', 'cv11';

  /* Font sizes */
  --fs-xs:   0.75rem;
  --fs-sm:   0.875rem;
  --fs-base: 1rem;
  --fs-lg:   1.125rem;
  --fs-xl:   1.25rem;
  --fs-2xl:  1.5rem;
  --fs-3xl:  1.875rem;
  --fs-4xl:  2.25rem;

  /* Font weights */
  --fw-normal:   400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;
  --fw-extrabold: 800;

  /* Line heights */
  --lh-tight:  1.25;
  --lh-normal: 1.5;
  --lh-loose:  1.75;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 400ms;

  /* Layout */
  --container-sm:  640px;
  --container-md:  900px;
  --container-lg:  1100px;
  --container-xl:  1300px;

  /* Z-index */
  --z-base:    1;
  --z-dropdown: 100;
  --z-sticky:  200;
  --z-modal:   300;
  --z-toast:   400;
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: var(--fw-normal);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================================
   3. TYPOGRAPHY
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-bright);
  margin-bottom: var(--sp-3);
  font-feature-settings: var(--font-feat-head);
}

h1 { letter-spacing: -0.03em; }
h2 { letter-spacing: -0.025em; }

h1 { font-size: clamp(var(--fs-2xl), 5vw, var(--fs-4xl)); }
h2 { font-size: clamp(var(--fs-xl), 4vw, var(--fs-3xl)); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-base); }
h6 { font-size: var(--fs-sm); }

p { margin-bottom: var(--sp-3); color: var(--text-primary); }

a {
  color: var(--edu-blue-light);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}

a:hover {
  color: var(--gold);
  text-decoration: underline;
}

strong, b { font-weight: var(--fw-semibold); color: var(--text-bright); }
em, i { font-style: italic; }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background: var(--bg-tertiary);
  border-radius: var(--r-xs);
  color: var(--gold);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  padding: var(--sp-4);
  background: var(--bg-tertiary);
  border-radius: var(--r-md);
  overflow-x: auto;
  margin-bottom: var(--sp-4);
}

pre code { padding: 0; background: none; color: var(--text-primary); }

blockquote {
  border-left: 3px solid var(--gold);
  padding-left: var(--sp-4);
  margin: var(--sp-4) 0;
  color: var(--text-secondary);
  font-style: italic;
}

ul, ol { padding-left: var(--sp-6); margin-bottom: var(--sp-3); }
li { margin-bottom: var(--sp-1); }
img { max-width: 100%; height: auto; display: block; }

/* ============================================================
   4. LAYOUT UTILITIES
   ============================================================ */

.container {
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

.container-sm { max-width: var(--container-sm); }
.container-md { max-width: var(--container-md); }
.container-lg { max-width: var(--container-lg); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ============================================================
   5. SPACING UTILITIES
   ============================================================ */

.m-0 { margin: 0; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }

.p-0 { padding: 0; }
.p-2 { padding: var(--sp-2); }
.p-3 { padding: var(--sp-3); }
.p-4 { padding: var(--sp-4); }
.p-6 { padding: var(--sp-6); }
.p-8 { padding: var(--sp-8); }
.px-4 { padding-left: var(--sp-4); padding-right: var(--sp-4); }
.py-4 { padding-top: var(--sp-4); padding-bottom: var(--sp-4); }

/* ============================================================
   6. TEXT UTILITIES
   ============================================================ */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-base { font-size: var(--fs-base); }
.text-lg { font-size: var(--fs-lg); }
.text-xl { font-size: var(--fs-xl); }
.text-2xl { font-size: var(--fs-2xl); }

.font-medium { font-weight: var(--fw-medium); }
.font-semibold { font-weight: var(--fw-semibold); }
.font-bold { font-weight: var(--fw-bold); }

.text-muted { color: var(--text-secondary); }
.text-dim { color: var(--text-dim); }
.text-bright { color: var(--text-bright); }
.text-gold { color: var(--gold); }
.text-blue { color: var(--edu-blue-light); }
.text-green { color: var(--accent-green); }
.text-red { color: var(--accent-red); }

.uppercase { text-transform: uppercase; letter-spacing: 0.5px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   7. VISIBILITY
   ============================================================ */

.hidden { display: none !important; }
.invisible { visibility: hidden; }
.block { display: block; }
.inline-block { display: inline-block; }
.w-full { width: 100%; }
.h-full { height: 100%; }

@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

/* ============================================================
   8. ACCESSIBILITY
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent-green);
  color: #fff;
  padding: 8px 16px;
  z-index: var(--z-toast);
  text-decoration: none;
  font-weight: var(--fw-semibold);
  border-radius: 0 0 var(--r-md) 0;
  transition: top var(--dur-base) var(--ease);
}

.skip-link:focus { top: 0; color: #fff; }

*:focus-visible {
  outline: 2px solid var(--edu-blue-light);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ============================================================
   9. SCROLLBAR
   ============================================================ */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
  background: var(--bg-overlay);
  border-radius: var(--r-full);
  border: 2px solid var(--bg-primary);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================================
   10. ANIMATIONS
   ============================================================ */

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

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

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes softPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

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

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

.fade-in { animation: fadeIn var(--dur-base) var(--ease); }
.slide-up { animation: slideUp var(--dur-base) var(--ease); }
.pulse { animation: pulse 2s infinite; }
.spin { animation: spin 1s linear infinite; }

/* ============================================================
   11. ANIMATION EFFECTS — Applied to content
   ============================================================ */

/* Fade in page sections */
.hero,
.section-heading-row,
.card,
.repo-card,
.course-card,
.video-card,
.paper-card,
.stat-card,
.dash-stat,
.lesson-row {
  animation: fadeUp 0.5s ease-out both;
}

/* Stagger delay for grid children */
.grid-courses > *:nth-child(1),
.grid-stats > *:nth-child(1),
.grid-featured > *:nth-child(1) { animation-delay: 0.05s; }

.grid-courses > *:nth-child(2),
.grid-stats > *:nth-child(2),
.grid-featured > *:nth-child(2) { animation-delay: 0.10s; }

.grid-courses > *:nth-child(3),
.grid-stats > *:nth-child(3),
.grid-featured > *:nth-child(3) { animation-delay: 0.15s; }

.grid-courses > *:nth-child(4),
.grid-stats > *:nth-child(4),
.grid-featured > *:nth-child(4) { animation-delay: 0.20s; }

.grid-courses > *:nth-child(5) { animation-delay: 0.25s; }
.grid-courses > *:nth-child(6) { animation-delay: 0.30s; }

/* Hover lift effect */
.card:hover,
.repo-card:hover,
.course-card:hover,
.video-card:hover,
.paper-card:hover {
  transform: translateY(-5px);
  transition: all 0.3s ease;
  box-shadow: 0 10px 30px rgba(35, 134, 54, 0.15);
}

.stat-card:hover,
.dash-stat:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
}

/* Floating logo on hero only */
.hero-logo-img {
  animation: float 3s ease-in-out infinite;
}

/* Navbar logo — static */
.navbar .logo-img {
  animation: none;
}

/* "Soon" badges pulse */
.coming-soon-badge {
  animation: softPulse 2s ease-in-out infinite;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
