/* ==========================================================================
   M3RBS shared foundation: tokens, base elements, header/menu, footer.
   Loaded by every page before its page-specific stylesheet
   (home, shuls, shops, services, groups, maps, links). style.css is no longer used by any page.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Colour: warm paper, green-black ink, one green accent family taken from the logo */
  --bg: #f6f5f0;
  --surface: #ffffff;
  --ink: #1c2620;
  --muted: #58645d;
  --line: #d7dcd3;
  --line-strong: #1c2620;
  --accent: #2e5e44;        /* links, active states (≈6.9:1 on --bg) */
  --accent-deep: #225632;   /* the logo's square green; buttons */
  --accent-logo: #47765b;   /* the wordmark green; small graphic details only */
  --accent-wash: #e8efe8;

  /* Type */
  --font-sans: "Instrument Sans", "Noto Sans Hebrew", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-hebrew: "Noto Sans Hebrew", "Instrument Sans", system-ui, sans-serif;

  /* Space: 8px foundation */
  --s-1: 4px;
  --s0: 8px;
  --s1: 16px;
  --s2: 24px;
  --s3: 32px;
  --s4: 48px;
  --s5: 64px;
  --s6: 96px;

  /* Geometry */
  --frame: 1160px;
  --gutter: clamp(16px, 4vw, 40px);
  --col-gap: 24px;
  --radius: 4px;
  --header-h: 64px;

  /* Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 150ms;
  --t-state: 220ms;
}

@media (min-width: 1000px) {
  :root { --header-h: 76px; }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--s1));
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

[lang="he"] { font-family: var(--font-hebrew); }

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  transition: color var(--t-fast) var(--ease), text-decoration-color var(--t-fast) var(--ease);
}
a:hover { color: var(--accent-deep); text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.frame {
  width: 100%;
  max-width: calc(var(--frame) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 100;
  padding: var(--s0) var(--s1);
  background: var(--ink);
  color: var(--surface);
  text-decoration: none;
}
.skip-link:focus { top: var(--s0); }

/* Text for assistive technology only (e.g. full shul names behind schedule codes, table captions) */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Small structural label used for section names (not decorative) */
.label {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.3;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
}

.brand { display: inline-flex; align-items: center; min-height: 44px; }
.brand img { width: 140px; height: auto; }

@media (min-width: 1000px) {
  .brand img { width: 160px; }
}

/* Menu toggle: shown only on narrow screens and only when JS is running */
.menu-toggle {
  display: none;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 var(--s0) 0 var(--s1);
  margin-right: calc(-1 * var(--s0));
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 500 0.9375rem/1 var(--font-sans);
  cursor: pointer;
  border-radius: var(--radius);
}
.menu-toggle:focus-visible { outline-offset: -2px; }

.menu-toggle__icon {
  position: relative;
  width: 18px;
  height: 10px;
}
.menu-toggle__icon::before,
.menu-toggle__icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  transition: transform var(--t-state) var(--ease), top var(--t-state) var(--ease);
}
.menu-toggle__icon::before { top: 0; }
.menu-toggle__icon::after { top: 8px; }

.menu-toggle[aria-expanded="true"] .menu-toggle__icon::before { top: 4px; transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle__icon::after { top: 4px; transform: rotate(-45deg); }

.site-menu__label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.site-menu a {
  color: var(--ink);
  text-decoration: none;
}
.site-menu a:hover { color: var(--accent); }

/* Desktop: a short row of in-page links; the six destinations are the index itself */
@media (min-width: 1000px) {
  .site-menu { display: flex; align-items: center; }
  .site-menu__group--directory,
  .site-menu__label { display: none; }
  .site-menu__group--page ul { display: flex; gap: var(--s3); }
  .site-menu__group--page a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 0.9375rem;
    font-weight: 500;
  }
}

