/* ============================================================
   Unified Index Page Stylesheet — Modern, Vibrant
   Shared across all subject index pages
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #fafafa;
  --bg-subtle: #f0f0f0;
  --fg: #111111;
  --muted: #6b7280;
  --border: #e5e7eb;
  --hover-bg: #f3f4f6;
  --card-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
  --card-hover: 0 20px 40px rgba(0,0,0,.08), 0 8px 16px rgba(0,0,0,.06);
  --ease: cubic-bezier(.4,0,.2,1);
  --spring: cubic-bezier(.34,1.56,.64,1);
  --accent: #6366f1;
  --accent-soft: rgba(99,102,241,.08);
  --accent-glow: rgba(99,102,241,.15);
  --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  --gradient-5: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --glass: rgba(255,255,255,.7);
  --glass-border: rgba(255,255,255,.3);
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --bg: #0f0f13;
  --bg-subtle: #1a1a22;
  --fg: #f0f0f0;
  --muted: #9ca3af;
  --border: #2a2a35;
  --hover-bg: #1f1f2a;
  --card-shadow: 0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --card-hover: 0 20px 40px rgba(0,0,0,.4), 0 8px 16px rgba(0,0,0,.3);
  --accent: #818cf8;
  --accent-soft: rgba(129,140,248,.1);
  --accent-glow: rgba(129,140,248,.2);
  --glass: rgba(20,20,30,.7);
  --glass-border: rgba(255,255,255,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ---- Animations ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes gradientMove {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes orb-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -20px) scale(1.05); }
  50% { transform: translate(-10px, 15px) scale(.95); }
  75% { transform: translate(-25px, -10px) scale(1.02); }
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  transition: background .4s var(--ease), color .4s var(--ease);
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* ---- Ambient background orbs ---- */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .12;
  pointer-events: none;
  z-index: 0;
  animation: orb-drift 20s ease-in-out infinite;
}
body::before {
  width: 500px; height: 500px;
  background: var(--gradient-1);
  top: -100px; right: -100px;
}
body::after {
  width: 400px; height: 400px;
  background: var(--gradient-3);
  bottom: -80px; left: -80px;
  animation-delay: -10s;
}
[data-theme="dark"] body::before,
[data-theme="dark"] body::after {
  opacity: .06;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---- Layout ---- */
.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 28px;
  position: relative;
  z-index: 1;
}

/* ---- Back link ---- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 48px 0 0;
  transition: color .2s, gap .2s var(--ease);
  animation: fadeIn .5s var(--ease) both;
}
.back-link:hover { color: var(--accent); gap: 12px; }
.back-link svg { width: 14px; height: 14px; transition: transform .2s var(--ease); }
.back-link:hover svg { transform: translateX(-3px); }

/* ---- Header ---- */
.page-header {
  padding: 32px 0 40px;
  border-bottom: 1px solid var(--border);
  animation: fadeInUp .6s var(--ease) .1s both;
}
.page-header h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--fg) 0%, var(--muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
[data-theme="dark"] .page-header h1 {
  background: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
.page-header .subtitle {
  font-size: 15px;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.5;
}
.page-header .stats {
  display: flex;
  gap: 20px;
  margin-top: 22px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}
.page-header .stats > div {
  background: var(--accent-soft);
  padding: 6px 14px;
  border-radius: 20px;
  transition: transform .2s var(--spring);
}
.page-header .stats > div:hover {
  transform: scale(1.05);
}
.page-header .stats span {
  font-weight: 700;
  color: var(--accent);
}

/* ---- Section label ---- */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 36px 0 14px;
  animation: fadeIn .5s var(--ease) .3s both;
}

/* ---- Chapter list ---- */
.chapter-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: fadeInUp .6s var(--ease) .35s both;
}
.chapter-list li {
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.chapter-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--fg);
  border-radius: var(--radius-sm);
  transition: all .2s var(--ease);
  position: relative;
}
.chapter-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 3px; height: 100%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  opacity: 0;
  transform: scaleY(0);
  transition: all .2s var(--ease);
}
.chapter-item:hover {
  background: var(--accent-soft);
}
.chapter-item:hover::before {
  opacity: 1;
  transform: scaleY(1);
}
.ch-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  transition: all .2s var(--ease);
}
.chapter-item:hover .ch-num {
  background: var(--accent);
  color: #fff;
}
.ch-title {
  flex: 1;
  font-size: 14.5px;
  font-weight: 500;
}
.ch-arrow {
  color: var(--border);
  transition: all .25s var(--ease);
}
.chapter-item:hover .ch-arrow {
  color: var(--accent);
  transform: translateX(4px);
}
.ch-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

