/* ============================================================================
   שיחון עברית-ערבית — הלימוד המשותף

   The palette and proportions are sampled directly out of the printed booklet
   (tools/palette.py), so this reads as the same object. Where the web has to
   diverge it is for a reason, and the reason is noted at the rule.
   ========================================================================= */

@font-face {
  font-family: 'Abraham';
  src: url('fonts/abraham-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Abraham';
  src: url('fonts/abraham-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Abraham';
  src: url('fonts/abraham-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Abraham';
  src: url('fonts/abraham-900.woff2') format('woff2');
  font-weight: 900; font-style: normal; font-display: swap;
}

:root {
  color-scheme: light;

  /* sampled from the print file */
  --sage:      #cdd8a3;
  --cream:     #faf7f1;
  --tan:       #f4e8d9;
  --olive:     #5d663b;
  --gold:      #d88901;
  --teal:      #2e667d;
  --stone:     #a2a78b;

  /* derived */
  --sage-dk:   #b9c78a;
  --tan-line:  #e4d5bc;
  --olive-lt:  #7c8752;
  --olive-hover: #4f592f;
  --teal-hover:  #25566c;
  --gold-ink:    #9a5d00;
  --ink:       #2b2a22;
  --muted:     #6b6658;

  --sheet-r:   18px;
  --card-r:    14px;
  --shadow-sm: 0 1px 2px rgba(45, 50, 25, .10);
  --shadow-md: 0 2px 4px rgba(45, 50, 25, .10), 0 8px 22px rgba(45, 50, 25, .07);

  --stack: 'Abraham', 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 8.5rem;   /* clears the sticky controls on deep links */
}

body {
  margin: 0;
  background: var(--sage);
  color: var(--ink);
  font-family: var(--stack);
  font-size: 17px;
  line-height: 1.5;
  padding: 0 0 4rem;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 clamp(10px, 3vw, 20px);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

:is(button, input, a):focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ============================ the "cover" ============================= */
/* Mirrors the printed cover: a cream page floating on the sage border. */

.cover {
  display: grid;
  grid-template-columns: clamp(92px, 14vw, 150px) minmax(0, 420px);
  justify-content: center;
  align-items: center;
  gap: clamp(14px, 3vw, 30px);
  width: 100%;
  max-width: 820px;
  background: var(--cream);
  border-radius: var(--sheet-r);
  box-shadow: var(--shadow-md);
  margin: clamp(12px, 3vw, 22px) auto 0;
  padding: clamp(14px, 3vw, 24px) clamp(14px, 4vw, 32px);
  text-align: center;
}

.cover picture { display: block; }
.cover .lockup {
  width: 100%;
  height: auto;
  margin: 0;
  display: block;
}
.cover-copy { min-width: 0; }

.cover h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 2.15rem);
  line-height: 1.12;
  font-weight: 900;
  color: var(--olive);
  letter-spacing: -.01em;
}
.cover h1 .ar { display: block; }

.cover .tagline {
  margin: .24em 0 0;
  font-size: clamp(1.05rem, 2.8vw, 1.6rem);
  line-height: 1.18;
  font-weight: 900;
  color: var(--gold-ink);
}
.cover .tagline .ar { display: block; }

.cover .lede {
  margin: clamp(14px, 3vw, 20px) auto 0;
  max-width: 46ch;
  font-size: .96rem;
  line-height: 1.62;
  color: var(--muted);
}
.cover .lede .ar { display: block; margin-top: .5em; }


/* ========================== sticky controls =========================== */

.controls {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: clamp(14px, 3vw, 20px) 0 0;
  padding: 10px 0 6px;
  background: var(--sage);
}
/* soft fade instead of a hard edge when content scrolls under */
.controls::after {
  content: '';
  position: absolute;
  inset: 100% 0 auto;
  height: 14px;
  background: linear-gradient(var(--sage), rgba(205, 216, 163, 0));
  pointer-events: none;
}

.bar { display: flex; gap: 8px; align-items: stretch; }

.search {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 16px;             /* < 16px makes iOS Safari zoom on focus */
  padding: 11px 16px;
  border: 1.5px solid var(--tan-line);
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.search::placeholder { color: var(--muted); opacity: 1; }
.search::-webkit-search-cancel-button { -webkit-appearance: none; }

.pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 15px;
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  color: var(--olive);
  background: var(--cream);
  border: 1.5px solid var(--tan-line);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.pill:hover { background: #fff; }
.pill[aria-pressed="true"] {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--cream);
}

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 9px 0 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  /* fades at both ends so a cut-off chip reads as "scrollable", not "broken" */
  -webkit-mask-image: linear-gradient(to left, transparent 0, #000 18px,
                                      #000 calc(100% - 18px), transparent 100%);
          mask-image: linear-gradient(to left, transparent 0, #000 18px,
                                      #000 calc(100% - 18px), transparent 100%);
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 6px 15px;
  font: inherit;
  font-size: .88rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--olive);
  background: var(--cream);
  border: 1.5px solid var(--tan-line);
  border-radius: 999px;
  cursor: pointer;
}
.chip[aria-pressed="true"] {
  background: var(--olive);
  border-color: var(--olive);
  color: var(--cream);
  font-weight: 700;
}
.chip .n { opacity: .6; font-weight: 500; font-size: .85em; }

.statusline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 2px 0;
  font-size: .85rem;
  font-weight: 500;
  color: var(--olive);
}
.linkish {
  font: inherit;
  color: var(--olive);
  background: none;
  border: 0;
  padding: 4px 2px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ========================== section headings ========================== */
/* Print sets these cream-on-sage. On screen that is ~1.5:1, so the Hebrew is
   olive and the Arabic teal instead - both clear AA at this size. */

.sec {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 .5em;
  margin: clamp(24px, 5vw, 34px) 2px 10px;
  font-size: clamp(1.18rem, 4.6vw, 1.45rem);
  font-weight: 900;
  line-height: 1.25;
}
.sec .he { color: var(--olive); }
.sec .ar { color: var(--teal); }

/* the printed table's tan header strip - desktop only, where columns line up */
.thead { display: none; }

@media (min-width: 860px) {
  .thead {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) 194px;
    gap: 0 18px;
    align-items: center;
    margin: 0 0 6px;
    padding: 9px 18px;
    background: var(--tan);
    border: 1px solid var(--tan-line);
    border-radius: 10px;
    font-size: .8rem;
    font-weight: 700;
    color: var(--olive);
  }
}

/* ============================ phrase rows ============================= */

.rows { display: flex; flex-direction: column; gap: 10px; }

.row {
  display: grid;
  gap: 6px 14px;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "num  num"
    "he   ar"
    "het  art"
    "acts acts";
  align-items: start;
  padding: 11px 13px 12px;
  background: var(--cream);
  border: 1px solid var(--tan-line);
  border-radius: var(--card-r);
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 8.5rem;
}
.row:target {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px var(--teal), var(--shadow-md);
}

.row .num  { grid-area: num;  font-size: .74rem; font-weight: 700; color: var(--stone); }
.row .he   { grid-area: he; }
.row .het  { grid-area: het; }
.row .ar   { grid-area: ar; }
.row .art  { grid-area: art; }
.row .acts { grid-area: acts; }

.f { min-width: 0; }

.f .label {
  display: block;
  width: fit-content;
  margin-bottom: 4px;
  padding: 2px 7px;
  font-size: .68rem;
  font-weight: 700;
  color: var(--olive);
  background: var(--tan);
  border-radius: 5px;
}

.f .txt {
  display: block;
  overflow-wrap: break-word;
  font-size: 1.14rem;
  font-weight: 700;
  color: var(--ink);
}
.f.het .txt, .f.art .txt { font-weight: 400; font-size: 1.05rem; color: var(--muted); }
/* Arabic script sits optically smaller at the same em size */
.f .txt:lang(ar) { font-size: 1.24rem; }
.f.het .txt:lang(ar) { font-size: 1.14rem; }

/* ============================== actions =============================== */

.acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; }

.play {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 15px;
  font: inherit;
  font-size: .88rem;
  font-weight: 700;
  color: var(--cream);
  background: var(--olive);
  border: 1.5px solid var(--olive);
  border-radius: 999px;
  cursor: pointer;
}
.play:hover { background: var(--olive-hover); border-color: var(--olive-hover); }
.play svg { flex: none; width: 16px; height: 16px; fill: currentColor; }

/* language colour code, echoing the section headings */
.play.p-ar { background: var(--teal); border-color: var(--teal); }
.play.p-ar:hover { background: var(--teal-hover); border-color: var(--teal-hover); }

.play[data-state="playing"] {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--cream);
}
.play[data-state="loading"] { opacity: .7; }
.play[data-state="error"] {
  background: #8a3c2b;
  border-color: #8a3c2b;
}

