/*
 * Bar-El Adam base stylesheet.
 * Context variables, gentle reset, typography, focus, links, buttons,
 * the section title with its amber rule, icons and the helpers.
 * Logical properties only. Colours come from theme.json presets and
 * customs; the one rgba() in this file is the divider on navy, noted
 * where it appears (redesign-plan section 4.9).
 */

/* ---------- Gentle reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  /* Hebrew and Latin runs both stay untracked (constraints 2). */
  letter-spacing: normal;
}

img {
  max-inline-size: 100%;
  height: auto;
}

[hidden] {
  display: none !important;
}

/* "only light" and not plain "light": plain "light" still lets Chromium's
 * Auto Dark Theme, and the dark mode in Samsung Internet, repaint the light
 * sections of the site into near black on an Android phone whose system
 * theme is dark. The "only" keyword is the documented opt out, and the same
 * declaration is printed as a meta tag in wp_head so it lands before the
 * stylesheet does. See decisions.md item 91. */
html {
  color-scheme: only light;
}

/* ---------- Context variables (redesign-plan section 2) ---------- *
 * Every component reads --ground, --ground-alt, --fg, --fg-strong,
 * --fg-muted, --accent, --line, --focus-ring, --btn-bg, --btn-fg.
 * Four contexts: is-white, is-tint, is-navy (navy-night), is-navy-deep.
 * body carries the white context as the resting default, so anything
 * outside an explicit context class still resolves to a real value. */
body,
.is-white {
  --ground: var(--wp--preset--color--white);
  --ground-alt: var(--wp--preset--color--tint);
  --fg: var(--wp--preset--color--text-body);
  --fg-strong: var(--wp--preset--color--text-heading);
  --fg-muted: var(--wp--preset--color--text-muted);
  --accent: var(--wp--preset--color--amber-text);
  --line: var(--wp--preset--color--border);
  --focus-ring: var(--wp--preset--color--navy-night);
  --btn-bg: var(--wp--preset--color--amber);
  --btn-fg: var(--wp--preset--color--navy-night);
}

.is-tint {
  --ground: var(--wp--preset--color--tint);
  --ground-alt: var(--wp--preset--color--white);
  --fg: var(--wp--preset--color--text-body);
  --fg-strong: var(--wp--preset--color--text-heading);
  --fg-muted: var(--wp--preset--color--text-muted);
  --accent: var(--wp--preset--color--amber-text);
  --line: var(--wp--preset--color--border);
  --focus-ring: var(--wp--preset--color--navy-night);
  --btn-bg: var(--wp--preset--color--amber);
  --btn-fg: var(--wp--preset--color--navy-night);
}

.is-navy {
  --ground: var(--wp--preset--color--navy-night);
  --ground-alt: var(--wp--preset--color--navy-deep);
  --fg: var(--wp--preset--color--white);
  --fg-strong: var(--wp--preset--color--white);
  --fg-muted: var(--wp--preset--color--text-muted-navy);
  --accent: var(--wp--preset--color--amber);
  --line: rgba(255, 255, 255, 0.15); /* allowed rgba: the footer divider on navy (redesign-plan 4.9) */
  --focus-ring: var(--wp--preset--color--amber);
  --btn-bg: var(--wp--preset--color--amber);
  --btn-fg: var(--wp--preset--color--navy-night);
}

.is-navy-deep {
  --ground: var(--wp--preset--color--navy-deep);
  --ground-alt: var(--wp--preset--color--navy-night);
  --fg: var(--wp--preset--color--white);
  --fg-strong: var(--wp--preset--color--white);
  --fg-muted: var(--wp--preset--color--text-muted-navy);
  --accent: var(--wp--preset--color--amber);
  --line: rgba(255, 255, 255, 0.15); /* allowed rgba: the footer divider on navy (redesign-plan 4.9) */
  --focus-ring: var(--wp--preset--color--amber);
  --btn-bg: var(--wp--preset--color--amber);
  --btn-fg: var(--wp--preset--color--navy-night);
}

body {
  caret-color: var(--wp--preset--color--navy-deep);
}

.ba-section,
.is-white,
.is-tint,
.is-navy,
.is-navy-deep {
  background: var(--ground);
  color: var(--fg);
}

/* ---------- Typography ---------- *
 * Families, sizes, weights and line heights live in theme.json. This
 * file adds the mobile sizes, the heading colour inside a context, and
 * the Hebrew-specific rules a preset cannot express. */

/* theme.json sets the heading colour once, globally (text-heading).
   That is right on white and tint, invisible on navy. A colour set
   directly on h1-h6 is not something the section's own `color` can
   override through inheritance, only a rule that targets the heading
   can: every heading inside a section reads the section's --fg-strong. */
.ba-section h1,
.ba-section h2,
.ba-section h3,
.ba-section h4,
.is-navy h1,
.is-navy h2,
.is-navy h3,
.is-navy h4,
.is-navy-deep h1,
.is-navy-deep h2,
.is-navy-deep h3,
.is-navy-deep h4 {
  color: var(--fg-strong);
}

h1,
h2,
h3,
h4 {
  margin-block: 0;
}

h2,
h3 {
  text-wrap: balance;
}

p {
  max-inline-size: 68ch;
}

/* Amber subheading (DESIGN.md section 2, "כותרת משנה בענבר"). */
.ba-sub {
  font-family: var(--wp--preset--font-family--heading);
  font-size: var(--wp--preset--font-size--sub);
  font-weight: 600;
  line-height: 1.4;
  color: var(--accent);
}

