/* ═══════════════════════════════════════════════════════════════════
   main.css — הממשק.

   כל ערך כאן מגיע ממשתנה ב-tokens.css. אין צבע, מרווח או גודל
   טקסט שנכתב ישירות, כדי שהחלפת מיתוג תהיה שינוי במקום אחד.

   נבנה mobile-first: הכללים הבסיסיים הם למסך צר, ו-media queries
   רק מוסיפים עליהם.
   ═══════════════════════════════════════════════════════════════════ */

/* ── פונט מאוחסן מקומית ────────────────────────────────────────────
   Heebo, פונט משתנה שמכסה משקלים 400–700 בקובץ אחד לכל תת-קבוצה.
   שני קבצים, 42KB יחד. אין קריאה ל-CDN חיצוני.                  */
@font-face {
  font-family: "Heebo";
  src: url("/assets/fonts/heebo-hebrew.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: "Heebo";
  src: url("/assets/fonts/heebo-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  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;
}

/* ── איפוס ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  /* 16px בסיס. פחות מזה גורם ל-iOS להגדיל את המסך בפוקוס על שדה. */
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;

  /* אף אלמנט לא יגרום לגלילה אופקית. */
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { max-width: 100%; height: auto; display: block; }

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

/* ── עזרי נגישות ──────────────────────────────────────────────── */
.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-4);
  top: -100px;
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  color: var(--brand-primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-float);
  text-decoration: none;
  font-weight: 600;
  transition: top var(--duration) var(--ease);
}
.skip-link:focus { top: var(--space-4); }

/* טבעת פוקוס אחידה לכל דבר שאפשר להגיע אליו במקלדת. */
:focus-visible {
  outline: 3px solid var(--brand-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* מלכודת בוטים. מוסתרת ויזואלית ומקוראי מסך, אבל לא ב-display:none
   שחלק מהבוטים מזהים ומדלגים עליו. */
.honeypot {
  position: absolute;
  inset-inline-start: -9999px;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* ── ראש העמוד ────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: var(--space-4) var(--space-4);
  padding-top: max(var(--space-4), env(safe-area-inset-top));
}

.site-header__inner {
  max-width: var(--content-max);
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.site-header__logo {
  height: 40px;
  width: auto;
  flex: none;
  color: var(--ink-faint);   /* לוגו ה-placeholder משתמש ב-currentColor */
}

.site-header__text {
  display: flex;
  flex-direction: column;
  min-width: 0;              /* מאפשר לטקסט ארוך להיחתך במקום לדחוף */
}

.site-header__name {
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--ink);
}

.site-header__tagline {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  line-height: var(--leading-tight);
}

/* ── פריסת העמוד ──────────────────────────────────────────────── */
.page {
  max-width: var(--content-max);
  margin-inline: auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
}

.intro { margin-bottom: var(--space-5); }

.intro__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-2);
  text-wrap: balance;
}

.intro__text {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

/* ── הכרטיס ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5) var(--space-4);
}

/* ── מחוון התקדמות ────────────────────────────────────────────── */
.progress { margin-bottom: var(--space-5); }

.progress__track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.progress__seg {
  height: 5px;
  border-radius: 99px;
  background: var(--line);
  transition: background var(--duration) var(--ease);
}

.progress__seg[data-state="done"]    { background: var(--brand-secondary); }
.progress__seg[data-state="current"] { background: var(--brand-primary); }

.progress__meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
}

.progress__counter {
  font-size: var(--text-xs);
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  flex: none;
}

.progress__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--brand-primary);
  text-align: end;
}

/* ── שלב ──────────────────────────────────────────────────────── */
.step[hidden] { display: none; }

.step__heading {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: var(--leading-tight);
  margin-bottom: var(--space-4);
}
/* השלב מקבל פוקוס במעבר, אבל אין טעם בטבעת סביב כותרת. */
.step__heading:focus { outline: none; }

.fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 var(--space-5);
}
.fieldset:last-child { margin-bottom: 0; }

.fieldset__legend {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-muted);
  padding: 0;
  margin-bottom: var(--space-3);
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

/* ── שדה ──────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; }

.field__label {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--ink);
}

.field__req {
  color: var(--error);
  margin-inline-start: 2px;
}

.field__optional {
  font-weight: 400;
  color: var(--ink-faint);
  font-size: var(--text-xs);
  margin-inline-start: var(--space-2);
}

.field__input {
  width: 100%;
  min-height: var(--tap-target);
  padding: var(--space-3);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  line-height: 1.4;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
}

.field__input::placeholder { color: var(--ink-faint); }
.field__input:hover:not(:focus) { border-color: var(--line-strong); }

.field__input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 18%, transparent);
}

/* טלפון, אימייל ומספרים נכתבים משמאל לימין גם בתוך עמוד RTL,
   אבל נשארים מיושרים לימין כדי לשבת נכון בפריסה. */
.field__input[dir="ltr"] { text-align: right; }

.field__input[aria-invalid="true"] {
  border-color: var(--error);
  background: var(--error-bg);
}
.field__input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--error) 18%, transparent);
}

.field__hint {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: var(--space-2);
}

.field__error {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--error);
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.field__error::before { content: "⚠"; font-size: 1em; }
.field__error[hidden] { display: none; }

/* ── תיבת סימון ───────────────────────────────────────────────── */
.checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-target);
  cursor: pointer;
  font-size: var(--text-sm);
}

