/* ===========================================================
   Nepal Budget 2083/84 — theme adapted from peptide.codekunda.com
   Warm "paper" palette · Manrope + Instrument Serif · terracotta accent
   =========================================================== */

:root {
  --bg: #f3efe8;
  --paper: #fbf8f3;
  --ink: #1a1815;
  --ink-soft: #6b665d;
  --line: #e3ddd1;
  --line-soft: #ece6da;
  --accent: #c8553d;
  --accent-dark: #a8412c;
  --accent-soft: #f4d9d0;
  --shadow: 0 8px 24px -16px rgba(200, 85, 61, 0.5);
  --shadow-lg: 0 18px 50px -30px rgba(26, 24, 21, 0.55);
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 88px; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

.serif {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(243, 239, 232, 0.82);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--ink); }
.brand .mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 17px;
  box-shadow: var(--shadow);
}
.brand small {
  display: block;
  font-weight: 500;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.nav-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-links a {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 8px;
  transition: background 120ms ease, color 120ms ease;
}
.nav-links a:hover { background: var(--paper); color: var(--ink); }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); }

/* ---------- Generic page container ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 64px 28px 110px; }

/* ---------- Hero ---------- */
.hero { padding: 86px 28px 40px; }
.hero-inner { max-width: var(--maxw); margin: 0 auto; }
.hero h1 {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(46px, 7.5vw, 86px);
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin: 18px 0 22px;
  max-width: 14ch;
}
.hero h1 .accent { color: var(--accent); }
.hero .lede {
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 620px;
  margin: 0 0 30px;
}
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.btn:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); color: var(--ink); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }

/* ---------- Stat strip ---------- */
.stats {
  max-width: var(--maxw);
  margin: 26px auto 0;
  padding: 0 28px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
}
.stat .num {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 34px;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 8px;
}
.stat .lbl { font-size: 13px; color: var(--ink-soft); line-height: 1.45; }

/* ---------- Section heading ---------- */
.section { max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }
.section-head {
  margin: 76px 0 22px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.section-head h2 {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-weight: 400;
  font-size: 30px;
  margin: 0;
}
.section-head .count {
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ---------- Card grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}
.card {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 24px 26px;
  color: var(--ink);
  transition: transform 130ms ease, border-color 130ms ease, box-shadow 130ms ease;
  position: relative;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); color: var(--ink); }
.card .tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 9px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.card h3 {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-weight: 400;
  font-size: 24px;
  margin: 0 0 8px;
  line-height: 1.15;
}
.card p { margin: 0 0 14px; color: var(--ink-soft); font-size: 14.5px; }
.card .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.card .chip {
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 9px;
}
.card .go {
  font-weight: 600; font-size: 14px; color: var(--accent);
  display: inline-flex; align-items: center; gap: 6px;
}
.card.feature { grid-column: span 1; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  margin-top: 90px;
}
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 40px 28px 70px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px 60px;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.footer a { color: var(--ink-soft); text-decoration: underline; text-decoration-color: var(--line); }
.footer a:hover { color: var(--accent); }
.footer h4 { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); margin: 0 0 10px; }
.footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }

/* ===========================================================
   READER
   =========================================================== */
.reader {
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 48px;
  padding: 30px 28px 120px;
}

/* sidebar / TOC */
.toc {
  position: sticky;
  top: 80px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 8px;
}
.toc .doc-switch { margin-bottom: 18px; }
.toc-title {
  font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 700; margin: 0 0 12px;
}
.toc-search {
  width: 100%;
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  margin-bottom: 14px;
}
.toc-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-list li { margin: 0; }
.toc-list a {
  display: block;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--ink-soft);
  padding: 6px 12px;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}
.toc-list a:hover { color: var(--ink); background: var(--paper); }
.toc-list a.lvl-3 { padding-left: 24px; font-size: 13px; }
.toc-list a.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.toc-list a.hidden { display: none; }

