@font-face { font-family: "Frank Ruhl Libre"; src: url("/fonts/FrankRuhlLibre.ttf") format("truetype"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "Noto Rashi Hebrew"; src: url("/fonts/NotoRashiHebrew.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }

:root {
  --paper: #fdfaf4;
  --card: #f6f0e4;
  --ink: #211f1c;
  --soft: #736b61;
  --rule: #e4dccb;
  --hl: #fce39e;
  --hl-ink: #211f1c;
  --accent: #8a5a1f;
  --shadow: 0 -6px 24px rgba(60, 45, 20, 0.10);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1915; --card: #25221d; --ink: #ece6da; --soft: #a59c8e; --rule: #3a352d;
    --hl: #6b5520; --hl-ink: #fff6dd; --accent: #e0b36a; --shadow: 0 -6px 24px rgba(0,0,0,.45); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1b1915; --card: #25221d; --ink: #ece6da; --soft: #a59c8e; --rule: #3a352d;
  --hl: #6b5520; --hl-ink: #fff6dd; --accent: #e0b36a; --shadow: 0 -6px 24px rgba(0,0,0,.45); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.5 "Iowan Old Style", "Palatino", Georgia, serif;
}
a { color: var(--accent); }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.he { font-family: "Frank Ruhl Libre", "Times New Roman", serif; direction: rtl; }
.rashi { font-family: "Noto Rashi Hebrew", "Frank Ruhl Libre", serif; direction: rtl; }

/* Masthead */
.mast { padding: 28px 0 18px; border-bottom: 1px solid var(--rule); text-align: center; }
.mast .he-title { font-family: "Frank Ruhl Libre", serif; font-size: 40px; font-weight: 700; line-height: 1.1; margin: 0; }
.mast .en-title { font-size: 15px; letter-spacing: .14em; text-transform: uppercase; color: var(--soft); margin: 6px 0 0; }
.mast .rabbi { font-size: 19px; margin: 10px 0 0; }
.mast .ornament { color: var(--accent); letter-spacing: .5em; font-size: 12px; margin-top: 12px; }

/* Home */
h2.section { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--soft); font-weight: 600; margin: 28px 0 10px; }
.latest { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 16px 18px; }
.latest .daf-he { white-space: nowrap; font-family: "Frank Ruhl Libre", serif; font-size: 30px; font-weight: 700; direction: rtl; text-align: right; }
.latest .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.latest .play { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--accent); font-weight: 600; }
.daf { border-bottom: 1px solid var(--rule); padding: 12px 0; }
.daf-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.daf-head .en { font-weight: 600; }
.daf-head .he { font-size: 22px; font-weight: 700; }
.classes { list-style: none; margin: 6px 0 0; padding: 0; }
.classes a { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; text-decoration: none; color: var(--ink); }
.classes a:active { background: var(--card); }
.meta { color: var(--soft); font-size: 15px; white-space: nowrap; }
.empty { color: var(--soft); text-align: center; padding: 40px 0; }

/* Footer credits */
footer.credits { color: var(--soft); font-size: 13px; line-height: 1.5; padding-top: 28px; padding-bottom: 40px; border-top: 1px solid var(--rule); margin-top: 32px; }
footer.credits p { margin: 0 0 6px; }

/* Class page */
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; height: 52px; }
.topbar .back { text-decoration: none; font-size: 15px; white-space: nowrap; }
.topbar .t { flex: 1; min-width: 0; text-align: center; }
.topbar .t b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .t span { font-size: 12px; color: var(--soft); }
.topbar .spacer { width: 52px; }

