/* ---------------------------------------------------------- Gemara page -- */
:root {
  --gemara-font: "Frank Ruhl Libre", "SBL Hebrew", "David Libre", "Times New Roman", serif;
  /* Drop a Rashi-script face (e.g. "Rashi", "Mekorot Rashi") first in this
     list if one is installed; it falls back to the square serif. */
  --rashi-font: "Rashi", "Mekorot Rashi", "Frank Ruhl Libre", "David Libre", serif;
  --rule: #8d7a55;
}

#reader { padding: 0; }
#daf { max-width: 1240px; margin: 0 auto; padding: 32px 40px 80px; color: var(--ink); }

.folio { margin-bottom: 56px; }
.folio-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline;
  font-family: var(--gemara-font); padding: 0 6px 6px;
  border-bottom: 2px solid var(--rule); margin-bottom: 14px;
}
.folio-head .tractate { font-size: 22px; letter-spacing: .04em; }
.folio-head .dafnum { font-size: 30px; font-weight: 700; }
.folio-head .right { text-align: right; }
.folio-head .left  { text-align: left; font-size: 13px; color: #6d5f45; font-family: var(--ui); direction: ltr; }

/* tzurat ha-daf: three columns, the Gemara wide in the middle. Rashi sits
   on the inner (binding) margin, Tosafot on the outer one -- so on amud a
   (a right-hand page, bound on its right) Rashi is to the RIGHT of the
   Gemara and Tosafot to the left; on amud b it flips. CSS grid "order"
   handles the swap (in an RTL grid, order 1 is the rightmost column). */
.tzurat {
  display: grid; gap: 0 22px; align-items: start;
  grid-template-columns: minmax(200px, 1fr) minmax(360px, 2.1fr) minmax(200px, 1fr);
}
.tzurat.side-a .col-rashi   { order: 1; }
.tzurat.side-a .col-gemara  { order: 2; }
.tzurat.side-a .col-tosafot { order: 3; }
.tzurat.side-b .col-rashi   { order: 3; }
.tzurat.side-b .col-gemara  { order: 2; }
.tzurat.side-b .col-tosafot { order: 1; }
.tzurat.no-rashi   { grid-template-columns: minmax(360px, 2.1fr) minmax(200px, 1fr); }
.tzurat.no-tosafot { grid-template-columns: minmax(200px, 1fr) minmax(360px, 2.1fr); }
.tzurat.no-rashi.no-tosafot { grid-template-columns: minmax(360px, 760px); justify-content: center; }
.tzurat.no-rashi .col-rashi, .tzurat.no-tosafot .col-tosafot { display: none; }

.col { font-family: var(--gemara-font); text-align: justify; }
.col-gemara { font-size: 23px; line-height: 1.75; }
.col-rashi, .col-tosafot {
  font-family: var(--rashi-font); font-size: 14.5px; line-height: 1.55; color: #2a2218;
  padding-top: 4px;
}
.col-head {
  font-family: var(--gemara-font); font-size: 13px; letter-spacing: .12em;
  text-align: center; color: #6d5f45; margin-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.seg { display: inline; }
.seg + .seg::before { content: " "; }
.seg big { font-size: 1.25em; }
.seg strong, .seg b { font-weight: 700; }
.word { cursor: pointer; border-radius: 3px; }
.word:hover { background: rgba(176, 141, 63, .22); }

/* commentary blocks: one per Gemara segment; the dibur ha-matchil bold */
.cm { display: inline; }
.cm + .cm::before { content: " "; }
.cm .dh { font-weight: 700; }
.cm img, .seg img { max-width: 100%; display: block; margin: 6px auto; }

/* hover linking: gemara segment <-> its commentary */
.seg.lit, .cm.lit { background: rgba(176, 141, 63, .22); }
.seg.pin, .cm.pin { background: rgba(163, 59, 31, .16); }

/* letters-only mode */
#daf.mode-letters .col-gemara { font-size: 22px; letter-spacing: .02em; line-height: 1.7; }

.hint { font-size: 11px; color: #8a7d64; margin-top: 6px; line-height: 1.4; }
.empty { font-family: var(--gemara-font); font-size: 18px; color: #6d5f45; text-align: center; padding: 60px 0; }

#inspOut .iword { font-family: var(--gemara-font); font-size: 26px; color: var(--accent-bright); direction: rtl; text-align: right; }
#inspOut .irow { display: flex; justify-content: space-between; font-size: 11px; color: #b3a78e; margin-top: 4px; }
#inspOut .ilet { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; direction: rtl; }
#inspOut .ilet span { font-family: var(--gemara-font); font-size: 18px; color: var(--panel-ink); background: #2e281e; border: 1px solid #463d2c; border-radius: 5px; padding: 1px 7px; }
#inspOut .ilet span small { display: block; font-family: var(--ui); font-size: 9px; color: #8a7d64; text-align: center; }

@media (max-width: 1100px) {
  .tzurat, .tzurat.no-rashi, .tzurat.no-tosafot { grid-template-columns: 1fr; gap: 18px; }
  .tzurat .col-gemara { order: 1 !important; }
  .tzurat .col-rashi { order: 2 !important; }
  .tzurat .col-tosafot { order: 3 !important; }
}

/* elucidation layers (Steinsaltz Hebrew / Davidson English) under each segment */
.col-gemara.eluc-on .seg { display: block; margin-bottom: 18px; }
.col-gemara.eluc-on .seg + .seg::before { content: none; }
.eluc { font-size: 15px; line-height: 1.5; color: #3a2f1c; margin: 6px 0 0; padding: 6px 10px; border-right: 3px solid #cdbf9e; text-align: justify; }
.eluc.english { font-family: var(--ui); font-size: 13.5px; border-right: none; border-left: 3px solid #cdbf9e; text-align: left; }
.eluc b, .eluc strong { font-weight: 700; }
.eluc i { font-style: italic; }

.mlink {
  font-family: var(--ui); font-size: 11px; letter-spacing: .06em; color: #7a6633; text-decoration: none;
  border: 1px solid #cdbf9e; border-radius: 10px; padding: 1px 8px; margin-left: 8px; vertical-align: middle; white-space: nowrap;
}
.mlink:hover { background: #e9dcc0; color: #5a4520; }
