/* UGC NET Statistics Study Material - Shared Stylesheet */

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

:root {
  --primary: #1e3a8a;
  --primary-light: #3b82f6;
  --accent: #f59e0b;
  --success: #10b981;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --code-bg: #f1f5f9;
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
}

/* HEADER */
.site-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.site-header h1 { font-size: 2.2rem; margin-bottom: 0.5rem; }
.site-header p { font-size: 1.05rem; opacity: 0.95; }
.site-header .badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* NAV */
.topnav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}
.topnav a {
  text-decoration: none;
  color: var(--primary);
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}
.topnav a:hover { background: var(--primary); color: #fff; }
.topnav a.home { background: var(--accent); color: #fff; }

/* LAYOUT */
.container {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* UNIT CARDS (Index) */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}
.unit-card {
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--primary-light);
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.unit-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  border-left-color: var(--accent);
}
.unit-card .unit-number {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 1px;
}
.unit-card h3 { color: var(--primary); margin: 0.4rem 0 0.6rem; font-size: 1.2rem; }
.unit-card p { color: var(--muted); font-size: 0.92rem; }

/* CONTENT */
section.unit-content {
  background: var(--card);
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}
h2 {
  color: var(--primary);
  border-bottom: 3px solid var(--primary-light);
  padding-bottom: 0.5rem;
  margin: 2rem 0 1rem;
  font-size: 1.7rem;
}
h2:first-child { margin-top: 0; }
h3 {
  color: var(--primary-light);
  margin: 1.5rem 0 0.7rem;
  font-size: 1.3rem;
}
h4 { color: var(--text); margin: 1.2rem 0 0.5rem; font-size: 1.1rem; }

p { margin-bottom: 0.9rem; }

ul, ol { margin: 0.5rem 0 1rem 1.7rem; }
li { margin-bottom: 0.35rem; }

/* DEFINITION BOX */
.definition {
  background: #eef2ff;
  border-left: 5px solid var(--primary);
  padding: 1rem 1.2rem;
  margin: 1rem 0;
  border-radius: 0 8px 8px 0;
}
.definition strong { color: var(--primary); }

/* THEOREM BOX */
.theorem {
  background: #fef3c7;
  border-left: 5px solid var(--accent);
  padding: 1rem 1.2rem;
  margin: 1rem 0;
  border-radius: 0 8px 8px 0;
}
.theorem strong { color: #92400e; }

/* EXAMPLE BOX */
.example {
  background: #ecfdf5;
  border-left: 5px solid var(--success);
  padding: 1rem 1.2rem;
  margin: 1rem 0;
  border-radius: 0 8px 8px 0;
}
.example strong { color: #065f46; }
.example .ex-label {
  display: inline-block;
  background: var(--success);
  color: #fff;
  font-size: 0.78rem;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  font-weight: 700;
  margin-bottom: 0.4rem;
  letter-spacing: 0.5px;
}

/* NOTE BOX */
.note {
  background: #fef2f2;
  border-left: 5px solid #ef4444;
  padding: 1rem 1.2rem;
  margin: 1rem 0;
  border-radius: 0 8px 8px 0;
  font-size: 0.95rem;
}
.note strong { color: #991b1b; }

/* CODE / FORMULA */
code {
  background: var(--code-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.92em;
  color: #be123c;
}
pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
}
pre code { background: transparent; color: inherit; padding: 0; }

/* TABLE */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border-radius: 6px;
  overflow: hidden;
}
th, td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
tr:nth-child(even) { background: #f8fafc; }
tr:hover { background: #eef2ff; }

/* TOC */
.toc {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  margin-bottom: 2rem;
}
.toc h4 { margin-top: 0; color: var(--primary); }
.toc ul { margin-left: 1.2rem; }
.toc a { color: var(--primary-light); text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* ---------- Topics Covered chips ---------- */
/* Copied from the subject stylesheet so a chip looks the same in every
   section. This sheet is standalone -- not one of the 23 byte-identical
   copies -- so the md5 invariant those carry is unaffected. */
.chips { margin: 12px 0 24px; }
.chip {
  display: inline-block;
  background: #e6f1fb;
  color: #0f4c81;
  padding: 4px 12px;
  border-radius: 14px;
  margin: 4px 4px 4px 0;
  font-size: 0.85rem;
  font-weight: 500;
}

/* FOOTER */
.site-footer {
  background: #0f172a;
  color: #cbd5e1;
  padding: 2rem 1.5rem;
  text-align: center;
  margin-top: 3rem;
  font-size: 0.92rem;
}
.site-footer a { color: var(--accent); text-decoration: none; }

/* PAGINATION */
.pagination {
  display: flex;
  justify-content: space-between;
  margin: 2rem 0;
  gap: 1rem;
}
.pagination a {
  flex: 1;
  background: var(--card);
  padding: 1rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--primary);
  border: 1px solid var(--border);
  font-weight: 600;
  transition: all 0.2s;
}
.pagination a:hover { background: var(--primary); color: #fff; }
.pagination .next { text-align: right; }

/* MathJax sizing */
mjx-container { font-size: 1.05em !important; }

/* Responsive */
@media (max-width: 600px) {
  /* A wide table must scroll inside itself rather than widen the page.
     Without this the table pushes the whole document sideways on a phone and
     the code chips in its cells are cut off at the screen edge. */
  table { display: block; max-width: 100%; overflow-x: auto; }
  /* A long file path or command in running text is one unbreakable word; it
     drags the paragraph, and the page with it, past the screen edge. break-word
     (not anywhere) lets it wrap without shrinking a table's columns. */
  code { overflow-wrap: break-word; }
  pre code { overflow-wrap: normal; }
  /* Same for prose: a run of dot leaders, or a sum written out term by term,
     is one word as far as the line-breaker is concerned. This only affects a
     word that cannot fit; ordinary text wraps exactly as before. */
  p, li, td, th, h1, h2, h3, h4 { overflow-wrap: break-word; }
  /* Display math is typeset at its natural width, so it scrolls in its own box
     rather than widening the page. */
  mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; max-width: 100%; }
  .site-header h1 { font-size: 1.6rem; }
  section.unit-content { padding: 1.5rem; }
  h2 { font-size: 1.4rem; }
  .topnav { padding: 0.5rem; }
  .topnav a { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
}

/* DIAGRAMS / FIGURES */
.diagram {
  margin: 1.5rem 0;
  padding: 1rem 1rem 0.6rem;
  background: #fbfdff;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.diagram svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.diagram .cap { color: var(--muted); font-size: 0.86rem; margin-top: 0.5rem; text-align: center; }
.diagram .cap strong { color: var(--primary); }

/* REAL-WORLD USES BOX */
.realworld {
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-left: 5px solid var(--primary-light);
  border-radius: 0 8px 8px 0;
  padding: 0.8rem 1.1rem;
  margin: 1.3rem 0 0.6rem;
}
.realworld h4 { margin: 0 0 0.4rem; color: var(--primary); font-size: 1rem; }
.realworld ol { margin: 0 0 0 1.3rem; }
.realworld li { margin-bottom: 0.2rem; font-size: 0.93rem; color: var(--text); }

/* HOME PAGE COLOUR-GUIDE LEGEND */
.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.legend-grid > div { margin: 0; }
.legend-grid .realworld h4 { margin: 0 0 0.25rem; }
