/* ===== CSS Variables ===== */
:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --secondary: #34a853;
  --accent: #fbbc04;
  --text: #202124;
  --text-light: #5f6368;
  --bg: #ffffff;
  --bg-light: #f8f9fa;
  --bg-card: #ffffff;
  --border: #dadce0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 14px rgba(0,0,0,0.1);
  --max-width: 1200px;
  --transition: 0.2s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 2px; }

/* ===== Skip Link (Accessibility) ===== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  z-index: 1000;
  font-size: 0.875rem;
}
.skip-link:focus { top: 0; }

/* ===== Container ===== */
.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

/* ===== Header ===== */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
}

/* Main Nav */
.main-nav { display: flex; align-items: center; gap: 4px; }
.main-nav a {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  transition: background var(--transition);
}
.main-nav a:hover, .main-nav a[aria-current="page"] {
  background: var(--bg-light);
  color: var(--primary);
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  color: var(--text);
}
.menu-toggle:hover { background: var(--bg-light); }
.menu-toggle svg { width: 24px; height: 24px; }

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, #e8f0fe 0%, #fce8e6 50%, #e6f4ea 100%);
  padding: 60px 20px;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  color: var(--text);
}

.hero p {
  font-size: 1.15rem;
  color: var(--text-light);
  max-width: 640px;
  margin: 0 auto 28px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.hero-stat {
  text-align: center;
}

.hero-stat .num {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

.hero-stat .label {
  font-size: 0.85rem;
  color: var(--text-light);
}

.cta-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

/* ===== Section ===== */
.section { padding: 48px 0; }
.section-alt { background: var(--bg-light); }

.section-header {
  text-align: center;
  margin-bottom: 36px;
}

.section-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.section-header p {
  color: var(--text-light);
  font-size: 1rem;
  max-width: 560px;
  margin: 0 auto;
}

/* ===== Class Cards ===== */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px;
}

.class-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
.class-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.class-card-header {
  padding: 20px 24px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.class-card-header h3 { font-size: 1.25rem; font-weight: 700; }
.class-card-header .badge {
  background: rgba(255,255,255,0.25);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.class3-header { background: linear-gradient(135deg, #1a73e8, #4285f4); }
.class4-header { background: linear-gradient(135deg, #34a853, #0d652d); }

.class-card-body { padding: 20px 24px; }

.subject-group { margin-bottom: 16px; }
.subject-group:last-child { margin-bottom: 0; }

.subject-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--text);
}

.subject-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

.icon-maths { background: #ea4335; }
.icon-evs { background: #34a853; }
.icon-english { background: #4285f4; }

.topic-count {
  font-weight: 400;
  color: var(--text-light);
  font-size: 0.85rem;
}

.subject-group a {
  display: block;
  padding: 6px 0;
  font-size: 0.875rem;
  color: var(--text);
  border-bottom: 1px solid var(--bg-light);
  transition: padding-left var(--transition), color var(--transition);
}
.subject-group a:hover { padding-left: 6px; color: var(--primary); }
.subject-group a:last-child { border-bottom: none; }

.view-all-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 8px;
  color: var(--primary);
}

/* ===== Features ===== */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  transition: box-shadow var(--transition);
}
.feature-card:hover { box-shadow: var(--shadow-lg); }

.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 1.4rem;
}

.feature-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.feature-card p { font-size: 0.85rem; color: var(--text-light); }

/* ===== Ad Placeholder ===== */
.ad-slot {
  background: var(--bg-light);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  color: var(--text-light);
  font-size: 0.8rem;
  margin: 24px auto;
  max-width: 728px;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--text);
  color: #e8eaed;
  padding: 40px 0 20px;
  margin-top: auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 32px;
  margin-bottom: 32px;
}

.footer-col h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: #fff;
}

.footer-col a {
  display: block;
  color: #9aa0a6;
  font-size: 0.85rem;
  padding: 3px 0;
  transition: color var(--transition);
}
.footer-col a:hover { color: #fff; }

.footer-col p {
  font-size: 0.85rem;
  color: #9aa0a6;
  line-height: 1.5;
}

.footer-bottom {
  border-top: 1px solid #3c4043;
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  color: #9aa0a6;
}

.footer-bottom a { color: #9aa0a6; }
.footer-bottom a:hover { color: #fff; }

/* ===== Cookie Banner (GDPR) ===== */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--text);
  color: #e8eaed;
  padding: 16px 20px;
  z-index: 9999;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
  display: none;
}

.cookie-banner.show { display: block; }

.cookie-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.cookie-inner p {
  font-size: 0.85rem;
  flex: 1;
  min-width: 240px;
}

.cookie-inner p a { color: var(--accent); }

.cookie-btns { display: flex; gap: 8px; flex-shrink: 0; }

.cookie-btns button {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition);
}

.btn-accept { background: var(--primary); color: #fff; }
.btn-accept:hover { background: var(--primary-dark); }
.btn-reject { background: #3c4043; color: #e8eaed; }
.btn-reject:hover { background: #5f6368; }

/* ===== Privacy / About Pages ===== */
.page-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}

.page-content h1 { font-size: 2rem; margin-bottom: 8px; }
.page-content .updated { color: var(--text-light); font-size: 0.85rem; margin-bottom: 24px; }
.page-content h2 { font-size: 1.3rem; margin: 28px 0 8px; }
.page-content p, .page-content li { font-size: 0.95rem; margin-bottom: 10px; color: var(--text); }
.page-content ul { margin-left: 20px; margin-bottom: 16px; }

/* ===== Browse Page ===== */
.browse-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  justify-content: center;
}

.filter-btn {
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text);
}
.filter-btn:hover, .filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.topic-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  transition: all var(--transition);
  color: var(--text);
  font-size: 0.875rem;
}
.topic-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  color: var(--primary);
}

.topic-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
}

.badge-maths { background: #ea4335; }
.badge-evs { background: #34a853; }
.badge-english { background: #4285f4; }

/* ===== Search ===== */
.search-box {
  max-width: 480px;
  margin: 0 auto 24px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition);
}
.search-box input:focus { border-color: var(--primary); }

.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-light);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.75rem; }
  .hero p { font-size: 1rem; }
  .hero { padding: 40px 16px; }
  .hero-stats { gap: 20px; }
  .hero-stat .num { font-size: 1.5rem; }

  .menu-toggle { display: block; }

  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px 16px;
    box-shadow: var(--shadow-lg);
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 12px 14px; width: 100%; }

  .class-grid { grid-template-columns: 1fr; }
  .features-grid { grid-template-columns: 1fr 1fr; }

  .footer-bottom { flex-direction: column; text-align: center; }
  .section { padding: 32px 0; }
}

@media (max-width: 480px) {
  .features-grid { grid-template-columns: 1fr; }
  .cta-group { flex-direction: column; align-items: center; }
  .btn { width: 100%; justify-content: center; }
}

/* ===== Print ===== */
@media print {
  .site-header, .site-footer, .cookie-banner, .ad-slot { display: none !important; }
  .hero { background: none !important; padding: 20px 0; }
}
