/* ── 1. TOKENS ────────────────────────────────────────── */
:root {
  --accent:       #5c8e7a;
  --accent-light: #d4ede5;
  --accent-dim:   #4a7263;

  --bg:           #f7f6f3;
  --bg-card:      #ffffff;
  --bg-alt:       #f0eeea;
  --bg-hover:     #e9e7e2;

  --text:         #1a1a1a;
  --text-muted:   #6b6860;
  --text-faint:   #aaa9a5;

  --border:       #e2e0db;
  --border-strong:#c8c5bf;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lift:0 8px 24px rgba(0,0,0,.10), 0 3px 8px rgba(0,0,0,.06);

  --max-w:     900px;
  --gap:       1.5rem;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition:200ms ease;
}

[data-theme="dark"] {
  --bg:           #141412;
  --bg-card:      #1e1d1b;
  --bg-alt:       #252320;
  --bg-hover:     #2e2c29;

  --text:         #e8e6e0;
  --text-muted:   #9a9790;
  --text-faint:   #5a5854;

  --border:       #2e2c29;
  --border-strong:#3e3c38;
  --accent-light: #1e3028;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.3);
  --shadow-md:  0 4px 12px rgba(0,0,0,.35);
  --shadow-lift:0 8px 24px rgba(0,0,0,.45);
}

/* ── 2. RESET & BASE ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-dim); }
img { display: block; max-width: 100%; }
ul { list-style: none; }

/* ── 3. TYPOGRAPHY ────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
}
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.85rem); }
h3 { font-size: 1.1rem; font-weight: 500; }
p  { color: var(--text-muted); }

/* Gradient underline on page titles */
.page-title {
  position: relative;
  display: inline-block;
  padding-bottom: .35rem;
}
.page-title::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: 2px;
}

/* ── 4. LAYOUT ────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: 1.25rem;
}
main { flex: 1; padding-block: 2.5rem 4rem; }

.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;
}

/* ── 5. HEADER & NAVBAR ───────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  transition: background var(--transition), border-color var(--transition);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 60px;
}

.site-logo {
  font-size: 1.1rem; font-weight: 600;
  color: var(--text); letter-spacing: -0.03em;
  white-space: nowrap;
  display: flex; align-items: center; gap: .45rem;
}
.site-logo span.accent { color: var(--accent); }
.site-logo:hover { color: var(--text); }

.primary-nav { display: flex; align-items: center; gap: .15rem; }
.primary-nav a {
  font-size: .82rem; font-weight: 500;
  color: var(--text-muted);
  padding: .3rem .6rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}
.primary-nav a:hover,
.primary-nav a.active { color: var(--text); background: var(--bg-alt); }
.primary-nav a.active { color: var(--accent); }

.header-controls { display: flex; align-items: center; gap: .5rem; }

.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), transform var(--transition);
}
.theme-toggle:hover {
  background: var(--bg-hover); color: var(--text); transform: rotate(20deg);
}

.menu-toggle {
  display: none; width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card); cursor: pointer;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 5px; flex-shrink: 0;
}
.menu-toggle span {
  display: block; width: 18px; height: 1.5px;
  background: var(--text-muted); border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}
.menu-toggle.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ── 6. MOBILE MENU ───────────────────────────────────── */
.mobile-nav {
  display: none; flex-direction: column;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.25rem 1rem; gap: .25rem;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  font-size: .9rem; font-weight: 500;
  color: var(--text-muted); padding: .5rem .5rem;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: color var(--transition), background var(--transition),
              border-color var(--transition);
}
.mobile-nav a:hover,
.mobile-nav a.active {
  color: var(--accent); border-left-color: var(--accent);
  background: var(--accent-light);
}

/* ── 7. HERO ──────────────────────────────────────────── */
.hero {
  padding-block: 3rem 2.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .75rem; font-weight: 500;
  color: var(--accent); background: var(--accent-light);
  padding: .25rem .65rem; border-radius: 99px;
  margin-bottom: 1rem; letter-spacing: .04em;
  text-transform: uppercase;
}
.hero h1 { margin-bottom: .75rem; }
.hero p  { max-width: 55ch; font-size: 1.05rem; }

/* ── 8. CATEGORY GRID ─────────────────────────────────── */
.section-label {
  font-size: .72rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 1.25rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--gap);
}

