/* Learn Hebrew section: letter tables and the ancient script.
 *
 * Paleo-Hebrew has no font of its own on most devices. Unicode encodes it as Phoenician
 * (U+10900-1091F), the same 22-letter alphabet Israel wrote before the exile, so the Phoenician
 * font draws it. */
@import url("https://fonts.googleapis.com/css2?family=Gveret+Levin&family=Noto+Sans+Phoenician&family=Noto+Serif+Hebrew:wght@400;600&display=swap");

/* Hebrew in running text. The site font (Roboto) has no Hebrew, so a browser substituted whatever
 * the device had, at body size, and vowel points crowded into illegibility. Noto Serif Hebrew is
 * imported above already and is drawn for pointed text. A step up in size because Hebrew letters
 * sit on a smaller body than Latin ones; line-height 1 keeps the bigger word from opening a gap
 * between lines. :where() keeps this at the weight of one class, so the word cards' and memory
 * verses' own rules win, and a Hebrew word inside a Hebrew span is not enlarged twice. */
.md-typeset :where([dir="rtl"], [lang="he"]):where(:not(.paleo, .he-big, .he-vowel, .he-cursive)) {
  font-family: "Noto Serif Hebrew", "SBL Hebrew", "Ezra SIL", "Times New Roman", serif;
  font-size: 1.2em;
  line-height: 1;
}
.md-typeset :where([dir="rtl"], [lang="he"]) :where([dir="rtl"], [lang="he"]),
.md-typeset :where([data-no-popups] :is([dir="rtl"], [lang="he"])) {
  font-size: inherit;
}
.pop-script[lang="he"] {
  font-family: "Noto Serif Hebrew", "SBL Hebrew", "Ezra SIL", "Times New Roman", serif;
}

.he-big {
  font-family: "Noto Serif Hebrew", serif;
  font-size: 1.6em;
  line-height: 1.2;
}

.paleo {
  font-family: "Noto Sans Phoenician", sans-serif;
  font-size: 1.4em;
  line-height: 1.2;
}

/* A vowel point needs a letter to sit on; the carrier is drawn faint so the point stands out. */
.he-vowel {
  font-family: "Noto Serif Hebrew", serif;
  font-size: 2em;
  line-height: 1.3;
}

.he-vowel .carrier {
  opacity: 0.35;
}

/* ---- Word cards (hooks/hebrew_cards.py) ------------------------------------------------------
 * Sheet, grid, crop marks and print rules come from memory-verses.css (.mv-*); only the card's
 * insides are styled here, in the same sheet millimetres (--mm). */

.hc-deck:not(:has(.hc-opt-paleo:checked)) .hc-paleo { display: none; }
.hc-deck:not(:has(.hc-opt-modern:checked)) .hc-modern { display: none; }

.hc-card [lang="he"], .hc-word {
  font-family: "Noto Serif Hebrew", "SBL Hebrew", "Ezra SIL", "Times New Roman", serif;
}
.hc-card p { margin: 0; }

.hc-word {
  text-align: center;
  font-size: calc(8 * var(--mm));
  line-height: 1.35;
  color: var(--mv-hebrew);
}
.hc-paleo {
  text-align: center;
  font-family: "Noto Sans Phoenician", sans-serif;
  font-size: calc(4.2 * var(--mm));
  letter-spacing: 0.06em;
  color: var(--mv-muted);
}