/* article */
.article-wrap { min-width: 0; }
.article-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}
.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--paper);
}
.lang-toggle button {
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.lang-toggle button.active { background: var(--accent); color: #fff; }
.crumb { font-size: 13px; color: var(--ink-soft); margin-bottom: 18px; }
.crumb a { color: var(--ink-soft); }
.crumb a:hover { color: var(--accent); }

/* progress bar */
.progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--accent); z-index: 60; transition: width 80ms linear;
}

/* ---------- Rendered markdown prose ---------- */
.prose { font-size: 16.5px; color: var(--ink); max-width: 760px; }
.prose > *:first-child { margin-top: 0; }
.prose h1 {
  font-family: 'Instrument Serif', serif;
  font-style: italic; font-weight: 400;
  font-size: clamp(34px, 5vw, 50px);
  line-height: 1.08;
  margin: 0 0 8px;
}
.prose h2 {
  font-family: 'Instrument Serif', serif;
  font-style: italic; font-weight: 400;
  font-size: 30px;
  margin: 56px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 90px;
}
.prose h3 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 38px 0 12px;
  scroll-margin-top: 90px;
}
.prose h4 { font-size: 16px; font-weight: 700; margin: 28px 0 10px; }
.prose p { margin: 0 0 18px; }
.prose strong { font-weight: 700; color: var(--ink); }
.prose em { font-style: italic; }
.prose a { text-decoration: underline; text-decoration-color: var(--accent-soft); }
.prose ul, .prose ol { margin: 0 0 18px; padding-left: 24px; }
.prose li { margin: 0 0 6px; }
.prose hr { border: none; border-top: 1px solid var(--line); margin: 40px 0; }
.prose code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.86em;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 4px;
}
.prose blockquote {
  margin: 24px 0;
  padding: 14px 20px;
  background: var(--paper);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  color: var(--ink-soft);
  font-size: 15px;
}
.prose blockquote p:last-child { margin-bottom: 0; }

/* anchor link on headings */
.prose h2, .prose h3 { position: relative; }
.anchor-link {
  position: absolute; left: -22px; top: 0;
  opacity: 0; color: var(--ink-soft);
  text-decoration: none; font-weight: 400;
  transition: opacity 120ms ease;
}
.prose h2:hover .anchor-link, .prose h3:hover .anchor-link { opacity: 0.6; }

/* tables (tariff schedules) */
.table-scroll { overflow-x: auto; margin: 0 0 22px; border: 1px solid var(--line); border-radius: 10px; }
.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13.5px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.prose thead th {
  background: var(--accent-soft);
  color: var(--accent-dark);
  text-align: left;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 9px 14px;
  position: sticky; top: 0;
}
.prose tbody td { padding: 7px 14px; border-top: 1px solid var(--line-soft); }
.prose tbody tr:nth-child(even) { background: var(--paper); }
.prose td:last-child, .prose th:last-child { text-align: right; }

/* back to top */
.to-top {
  position: fixed; right: 24px; bottom: 24px;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent); color: #fff;
  border: none; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  font-size: 18px;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { transform: translateY(-2px); }

.loading { color: var(--ink-soft); padding: 60px 0; font-size: 15px; }

/* mobile TOC toggle */
.toc-toggle { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 940px) {
  .reader { grid-template-columns: 1fr; gap: 0; }
  .toc {
    position: static; max-height: none; overflow: visible;
    margin-bottom: 24px; padding: 16px;
    background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  }
  .toc.collapsed .toc-body { display: none; }
  .toc-toggle {
    display: flex; width: 100%; align-items: center; justify-content: space-between;
    background: none; border: none; font-family: inherit; font-weight: 700;
    font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--ink-soft); cursor: pointer; padding: 0;
  }
  .prose { font-size: 16px; }
}
@media (max-width: 620px) {
  .nav-links a:not(.cta) { display: none; }
  .hero { padding: 60px 22px 30px; }
  .wrap, .section, .stats { padding-left: 20px; padding-right: 20px; }
  .topbar-inner { padding: 12px 20px; }
}
