@font-face {
  font-family: Vazirmatn;
  src: url("fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4efe6;
  --bg-accent: #ece4d6;
  --paper: #fffcf7;
  --ink: #1d1914;
  --muted: #5d564c;
  --line: #ddd4c6;
  --accent: #0f4f4c;
  --accent-soft: #e4f0ee;
  --accent-hover: #0a3b39;
  --link: #0f4f4c;
  --shadow: 0 1px 2px rgba(29, 25, 20, 0.06), 0 8px 24px rgba(29, 25, 20, 0.06);
  --sidebar-w: 17.5rem;
  --font: Vazirmatn, Tahoma, "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.9;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--link);
  text-underline-offset: 0.18em;
}
a:hover { color: var(--accent-hover); }

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  flex: 1;
}
.brand:hover { color: var(--accent); }

.updated {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
  align-items: center;
  gap: 0.45rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
}

.menu-toggle-icon,
.menu-toggle-icon::before,
.menu-toggle-icon::after {
  display: block;
  width: 1rem;
  height: 2px;
  background: var(--ink);
  border-radius: 1px;
  position: relative;
}
.menu-toggle-icon::before,
.menu-toggle-icon::after {
  content: "";
  position: absolute;
}
.menu-toggle-icon::before { top: -5px; }
.menu-toggle-icon::after { top: 5px; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  max-width: 78rem;
  width: 100%;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 3.4rem;
  align-self: start;
  height: calc(100vh - 3.4rem);
  overflow: auto;
  padding: 1.5rem 0.75rem 2rem 1rem;
  border-left: 1px solid var(--line);
  background: transparent;
}

.nav-heading {
  margin: 0 0.75rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.sidebar ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar a {
  display: block;
  text-decoration: none;
  color: var(--ink);
  padding: 0.35rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
}
.sidebar a:hover {
  background: var(--bg-accent);
}
.sidebar a.is-active {
  background: var(--accent);
  color: #f7fffe;
  font-weight: 500;
}

.main {
  padding: 2rem 1.75rem 4rem;
}

.article {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 2rem 2.1rem 2.4rem;
  max-width: 52rem;
}

.article h1 {
  margin: 0 0 1rem;
  font-size: 1.7rem;
  line-height: 1.5;
  font-weight: 700;
  color: var(--accent);
}

.article h2 {
  margin: 2rem 0 0.7rem;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.6;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--line);
}

.article h3 {
  margin: 1.4rem 0 0.5rem;
  font-size: 1.02rem;
  font-weight: 700;
}

.article p { margin: 0.7rem 0; }

.article em {
  color: var(--muted);
  font-style: italic;
}

.article ul,
.article ol {
  margin: 0.5rem 0 1rem;
  padding-right: 1.25rem;
  padding-left: 0;
}

.article li { margin: 0.25rem 0; }

.article li::marker { color: var(--accent); }

.article strong { font-weight: 700; }

.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.4rem;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}

.article th,
.article td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.7rem;
  text-align: right;
  vertical-align: top;
  background: var(--paper);
}

.article thead th,
.article tr:first-child th,
.article table tr:first-child td {
  background: var(--accent-soft);
  font-weight: 700;
  color: var(--accent-hover);
}

.article tr:first-child td { font-weight: 700; }

.footer {
  border-top: 1px solid var(--line);
  padding: 1rem 1.5rem 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
.footer p { margin: 0; }

.backdrop {
  display: none;
}

@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  .updated { display: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(20rem, 86vw);
    height: 100%;
    z-index: 30;
    background: var(--paper);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateX(110%);
    transition: transform 0.2s ease;
    padding-top: 4.5rem;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(29, 25, 20, 0.35);
    z-index: 25;
  }
  .backdrop[hidden] { display: none; }
  .main { padding: 1rem 0.85rem 3rem; }
  .article { padding: 1.3rem 1.1rem 1.8rem; border-radius: 0.75rem; }
  .article h1 { font-size: 1.4rem; }
}

@media print {
  .sidebar, .menu-toggle, .backdrop { display: none !important; }
  .layout { display: block; }
  .topbar { position: static; background: none; }
  .article { box-shadow: none; border: none; padding: 0; }
}