.amud-head { text-align: center; margin: 26px 0 8px; }
.amud-head .he { font-size: 26px; font-weight: 700; }
.amud-head .en { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); }
.daftext { font-size: 23px; line-height: 2.0; text-align: justify; }
.daftext .line { margin: 0 0 4px; }
.ph { border-radius: 5px; padding: 1px 2px; cursor: pointer; transition: background-color .25s ease, color .25s ease; -webkit-tap-highlight-color: transparent; }
.ph.on { background: var(--hl); color: var(--hl-ink); box-shadow: 0 0 0 2px var(--hl); }
.ph.done { color: color-mix(in srgb, var(--ink) 78%, transparent); }
.line.lit { background: linear-gradient(to left, color-mix(in srgb, var(--hl) 22%, transparent), transparent 80%); border-radius: 6px; }
.unaligned { color: var(--soft); font-size: 15px; text-align: center; margin: 8px 0; }

/* The panel at the bottom: what is said now, then the player */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--paper); box-shadow: var(--shadow);
  border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom); }
.dock .wrap { padding-top: 10px; padding-bottom: 10px; }
.now { max-height: 30vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.now .tabs { display: flex; gap: 6px; margin-bottom: 6px; }
.now .tabs button { font: inherit; font-size: 13px; border: 1px solid var(--rule); background: transparent; color: var(--soft); border-radius: 99px; padding: 3px 12px; cursor: pointer; }
.now .tabs button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.now .where { font-size: 12px; color: var(--soft); margin-left: auto; align-self: center; }
.now .en { font-size: 16px; line-height: 1.45; }
.now .en b { font-weight: 700; }
.now .rashi-list { font-size: 17px; line-height: 1.6; text-align: justify; }
.now .rashi-list p { margin: 0 0 6px; }
.now .rashi-list b { font-weight: 700; }
.now .none { color: var(--soft); font-size: 14px; }

.player { display: grid; grid-template-columns: auto auto auto 1fr auto; align-items: center; gap: 10px; margin-top: 8px; }
.player button { font: inherit; border: 0; background: transparent; color: var(--ink); cursor: pointer; padding: 6px; border-radius: 99px; line-height: 0; }
.player .pp { background: var(--ink); color: var(--paper); width: 46px; height: 46px; display: grid; place-items: center; }
.player .skip { font-size: 12px; position: relative; }
.player .speed { font-size: 14px; line-height: 1; border: 1px solid var(--rule); padding: 6px 9px; min-width: 52px; }
.scrub { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.scrub input { width: 100%; accent-color: var(--accent); margin: 0; }
.scrub .times { display: flex; justify-content: space-between; font-size: 12px; color: var(--soft); font-variant-numeric: tabular-nums; }
.padbottom { height: 46vh; }

/* ---- Class page views: Gemara, Translation, Both ---- */
[hidden] { display: none !important; }
.viewbar { display: flex; justify-content: center; padding: 0 16px 8px; }
.seg3 { display: inline-flex; background: var(--card); border: 1px solid var(--rule); border-radius: 99px; padding: 3px; gap: 2px; }
.seg3 button { font: inherit; font-size: 14px; font-weight: 600; border: 0; background: transparent; color: var(--soft); border-radius: 99px; padding: 6px 16px; min-height: 34px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.seg3 button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.dock .licence { font-size: 11px; line-height: 1.3; color: var(--soft); text-align: center; margin-top: 4px; }

/* Gemara: the daf page in a pan and zoom box between the top bar and the dock */
html.in-gemara, html.in-gemara body { overflow: hidden; height: 100%; overscroll-behavior: none; }
#v-gemara { position: fixed; left: 0; right: 0; top: var(--top-h, 96px); bottom: var(--dock-h, 110px); }
.dafscroll { position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; overscroll-behavior: contain; background: #fff; }
.dafsizer { position: relative; overflow: hidden; }
.dafpages { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.dafcredits { padding: 16px; margin: 0; color: #6b6b6b; border-top: 1px solid #e6e6e6; }
.sheet { display: flex; flex-direction: column; align-items: center; padding: 14px 12px 26px; color: #1a1a1a; background: #fff; -webkit-user-select: none; user-select: none; }
.sheet + .sheet { border-top: 1px solid #e6e6e6; }
.dhead { direction: rtl; display: flex; justify-content: space-between; align-items: baseline; font-family: "Frank Ruhl Libre", serif; font-weight: 700; margin-bottom: 10px; line-height: 1.1; }
.dhead .h-group { display: flex; flex: 1; justify-content: space-around; align-items: baseline; }
.dhead .h-daf { font-size: 1.3em; min-width: 1.6em; }
.dhead .h-daf.outer-left { text-align: left; }
.dhead .h-daf.outer-right { text-align: right; }
.dafbox { position: relative; }
.dafbox .layer { position: absolute; top: 0; left: 0; pointer-events: none; }
.dafbox .text { direction: rtl; text-align: justify; text-align-last: auto; hyphens: none; -webkit-font-kerning: normal; }
.dafbox .main .text { font-family: "Frank Ruhl Libre", serif; font-weight: 500; }
.dafbox .side .text { font-family: "Noto Rashi Hebrew", serif; }
.dafbox .text span { pointer-events: auto; }
.dafbox .cl, .dafbox .cm, .dafbox .seg { border-radius: 2px; transition: background-color .2s ease; -webkit-tap-highlight-color: transparent; }
.dafbox .cl { cursor: pointer; }
.dafbox .seg.hl-soft { background: rgba(255, 212, 0, .10); }
.dafbox .cl.hl { background: rgba(255, 212, 0, .62); box-shadow: 0 0 0 1px rgba(255, 212, 0, .62); }
.dafbox .cm.hl { background: rgba(255, 212, 0, .30); }
.dafbox .cl.picked { outline: 2px dashed #8a5a1f; outline-offset: 1px; }
.dafbox .cm b { font-family: "Frank Ruhl Libre", serif; font-weight: 700; font-size: 1.06em; line-height: 1; }
.dafbox .cm .lead { font-size: 1.9em; line-height: .5; }
.dafbox .cm .dash, .dafbox .cm .dash-space { display: inline-block; font-size: 0; }
.dafbox .cm .dash::after { content: "."; font-size: var(--side-fs); }
.dafbox .seg big { font-size: 1.22em; font-weight: 800; line-height: .8; }
.dafbox .seg .opener { display: block; width: fit-content; margin: 0 auto .3em; padding: .12em .7em .02em; font-size: 2.3em; font-weight: 800; line-height: 1.15; border: 3px double #1a1a1a; outline: 1px solid #1a1a1a; outline-offset: 3px; }
.dafbox .seg .opener.mid { font-size: 1.8em; margin-top: .25em; }
.dafbox .seg.hadran { display: block; text-align: center; text-align-last: center; margin: .2em 0; }
.zoom { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; z-index: 3; }
.zoom button { font: 600 18px/1 system-ui, -apple-system, sans-serif; min-width: 44px; height: 44px; padding: 0 10px; border-radius: 22px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); box-shadow: 0 2px 10px rgba(0,0,0,.15); cursor: pointer; }
.zoom #zoom-fit { font-size: 13px; min-width: 56px; }

/* Jump here: shown after a tap on a phrase in the Gemara or Translation view */
.jump { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--dock-h, 110px) + 14px); z-index: 12; font: 600 15px system-ui, -apple-system, sans-serif; color: var(--paper); background: var(--accent); border: 0; border-radius: 22px; min-height: 44px; padding: 0 20px; box-shadow: 0 4px 16px rgba(0,0,0,.22); cursor: pointer; }
.jump span { font-variant-numeric: tabular-nums; opacity: .85; margin-left: 6px; }
.jump:disabled { background: var(--soft); cursor: default; }

/* Translation: like Talmid's translation page */
.trpage { --fs: 20px; max-width: 760px; margin: 0 auto; padding: 14px 18px 0; font-family: "Iowan Old Style", "Palatino", Georgia, "Times New Roman", serif; font-size: var(--fs); line-height: 1.55; }
.trpage .running { display: flex; justify-content: space-between; align-items: baseline; font: 700 12.5px system-ui, -apple-system, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: var(--soft); padding: 14px 0 7px; border-bottom: 1px solid var(--ink); margin-bottom: 8px; }
.trpage .running .he { font-family: "Frank Ruhl Libre", serif; font-size: 17px; letter-spacing: 0; text-transform: none; }
.trpage .sec { padding: 8px 8px 10px; margin: 0 -8px 6px; border-radius: 8px; }
.trpage .sec.sel { background: color-mix(in srgb, var(--hl) 14%, transparent); }
.trpage .trp { position: relative; padding: 6px 8px; margin: 0 -8px; border-radius: 6px; cursor: pointer; transition: background-color .2s ease; -webkit-tap-highlight-color: transparent; }
.trpage .trp + .trp { margin-top: 4px; }
.trpage .trp.hl { background: var(--hl); color: var(--hl-ink); }
.trpage .trp.picked { outline: 2px dashed var(--accent); }
.trpage .trp .he { font-family: "Frank Ruhl Libre", serif; font-weight: 700; font-size: 1.18em; line-height: 1.45; direction: rtl; text-align: right; }
.trpage .trp .en { margin-top: 2px; text-align: left; overflow-wrap: anywhere; }
.trpage .trp .en b { font-weight: 700; }
.trpage .label { display: block; font-weight: 700; font-style: italic; font-size: 1.15em; margin: 2px 0 4px; }
.trpage sup.n { font: 600 .62em system-ui, -apple-system, sans-serif; color: var(--accent); padding: 0 2px; line-height: 0; }
.trpage .notes { margin: 10px 0 2px; padding-top: 8px; border-top: 1px solid var(--rule); font-size: .82em; line-height: 1.45; column-gap: 26px; }
.trpage .note { break-inside: avoid; margin: 0 0 8px; padding: 5px 7px; border-radius: 6px; }
.trpage .note.hl { background: color-mix(in srgb, var(--hl) 70%, transparent); color: var(--hl-ink); }
.trpage .note .who { font: 700 .8em system-ui, -apple-system, sans-serif; letter-spacing: .06em; color: var(--accent); }
.trpage .note .ai { font: 600 .68em system-ui, -apple-system, sans-serif; color: var(--soft); letter-spacing: .05em; margin-left: 6px; }
.trpage .note .nhe { font-family: "Frank Ruhl Libre", serif; direction: rtl; text-align: right; font-size: 1.08em; margin: 2px 0 3px; }
.trpage .note .nen { text-align: left; }
@media (min-width: 640px) { .trpage .notes.two { columns: 2; } }
/* Landscape and wide screens: Hebrew and English side by side, wider page. */
@media (orientation: landscape) and (min-width: 600px) {
  .trpage { max-width: 1180px; --fs: 19px; }
  .trpage .trp { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; align-items: start; }
  .trpage .trp .label { grid-column: 1 / -1; }
  .trpage .trp .en { grid-column: 1; grid-row: 1; margin-top: 0; }
  .trpage .trp .he { grid-column: 2; grid-row: 1; }
  .trpage .trp:has(.label) .he, .trpage .trp:has(.label) .en { grid-row: 2; }
}
@media (max-width: 430px) { .trpage { --fs: 19px; padding: 10px 16px 0; } }
/* Short screens (a phone on its side): one slim bar on top, a slim dock. */
@media (max-height: 500px) {
  .topbar { display: flex; align-items: center; }
  .topbar .wrap { flex: 1; height: 42px; max-width: none; }
  .topbar .t span { display: none; }
  .topbar .spacer { display: none; }
  .viewbar { padding: 0 12px 0 0; }
  .seg3 button { padding: 4px 12px; min-height: 32px; font-size: 13px; }
  .dock .wrap { padding-top: 4px; padding-bottom: 4px; }
  .player { margin-top: 0; gap: 6px; }
  .player .pp { width: 38px; height: 38px; }
  .dock .licence { font-size: 10px; margin-top: 0; }
}
