@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-SemiBold.woff2") format("woff2");
  font-weight: 600;
  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: #e4dccf;
  --sheet: #fbf6ee;
  --ink: #241c16;
  --muted: #6d6256;
  --faint: #8a7d6e;
  --line: #e3d8c8;
  --rule: #c4b5a2;
  --accent: #7c3428;
  --green: #1d463d;
  --chip: #efe6d8;
  --shadow: 0 18px 50px rgba(60, 40, 20, 0.12);
  --nav: rgba(251, 246, 238, 0.9);
  --verse: #3d4f3a;
  --select: #ead3b4;
  color-scheme: light;
}

:root[data-theme="night"] {
  --bg: #12100e;
  --sheet: #1c1814;
  --ink: #f0e7d8;
  --muted: #b5a898;
  --faint: #8d8173;
  --line: #322c26;
  --rule: #4a4036;
  --accent: #e0a090;
  --green: #d7c4a4;
  --chip: #2a241e;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --nav: rgba(28, 24, 20, 0.92);
  --verse: #d5c7a4;
  --select: #4a3428;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse at top, rgba(255, 250, 242, 0.45), transparent 42%),
    var(--bg);
  color: var(--ink);
  font-family: Vazirmatn, "Noto Naskh Arabic", serif;
  font-size: 19px;
  line-height: 2.05;
  font-weight: 400;
}

:root[data-theme="night"] body {
  background:
    radial-gradient(ellipse at top, rgba(80, 60, 40, 0.18), transparent 46%),
    var(--bg);
}

::selection { background: var(--select); }

