/* ============================================================================
   base.css - the foundation. Copy in as-is. Requires tokens.css first.

   Everything here exists because it is a bug that ships otherwise:
   RTL correctness, focus visibility, touch targets, reduced motion,
   horizontal-overflow prevention, and text that stays readable over images.
   Do not "clean up" rules here without knowing which bug each one prevents.
   ============================================================================ */

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

html {
  /* clip not hidden: hidden silently kills position:sticky anywhere on the
     page. This single line prevents the most common mobile defect. */
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  letter-spacing: var(--tracking-display);
  line-height: 1.1;
  margin: 0 0 var(--space-4);
  /* Stops a two-word heading dropping one word alone on the last line. */
  text-wrap: balance;
}
h1 { font-size: var(--step-5); }
h2 { font-size: var(--step-4); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }

p { margin: 0 0 var(--space-4); max-width: var(--measure); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

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

/* ---- Layout primitives ---------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--section-y); position: relative; }
.section--tight { padding-block: var(--section-y-tight); }

/* Split layout. Logical properties throughout, so RTL mirrors automatically:
   .split__content lands on the right in RTL and the left in LTR with no
   extra CSS. This is the fix for the most common RTL bug there is. */
.split {
  display: grid;
  gap: var(--space-7);
  align-items: center;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .split { grid-template-columns: 1fr 1fr; gap: var(--space-8); }
  /* Content first in source order = inline-start = right in RTL. Correct by
     construction. To flip a specific instance, use .split--media-first. */
  .split--media-first .split__content { order: 2; }
  .split--media-first .split__media   { order: 1; }
}

.stack > * + * { margin-block-start: var(--flow, var(--space-4)); }

/* ---- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  /* 44px minimum touch target, enforced by min-height not by padding luck. */
  min-height: 44px;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: color-mix(in oklab, var(--accent) 85%, var(--ink)); }
.btn--secondary { background: transparent; color: var(--ink); border-color: color-mix(in oklab, var(--ink) 25%, transparent); }
.btn--secondary:hover { border-color: var(--ink); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

/* Directional icons inside buttons flip in RTL; meaning-fixed icons
   (phone, search, play, social logos) must carry .icon--fixed and never flip. */
[dir="rtl"] .btn .icon--dir { transform: scaleX(-1); }
.icon--fixed { transform: none !important; }

/* ---- Focus ---------------------------------------------------------------- */

/* :focus-visible only, so a mouse click does not leave a ring, but every
   keyboard user always sees one. Never remove this without a replacement. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-4);
  top: -100%;
  z-index: 999;
  padding: var(--space-3) var(--space-4);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: var(--space-4); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---- Text over imagery ---------------------------------------------------- */

/* A hero headline over a photo fails contrast at some breakpoint unless the
   scrim is part of the component. This is that scrim - keep it. */
.media-scrim { position: relative; isolation: isolate; }
.media-scrim > img,
.media-scrim > video,
.media-scrim > picture { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; }
/* <picture> is an inline wrapper - the img inside it needs the cover, too. */
.media-scrim > img,
.media-scrim > video,
.media-scrim > picture > img { object-fit: cover; width: 100%; height: 100%; }
.media-scrim::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(
    to top,
    color-mix(in oklab, var(--ink) 78%, transparent) 0%,
    color-mix(in oklab, var(--ink) 45%, transparent) 45%,
    color-mix(in oklab, var(--ink) 20%, transparent) 100%
  );
}
.media-scrim, .media-scrim :is(h1,h2,h3,p) { color: #fff; }

/* ---- Numbers and Latin inside RTL ---------------------------------------- */

/* Phone numbers, prices and Latin brand names stay LTR inside Hebrew text.
   Without this a phone number renders with its parts reordered. */
.ltr-isolate { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* ---- Motion --------------------------------------------------------------- */

.reveal {
  /* Content must remain visible even if the optional motion layer is delayed
     or unavailable. Animation is enhancement, never the rendering path. */
  opacity: 1;
  transform: none;
  transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}
.reveal.is-visible { opacity: 1; transform: none; }

/* One global switch. Any animation added later is already covered. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---- Header --------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-block-end: var(--border);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  min-height: 68px;
}
.site-header__logo img, .site-header__logo svg { height: 40px; width: auto; }

/* ---- Mobile menu: full screen, always ------------------------------------- */

/* The partial dropdown is the single most common mobile defect: a panel that
   covers 60% of the screen while the page and any sticky bar stay visible
   around it. inset:0 + 100dvh makes that impossible. */
.nav-toggle { display: none; }
.mobile-menu {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  z-index: var(--z-menu);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--gutter);
  /* Respect the notch and the home indicator. */
  padding-block: max(var(--gutter), env(safe-area-inset-top))
                 max(var(--gutter), env(safe-area-inset-bottom));
  overflow-y: auto;
  transform: translateY(-100%);
  visibility: hidden;
  transition: transform var(--dur) var(--ease), visibility var(--dur);
}
.mobile-menu[data-open="true"] { transform: none; visibility: visible; }
.mobile-menu a { font-size: var(--step-2); text-decoration: none; color: var(--ink); padding-block: var(--space-3); }

/* While the menu is open: lock scroll, and hide every floating element so
   nothing can sit on top of the menu. */
body[data-menu-open="true"] { overflow: hidden; }
body[data-menu-open="true"] :is(.sticky-bar, .a11y-fab) { visibility: hidden; }

@media (min-width: 900px) { .mobile-menu { display: none; } }
@media (max-width: 899px) { .nav-toggle { display: inline-flex; } .site-nav { display: none; } }

/* ---- Sticky mobile conversion bar ----------------------------------------- */

.sticky-bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: var(--z-float);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--accent);
  padding-block-end: env(safe-area-inset-bottom);
}
.sticky-bar a {
  min-height: 52px;
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  color: var(--accent-ink); text-decoration: none; font-weight: 600;
}
@media (min-width: 900px) { .sticky-bar { display: none; } }
/* Stops the bar covering the last section's content. */
@media (max-width: 899px) { body:has(.sticky-bar) { padding-block-end: 52px; } }

/* ---- Forms ---------------------------------------------------------------- */

.field { display: grid; gap: var(--space-2); margin-block-end: var(--space-4); }
.field label { font-weight: 600; font-size: var(--step--1); }
.field input, .field textarea, .field select {
  font: inherit;
  /* 16px minimum on mobile or iOS zooms the page on focus. */
  font-size: max(16px, var(--step-0));
  padding: var(--space-3);
  min-height: 44px;
  border: 1px solid color-mix(in oklab, var(--ink) 22%, transparent);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  width: 100%;
}
.field input:focus-visible, .field textarea:focus-visible { border-color: var(--accent); }
/* Errors carry an icon or text, never colour alone. */
.field[data-invalid="true"] input { border-color: #b91c1c; }
.field__error { color: #b91c1c; font-size: var(--step--1); }
.field__error::before { content: "! "; font-weight: 700; }

/* ---- Accessibility ---------------------------------------------------------

   The floating trigger and its panel live entirely in the a11y kit
   (a11y/a11y.css + a11y/a11y.js), which mounts itself. Nothing here styles
   them, so the icon is identical on every site and cannot drift. The only
   thing a project changes is colour, via the tokens the kit already reads
   (--accent / --accent-ink / --bg / --ink).

   The one rule kept here: hide the trigger while the mobile menu is open,
   because that is this shell's concern, not the kit's. See the rule above.
   --------------------------------------------------------------------------- */