.play[disabled] {
  background: transparent;
  color: var(--stone);
  border: 1.5px dashed var(--tan-line);
  cursor: default;
  font-weight: 500;
}
.play[disabled] svg { display: none; }

/* ============================== empty ================================= */

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--cream);
  border: 1px solid var(--tan-line);
  border-radius: var(--card-r);
}
.empty b { display: block; margin-bottom: 6px; color: var(--olive); font-size: 1.05rem; }

/* ============================== footer ================================ */

.colophon {
  margin: clamp(26px, 5vw, 38px) 0 0;
  padding: clamp(18px, 4vw, 26px) clamp(16px, 4vw, 26px);
  background: var(--cream);
  border-radius: var(--sheet-r);
  box-shadow: var(--shadow-sm);
  text-align: center;
  font-size: .88rem;
  line-height: 1.65;
  color: var(--muted);
}
.colophon p { margin: 0 0 .45em; }
.colophon .partners {
  width: 100%;
  max-width: 520px;
  height: auto;
  margin: clamp(14px, 3vw, 20px) auto 0;
  display: block;
}

/* ======================= responsive escalation ======================== */

/* very narrow phones: one language above the other */
@media (max-width: 359px) {
  body { font-size: 16px; }
  .row {
    grid-template-columns: 1fr;
    grid-template-areas: "num" "he" "het" "ar" "art" "acts";
  }
  .row .ar { margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--tan-line); }
}