button, input, select {
  font-family: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  background: var(--nav);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

a.brand {
  color: inherit;
  text-decoration: none;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
  min-width: 0;
}

.brand strong {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.brand span {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.sitenav {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.sitenav a {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.6;
}

.sitenav a[aria-current="page"] {
  border-color: var(--rule);
  background: var(--chip);
}

.sitenav a:hover { background: var(--chip); }

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.doors {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.door {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 18px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  color: inherit;
  text-decoration: none;
}

.door strong {
  font-size: 20px;
  line-height: 1.5;
  color: var(--green);
}

.door span {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.door:hover { background: var(--chip); }

.catalog {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.entry {
  display: block;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  color: inherit;
  text-decoration: none;
}

.entry h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.6;
  color: var(--green);
}

.entry p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.entry:hover { background: var(--chip); }

.layout:has(.board) {
  width: min(1280px, calc(100% - 32px));
}

.sheet.board-sheet {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding-inline: 0;
}

.feed.board {
  columns: 5 210px;
  column-gap: 16px;
}

.feed.board .empty {
  column-span: all;
}

.feed-sentinel {
  height: 1px;
}

.note {
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin: 0 0 16px;
  padding: 0 0 12px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.note h2 {
  margin: 0;
  padding: 8px 12px 0;
  font-size: 16px;
  line-height: 1.55;
}

.note time {
  display: block;
  color: var(--faint);
  font-size: 12px;
  padding: 10px 12px 0;
}

.note .lede {
  margin: 0;
  padding: 4px 12px 0;
  font-size: 13px;
  line-height: 1.6;
}

.note .lede a {
  color: var(--accent);
}

.note p {
  margin: 0;
  padding: 8px 12px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14.5px;
  line-height: 1.75;
}

.pin-media {
  display: grid;
  gap: 2px;
  background: #16130f;
}

.pin-media.n1 img,
.pin-media.n1 video {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  background: #16130f;
}

.pin-media.multi {
  grid-template-columns: 1fr 1fr;
}

.pin-media.multi .pin-slot {
  aspect-ratio: 1;
  overflow: hidden;
}

.pin-media.multi .pin-slot img,
.pin-media.multi .pin-slot video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pin-media.multi .pin-slot.video {
  aspect-ratio: auto;
  grid-column: 1 / -1;
  overflow: visible;
}

.pin-media.multi .pin-slot.video video {
  height: auto;
  object-fit: contain;
}

.empty {
  color: var(--muted);
  line-height: 1.9;
}

.lede {
  color: var(--muted);
  font-size: 16px;
  margin: 0 0 1.4em;
}

.source {
  display: block;
  margin-top: 8px;
  font-size: 14px;
}

.source a { color: var(--accent); }

.topbar .spacer { flex: 1; }

.ghost {
  appearance: none;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.ghost:hover { background: var(--chip); }

.progress {
  position: sticky;
  top: 57px;
  z-index: 19;
  height: 3px;
  background: transparent;
}

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.layout {
  width: min(960px, calc(100% - 48px));
  margin: 32px auto 80px;
}

.layout:has(> .toc) {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 28px;
  width: min(1120px, calc(100% - 48px));
  align-items: start;
}

.toc {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding: 18px 16px 16px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.toc h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.toc a {
  display: block;
  color: var(--ink);
  text-decoration: none;
  font-size: 14.5px;
  line-height: 1.55;
  padding: 6px 8px;
  border-radius: 8px;
}

.toc a small {
  display: block;
  color: var(--faint);
  font-size: 11.5px;
}

.toc a:hover,
.toc a.active { background: var(--chip); }

.sheet {
  background: var(--sheet);
  border-radius: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 54px 64px 72px;
}

.masthead {
  text-align: center;
  margin-bottom: 42px;
}

.ornament {
  width: 74px;
  height: 14px;
  margin: 0 auto 18px;
  background:
    linear-gradient(var(--accent), var(--accent)) center / 46px 1px no-repeat,
    linear-gradient(var(--accent), var(--accent)) center / 1px 14px no-repeat;
}

.masthead h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--green);
}

.masthead p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.page {
  scroll-margin-top: 84px;
  padding-top: 8px;
}

.page-mark {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 38px 0 18px;
  color: var(--faint);
  font-size: 13px;
  font-weight: 600;
}

.page-mark::before,
.page-mark::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.page h2 {
  margin: 22px 0 8px;
  font-size: 26px;
  line-height: 1.6;
  font-weight: 700;
  color: var(--green);
}

.page h3 {
  margin: 18px 0 6px;
  font-size: 21px;
  line-height: 1.7;
  font-weight: 600;
  color: var(--accent);
}

.page p,
.page h2,
.page h3,
.masthead h1,
.lede,
.toc a {
  overflow-wrap: anywhere;
}

.page p {
  margin: 0 0 0.85em;
  text-align: justify;
}

.page ul {
  margin: 0.2em 0 1em;
  padding: 0 1.2em 0 0;
}

.page li { margin: 0.25em 0; }

.verse {
  margin: 1.15em auto 1.3em;
  max-width: 34em;
  text-align: center;
  color: var(--verse);
  font-weight: 500;
  line-height: 1.95;
}

.verse span {
  display: block;
}

.footnotes {
  margin-top: 22px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.85;
}

.footnotes p { margin: 0.35em 0; text-align: right; }

.fn-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  margin-bottom: 4px !important;
}

footer.colophon {
  width: min(1180px, calc(100% - 36px));
  margin: -48px auto 40px;
  color: var(--faint);
  font-size: 13px;
  text-align: center;
}

.toc-toggle { display: none; }

@media (max-width: 1100px) {
  body { font-size: 17px; }
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "nav nav";
    align-items: center;
    gap: 8px 10px;
    padding: 12px 18px;
  }
  .brand { grid-area: brand; }
  .brand strong { font-size: 15px; }
  .sitenav { grid-area: nav; }
  .top-actions { grid-area: actions; }
  .topbar .spacer { display: none; }
  .toc-toggle { display: inline-flex; padding: 6px 12px; }
  [data-theme-toggle] { padding: 6px 12px; }
  .doors { grid-template-columns: 1fr; }
  .progress { position: static; }
  .layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0 0 40px;
    gap: 0;
  }
  .sheet,
  .toc {
    width: 100%;
    min-width: 0;
    border-radius: 0;
    border-inline: 0;
    box-shadow: none;
  }
  .sheet { padding: 22px 18px 40px; }
  .masthead { margin-bottom: 22px; text-align: start; }
  .masthead h1 { font-size: 24px; }
  .ornament { margin-inline: 0; }
  .toc {
    display: block;
    position: relative;
    top: auto;
    height: auto;
    max-height: 38vh;
    overflow: auto;
    order: -1;
    scroll-margin-top: 12px;
    flex: 0 0 auto;
    padding: 14px 18px;
  }
  .toc a { padding-inline: 0; }
  footer.colophon { width: 100%; margin: 8px 0 28px; padding-inline: 18px; }
  .layout:has(.board) { width: 100%; }
  .feed.board { columns: 2 150px; column-gap: 10px; }
  .note { margin-bottom: 10px; border-radius: 14px; }
}

@media print {
  .topbar, .progress, .toc, .toc-toggle, footer.colophon { display: none !important; }
  body { background: white; }
  .layout { display: block; width: auto; margin: 0; }
  .sheet { box-shadow: none; border: 0; }
}