/* ---- Info card (course info blocks) ---- */
.info-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  animation: fadeInUp .6s var(--ease) .4s both;
}
.info-card p {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--fg);
  margin-bottom: 10px;
}
.info-card p strong { color: var(--accent); font-weight: 700; }

/* ---- Subject card grid (main index) ---- */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  padding: 36px 0;
}
.subject-card {
  display: flex;
  gap: 18px;
  padding: 26px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg);
  transition: all .35s var(--ease);
  position: relative;
  overflow: hidden;
  animation: fadeInUp .6s var(--ease) both;
}
.subject-card:nth-child(1) { animation-delay: .1s; }
.subject-card:nth-child(2) { animation-delay: .18s; }
.subject-card:nth-child(3) { animation-delay: .26s; }
.subject-card:nth-child(4) { animation-delay: .34s; }
.subject-card:nth-child(5) { animation-delay: .42s; }

.subject-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0;
  transition: opacity .35s var(--ease);
}
.subject-card:nth-child(1)::before { background: var(--gradient-1); }
.subject-card:nth-child(2)::before { background: var(--gradient-3); }
.subject-card:nth-child(3)::before { background: var(--gradient-5); }
.subject-card:nth-child(4)::before { background: var(--gradient-4); }
.subject-card:nth-child(5)::before { background: var(--gradient-2); }

.subject-card:hover {
  border-color: var(--accent-glow);
  box-shadow: var(--card-hover);
  transform: translateY(-4px);
}
.subject-card:hover::before {
  opacity: 1;
}
.subject-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  transition: all .3s var(--spring);
}
.subject-card:nth-child(1) .subject-icon { background: linear-gradient(135deg, rgba(102,126,234,.15), rgba(118,75,162,.15)); }
.subject-card:nth-child(2) .subject-icon { background: linear-gradient(135deg, rgba(79,172,254,.15), rgba(0,242,254,.15)); }
.subject-card:nth-child(3) .subject-icon { background: linear-gradient(135deg, rgba(250,112,154,.15), rgba(254,225,64,.15)); }
.subject-card:nth-child(4) .subject-icon { background: linear-gradient(135deg, rgba(67,233,123,.15), rgba(56,249,215,.15)); }
.subject-card:nth-child(5) .subject-icon { background: linear-gradient(135deg, rgba(240,147,251,.15), rgba(245,87,108,.15)); }

.subject-card:hover .subject-icon {
  transform: scale(1.1) rotate(-3deg);
}
.subject-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.subject-card:nth-child(1) .subject-icon svg { stroke: #667eea; }
.subject-card:nth-child(2) .subject-icon svg { stroke: #4facfe; }
.subject-card:nth-child(3) .subject-icon svg { stroke: #f5576c; }
.subject-card:nth-child(4) .subject-icon svg { stroke: #43e97b; }
.subject-card:nth-child(5) .subject-icon svg { stroke: #f093fb; }

.subject-info h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.3;
}
.subject-info p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 10px;
}
.subject-info .count {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 6px;
  display: inline-block;
}

/* ---- Footer ---- */
.page-footer {
  text-align: center;
  padding: 40px 0;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 40px;
  animation: fadeIn .5s var(--ease) .5s both;
}
.page-footer a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity .2s;
}
.page-footer a:hover { opacity: .7; }

/* ---- Search ---- */
.search-wrap {
  padding: 24px 0 0;
  animation: fadeInUp .5s var(--ease) .25s both;
}
.search-input {
  width: 100%;
  padding: 12px 18px 12px 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: all .25s var(--ease);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-input::placeholder {
  color: var(--muted);
}
[data-theme="dark"] .search-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .container { padding: 0 16px; }
  .page-header h1 { font-size: 28px; }
  .subject-grid { grid-template-columns: 1fr; gap: 14px; }
  .subject-card { padding: 20px; }
  .chapter-item { padding: 12px 10px; gap: 12px; }
  .ch-badge { display: none; }
  body::before { width: 300px; height: 300px; }
  body::after { width: 250px; height: 250px; }
}

@media print {
  .back-link, .search-wrap { display: none; }
  body::before, body::after { display: none; }
}
