/* Arabic worksheet sheets (arabic.js). RTL variant of references/design/WORKSHEET_TEMPLATE.md.
   Builds on the shared .worksheet-page / .worksheet-header / .worksheet-footer rules in styles.css. */

@font-face {
  font-family: "PP Naskh Arabic";
  src: url("fonts/NotoNaskhArabic%5Bwght%5D.ttf") format("truetype");
  font-weight: 400 700;
  font-display: block;
}

/* Atkinson Hyperlegible Next only ships a slashed zero (no OpenType feature to turn it off),
   so digits 0-9 come from Andika (plain zero) inside the same family, with Atkinson's line metrics so lines do not grow. Two weight bands keep bold digits bold. */
@font-face { font-family: "PP Atkinson"; src: url("fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2"); font-weight: 200 549; font-display: block; unicode-range: U+0000-002F, U+003A-FFFF; }
@font-face { font-family: "PP Atkinson"; src: url("fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2"); font-weight: 550 800; font-display: block; unicode-range: U+0000-002F, U+003A-FFFF; }
@font-face { font-family: "PP Atkinson"; src: url("fonts/andika-latin-regular.woff2") format("woff2"); font-weight: 200 549; font-display: block; unicode-range: U+0030-0039; ascent-override: 98.4%; descent-override: 31.6%; line-gap-override: 0%; }
@font-face { font-family: "PP Atkinson"; src: url("fonts/andika-latin-bold.woff2") format("woff2"); font-weight: 550 800; font-display: block; unicode-range: U+0030-0039; ascent-override: 98.4%; descent-override: 31.6%; line-gap-override: 0%; }

.ar-sheet {
  --ar-ink: #1d2330;
  --ar-muted: #1D2330; /* print ink rule (WORKSHEET_STYLE 3.8): no grey text */
  --ar-trace: #1D2330; /* solid ink (WORKSHEET_STYLE 3.8); the trace letter is told apart by its hollow outline */
  --ar-answer: var(--key-ink);
  color: var(--ar-ink);
  font-family: "PP Naskh Arabic", serif;
  direction: rtl;
  text-align: right;
}

.ar-sheet svg {
  fill: none;
  stroke: none;
  flex: none;
}

.ar-en {
  display: block;
  font-family: "PP Atkinson", "PP Naskh Arabic", "Segoe UI", sans-serif;
  direction: ltr;
  unicode-bidi: isolate;
  color: var(--ar-muted);
  font-size: 10pt;
  font-weight: 500;
  line-height: 1.25;
}

/* ---- header ---- */
.ar-header {
  align-items: start;
}

.ar-header h2 {
  margin: 0;
  font-family: "PP Naskh Arabic", serif;
  font-size: 22pt;
  font-weight: 700;
  line-height: 1.3;
}

/* Name/Date sit on their own row under the title (styles.css header rule); keep the stacked header compact. */
.ar-sheet .worksheet-header.ar-header { padding-bottom: 4px; }

.ar-subtitle {
  text-align: right;
  font-size: 10.5pt;
}

.ar-sheet .student-fields {
  justify-content: flex-start;
  padding-top: 0;
}

.ar-sheet .field-line {
  font-family: "PP Naskh Arabic", serif;
  font-size: 12.5pt;
  font-weight: 700;
}

.ar-cont-header {
  align-items: center;
  font-family: "PP Naskh Arabic", serif;
  font-size: 13pt;
  line-height: 1.6;
}

.ar-teacher-pill {
  padding: 0 10px;
  border: 0.75pt solid var(--ar-muted);
  border-radius: 999px;
  font-size: 10pt;
  font-weight: 600;
}

/* ---- instruction ---- */
.ar-instruction {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 0 14px;
}

.ar-step {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-top: 6px;
  border: 0.75pt solid var(--ar-ink);
  border-radius: 50%;
  font-size: 13pt;
  line-height: 1;
}

.ar-inst-ar {
  margin: 0;
  font-size: 14pt;
  font-weight: 700;
  line-height: 2;
}

.ar-inst-en {
  font-size: 9.5pt;
  text-align: right;
}

/* ---- footer (mirrors renderPageFooter: brand/grade right, page left) ---- */
.ar-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 0.5pt solid var(--sheet-ink, #1D2330);
  font-family: "PP Naskh Arabic", serif;
  font-size: 9pt;
  font-weight: 500;
  color: var(--ar-muted);
  text-align: right;
}

.ar-subject-mark {
  display: inline-block;
  width: 6pt;
  height: 6pt;
  margin-left: 6px;
  background: #2f7d6b;
  vertical-align: middle;
}