.hc-prompt { justify-content: center; align-items: center; gap: calc(2 * var(--mm)); }
.hc-prompt .hc-word { font-size: calc(11 * var(--mm)); }
.hc-new {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: calc(1.2 * var(--mm)) calc(2.4 * var(--mm));
  font-family: system-ui, sans-serif;
  font-size: calc(2 * var(--mm));
  color: var(--mv-muted);
}
.hc-new em {
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.hc-new span { display: inline-flex; align-items: baseline; gap: calc(0.8 * var(--mm)); }
.hc-new b { font-size: calc(4 * var(--mm)); color: var(--mv-ink); font-weight: 600; }

.hc-progress {
  display: flex;
  align-items: center;
  gap: calc(1.5 * var(--mm));
  width: 60%;
  font-family: system-ui, sans-serif;
  font-size: calc(1.8 * var(--mm));
  color: var(--mv-muted);
}
.hc-progress i {
  flex: 1;
  height: calc(1 * var(--mm));
  border: calc(0.2 * var(--mm)) solid var(--mv-rule);
  background: linear-gradient(to right, var(--mv-hebrew) calc(var(--known) / var(--total, 22) * 100%), transparent 0);
}

.hc-full { gap: calc(1.8 * var(--mm)); }
.hc-full .hc-word { font-size: calc(6.5 * var(--mm)); }
/* On the one-sided card the word is already printed large above its reading. */
.mv-cards .hc-syl b { display: none; }
.hc-reading {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: calc(1 * var(--mm)) calc(4 * var(--mm));
}
.hc-syl { display: inline-flex; flex-direction: column; align-items: center; }
.hc-syl b { font-size: calc(6.5 * var(--mm)); font-weight: 400; line-height: 1.3; }
.hc-syl i { direction: ltr; font-size: calc(3.6 * var(--mm)); }
.hc-syl u { font-weight: 600; text-underline-offset: 0.18em; }
.hc-meaning {
  text-align: center;
  font-size: calc(4.4 * var(--mm));
  font-weight: 600;
}
.hc-meaning small {
  display: block;
  font-weight: 400;
  font-size: calc(2.3 * var(--mm));
  color: var(--mv-muted);
}
.hc-full .mv-en { margin-top: auto; font-size: calc(2.7 * var(--mm)); }
.hc-modern {
  font-family: system-ui, sans-serif;
  font-size: calc(2.1 * var(--mm));
  color: var(--mv-muted);
}
.hc-modern b {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-right: calc(1 * var(--mm));
}

/* ---- Writing sheets (hooks/hebrew_writing.py) -------------------------------------------------
 * Four guide lines per row, as on a child's exercise book: the ascender (lamed), the top line the
 * letters hang from, the baseline, and the descender (qof and four of the final forms). */

.hw-set { display: none; }
.hw-deck:has(.hw-opt-square:checked) .hw-square,
.hw-deck:has(.hw-opt-cursive:checked) .hw-cursive,
.hw-deck:has(.hw-opt-paleo:checked) .hw-paleo,
.hw-deck:has(.hw-opt-names:checked) .hw-names { display: block; }

.hw-deck {
  --hw-guide: #c9c4bb;
  --hw-base: #8f8a81;
  --hw-trace: #cfcac2;
}
.hw-square, .hw-names .hw-line:first-of-type { --hw-font: "Noto Serif Hebrew", serif; }
.hw-cursive, .hw-line-cursive { --hw-font: "Gveret Levin", cursive; }
.hw-paleo, .hw-line-paleo { --hw-font: "Noto Sans Phoenician", sans-serif; }

.hw-rows {
  position: absolute;
  left: calc(10 * var(--mm));
  top: calc(10 * var(--mm));
  width: calc(190 * var(--mm));
  height: calc(270 * var(--mm));
  display: grid;
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
}

.hw-row {
  display: grid;
  grid-template-columns: calc(32 * var(--mm)) repeat(7, 1fr);
  background:
    linear-gradient(var(--hw-guide), var(--hw-guide)) 0 14% / 100% calc(0.2 * var(--mm)) no-repeat,
    linear-gradient(var(--hw-base), var(--hw-base)) 0 32% / 100% calc(0.25 * var(--mm)) no-repeat,
    linear-gradient(var(--hw-base), var(--hw-base)) 0 70% / 100% calc(0.4 * var(--mm)) no-repeat,
    linear-gradient(var(--hw-guide), var(--hw-guide)) 0 88% / 100% calc(0.2 * var(--mm)) no-repeat;
}

.hw-cell {
  position: relative;
  border-left: calc(0.2 * var(--mm)) dotted var(--hw-guide);
  font-family: var(--hw-font);
  font-size: calc(var(--hw-size, 17) * var(--mm));
  line-height: 1;
  text-align: center;
}
.hw-cell:last-child { border-left: 0; }
/* The glyph's baseline sits on the row's baseline (70 %): the em box is lifted by the font's
   descent, which differs per script. */
.hw-model, .hw-trace {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: calc(30% - var(--hw-descent, 0.27em));
}
.hw-square { --hw-size: 17; --hw-descent: 0.28em; }
.hw-cursive { --hw-size: 15; --hw-descent: 0.22em; }
.hw-paleo { --hw-size: 15; --hw-descent: 0em; }
.hw-trace { color: var(--hw-trace); }
.hw-model small {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(1 * var(--mm));
  font-family: system-ui, sans-serif;
  font-size: calc(2 * var(--mm));
  color: var(--mv-muted);
}

.hw-name {
  display: grid;
  grid-template-rows: calc(6 * var(--mm)) repeat(3, minmax(0, 1fr));
  padding-bottom: calc(1.5 * var(--mm));
  overflow: hidden;
}
.hw-name header {
  font-size: calc(3 * var(--mm));
  border-bottom: calc(0.3 * var(--mm)) solid var(--mv-hebrew);
  color: var(--mv-ink);
}
.hw-name header b { color: var(--mv-hebrew); margin-right: calc(1.5 * var(--mm)); }
.hw-name cite {
  float: right;
  font-style: normal;
  font-family: system-ui, sans-serif;
  font-size: calc(2.2 * var(--mm));
  color: var(--mv-muted);
}
.hw-line {
  display: grid;
  grid-template-columns: calc(18 * var(--mm)) calc(56 * var(--mm)) 1fr;
  align-items: end;
  min-height: 0;
  background: linear-gradient(var(--hw-base), var(--hw-base)) 0 78% / 100% calc(0.3 * var(--mm)) no-repeat;
}
.hw-script {
  align-self: start;
  margin-top: calc(1.5 * var(--mm));
  font-family: system-ui, sans-serif;
  font-size: calc(1.9 * var(--mm));
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--mv-muted);
  direction: ltr;
  text-align: right;
  padding-left: calc(2 * var(--mm));
}
.hw-model-word {
  font-family: var(--hw-font);
  font-size: calc(7 * var(--mm));
  line-height: 1;
  padding-bottom: calc(22% - var(--hw-descent, 0.27em));
  white-space: nowrap;
}
.hw-line:first-of-type { --hw-descent: 0.28em; }
.hw-line-cursive { --hw-descent: 0.22em; }
.hw-line-paleo { --hw-descent: 0.02em; }
.hw-model-word { align-self: stretch; display: flex; align-items: flex-end; justify-content: flex-start; }
.hw-copy { border-right: calc(0.2 * var(--mm)) dotted var(--hw-guide); align-self: stretch; }

