@font-face {
  font-family: Vilna;
  src:
    url("../fonts/Mekorot-Vilna.ttf"),
    url("../../examples/fonts/Mekorot-Vilna.ttf");
}

@font-face {
  font-family: Rashi;
  src:
    url("../fonts/Mekorot-Rashi.ttf"),
    url("../../examples/fonts/Mekorot-Rashi.ttf");
}

:root {
  color-scheme: light;
  --ink: #17241f;
  --muted: #67746f;
  --paper: #f5f3ed;
  --paper-warm: #fffaf0;
  --panel: #ffffff;
  --line: #ddd7ca;
  --line-strong: #c7bda8;
  --accent: #0f6b5d;
  --accent-strong: #12382f;
  --accent-soft: #e3f1ec;
  --gold: #b89035;
  --warn: #a3372b;
  --shadow: 0 20px 55px rgba(31, 37, 35, .12);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(15, 107, 93, .12), transparent 32rem),
    linear-gradient(180deg, #fbfaf6 0, var(--paper) 42rem);
  color: var(--ink);
  font-family: Arial, "Noto Sans Hebrew", sans-serif;
}

button,
select,
input {
  font: inherit;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(16px, 4vw, 52px);
  background: rgba(255, 255, 255, .86);
  border-bottom: 1px solid rgba(199, 189, 168, .7);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  color: var(--paper-warm);
  background: var(--accent-strong);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(18, 56, 47, .22);
}

.brand-mark svg {
  width: 27px;
  height: 27px;
  stroke-width: 1.9;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 38px);
  font-weight: 800;
  line-height: 1.05;
}

p {
  max-width: 56ch;
  margin: 5px 0 0;
  color: var(--muted);
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid rgba(15, 107, 93, .16);
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
}

.source-link:hover {
  border-color: rgba(15, 107, 93, .36);
  color: var(--accent);
}

main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 22px clamp(12px, 3vw, 32px) 56px;
}

.reader-toolbar {
  display: grid;
  gap: 14px;
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 16px;
  background: rgba(255, 255, 255, .9);
  border: 1px solid rgba(199, 189, 168, .72);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  grid-template-columns: minmax(190px, 1.45fr) minmax(110px, .8fr) minmax(100px, .75fr) auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select {
  min-height: 44px;
  width: 100%;
  padding: 0 12px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
}

select:focus-visible,
input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(15, 107, 93, .22);
  outline-offset: 2px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: progress;
  transform: none;
  opacity: .62;
}

.primary-action {
  min-width: 112px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 24px rgba(15, 107, 93, .24);
}

.primary-action:hover {
  background: var(--accent-strong);
}

.pager,
.display-options {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.display-options {
  flex-wrap: wrap;
}

.zoom-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.zoom-control .icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.zoom-slider-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 178px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.zoom-slider-label input {
  width: 118px;
  accent-color: var(--accent);
}

.zoom-value {
  min-width: 48px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.icon-button,
.secondary-action {
  color: var(--accent-strong);
  background: #fff;
  border-color: var(--line);
}

.icon-button:hover,
.secondary-action:hover {
  border-color: var(--line-strong);
  background: var(--paper-warm);
}

#status {
  min-width: 180px;
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 6px 14px;
  color: var(--muted);
  background: #f7f5ef;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

#status.error {
  color: var(--warn);
  background: #fff0ee;
  border-color: rgba(163, 55, 43, .28);
}

.daf-shell {
  margin-top: 24px;
  padding: 20px 0 28px;
  overflow-x: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, .72), rgba(255, 255, 255, .34));
  border: 1px solid rgba(199, 189, 168, .58);
  border-radius: 8px;
  box-shadow: 0 16px 50px rgba(31, 37, 35, .08);
}

#daf-heading {
  direction: ltr;
  position: relative;
  width: 100%;
  margin: 0 auto 12px;
  padding: 0;
  font-family: Vilna, serif;
  min-height: 44px;
}

.daf-ref-label,
.chapter-label {
  color: var(--ink);
  direction: rtl;
  font-size: 40px;
  line-height: 1.08;
  white-space: nowrap;
}

.chapter-label {
  padding: 0 82px;
  text-align: center;
}

.daf-ref-label {
  position: absolute;
  top: 0;
  left: 0;
  text-align: left;
}

.commentary-label {
  display: none;
  position: absolute;
  top: 13px;
  width: 25%;
  direction: rtl;
  font-family: Vilna, serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.has-commentary-labels .commentary-label {
  display: block;
}

.commentary-label-left {
  left: 0;
}

.commentary-label-right {
  right: 0;
}

#daf-heading[data-amud="b"] .daf-ref-label {
  right: 0;
  left: auto;
  text-align: right;
}

#daf-container {
  position: absolute;
  top: 0;
  left: 50%;
  width: max-content;
  min-width: 660px;
  margin: 0;
  padding: 18px 10px 14px;
  background: var(--paper-warm);
  border: 1px solid rgba(199, 189, 168, .72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .68);
  transform: translateX(-50%) scale(var(--daf-zoom, 1));
  transform-origin: top center;
}

#daf-render {
  margin: 0 auto;
}

.daf-stage {
  --daf-zoom: 1;
  position: relative;
  width: max-content;
  margin: 0 auto;
}

.sentence:hover,
.word:hover {
  color: var(--accent);
}

.sentence,
.word[data-sentence],
.commentary-segment[data-sentence] {
  cursor: pointer;
}

.is-selected-source,
.is-selected-source .word,
.is-linked-highlight,
.is-linked-highlight .word,
.word.is-linked-highlight {
  color: var(--accent-strong);
  background: rgba(184, 144, 53, .25);
  box-shadow: 0 0 0 2px rgba(184, 144, 53, .12);
}

.is-linked-highlight,
.is-linked-highlight .word,
.word.is-linked-highlight {
  background: rgba(15, 107, 93, .14);
  box-shadow: 0 0 0 2px rgba(15, 107, 93, .08);
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: start;
    display: grid;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .source-link {
    width: max-content;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .controls label:first-child,
  #load {
    grid-column: 1 / -1;
  }

  .pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  #status {
    grid-column: 1 / -1;
    grid-row: 1;
    min-width: 0;
  }

  .display-options {
    justify-content: stretch;
  }

  .zoom-control,
  .secondary-action {
    width: 100%;
  }

  .zoom-slider-label {
    flex: 1 1 auto;
    min-width: 0;
  }

  .zoom-slider-label input {
    width: 100%;
  }
}