@media (min-width: 560px) {
  .row { padding: 12px 16px 14px; gap: 6px 20px; }
  .f .txt { font-size: 1.18rem; }
}

/* wide: the printed four-column table, with the actions in a fifth column.
   Buttons collapse to icons here - three stacked pills would triple the row
   height and destroy the compact table rhythm the print piece has. */
@media (min-width: 860px) {
  .row {
    grid-template-columns: repeat(4, minmax(0, 1fr)) 194px;
    grid-template-areas:
      "num num num num acts"
      "he  het ar  art acts";
    gap: 8px 18px;
    align-items: center;
    padding: 13px 18px 14px;
  }
  .row .acts { flex-wrap: nowrap; justify-content: flex-start; gap: 6px; margin-top: 0; }
  .row .acts .play { flex: 1 1 0; justify-content: center; padding-inline: 10px; }

  /* the "no recording" slot keeps its width so columns stay aligned */
  .row .acts .play[disabled]::before {
    content: '—';
    font-size: 1rem;
    color: var(--stone);
  }

  .f .label { display: none; }          /* .thead carries the column names */
  .f .txt { font-size: 1.12rem; }
  .f .txt:lang(ar) { font-size: 1.2rem; }
  .f.het .txt, .f.art .txt { font-size: 1.02rem; }
  .f.het .txt:lang(ar) { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .controls, .acts, .statusline { display: none !important; }
  body { background: #fff; }
  .row { break-inside: avoid; box-shadow: none; }
}