.he-cursive {
  font-family: "Gveret Levin", cursive;
  font-size: 1.7em;
  line-height: 1.2;
}

/* ---- On-screen practice (app/src/entries/hebrew-cards.js) ------------------------------------ */

.hc-screen { display: none; }
.hc-deck:has(.hc-opt-screen:checked) .hc-screen { display: block; }
.hc-deck:has(.hc-opt-screen:checked) :is(.mv-cards, .mv-flash),
.hc-deck:has(.hc-opt-screen:checked) .mv-controls .md-button--primary[onclick] { display: none; }

.hc-screen {
  --mm: 1.6px;
  --mv-ink: var(--md-default-fg-color);
  --mv-muted: var(--md-default-fg-color--light);
  max-width: 34rem;
  margin: 0 auto 2rem;
  text-align: center;
}
.hc-screen-status { font-size: 0.75rem; color: var(--md-default-fg-color--light); }
.hc-screen-card {
  padding: 1.5rem 1rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 0.4rem;
  background: var(--md-code-bg-color);
}
.hc-screen-card .hc-word { font-size: 3rem; color: var(--md-typeset-a-color); margin: 0; }
.hc-screen-card .hc-paleo { font-size: 1.4rem; margin: 0.2rem 0 0; }
.hc-deck:not(:has(.hc-opt-paleo:checked)) .hc-screen-card .hc-paleo { display: none; }
.hc-screen-back p { margin: 0.4rem 0; }
.hc-screen-reading { font-style: italic; font-size: 1.1rem; }
.hc-screen-card .hc-meaning { font-size: 1.1rem; }
.hc-screen-name, .hc-screen-quote { font-size: 0.8rem; color: var(--md-default-fg-color--light); }
.hc-screen-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin-top: 1rem; }
.hc-screen-actions .md-button { margin: 0; }