.checkbox__input {
  flex: none;
  width: 22px;
  height: 22px;
  accent-color: var(--brand-primary);
  cursor: pointer;
}

/* ── שם לחשבונית ──────────────────────────────────────────────── */
.invoice-preview {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
}

.invoice-preview__label {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  display: block;
}

.invoice-preview__value {
  font-weight: 600;
  font-size: var(--text-base);
}
.invoice-preview__value:empty::after {
  content: "יתמלא משם פרטי ושם משפחה";
  color: var(--ink-faint);
  font-weight: 400;
}

.invoice-preview__value--empty {
  color: var(--ink-faint);
  font-weight: 400;
}

.invoice-custom { margin-top: var(--space-4); }
.invoice-custom[hidden] { display: none; }

/* ── קישור לא תקין ────────────────────────────────────────────────
   מחליף את הטופס לגמרי. מכוון להיראות כמו הודעה שקטה של עסק
   מסודר ולא כמו שגיאת מערכת.                                    */
.notice { text-align: center; }
.notice[hidden] { display: none; }

.notice__title {
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: var(--leading-tight);
  margin-bottom: var(--space-3);
}
.notice__title:focus { outline: none; }

.notice__body {
  color: var(--ink-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
  text-wrap: pretty;
}

.notice__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  text-decoration: none;
  min-width: 60%;
}

/* ── מסך הבדיקה ───────────────────────────────────────────────── */
.review__intro {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin-bottom: var(--space-4);
}

.review__group {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-3);
}

.review__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
}

.review__title {
  font-size: var(--text-sm);
  font-weight: 700;
}

.review__edit {
  background: none;
  border: 0;
  padding: var(--space-2);
  margin: calc(var(--space-2) * -1);
  color: var(--brand-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  min-height: var(--tap-target);
}
.review__edit:hover { text-decoration: underline; }

.review__list { padding: var(--space-2) var(--space-4); }

.review__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
}
.review__row:last-child { border-bottom: 0; }

.review__key { color: var(--ink-muted); flex: none; }

.review__val {
  font-weight: 600;
  text-align: end;
  overflow-wrap: anywhere;   /* מייל ארוך לא ישבור את הפריסה */
}
.review__val--empty { font-weight: 400; color: var(--ink-faint); }
.review__val--ltr { direction: ltr; }

/* ── התראות ───────────────────────────────────────────────────── */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  border: 1px solid;
}
.alert[hidden] { display: none; }

.alert--error {
  background: var(--error-bg);
  border-color: color-mix(in srgb, var(--error) 35%, transparent);
  color: var(--error);
}
.alert--warn {
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--warn);
}

.alert--success {
  background: var(--success-bg);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
  color: var(--success);
}

/* ── פעולות ───────────────────────────────────────────────────── */
.actions { margin-top: var(--space-5); }

.privacy {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  text-align: center;
  margin-bottom: var(--space-3);
  text-wrap: pretty;
}
.privacy[hidden] { display: none; }

.actions__row {
  display: flex;
  gap: var(--space-3);
}

.btn {
  flex: 1;
  min-height: 52px;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--duration) var(--ease),
              border-color var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn[hidden] { display: none; }

.btn--primary {
  background: var(--brand-primary);
  color: #fff;
  flex: 2;   /* הפעולה הראשית מקבלת יותר מקום מהמשנית */
}
.btn--primary:hover:not(:disabled) { background: var(--brand-primary-dark); }

.btn--ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-muted);
}
.btn--ghost:hover:not(:disabled) {
  border-color: var(--ink-muted);
  color: var(--ink);
}

/* ── התאמות למסך רחב יותר ─────────────────────────────────────── */
@media (min-width: 30rem) {          /* 480px */
  .grid--half  { grid-template-columns: 1fr 1fr; }
  .grid--third { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 40rem) {          /* 640px */
  .page { padding-block: var(--space-6) var(--space-7); }
  .card { padding: var(--space-6); }
  .site-header { padding-block: var(--space-5); }
  .site-header__logo { height: 48px; }

  /* במסך רחב יש מקום להציג את שם כל שלב מתחת לפס שלו. */
  .progress__seg { position: relative; }
  .progress__seg::after {
    content: attr(data-name);
    position: absolute;
    top: calc(100% + var(--space-2));
    inset-inline-start: 0;
    font-size: var(--text-xs);
    color: var(--ink-faint);
    white-space: nowrap;
  }
  .progress__seg[data-state="current"]::after {
    color: var(--brand-primary);
    font-weight: 600;
  }
  .progress__track { margin-bottom: var(--space-6); }
  .progress__meta { display: none; }   /* המונה מיותר כששמות השלבים גלויים */
}

/* ── פס פעולות דביק במובייל ────────────────────────────────────
   הפעולה הראשית צריכה להיות תמיד בהישג האגודל, בלי לגלול. */
@media (max-width: 39.99rem) {
  .actions {
    position: sticky;
    bottom: 0;
    margin-inline: calc(var(--space-4) * -1);
    padding: var(--space-3) var(--space-4);
    padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--ground) 92%, transparent);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
  }
}

/* ── הדפסה ────────────────────────────────────────────────────── */
@media print {
  .actions, .progress, .skip-link { display: none; }
  .card { box-shadow: none; border: 1px solid #000; }
  body { background: #fff; }
}
