:root {
  --primary-50: #eef4ff;
  --primary-100: #dfeaff;
  --primary-500: #2563eb;
  --primary-600: #1d4ed8;
  --primary-700: #1e3a8a;
  --secondary-500: #0ea5e9;
  --secondary-600: #0284c7;
  --accent-500: #f59e0b;
  --success-500: #22c55e;
  --error-500: #ef4444;
  --warning-500: #f59e0b;
  --neutral-900: #111827;
  --neutral-800: #1f2937;
  --neutral-700: #374151;
  --neutral-600: #4b5563;
  --neutral-500: #6b7280;
  --neutral-300: #d1d5db;
  --neutral-200: #e5e7eb;
  --neutral-100: #f3f4f6;
  --neutral-50: #f9fafb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 20px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.16);
  --radius-sm: 0.75rem;
  --radius-md: 1rem;
  --radius-lg: 1.5rem;
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 0.75rem;
  --spacing-lg: 1rem;
  --spacing-xl: 1.5rem;
  --spacing-2xl: 2rem;
  --container-max: 1200px;
  --font-sans: "Inter", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  line-height: 1.7;
  color: var(--neutral-800);
  background: linear-gradient(180deg, #f8fbff 0%, #f8fafc 100%);
}

img,
svg,
video {
  max-width: 100%;
  display: block;
  height: auto;
}

a {
  color: var(--primary-600);
  text-decoration: none;
}

a:hover {
  color: var(--primary-700);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.8rem 1rem;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--neutral-800);
  font-size: 16px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--neutral-900);
  line-height: 1.2;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2rem, 4vw, 3.3rem); }
h2 { font-size: clamp(1.65rem, 2.8vw, 2.4rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.7rem); }

p,
li {
  margin-bottom: 0.9rem;
  color: var(--neutral-700);
  line-height: 1.8;
}

.container {
  width: min(var(--container-max), calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(229, 231, 235, 0.9);
  box-shadow: var(--shadow-sm);
}

.site-header .nav-container,
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  min-height: 74px;
  width: min(var(--container-max), calc(100% - 2rem));
  margin-inline: auto;
  position: relative;
}

.brand-logo,
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: clamp(1.2rem, 2vw, 1.7rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--neutral-900);
  flex-shrink: 0;
}

.logo-bold,
.brand-logo .logo-bold {
  color: var(--neutral-900);
}

.logo-light,
.brand-logo .logo-light {
  color: var(--neutral-600);
  font-weight: 600;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
}

.nav-menu {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
}

.nav-list {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  list-style: none;
  flex-wrap: wrap;
  margin-left: auto;
}

.nav-list li {
  list-style: none;
}

.nav-list a,
.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.75rem 0.95rem;
  border-radius: 0.8rem;
  color: var(--neutral-600);
  font-weight: 700;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-list a:hover,
.nav-list a.active,
.nav-link:hover,
.nav-link.active {
  background: rgba(37, 99, 235, 0.06);
  color: var(--primary-600);
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.28rem;
  width: 46px;
  height: 46px;
  padding: 0.7rem 0.6rem;
  border: 1px solid var(--neutral-200);
  border-radius: 0.8rem;
  background: rgba(255,255,255,0.9);
  box-shadow: none;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.menu-toggle .bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--primary-600);
  border-radius: 999px;
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.menu-toggle.is-open .bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.menu-toggle.is-open .bar:nth-child(2) {
  opacity: 0;
}

.menu-toggle.is-open .bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

@media (max-width: 767px) {
  .site-header .nav-container,
  .site-header .container {
    min-height: 68px;
    width: min(var(--container-max), calc(100% - 1.25rem));
  }

  .menu-toggle {
    display: inline-flex;
    margin-left: auto;
    z-index: 3;
  }

  .nav-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    display: block;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid var(--neutral-200);
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
  }

  .nav-menu.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
  }

  .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    margin-left: 0;
  }

  .nav-list a,
  .nav-link {
    justify-content: flex-start;
    width: 100%;
    padding: 0.9rem 1rem;
  }
}

.hero-section {
  position: relative;
  padding: clamp(3.25rem, 6vw, 5.5rem) 0;
  background: linear-gradient(135deg, var(--primary-600) 0%, #7c3aed 100%);
  color: #fff;
  overflow: hidden;
}

.hero-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(255,255,255,0.18), transparent 42%);
}

.hero-section .container {
  position: relative;
  z-index: 1;
  text-align: center;
}

.hero-section h1,
.hero-section p {
  color: #fff;
}

.hero-section p {
  max-width: 42rem;
  margin-inline: auto;
  opacity: 0.94;
}

.search-wrapper {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  max-width: 38rem;
  margin: 2rem auto 0;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 1rem;
  padding: 0.55rem;
}

.search-input {
  flex: 1;
  background: rgba(255,255,255,0.96);
  border: none;
  border-radius: 0.8rem;
}

.search-btn {
  border: none;
  border-radius: 0.8rem;
  background: var(--accent-500);
  color: #fff;
  font-weight: 800;
  min-height: 44px;
  padding: 0.75rem 1.2rem;
}

.classes-section,
.subjects-section,
.chapters-section,
.solution-section,
.faq-section {
  padding: clamp(2.5rem, 5vw, 4rem) 0;
}

.classes-grid,
.subjects-grid,
.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--spacing-xl);
  margin-top: 2rem;
}

