/* ==========================================================================
   M3RBS: Minyanim & Shuls page
   Loaded only by shuls.html, after base.css (shared tokens, header, footer).
   ========================================================================== */

/* ---------- Overview: intro, schedules, code key ----------
   One grid. Source order (intro, schedules, key) is the order phones and tablets show;
   on desktop the key is placed beside the intro. */
.overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--s3);
  padding-top: var(--s3);
  padding-bottom: var(--s5);
}

.page-head__lede {
  margin-top: var(--s1);
  font-size: 1.0625rem;
  max-width: 34rem;
}

/* The Shabbat/chag caveat: set apart because it changes what the page covers */
.page-head__note {
  margin-top: 12px;
  padding-left: 12px;
  border-left: 2px solid var(--accent-logo);
  font-size: 0.9375rem;
  color: var(--muted);
  max-width: 34rem;
}

/* Jump links: an ordinary inline row, not a sticky toolbar */
.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s2);
  margin-top: var(--s1);
}
.jump a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ink);
}
.jump a:hover { color: var(--accent); }

/* Shul code key */
.codes .label { padding-bottom: var(--s0); }

/* Phones: a two-column key, code then name, names may wrap within their column */
.codes__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--s1);
}
.codes__list a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 36px;
  padding-block: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.3;
}
.codes__code {
  flex: 0 0 2.25rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--accent);
}
.codes__list a:hover .codes__name { text-decoration: underline; text-underline-offset: 0.18em; }

/* Key below the schedules (phones and tablets): ruled like the tables above it */
.codes { border-top: 1px solid var(--line-strong); padding-top: 12px; }

@media (max-width: 639.98px) {
  .overview { padding-top: var(--s2); padding-bottom: var(--s4); row-gap: var(--s2); }
  .page-head__note { font-size: 0.875rem; }
  .jump { margin-top: 6px; }
  .codes { margin-top: var(--s0); }
  .directory { padding-top: var(--s4); }
}

@media (min-width: 640px) {
  .overview { padding-top: var(--s4); }
  .codes { margin-top: var(--s1); }
  .codes__list { gap: 0 var(--s3); }
  .codes__list li { border-bottom: 1px solid var(--line); }
  .codes__list a { align-items: center; font-size: 0.9375rem; min-height: 40px; padding-block: 4px; }
  .codes__code { flex-basis: 3rem; }
}

@media (min-width: 1000px) {
  .overview {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--col-gap);
    row-gap: var(--s3);
    align-items: start;
    padding-top: var(--s4);
    padding-bottom: var(--s6);
  }
  .page-head__text { grid-column: 1 / span 7; grid-row: 1; }
  .codes { grid-column: 9 / -1; grid-row: 1; margin-top: 6px; }
  .schedules { grid-column: 1 / -1; grid-row: 2; }
  .codes__list { grid-template-columns: 1fr; }
  .codes__list a { min-height: 32px; padding-block: 2px; }
  /* Schedules sit side by side and the key is beside the intro: only the directory jump is kept */
  .jump .jump__narrow { display: none; }
  .schedule td { padding-block: 8px; }
}

/* ---------- Weekday schedules ---------- */

.schedules__grid {
  display: grid;
  gap: var(--s4) var(--s5);
  align-items: start;
}

.tefilla__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s1);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-strong);
}
.tefilla__heb {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--muted);
}

.schedule {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  /* 1.6 x 15px = 24px lines: every schedule link can be a 24px-tall target (WCAG 2.2 SC 2.5.8)
     while times, codes and notes keep a shared baseline. */
  line-height: 1.6;
}

.schedule th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px 6px 0;
  border-bottom: 1px solid var(--line);
}

.schedule td {
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.schedule th:last-child,
.schedule td:last-child { padding-right: 0; }

/* Fixed clock times: dark, tabular figures */
.schedule .time {
  width: 5.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink);
}

/* Times relative to the day's zmanim: green, medium weight, dotted link */
.schedule .time--rel { color: var(--accent); font-weight: 500; }
.schedule .time--rel a,
.schedule .notes a {
  color: var(--accent);
  text-decoration-style: dotted;
  text-decoration-color: currentColor;
}

.schedule .shuls { width: 4.25rem; }
.schedule .shuls a {
  display: inline-block;
  min-width: 24px;
  min-height: 24px;
  margin-right: 6px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
}
/* Zmanim links (HaNetz, B'zman, Shkiya) in the Time column: same 24px minimum */
.schedule .time--rel a {
  display: inline-block;
  min-height: 24px;
}
.schedule .shuls a:hover { text-decoration: underline; }

.schedule .notes { color: var(--ink); }

@media (hover: hover) {
  .schedule tbody tr:hover td { background: color-mix(in srgb, var(--accent-wash) 60%, transparent); }
}

.schedules__notes {
  display: grid;
  gap: var(--s0);
  font-size: 0.875rem;
  color: var(--muted);
  padding-top: var(--s1);
  border-top: 1px solid var(--line);
}
.schedules__notes p { max-width: 38rem; }