/* Narrow screens */
@media (max-width: 999.98px) {
  .js .menu-toggle { display: inline-flex; }

  .site-menu__directory-anchor { display: none; }

  /* Panel: sits directly under the header, sized to its content */
  .js .site-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding: var(--s1) var(--gutter) var(--s2);
    background: var(--bg);
    border-bottom: 1px solid var(--line-strong);
    visibility: hidden;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity var(--t-state) var(--ease), transform var(--t-state) var(--ease), visibility 0s linear var(--t-state);
  }
  .js .site-menu.is-open {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: opacity var(--t-state) var(--ease), transform var(--t-state) var(--ease), visibility 0s;
  }

  .site-menu__group--directory ul { margin-top: var(--s0); }
  .site-menu__group--directory li + li { border-top: 1px solid var(--line); }
  .site-menu__group--directory a {
    display: flex;
    align-items: center;
    min-height: 48px;
    font-size: 1.125rem;
    font-weight: 500;
  }

  .site-menu__group--page {
    margin-top: var(--s0);
    padding-top: var(--s0);
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--s0) var(--s2);
  }
  .site-menu__group--page ul { display: flex; flex-wrap: wrap; gap: 0 var(--s2); }
  .site-menu__group--page a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 1rem;
  }

  /* Without JavaScript, the menu is simply shown as a static block under the header */
  html:not(.js) .site-header__inner { height: auto; min-height: var(--header-h); flex-wrap: wrap; padding-block: var(--s0); }
  html:not(.js) .site-menu { width: 100%; }
  html:not(.js) .site-menu__group--directory { display: none; }
  html:not(.js) .site-menu__group--page { margin-top: 0; padding-top: 0; border-top: 0; }
}

/* Eyebrow: a short context line above a page title */
.eyebrow {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-logo);
  margin-bottom: var(--s1);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line-strong);
  padding-block: var(--s4) var(--s5);
  font-size: 0.875rem;
  color: var(--muted);
}

.site-footer__inner { display: grid; gap: var(--s3); }

.site-footer__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: var(--s0);
}

.site-footer__copyright { max-width: 34rem; }

.site-footer__links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--s2);
}
.site-footer__links a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9375rem;
}
.site-footer__links a:hover { color: var(--accent); text-decoration: underline; }

@media (min-width: 1000px) {
  .site-footer__inner { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--col-gap); }
  .site-footer__id { grid-column: 1 / span 5; }
  .site-footer nav { grid-column: 8 / -1; }
  .site-footer__links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Page title for directory pages (shuls, shops): Newsreader, moderate size */
.page-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-optical-sizing: auto;
  font-size: clamp(2.125rem, 1.45rem + 2.4vw, 3.25rem);
  line-height: 1.04;
  letter-spacing: -0.018em;
  text-wrap: balance;
}

/* ---------- Header variant for directory pages ----------
   Inner pages add .site-nav--pages: on desktop the header lists the six directory
   destinations (with the current page marked) instead of the homepage's in-page links.
   The homepage does not use this modifier, so its header is unaffected. */
.site-menu a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
  text-decoration-color: var(--accent-logo);
}

@media (min-width: 1000px) {
  .site-nav--pages .site-menu__group--directory { display: block; }
  .site-nav--pages .site-menu__group--directory ul { display: flex; gap: var(--s2); }
  .site-nav--pages .site-menu__group--directory a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 0.9375rem;
    font-weight: 500;
  }
  .site-nav--pages .site-menu__group--directory a[aria-current="page"] { font-weight: 600; text-underline-offset: 8px; }
  .site-nav--pages .site-menu__group--page { display: none; }
}

@media (max-width: 999.98px) {
  html:not(.js) .site-nav--pages .site-menu__group--directory { display: block; }
  html:not(.js) .site-nav--pages .site-menu__group--directory ul { display: flex; flex-wrap: wrap; gap: 0 var(--s2); margin-top: 0; }
  html:not(.js) .site-nav--pages .site-menu__group--directory li + li { border-top: 0; }
  html:not(.js) .site-nav--pages .site-menu__group--directory a { min-height: 44px; font-size: 1rem; }
  html:not(.js) .site-nav--pages .site-menu__label { display: none; }
}
