/* Every home is a book (App\Support\Book): its posts as book pages cut by public/js/book.js, its home page as the
   book's contents. Type and measures follow «دانشنامهٔ دواوین»: IR Mitra for headings, Mtif Lotus for the text,
   pages cut at one fixed desktop measure (590px, 21px) so page numbers are the same on every screen. */

@font-face { font-family: IRMitra; src: url("/fonts/IRMitra.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: IRMitra; src: url("/fonts/IRMitra-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Mtif Lotus"; src: url("/fonts/MtifLotus-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Mtif Lotus"; src: url("/fonts/MtifLotus-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root { --font-book: IRMitra, serif; --font-prose: "Mtif Lotus", IRMitra, serif; --sheet-ink: #1f1f1f; --ground: #f6f5f2; }

/* ---------------------------------------------------------------- the home's own header, above its book */
.book-top { max-width: 1200px; margin: 1.2rem auto 0; padding: 0 1.25rem; }
/* Old headers: centred on the plain page at their own size (at most 240px high, never enlarged, never cropped).
   A header designed for the site (.is-wide, 2400×480): as wide as the page; on a phone only its middle half. */
.book-top .band { display: block; text-align: center; }
.book-top .band img { display: inline-block; vertical-align: top; width: auto; height: auto; max-width: 100%; max-height: 240px; }
.book-top .band.is-wide img { display: block; width: 100%; max-height: none; border-radius: 4px; }
.book-top .no-header { font-family: var(--font-book); font-weight: 700; font-size: 2.4rem; color: var(--maroon); text-align: center; padding: 1rem 0; border-bottom: 3px double var(--gold); }
@media (max-width: 640px) {
  .book-top .band.is-wide img { aspect-ratio: 5 / 2; object-fit: cover; object-position: center; }
}

/* ---------------------------------------------------------------- post: side column + pages */
.book-layout { display: grid; grid-template-columns: 270px 1fr; gap: 2.2rem; align-items: start; margin-top: 1.6rem; }
.book-main { min-width: 0; background: var(--ground); border-radius: 8px; padding: 26px 22px 30px; }
.book-side { font-size: .92rem; min-width: 0; }  /* an ordinary column: it does not scroll by itself or follow the page */
.side-portrait { display: block; text-align: center; margin-bottom: 1.2rem; }
.side-portrait img { display: block; width: 100%; aspect-ratio: 3/4; object-fit: contain; object-position: bottom; border-bottom: 1px solid var(--line); }
.side-portrait b { display: block; margin-top: .4rem; font-family: var(--font-book); font-size: 1.35rem; color: var(--maroon); }
.book-side h2 { font-family: var(--font-book); font-size: 1.15rem; color: var(--navy); margin: 1.4rem 0 .4rem; padding-bottom: .2rem; border-bottom: 2px solid var(--ink); }
.book-side h2:first-child { margin-top: 0; }
.book-side .where { font-family: var(--font-book); font-size: 1.05rem; line-height: 1.8; }
.book-side .where small { display: block; font-family: Vazirmatn, sans-serif; color: var(--muted); font-size: .8rem; }
.side-toc { list-style: none; margin: 0; padding: 0; }
.side-toc li { display: flex; gap: .4rem; align-items: baseline; padding: .18rem 0; line-height: 1.6; }
.side-toc li a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-book); font-size: 1rem; }
.side-toc li .n { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.side-toc li[aria-current] { background: #f3ece0; margin-inline: -.4rem; padding-inline: .4rem; border-radius: 3px; }
.side-toc li[aria-current] a { color: var(--maroon); font-weight: 700; }
.side-search { display: flex; border: 1px solid var(--line); border-radius: .4rem; overflow: hidden; background: #fff; }
.side-search input { flex: 1; min-width: 0; border: 0; padding: .4rem .7rem; font: inherit; }
.side-search button { border: 0; background: var(--maroon); color: #fff; padding: 0 .8rem; font: inherit; }
.side-years { display: flex; flex-wrap: wrap; gap: .3rem .7rem; }
.estimate-note { color: var(--muted); font-size: .78rem; margin-top: .3rem; }

/* the pages */
.book-sheet { background: #fff; border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 28px rgba(0,0,0,.05); padding: 44px 110px 40px; margin: 0 auto 26px; max-width: 830px; }
.book-sheet .running-header { display: flex; justify-content: space-between; gap: 16px; font-family: var(--font-book); font-weight: 700; font-size: 15px; line-height: 1.25; padding-bottom: 1px; border-bottom: 2.25px solid #111; white-space: pre-wrap; }
.book-sheet.is-even .running-header { flex-direction: row-reverse; }  /* the number on the outer edge, as in a Persian book */
.book-sheet.is-opening .running-header { visibility: hidden; }        /* a post's first page has no running header */
.book-flow, .book-body { display: flow-root; margin-top: 18px; font-family: var(--font-prose); font-size: 21px; line-height: 1.7; color: var(--sheet-ink); }
.book-body { min-height: var(--bk-h, 0); }
.book:not(.is-paged) .book-flow { max-width: 590px; margin-inline: auto; }  /* before (or without) the cutting */

.bk-p { margin: 0; text-align: justify; overflow-wrap: anywhere; }
.bk-cut { text-align-last: justify; }
.bk-p + .bk-p { text-indent: 1.2em; }
.bk-p.align-center { text-align: center; text-indent: 0; } .bk-p.align-left { text-align: left; text-indent: 0; }
.bk-gap { height: 1em; } .bk-gap--half { height: .5em; }
.bk-h { margin: 1.4em 0 .3em; font-family: var(--font-book); font-weight: 700; font-size: 1.05em; line-height: 1.6; }
.bk-h2 { font-size: 1.15em; text-align: center; }
/* A heading at the top of a page needs no space above it. */
.book-body > .bk-h:first-child { margin-top: 0; }
/* quotations: indented from the right, a little smaller, no first-line indent */
.book-flow, .book-body { --bk-q: 2.5cm; }  /* a quotation's indent */
.bk-quote { margin-inline-start: var(--bk-q); font-size: .9em; line-height: 1.55; color: #2e2a25; text-indent: 0 !important; }
.bk-quote + .bk-quote { margin-top: .25em; }
/* a short all-bold paragraph used as a heading («دوم.»): space above, kept with what follows */
.bk-p.bk-hb { margin-top: 1.4em; text-indent: 0; }
.book-body > .bk-hb:first-child { margin-top: 0; }
.bk-hb + .bk-p { text-indent: 0; }
/* the author's own abstract, above the text: indented from both sides, a little smaller */
.bk-abs { margin-inline: 2em; font-size: .92em; line-height: 1.85; color: #34302a; text-indent: 0 !important; }
.bk-box { margin-inline: 1.2em; padding: .1em .8em; background: #f7f3ea; font-size: .9em; text-indent: 0 !important; }
/* couplets as in Dawawin: each hemistich as wide as the poem's longest (public/js/poems.js sets --wem), 1.6em apart */
.bk-beyt { display: flex; width: fit-content; max-width: 100%; margin: 0 auto; align-items: baseline; gap: 1.6em; font-family: var(--font-book); font-size: 1.02em; line-height: 1.95; }
.bk-beyt .m { display: block; flex: none; width: calc(var(--wem, 12) * 1em); white-space: nowrap; text-align: justify; text-align-last: justify; }
.bk-beyt.is-stepped { flex-direction: column; align-items: stretch; gap: 0; width: calc(var(--wem, 12) * 1.25em); margin-bottom: .3em; }
.bk-beyt.is-stepped .m:last-child { align-self: flex-end; }
/* too wide even stepped (set by poems.js on the real page): hemistichs one under the other, unstretched and
   free to wrap, a blank line between couplets */
.bk-beyt.is-plain { display: block; width: auto; margin: 0 0 1.95em; }
.bk-beyt.is-plain .m { width: auto; white-space: normal; text-align: start; text-align-last: auto; }
/* headings, couplets, lists and pictures inside a quotation: in its indented column, centred there, not in the page.
   A couplet keeps margin auto and adds the indent as padding, so its text is centred in what is left of the line. */
.bk-h.bk-in-quote, .bk-li.bk-in-quote, .bk-block.bk-in-quote { margin-inline-start: var(--bk-q); }
.bk-beyt.bk-in-quote { box-sizing: content-box; padding-inline-start: var(--bk-q); max-width: calc(100% - var(--bk-q)); }
.bk-li { text-indent: 0 !important; padding-inline-start: 1.2em; } .bk-li__m { margin-inline-start: -1.2em; display: inline-block; width: 1.2em; }
.bk-rule { text-align: center; color: var(--gold); letter-spacing: .5em; margin: .4em 0; }
.bk-block { margin: .5em 0; } .bk-block figure { margin: 0; text-align: center; } .bk-block img { max-width: 100%; max-height: 520px; height: auto; }
/* the post's main picture, under the title: its width/height attributes keep its room before it loads */
.bk-photo { margin: .2em 0 1em; } .bk-photo img { max-width: 100%; max-height: none; height: auto; }
.bk-block figcaption { font-size: .8em; color: var(--muted); }
.bk-block table { border-collapse: collapse; margin: 0 auto; font-size: .85em; line-height: 1.5; } .bk-block td { border: 1px solid #ccc; padding: .2em .5em; }
/* the line above the notes (no heading: the line says it) */
.bk-notes { margin: .8em 0 .4em; border-top: 1px solid #bbb; width: 35%; }
.bk-date { text-align: left; text-indent: 0 !important; margin-top: .6em; font-family: var(--font-book); font-size: .82em; color: #5e5249; }
.bk-fn { font-size: .8em; line-height: 1.75; text-indent: 0 !important; }
.bk-fn .fn-back { font-weight: 700; color: var(--maroon); text-decoration: none; margin-inline-end: .2em; }
.book-flow sup.fn-ref { line-height: 0; font-size: .7em; } .book-flow sup.fn-ref a { color: var(--maroon); text-decoration: none; font-weight: 700; }
.book-flow a { color: inherit; text-decoration-color: rgba(42,22,12,.3); }
.book-flow .quran { color: var(--quran); } .book-flow span[lang=ar] { font-family: var(--font-prose); }
.book-flow .accent { color: var(--maroon); } .book-flow mark { background: #fff1b8; } .book-flow .large { font-size: 1.12em; }
.book-flow :target { background: #f5f5f5; }

/* a post's opening: its author's portrait, large, on the paper of its first page */
.bk-opening { text-align: center; padding: 4.8em 0 1.1em; }  /* a chapter's opening: the title well down the page */
.bk-opening .portrait { display: block; width: 230px; height: 300px; margin: 0 auto .4em; object-fit: contain; object-position: bottom; }
.bk-opening .home { font-family: Vazirmatn, sans-serif; font-size: 14px; color: var(--gold); font-weight: 700; letter-spacing: .02em; }
.bk-opening h1 { margin: .2em 0 .25em; font-family: var(--font-book); font-weight: 700; font-size: 34px; line-height: 1.5; color: #111; }
.bk-opening .by { font-family: var(--font-book); font-size: 20px; color: #4a3f36; text-align: left; margin-top: .3em; }  /* the author, at the left under the title */
.bk-opening .when { display: block; font-family: Vazirmatn, sans-serif; font-size: 13px; color: var(--muted); margin-top: .2em; }
.bk-opening::after { content: '❖'; display: block; color: var(--gold); font-size: 16px; margin-top: .7em; }

/* While book.js cuts the pages, every screen uses the desktop measure, so page numbers are the same everywhere. */
.book.bk-measure .book-body, .book.bk-measure .book-flow { width: 590px; font-size: 21px; line-height: 1.7; }

.after-book { max-width: 830px; margin: 0 auto; }
.post-summary { max-width: 830px; margin: 0 auto 1rem; background: #fbf8f1; border-inline-start: 3px solid var(--gold); border-radius: 4px; padding: .7rem 1.1rem; font-size: .98rem; line-height: 2; color: #3d3a33; }
.post-summary b { color: var(--navy); }
/* «همچنین بخوانید»: in the side column on a wide screen, after the text on a narrow one (the side column then comes last) */
.related ul { list-style: none; margin: 0; padding: 0; }
.related li { position: relative; padding: .35rem 0; padding-inline-start: 1rem; border-bottom: 1px dotted var(--line); line-height: 1.6; }
.related li::before { content: "●"; position: absolute; inset-inline-start: 0; top: .5rem; color: var(--maroon); font-size: .6rem; line-height: 1.6rem; }
.related li:last-child { border-bottom: 0; }
.related li a { font-family: var(--font-book); font-size: 1.02rem; }
.related li small { display: block; color: var(--muted); font-size: .8rem; }
.related-after { border-top: 3px double var(--gold); margin: 1.2rem 0; padding-top: .6rem; }
.related-after h2 { font-family: var(--font-book); font-size: 1.3rem; color: var(--maroon); margin: 0 0 .3rem; }
.related-after li a { font-size: 1.1rem; }
@media (min-width: 981px) { .related-after { display: none; } }
@media (max-width: 980px) { .related-side { display: none; } }
.post-tags { border-top: 3px double var(--gold); margin: 1.2rem 0; padding-top: .6rem; }
.post-tags h2 { font-family: var(--font-book); font-size: 1.3rem; color: var(--maroon); margin: 0 0 .5rem; }
.post-tags dl { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1rem; margin: 0; font-size: .92rem; }
.post-tags dt { color: var(--muted); font-weight: 700; white-space: nowrap; }
.post-tags dd { margin: 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.post-tags dd a, .post-tags dd span { border: 1px solid var(--line); border-radius: .3rem; padding: 0 .55rem; line-height: 1.9; }
.post-tags dd a { color: var(--navy); background: #fff; }
.post-tags dd a:hover { border-color: var(--maroon); color: var(--maroon); }
.post-tags dd span { color: #5b5348; border-style: dashed; }
@media (max-width: 640px) { .post-tags dl { grid-template-columns: 1fr; gap: .1rem; } .post-tags dd { margin-bottom: .5rem; } }
.cite { background: #fff; border: 1px solid var(--line); border-inline-start: 3px solid var(--gold); border-radius: 4px; padding: .8rem 1.1rem; font-size: .92rem; }
.cite b { font-family: var(--font-book); font-size: 1.05rem; color: var(--navy); }
.cite p { margin: .3rem 0 0; font-family: var(--font-prose); font-size: 1.08rem; line-height: 1.9; }

/* ---------------------------------------------------------------- a home's page: the book's contents */
.toc-head { display: grid; grid-template-columns: 200px 1fr; gap: 2rem; align-items: end; padding: 1.6rem 0 1.2rem; border-bottom: 1px solid var(--line); }
.toc-head .pic { aspect-ratio: 3/4; display: flex; align-items: flex-end; justify-content: center; }
.toc-head .pic.none { display: none; }
.toc-head:has(> .pic.none) { grid-template-columns: 1fr !important; }  /* no photo: nothing in its place, the title takes the width */
.toc-head .pic img { width: 100%; height: 100%; object-fit: contain; object-position: bottom; }
.toc-head h1 { font-family: var(--font-book); font-size: 2.4rem; color: var(--maroon); margin: 0; line-height: 1.4; }
.toc-head .facts { color: var(--muted); }
.toc-head .by { font-family: var(--font-book); font-weight: 700; font-size: 1.95rem; line-height: 1.4; color: #222; margin-top: .1rem; }  /* the author: a little smaller than the title */
.toc-head .role { color: var(--muted); font-size: .85rem; line-height: 1.6; margin-top: 0; }  /* the author's job, small, under the name */
.volumes { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.volumes a { border: 1px solid var(--line); border-radius: .3rem; padding: .1rem .8rem; font-family: var(--font-book); font-size: 1.05rem; }
.volumes a[aria-current] { background: var(--maroon); border-color: var(--maroon); color: #fff; }
.about-author { max-width: 830px; margin: 1.6rem auto 0; padding: 0 90px; font-family: var(--font-prose); font-size: 17px; line-height: 1.95; text-align: justify; }
.about-author h2 { font-family: var(--font-book); font-size: 1.3rem; color: var(--navy); margin: 0 0 .4rem; }
.about-author p { margin: 0 0 .6rem; }
/* a section of the site (no author): browse by writer or by journal; «نخست در» under a reprinted article */
.section-browse { max-width: 830px; margin: 1.2rem auto 0; padding: 0 90px; }
.section-browse h2 { font-family: var(--font-book); font-size: 1.1rem; color: var(--navy); margin: .8rem 0 .4rem; }
.section-browse .tags a[aria-current] { background: var(--navy); color: #fff; border-color: var(--navy); }
.section-browse .tags a[aria-current] small { color: #dde; }
.first-printed { font-family: var(--font-prose); font-size: 16px; line-height: 1.9; margin: 0 0 1rem; }
.attachments { margin: 0 0 1.2rem; font-family: var(--font-prose); }
.attachments h2 { font-family: var(--font-book); font-size: 1.15rem; color: var(--navy); margin: 0 0 .4rem; }
.attachments ul { list-style: none; margin: 0; padding: 0; }
.attachments li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; padding: .35rem 0; border-bottom: 1px solid var(--line); font-size: 16px; }
.attachments li a { display: inline-flex; align-items: center; gap: .6rem; }
.attachments img { width: 72px; height: 72px; object-fit: cover; border: 1px solid var(--line); border-radius: 3px; }
.attachments small { color: var(--muted); font-size: 13px; }
.pdf-pages { margin: 1.2rem 0 0; }
.pdf-pages header { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; margin: 0 0 .7rem; }
.pdf-pages h3 { font-family: var(--font-book); font-size: 1.05rem; color: var(--navy); margin: 0; }
.pdf-pages .muted { font-size: 13px; }
.pdf-get { margin-inline-start: auto; padding: .35rem .9rem; border-radius: 4px; background: var(--navy); color: #fff !important; text-decoration: none; font-size: 15px; }
.pdf-pages figure { margin: 0 0 .9rem; }
.pdf-pages img { display: block; width: 100%; height: auto; background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 6px rgba(0,0,0,.08); }
.pdf-pages figcaption { text-align: center; font-size: 13px; color: var(--muted); margin-top: .2rem; }
.pdf-more { text-align: center; font-size: 17px; }
.pdf-page { max-width: 900px; margin-block: 1.2rem 2rem; }
.contents { max-width: 830px; margin: 1.6rem auto 0; background: #fff; border-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 28px rgba(0,0,0,.05); padding: 44px 90px 50px; }
.contents h2 { text-align: center; font-family: var(--font-book); font-size: 30px; margin: 0 0 .8em; }
.contents .vol { text-align: center; font-family: var(--font-book); font-size: 20px; color: var(--muted); margin: -.6em 0 1em; }
.bk-toc { display: flex; align-items: baseline; gap: 6px; margin: .55em 0 0; font-family: var(--font-book); font-weight: 700; font-size: 19px; line-height: 1.6; }
.bk-toc a { text-decoration: none; } .bk-toc a:hover { text-decoration: underline; }
.bk-toc__dots { flex: 1; min-width: 1.5em; border-bottom: 1.5px dotted #9a8f84; transform: translateY(-.3em); }
.bk-toc__n { font-weight: 400; white-space: nowrap; }
.bk-toc__date { font-family: Vazirmatn, sans-serif; font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.bk-toc__by { font-size: 14px; font-weight: 400; color: var(--navy, #2d3a5a); }  /* the post's own author, in a home of several */
.bk-toc__teaser { padding-inline-start: 1em; font-family: var(--font-prose); font-size: 16.5px; line-height: 1.85; color: #5e5249; text-align: justify; }

@media (max-width: 980px) {
  .book-layout { grid-template-columns: 1fr; }
  .book-side { order: 2; }
}
@media (max-width: 640px) {
  .book-main { padding: 10px 4px 20px; margin-inline: -1rem; border-radius: 0; }
  .book-sheet { padding: 22px 18px 24px; }
  .book-flow, .book-body { font-size: 18.5px; }
  /* only after the cutting (not .bk-measure), so the page count is the same as on a desktop */
  .book:not(.bk-measure) .bk-opening .portrait { width: 170px; height: 225px; } .book:not(.bk-measure) .bk-opening h1 { font-size: 26px; }
  .book:not(.bk-measure) .book-flow, .book:not(.bk-measure) .book-body { --bk-q: 1.2cm; }
  .toc-head { grid-template-columns: 120px 1fr; gap: 1rem; } .toc-head h1 { font-size: 1.7rem; } .toc-head .by { font-size: 1.4rem; }
  .about-author, .section-browse { padding: 0; }
  .pdf-pages img { border-inline: 0; } .pdf-pages figure { margin-inline: -1rem; }
  .contents { padding: 22px 16px 30px; margin-inline: -1rem; border-radius: 0; }
  .bk-toc { font-size: 17px; } .bk-toc__date { display: none; } .bk-toc__teaser { font-size: 15px; }
}
@media print {
  .book-side, .book-top, .related { display: none; } .book-layout { display: block; } .book-main { background: none; padding: 0; }
  .book-sheet { box-shadow: none; page-break-after: always; margin: 0; }
}