@media (max-width: 639.98px) {
  .schedules__grid { gap: var(--s4); }
  .schedule .time { width: 5rem; }
  .schedule .shuls { width: 3.75rem; }
}

@media (min-width: 640px) {
  .schedules__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .schedules__notes { align-self: start; margin-top: 44px; }
}

@media (min-width: 1000px) {
  .schedules__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: var(--s4); row-gap: var(--s3); }
  .schedules__notes {
    grid-column: 1 / -1;
    margin-top: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--s4);
  }
}

/* ---------- Shul directory ---------- */
.directory {
  border-top: 1px solid var(--line);
  padding-block: var(--s5);
}

.directory__head { display: grid; gap: 12px; }

.directory__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.75rem, 1.35rem + 1.4vw, 2.375rem);
  line-height: 1.1;
  letter-spacing: -0.012em;
}

.directory__intro {
  font-size: 0.9375rem;
  color: var(--muted);
  max-width: 40rem;
}

.shul-list {
  margin-top: var(--s3);
  border-top: 1px solid var(--line-strong);
}

/* One reference entry per shul. Heights follow content; nothing is padded for symmetry. */
.shul {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "id    logo"
    "facts facts";
  gap: 12px var(--s1);
  padding: 20px 0 var(--s2);
  border-bottom: 1px solid var(--line);
}

.shul__logo {
  grid-area: logo;
  justify-self: end;
  width: auto;
  height: 56px;
  max-width: 84px;
  object-fit: contain;
  object-position: right top;
  /* White plates in some logo files take on the page colour; dark artwork is unaffected */
  mix-blend-mode: multiply;
}

/* Wide wordmarks (KH, KYH, MM) carry large empty margins in their files, so they are sized
   by width rather than height. Their measured empty top/bottom margins (--trim-t/--trim-b, as
   fractions of the image height) are offset with negative margins: no artwork is cropped. */
.shul__logo--mark {
  --logo-w: 92px;
  width: var(--logo-w);
  height: auto;
  max-width: none;
  margin-top: calc(var(--logo-w) / var(--ar) * var(--trim-t) * -1);
  margin-bottom: calc(var(--logo-w) / var(--ar) * var(--trim-b) * -1);
}

.shul__id { grid-area: id; min-width: 0; }

.shul__code {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-logo);
  margin-bottom: 2px;
}

.shul__name {
  font-size: 1.3125rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.005em;
}

.shul__aka { margin-top: 2px; font-size: 0.9375rem; color: var(--muted); }

.shul__heb {
  margin-top: 10px;
  font-size: 1.125rem;
  line-height: 1.35;
}

.shul__nusach {
  margin-top: 4px;
  font-size: 0.9375rem;
}
.shul__nusach-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 6px;
}

.shul__facts { grid-area: facts; margin: 0; }

.fact {
  display: grid;
  grid-template-columns: 6.25rem minmax(0, 1fr);
  gap: var(--s1);
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.fact:first-child { border-top: 0; padding-top: 0; }
.fact:last-child { padding-bottom: 0; }

.fact dt {
  padding-top: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.fact dd {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.fact bdi { white-space: nowrap; }

.fact__action {
  display: inline-block;
  margin-top: 4px;
  font-weight: 500;
}

.person { display: block; font-weight: 500; }
.contact { display: block; }
.contact + .person { margin-top: 8px; }
.contact a { font-variant-numeric: tabular-nums; }

/* Touch: give inline contact links a taller hit area without changing the layout */
@media (pointer: coarse) {
  .fact dd a { display: inline-block; padding-block: 6px; }
  .fact__action { margin-top: 0; }
}

@media (min-width: 640px) {
  .directory__head { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); column-gap: var(--s4); align-items: baseline; }
  /* Tablet: logo in a narrow left column; identity, then facts at full remaining width */
  .shul {
    grid-template-columns: 5.5rem minmax(0, 1fr);
    grid-template-areas:
      "logo id"
      "logo facts";
    column-gap: var(--s3);
  }
  .shul__logo { justify-self: start; object-position: left top; max-width: 88px; }
  .shul__logo--mark { --logo-w: 88px; }
}

@media (min-width: 1000px) {
  .directory { padding-block: var(--s6); }
  .directory__head {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--col-gap);
  }
  .directory__title { grid-column: 1 / span 4; }
  .directory__intro { grid-column: 6 / -1; }
  .shul {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-areas: none;
    column-gap: var(--col-gap);
    padding: var(--s3) 0;
  }
  .shul__logo { grid-column: 1 / span 2; grid-row: 1; height: 72px; max-width: 120px; }
  .shul__logo--mark { --logo-w: 124px; height: auto; max-width: none; }
  .shul__id { grid-column: 3 / span 4; grid-row: 1; }
  .shul__facts { grid-column: 7 / -1; grid-row: 1; }
  .shul__name { font-size: 1.5rem; }
  .fact { grid-template-columns: 7rem minmax(0, 1fr); }
  .fact:first-child { padding-top: 2px; }
}