.ar-brand {
  font-family: "PP Atkinson", "Segoe UI", sans-serif;
  font-weight: 700;
  unicode-bidi: isolate;
}

/* ---- shared activity pieces ---- */
.ar-activity {
  display: grid;
  gap: 10px;
}

.ar-grid.ar-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 26px; }
.ar-grid.ar-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 20px; }
.ar-grid.ar-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 12px; }
.ar-grid.ar-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 20px 14px; }

.ar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ar-num {
  flex: none;
  min-width: 22px;
  color: var(--ar-muted);
  font-size: 13pt;
  font-weight: 700;
}

.ar-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ar-cell > .ar-num {
  position: absolute;
  top: 0;
  right: 0;
}

.ar-label {
  flex: none;
  width: 74px;
  text-align: center;
}

.ar-label-ar {
  display: block;
  font-size: 15pt;
  font-weight: 700;
  line-height: 1.6;
}

.ar-label .ar-en {
  font-size: 9pt;
}

.ar-big-digit {
  font-size: 24pt;
}

/* writing guides */
.ar-guide .g-top { stroke: var(--sheet-ink, #1D2330); stroke-width: 1; }
.ar-guide .g-body { stroke: var(--sheet-ink, #1D2330); stroke-width: 1; stroke-dasharray: 2 4; }
.ar-guide .g-base { stroke: var(--sheet-ink, #1D2330); stroke-width: 1.25; }
.ar-guide text { font-family: "PP Naskh Arabic", serif; font-weight: 400; }
.ar-guide .g-solid { fill: var(--ar-ink); }
.ar-guide .g-trace {
  fill: #f2f2f2;
  stroke: var(--ar-trace);
  stroke-width: 1.3;
  stroke-dasharray: 3 2.2;
  stroke-linejoin: round;
}
.ar-guide .g-answer { fill: var(--ar-answer); }

.ar-big-glyph {
  font-size: 34pt;
  line-height: 1.6;
}

.ar-box {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1pt solid var(--sheet-ink, #1D2330);
  border-radius: 6px;
  font-size: 22pt;
  line-height: 1;
}

.ar-box.wide {
  width: 70px;
}

.ar-ans {
  color: var(--ar-answer);
}

.circled {
  border-radius: 50%;
  box-shadow: 0 0 0 var(--w-loop, 1.5pt) var(--ar-answer);
}

/* letter tiles (separated letters of a word) */
.ar-tiles {
  display: inline-flex;
  gap: 6px;
  direction: rtl;
}

.ar-tile {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 48px;
  padding: 0 4px;
  border: 0.75pt solid var(--sheet-ink, #1D2330);
  border-radius: 6px;
  font-size: 19pt;
  line-height: 1;
}

.ar-tile.blank {
  border: 1.25pt dashed var(--sheet-ink, #1D2330);
}

.ar-tile.circled {
  border-color: transparent;
  border-radius: 50%;
}

/* options to circle */
.ar-options {
  display: inline-flex;
  gap: 14px;
  align-items: center;
}

.ar-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 42px;
  min-height: 40px;
  padding: 0 9px;
  border: 0.75pt solid var(--sheet-ink, #1D2330);
  border-radius: 999px;
}

.ar-option.circled {
  border-color: transparent;
  border-radius: 999px;
}

.ar-opt-glyph {
  font-size: 18pt;
  line-height: 1.45;
}

.ar-blank-mark {
  color: var(--sheet-ink, #1D2330);
}

.ar-option .ar-en {
  font-size: 9pt;
}

.ar-opt-word {
  font-size: 12pt;
  line-height: 1.5;
}

.ar-icon {
  stroke: var(--ar-ink) !important;
  stroke-width: 1.4;
  stroke-linecap: round;
}

/* words */
.ar-word {
  font-size: 25pt;
  line-height: 1.6;
}

.ar-word.small {
  font-size: 18pt;
  line-height: 1.6;
}

.ar-gloss {
  font-size: 9.5pt;
  text-align: center;
}

.ar-word-cell {
  gap: 3px;
  padding: 2px 0 8px;
  border-bottom: 0.5pt solid var(--sheet-ink, #1D2330);
}

.ar-word-blank {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* recognition */
.ar-recog-row {
  min-height: 74px;
  border-bottom: 0.5pt solid var(--sheet-ink, #1D2330);
}

.ar-target {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1.25pt solid var(--ar-ink);
  border-radius: 8px;
  font-size: 32pt;
  line-height: 1;
}

.ar-recog-cells {
  display: flex;
  flex: 1;
  justify-content: space-around;
}

.ar-recog-cell {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 64px;
  font-size: 32pt;
  line-height: 1;
}

/* forms table */
.ar-forms {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.ar-forms th {
  padding: 4px 0;
  text-align: center;
  border-bottom: 1pt solid var(--ar-ink);
  font-size: 13pt;
  font-weight: 700;
  line-height: 1.5;
}

.ar-forms th .ar-en {
  font-size: 9pt;
  text-align: center;
}

.ar-form-cell {
  height: 84px;
  border: 0.75pt solid var(--sheet-ink, #1D2330);
  text-align: center;
}

.ar-form-cell.blank {
  background: #ffffff;
}

.ar-form-glyph {
  font-size: 34pt;
  line-height: 1;
}

/* The given (isolated) column is marked by a heavier rule, not a fill (TEMPLATE_DECISIONS §2, Arabic). */
.ar-forms td:first-child,
.ar-forms th:first-child {
  border-left: 2pt solid var(--ar-ink);
}

/* join / missing letter rows */
.ar-join-row,
.ar-missing-row {
  justify-content: space-between;
  padding-bottom: 2px;
  border-bottom: 0.5pt solid var(--sheet-ink, #1D2330);
}

.ar-join-cue {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}

/* harakat sounds */
.ar-sound-cell {
  padding-bottom: 6px;
  border-bottom: 0.5pt solid var(--sheet-ink, #1D2330);
}

.ar-sound-cue {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ar-sound {
  font-size: 15pt;
  font-weight: 700;
  color: var(--ar-ink);
}

/* counting */
.ar-count-cell {
  padding: 24px 0 22px;
  border: 0.75pt solid var(--sheet-ink, #1D2330);
  border-radius: 8px;
}

.ar-count {
  stroke: var(--ar-ink) !important;
  stroke-width: 1.4;
}

.ar-dots-cell .ar-big-glyph {
  font-size: 40pt;
}

/* answer key: everything that is not an answer is lighter */
.ar-key .ar-guide .g-solid,
.ar-key .ar-word:not(.ar-ans),
.ar-key .ar-big-glyph,
.ar-key .ar-recog-cell:not(.circled),
.ar-key .ar-target,
.ar-key .ar-form-cell:not(.ar-ans) .ar-form-glyph,
.ar-key .ar-tile:not(.blank),
.ar-key .ar-word-blank > .ar-word {
  color: var(--sheet-ink, #1D2330);
  fill: var(--sheet-ink, #1D2330);
}

/* standalone preview / headless render page */
body.ar-preview {
  margin: 0;
  background: #e9ebf0;
}

body.ar-preview .worksheet-preview {
  display: grid;
  gap: 26px;
  justify-items: center;
  padding: 26px 0;
}

@media print {
  body.ar-preview {
    background: #ffffff;
  }

  body.ar-preview .worksheet-preview {
    display: block;
    padding: 0;
  }
}

/* Round 2: count the dots fills the page; answer boxes about 0.75 in. */
.ar-dots-cell { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ar-dots-cell .ar-big-glyph { font-size: 56pt; line-height: 1.5; }
.ar-dots-cell .ar-box { width: 72px; height: 72px; font-size: 32pt; }
.ar-grid.ar-cols-5:has(.ar-dots-cell) { row-gap: 46px; padding-top: 10px; }
/* Harakat sounds: 68px writing band plus descender room. */
.ar-sound-cell { display: flex; flex-direction: column; gap: 4px; }
/* Letter bank for harakat-sounds with hideLetter: the letters to choose from, no harakat. */
.ar-letter-bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; margin: 4px auto 14px; padding: 6px 18px; width: max-content; max-width: 100%; border: 1.5px solid var(--sheet-ink, #222); border-radius: 8px; font-size: 30pt; line-height: 1.5; }
/* Teacher note on the last answer-key page (English, left to right). */
.ar-key-note { margin: 10px 0 0; font-family: var(--font-ui); font-size: 10.5pt; line-height: 1.4; color: var(--sheet-muted, var(--sheet-ink, #1D2330)); text-align: left; }

/* Number tracing: the five rows share the page height instead of leaving the bottom fifth empty (critic round 6). */
.ar-type-numbers-trace .worksheet-page-body { display: flex; flex-direction: column; }
.ar-type-numbers-trace .ar-activity { flex: 1 1 auto; align-content: space-evenly; padding-bottom: 8px; }
