/* קלורי — base (FROZEN, SPEC §12): reset, typography, RTL rules, forms, a11y.
   Rules: logical properties only; numeric inputs are LTR with text-align:end;
   .stepper / .chart / .ring are LTR islands; only .icon--dir mirrors in RTL. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh);
  background: var(--c-bg);
  color: var(--c-text);
  overflow-x: clip;
}

body {
  margin: 0;
  min-block-size: 100dvh;
  background: var(--c-bg);
  color: var(--c-text);
  text-align: start;
  overflow-wrap: anywhere;
  overflow-x: clip;
}

html.has-dialog,
html.has-dialog body {
  overflow: hidden;
}

/* ---------- typography ---------- */
h1, h2, h3, h4, p, ul, ol, dl, figure, blockquote {
  margin: 0;
}
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-sm); }
p + p { margin-block-start: var(--sp-2); }
small { font-size: var(--fs-sm); }
strong, b { font-weight: 700; }
em, i { font-style: normal; font-weight: 600; } /* no italics in Hebrew UI */
a {
  color: var(--c-primary-text);
  text-decoration: none;
  text-underline-offset: 2px;
}
a:hover { text-decoration: underline; }
ul, ol { padding-inline-start: 1.25em; }
hr {
  border: 0;
  border-block-start: 1px solid var(--c-border);
  margin-block: var(--sp-4);
}
code, kbd, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9375em;
  direction: ltr;
  unicode-bidi: isolate;
}
table {
  border-collapse: collapse;
  inline-size: 100%;
  font-variant-numeric: tabular-nums;
}
th, td {
  text-align: start;
  padding: var(--sp-2);
  border-block-end: 1px solid var(--c-border);
}
th { font-size: var(--fs-sm); color: var(--c-text-2); font-weight: 600; }

/* numbers: tabular digits, isolated from the surrounding bidi run */
.num,
bdi {
  font-variant-numeric: tabular-nums;
  unicode-bidi: isolate;
}
bdi[dir="ltr"] { direction: ltr; }
[lang="en"] {
  unicode-bidi: isolate;
  direction: ltr;
  display: inline-block;
}

/* ---------- media & icons ---------- */
img, svg, video, canvas {
  max-inline-size: 100%;
  vertical-align: middle;
}
img { block-size: auto; }
.icon {
  inline-size: 1.25em;
  block-size: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
}
/* mirror ONLY directional glyphs (chevrons, arrows, back) in RTL */
[dir="rtl"] .icon--dir {
  transform: scaleX(-1);
}

/* ---------- forms ---------- */
button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  margin: 0;
}
button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  text-align: center;
}
button:disabled { cursor: not-allowed; }
input, select, textarea {
  font-size: var(--fs-md); /* never below 16px: prevents iOS zoom */
  min-inline-size: 0;
}
textarea { resize: vertical; }
label { cursor: pointer; }
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-inline-size: 0;
}
legend { padding: 0; }

/* numeric inputs: LTR digits, aligned to the end; the unit sits as a sibling */
input[type="number"],
input[inputmode="decimal"],
input[inputmode="numeric"],
input[type="tel"] {
  direction: ltr;
  text-align: end;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="date"],
input[type="time"],
input[type="email"],
input[type="url"] {
  direction: ltr;
  text-align: end;
}
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
::placeholder { color: var(--c-text-2); opacity: 1; } /* 6:1 light / 6.5:1 dark; explicit 1 also overrides Firefox's .54 default */

/* LTR islands */
.stepper,
.chart,
.ring {
  direction: ltr;
}

/* ---------- a11y ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
}
main:focus,
[tabindex="-1"]:focus { outline: none; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute !important;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  inset-block-start: var(--sp-2);
  inset-inline-start: var(--sp-2);
  z-index: var(--z-skip);
  padding: var(--sp-2) var(--sp-4);
  background: var(--c-primary-strong);
  color: var(--c-primary-contrast);
  border-radius: var(--r-2);
  font-weight: 700;
  transform: translateY(-200%);
  opacity: 0;
  transition: transform var(--dur-1) var(--ease), opacity var(--dur-1);
}
.skip-link:focus-visible {
  transform: none;
  opacity: 1;
  outline-color: var(--c-primary-contrast);
  outline-offset: -4px;
}

::selection {
  background: var(--c-primary-soft);
  color: var(--c-text);
}

/* reduced motion (OS or in-app setting) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
html[data-reduce-motion="on"] *,
html[data-reduce-motion="on"] *::before,
html[data-reduce-motion="on"] *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
  scroll-behavior: auto !important;
}

/* ---------- tiny utilities (not page-specific) ---------- */
.muted { color: var(--c-text-2); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-center { text-align: center; }
.text-end { text-align: end; }
.nowrap { white-space: nowrap; }
.row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-inline-size: 0;
}
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.row > .grow,
.grow { flex: 1 1 auto; min-inline-size: 0; }
.stack {
  display: grid;
  gap: var(--sp-3);
  align-content: start;
}
.stack--sm { gap: var(--sp-2); }
.stack--lg { gap: var(--sp-4); }
.divider {
  border: 0;
  border-block-start: 1px solid var(--c-border);
  margin-block: var(--sp-3);
}
.section-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--c-text-2);
  letter-spacing: .01em;
  margin-block: var(--sp-2) var(--sp-2);
}