.category-card {
  display: flex; flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.4rem 1.25rem 1.25rem;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition),
              border-color var(--transition), background var(--transition);
}
.category-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: var(--accent);
  color: var(--text);
}
.category-icon { font-size: 1.75rem; margin-bottom: .85rem; line-height: 1; }
.category-card h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }
.category-card p  { font-size: .82rem; color: var(--text-muted); line-height: 1.5; flex: 1; margin-bottom: .9rem; }
.card-arrow {
  font-size: .75rem; color: var(--accent); font-weight: 500;
  display: flex; align-items: center; gap: .25rem;
  transition: gap var(--transition);
}
.category-card:hover .card-arrow { gap: .5rem; }

/* ── 9. SUBJECT GRID ──────────────────────────────────── */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.subject-card {
  display: flex; align-items: center; gap: .75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition),
              border-color var(--transition);
}
.subject-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}
.subject-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
  transition: transform var(--transition);
}
.subject-card:hover .subject-dot { transform: scale(1.4); }
.subject-card span { font-size: .9rem; font-weight: 500; color: var(--text); }

/* ── 10. RESOURCE LIST ────────────────────────────────── */
.resource-list { display: flex; flex-direction: column; gap: .6rem; }
.resource-item:nth-child(even) { background: var(--bg-alt); }

.resource-item {
  display: flex; align-items: flex-start; gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition),
              border-color var(--transition), background var(--transition);
}
.resource-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  background: var(--bg-card);
}
.resource-type-icon { font-size: 1.25rem; flex-shrink: 0; margin-top: .05rem; }
.resource-body { flex: 1; min-width: 0; }
.resource-title { font-size: .95rem; font-weight: 500; color: var(--text); margin-bottom: .2rem; }
.resource-desc  { font-size: .82rem; color: var(--text-muted); margin: 0; }
.resource-link-icon {
  flex-shrink: 0; color: var(--accent); opacity: .6;
  font-size: .85rem; margin-top: .15rem;
  transition: opacity var(--transition), transform var(--transition);
}
.resource-item:hover .resource-link-icon { opacity: 1; transform: translateX(2px); }

/* ── 11. BREADCRUMB ───────────────────────────────────── */
.breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: .35rem; font-size: .8rem; color: var(--text-faint);
  margin-bottom: 1.75rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--text-faint); }
.breadcrumb .current { color: var(--text-muted); }

.page-intro { margin-bottom: 2rem; }
.page-intro p { margin-top: .5rem; max-width: 60ch; }

/* ── 12. FOOTER ───────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 1.25rem;
  text-align: center;
  font-size: .78rem;
  color: var(--text-faint);
  transition: border-color var(--transition);
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }

/* ── 13. 404 ──────────────────────────────────────────── */
.not-found { text-align: center; padding-block: 5rem; }
.not-found .big-number {
  font-size: clamp(4rem, 15vw, 7rem);
  font-weight: 600; color: var(--border-strong);
  line-height: 1; margin-bottom: 1rem; letter-spacing: -0.05em;
}
.not-found h2 { margin-bottom: .5rem; }
.not-found p  { margin-bottom: 2rem; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--accent); color: #fff;
  font-size: .88rem; font-weight: 500;
  padding: .55rem 1.2rem;
  border-radius: var(--radius-md);
  border: none; cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  text-decoration: none;
}
.btn:hover { background: var(--accent-dim); color: #fff; transform: translateY(-1px); }

/* ── 14. ANIMATIONS ───────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp 350ms ease both; }

.stagger > * { animation: fadeUp 350ms ease both; }
.stagger > *:nth-child(1)  { animation-delay:  30ms; }
.stagger > *:nth-child(2)  { animation-delay:  80ms; }
.stagger > *:nth-child(3)  { animation-delay: 130ms; }
.stagger > *:nth-child(4)  { animation-delay: 180ms; }
.stagger > *:nth-child(5)  { animation-delay: 230ms; }
.stagger > *:nth-child(6)  { animation-delay: 280ms; }
.stagger > *:nth-child(7)  { animation-delay: 330ms; }
.stagger > *:nth-child(8)  { animation-delay: 380ms; }
.stagger > *:nth-child(9)  { animation-delay: 430ms; }
.stagger > *:nth-child(10) { animation-delay: 480ms; }

/* Smooth theme transitions */
.site-header, body, .category-card, .subject-card,
.resource-item, .mobile-nav, .site-footer {
  transition-property: background, color, border-color, box-shadow;
  transition-duration: 200ms;
  transition-timing-function: ease;
}

/* ── 15. RESPONSIVE ───────────────────────────────────── */
@media (max-width: 700px) {
  .primary-nav { display: none; }
  .menu-toggle  { display: flex; }
  .category-grid { grid-template-columns: 1fr 1fr; }
  .subject-grid  { grid-template-columns: 1fr; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
}
@media (max-width: 420px) {
  .category-grid { grid-template-columns: 1fr; }
}