.ba-small {
  font-size: var(--wp--preset--font-size--small);
  line-height: 1.7;
  color: var(--fg-muted);
}

/* Mobile type scale (DESIGN.md section 2). The presets are custom
   properties on :root; redeclaring them on body under 768px flips every
   consumer at once, theme.json element styles included. */
@media (max-width: 767px) {
  body {
    --wp--preset--font-size--heading-1: 30px;
    --wp--preset--font-size--heading-2: 26px;
    --wp--preset--font-size--heading-3: 22px;
    --wp--preset--font-size--sub: 18px;
    --wp--preset--font-size--small: 13px;
    --wp--preset--font-size--nav: 18px;
    --wp--preset--font-size--tel: 18px;
    --wp--preset--font-size--btn: 16px;
    --wp--preset--font-size--eyebrow: 15px;
  }
}

/* ---------- Section title with the amber rule (DESIGN.md section 3) ---------- */
.ba-section__title {
  font-family: var(--wp--preset--font-family--heading);
  font-size: var(--wp--preset--font-size--heading-2);
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-wrap: balance;
  margin-block: 0 var(--wp--preset--spacing--40);
}

.ba-section__title::after {
  content: "";
  display: block;
  inline-size: 56px;
  block-size: var(--wp--custom--rule);
  margin-block-start: 14px;
  margin-inline: auto;
  border-radius: 2px;
  background: var(--wp--preset--color--amber);
}

/* Start-aligned variant: the rule hugs the inline start (the right side in RTL). */
.ba-section__title--start {
  text-align: start;
}

.ba-section__title--start::after {
  margin-inline: 0;
}

/* ---------- Bidi isolation for Latin runs in Hebrew copy ---------- */
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}

/* ---------- Inline icons (inc/icons.php outputs ba-icon ba-icon--{name}) ---------- *
 * Lucide outlines: stroke inherits the text colour, no fill. */
.ba-icon {
  inline-size: 1.5em;
  block-size: 1.5em;
  flex: none;
  stroke: currentColor;
  fill: none;
}

/* The three brand marks are filled shapes, not strokes. */
.ba-icon--whatsapp,
.ba-icon--facebook,
.ba-icon--linkedin {
  fill: currentColor;
  stroke: none;
}

/* ---------- Visually hidden, still reachable by assistive technology ---------- */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  block-size: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  inline-size: 1px;
  word-wrap: normal;
  white-space: nowrap;
}

/* The skip link becomes visible once it takes focus. */
.skip-link:focus-visible {
  position: fixed;
  inset-block-start: 8px;
  inset-inline-start: 8px;
  clip: auto;
  clip-path: none;
  inline-size: auto;
  block-size: auto;
  margin: 0;
  overflow: visible;
  padding: var(--wp--preset--spacing--8) var(--wp--preset--spacing--16);
  background: var(--wp--preset--color--amber);
  color: var(--wp--preset--color--navy-night);
  border-radius: var(--wp--custom--radius);
  font-weight: 700;
  text-decoration: none;
  z-index: 1000;
}

/* ---------- Focus and selection ---------- */
:focus-visible {
  outline: var(--wp--custom--rule) solid var(--focus-ring);
  outline-offset: 2px;
}

::selection {
  background: var(--wp--preset--color--amber);
  color: var(--wp--preset--color--navy-night);
}

/* ---------- Links ---------- */
a {
  color: var(--accent);
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
  transition: text-decoration-thickness 200ms ease, color 200ms ease;
}

a:hover {
  text-decoration-thickness: 2px;
}

/* ---------- Buttons (DESIGN.md section 5) ---------- */
.ba-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wp--preset--spacing--8);
  min-block-size: 48px;
  padding-inline: var(--wp--preset--spacing--40);
  padding-block: 0;
  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--btn);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  border: var(--wp--custom--hairline) solid transparent;
  border-radius: var(--wp--custom--radius);
  cursor: pointer;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease;
}

.ba-btn:hover {
  text-decoration: none;
}

.ba-btn--primary {
  background: var(--wp--preset--color--amber);
  border-color: var(--wp--preset--color--amber);
  color: var(--wp--preset--color--navy-night);
}

.ba-btn--primary:hover {
  background: var(--wp--preset--color--amber-hover);
  border-color: var(--wp--preset--color--amber-hover);
  color: var(--wp--preset--color--navy-night);
}

/* Outline button on navy ground: amber line, fills amber on hover. */
.ba-btn--outline {
  min-block-size: 40px;
  padding-inline: var(--wp--preset--spacing--24);
  background: transparent;
  border-color: var(--wp--preset--color--amber);
  color: var(--wp--preset--color--amber);
}

.ba-btn--outline:hover {
  background: var(--wp--preset--color--amber);
  color: var(--wp--preset--color--navy-night);
}

/* Outline button on white ground: navy line, fills navy on hover. */
.ba-btn--outline-navy {
  background: transparent;
  border-color: var(--wp--preset--color--navy-night);
  color: var(--wp--preset--color--navy-night);
}

.ba-btn--outline-navy:hover {
  background: var(--wp--preset--color--navy-night);
  color: var(--wp--preset--color--white);
}

/* ---------- Motion: hover only, 200ms, and none at all on request ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  /* Hover lifts are transforms; a state glyph (chevron, crumb separator)
     is not, so only the hover state is neutralised here. Component
     sheets do the same for their own hover transforms. */
  .ba-btn:hover,
  .ba-tile:hover {
    transform: none !important;
  }
}
