/* Base layer — reset + primitives. Component styles live in css/components/.
 * RTL-first: use logical properties everywhere (inline-start/-end, not left/right).
 */

/* `hidden` always hides — even on an element whose class sets display
   (e.g. .field / .field-inline are display:flex, which silently beat the
   browser's own [hidden] rule and left every question type's fields
   showing in the form builder). */
[hidden] {
  display: none !important;
}

/* Rubik — self-hosted (docs/design.md §3). Subsets + weights only as needed;
   files in /assets/fonts/, licence there. font-display: swap so text paints in
   the fallback immediately and never blocks. */
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/rubik-hebrew-400.woff2") format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC,
    U+FB1D-FB4F;
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/rubik-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/rubik-latin-ext-400.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/rubik-hebrew-500.woff2") format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC,
    U+FB1D-FB4F;
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/rubik-latin-500.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/rubik-latin-ext-500.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/rubik-hebrew-700.woff2") format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC,
    U+FB1D-FB4F;
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/rubik-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/rubik-latin-ext-700.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Assistant + Heebo — alternate Hebrew typefaces the child can pick for a note
   in "הפתקים שלי" (the typing board). Hebrew subset only: Latin glyphs (digits,
   punctuation) fall through to Rubik above, so a note stays visually consistent
   with the rest of the app. Both are variable fonts — one file covers the whole
   400–700 range, so headings at weight 500 render natively. SIL OFL, see
   /assets/fonts/OFL-Assistant.txt and OFL-Heebo.txt. */
@font-face {
  font-family: "Assistant";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/assistant-hebrew.woff2") format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC,
    U+FB1D-FB4F;
}
@font-face {
  font-family: "Heebo";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/heebo-hebrew.woff2") format("woff2");
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC,
    U+FB1D-FB4F;
}

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

html {
  font-family: var(--font-sans);
  font-size: 100%;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-base);
}

img,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* Visible focus for everyone — never remove this without a replacement. */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Programmatic focus targets (route-change landing points) take focus for
   screen readers but must not show a ring. */
[tabindex="-1"]:focus {
  outline: none;
}

/* Control glyph from assets/icons/sprite.svg (ui.js icon()). Inherits text
   colour so it always matches its button; two sizes per docs/design.md §3
   (24px UI, 40px User-Mode actions). */
.icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
  flex: none;
  vertical-align: middle; /* lines up with adjacent text outside a flex parent */
}
[data-mode="user"] .icon {
  width: 40px;
  height: 40px;
}
/* A single-direction glyph (arrow_back, backspace) points the wrong way once
   the page is RTL — mirror it. chevron_left / chevron_right need no flip: the
   app already uses the pre-mirrored glyph name for each semantic ("next" is
   chevron_left, "previous" is chevron_right — see scripts/build_icons.py). */
.icon-flip {
  transform: scaleX(-1);
}

/* Visually hidden but available to assistive tech. */
.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;
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-2);
  inset-block-start: -3rem;
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  transition: inset-block-start 120ms ease;
}
.skip-link:focus {
  inset-block-start: var(--space-2);
}

.boot {
  display: grid;
  place-content: center;
  min-height: 100dvh;
  color: var(--color-text-muted);
}

/* User Mode interactive elements meet the touch-target floor — form fields
   too (the sign-in screen runs in User Mode). A checkbox or radio gets it
   through its <label> instead of growing the box itself. */
[data-mode="user"] button,
[data-mode="user"] a[role="button"],
[data-mode="user"] a.btn-link,
[data-mode="user"] .card,
[data-mode="user"] input:not([type="checkbox"], [type="radio"], [type="hidden"]),
[data-mode="user"] select,
[data-mode="user"] summary,
[data-mode="user"] label.checkbox,
[data-mode="user"] label.plan-pick-row {
  min-block-size: var(--touch-min);
  min-inline-size: var(--touch-min);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Stronger separation and full-contrast text when the OS asks for it. */
@media (prefers-contrast: more) {
  :root {
    --color-border: var(--color-border-strong);
    --color-text-muted: var(--color-text);
    --color-success-ink: var(--color-text);
    --color-warning-ink: var(--color-text);
  }
}

/* ---- The in-app accessibility menu (js/a11y-prefs.js, a11y-menu.js) ------
   Attributes on <html>, per device. Each mirrors an OS preference above, so
   the app behaves the same whichever way it was asked. Text size needs no
   CSS here: a11y-prefs.js sets the root font size and the scale is rem. */

/* ניגודיות גבוהה */
:root[data-a11y-contrast] {
  --color-border: var(--color-border-strong);
  --color-text-muted: var(--color-text);
  --color-success-ink: var(--color-text);
  --color-warning-ink: var(--color-text);
}
:root[data-a11y-contrast] :is(button, input, select, textarea, .card, .tile, .editor-card-row) {
  border-width: 2px;
}
:root[data-a11y-contrast] :focus-visible {
  outline-width: 4px;
}

/* עצירת אנימציות */
:root[data-a11y-motion] {
  --motion-duration: 0.001ms;
}
:root[data-a11y-motion] *,
:root[data-a11y-motion] *::before,
:root[data-a11y-motion] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* גופן קריא + קווים תחתונים לקישורים */
:root[data-a11y-readable] {
  --font-sans: Arial, "Helvetica Neue", Helvetica, system-ui, sans-serif;
}
:root[data-a11y-readable] body {
  letter-spacing: 0.03em;
  word-spacing: 0.1em;
  line-height: 1.7;
}
:root[data-a11y-readable] :is(a, .btn-link) {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* Windows High Contrast / forced-colors: let the system paint, keep focus seen. */
@media (forced-colors: active) {
  :focus-visible {
    outline: 3px solid CanvasText;
    outline-offset: 2px;
  }
  .icon {
    forced-color-adjust: auto;
  }
}