.class-card,
.subject-card,
.chapter-card,
.card,
.solution-box,
.math-box,
.code-block,
.note-box,
.faq-item {
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.35rem;
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
}

.class-card:hover,
.subject-card:hover,
.chapter-card:hover,
.card:hover,
.solution-box:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(37, 99, 235, 0.2);
}

.page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--neutral-200);
}

.breadcrumbs {
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}

.breadcrumbs ol {
  display: flex;
  align-items: center;
  list-style: none;
  gap: 0.5rem;
}

.breadcrumbs li {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: 0.5rem;
  color: var(--neutral-500);
}

.chapter-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 2rem;
}

.chapter-sidebar {
  position: sticky;
  top: 88px;
  align-self: start;
}

.toc-wrapper {
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.toc-list {
  list-style: none;
}

.toc-list a {
  display: block;
  min-height: 44px;
  padding: 0.7rem 0.8rem;
  border-radius: 0.7rem;
  color: var(--neutral-700);
}

.toc-list a:hover {
  background: rgba(37, 99, 235, 0.05);
  color: var(--primary-600);
}

.chapter-content {
  max-width: 54rem;
}

.chapter-content p,
.chapter-content li,
.solution-copy,
.note-box p {
  font-size: 1.02rem;
  line-height: 1.8;
}

.chapter-content h2,
.chapter-content h3,
.chapter-content h4 {
  margin-top: 2rem;
}

.chapter-content table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--neutral-200);
}

.chapter-content th,
.chapter-content td {
  padding: 0.75rem 0.8rem;
  border-bottom: 1px solid var(--neutral-200);
  text-align: left;
  vertical-align: top;
}

.chapter-content th {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: #fff;
}

.solution-box,
.math-box,
.code-block,
.note-box,
.faq-item {
  overflow-x: auto;
}

.math-box,
.code-block {
  background: #0f172a;
  color: #dbeafe;
  border-color: rgba(148, 163, 184, 0.25);
}

.table-responsive {
  overflow-x: auto;
  margin: 1.5rem 0;
}

.chapter-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--neutral-200);
}

.site-footer {
  background: linear-gradient(180deg, var(--neutral-900) 0%, #0f172a 100%);
  color: rgba(255,255,255,0.9);
  margin-top: clamp(2.5rem, 4vw, 4rem);
  padding: 3rem 0 1.5rem;
}

.site-footer .container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.site-footer p,
.site-footer a {
  color: rgba(255,255,255,0.82);
}

.back-to-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-500), var(--secondary-600));
  color: #fff;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (max-width: 1024px) {
  .chapter-layout {
    grid-template-columns: 1fr;
  }

  .chapter-sidebar {
    position: static;
  }
}

@media (max-width: 767px) {
  .nav {
    position: relative;
  }

  .navbar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-list {
    position: absolute;
    top: calc(100% + 0.7rem);
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    min-width: min(220px, 70vw);
    padding: 0.7rem;
    border: 1px solid var(--neutral-200);
    border-radius: 1rem;
    background: rgba(255,255,255,0.98);
    box-shadow: var(--shadow-lg);
  }

  .nav-list.mobile-open {
    display: flex;
  }

  .nav-list a {
    justify-content: flex-start;
    width: 100%;
  }

  .search-wrapper {
    flex-direction: column;
    padding: 0.8rem;
  }

  .search-input,
  .search-btn {
    width: 100%;
  }
}

@media (max-width: 479px) {
  .container {
    width: min(100% - 1rem, var(--container-max));
  }

  .class-card,
  .subject-card,
  .chapter-card,
  .card,
  .solution-box,
  .math-box,
  .code-block,
  .note-box,
  .faq-item {
    padding: 1rem;
  }
}

/* =====================================================================
 * NCERT Solutions - search results & accessibility (surgical additions)
 * ===================================================================== */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Search results panel - outside .hero-section so overflow:hidden does not clip results */
.search-results {
  max-width: calc(var(--container-max, 1200px) - 2rem);
  margin: 1rem auto 2rem;
  padding: 0 1rem;
  position: relative;
  z-index: 10;
  text-align: left;
}

.search-count {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--neutral-600);
  margin-bottom: 0.75rem;
}

.search-results-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.search-result-item:hover {
  border-color: var(--primary-500);
  box-shadow: var(--shadow-sm);
}

.search-result-item a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.search-result-title {
  font-weight: 600;
  color: var(--neutral-900);
  line-height: 1.4;
}

.search-result-meta {
  font-size: 0.85rem;
  color: var(--neutral-600);
  line-height: 1.4;
}

.search-result-tag {
  flex-shrink: 0;
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary-600);
  background: var(--primary-50);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  margin-top: 0.15rem;
}

.tag-subject {
  color: #0369a1;
  background: #e0f2fe;
}

.tag-chapter {
  color: #15803d;
  background: #dcfce7;
}

.search-result-item mark {
  background: #fef08a;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.search-no-results {
  font-size: 0.98rem;
  color: var(--neutral-700);
  background: var(--neutral-50);
  border: 1px dashed var(--neutral-300);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 9999;
  background: var(--primary-600);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 0.75rem 0;
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
}

/* Typography refinement: consistent focus ring on the hero search field */
.search-input:focus,
.search-btn:focus-visible {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

@media (max-width: 479px) {
  .search-result-item {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

