/* Minimal site styles: a permanent left sidebar with the section navigation. */

/* Design tokens (M5.1a). Single source of truth for the palette, typography and
   shape used across the site. Colours are grouped into: the M5 brand palette
   (introduced here, adopted by the header/hero/schedule in later M5 phases);
   neutral/semantic colours (applied everywhere now, at their pre-M5 values so
   this slice is a pure refactor); and a few surface-specific colours kept at
   their current values until the surface that owns them is restyled. */
:root {
  /* Brand palette (M5 redesign). */
  --color-primary: #bccee2;        /* пудрово-голубой — header/footer background */
  --color-primary-dark: #5f8298;
  --color-primary-light: #f3faff;  /* schedule day-card background */
  --color-secondary: #a7c4a0;      /* нежно-зелёный */
  --color-accent: #9e4b57;         /* нежно-бордовый */
  --color-sunday: #b03a3a;         /* Sunday in the schedule (M5.4) */
  --color-text-blue: #1d345b;      /* "Text blue" — owner-named heading/link accent */

  /* Neutral & semantic colours (applied now). */
  --color-bg: #ffffff;
  --color-surface: #f7f5f4;
  --color-border: #e3e3e3;
  --color-hover: #ecebea;
  --color-text: #222222;
  --color-text-muted: #6b6b6b;     /* unifies the former #777/#666/#555/#999 */
  --color-text-inverse: #ffffff;
  --color-success: #3f7d47;
  --color-error: #b03a3a;

  /* Surface-specific colours kept at their current values for now; re-pointed
     to the brand palette when those surfaces are restyled in later M5 phases. */
  --color-nav-active-fg: #7b1113;
  --color-nav-active-bg: #f0e2e2;
  --color-chip-active: #6b4f2a;
  --color-chip-border: #d8d2cc;
  --color-chip-border-hover: #b9afa5;

  /* Draft-preview notice banner. */
  --color-notice-bg: #fff3cd;
  --color-notice-border: #ffe08a;
  --color-notice-text: #7a5b00;

  /* Lightbox overlay. */
  --overlay: rgba(0, 0, 0, 0.9);
  --overlay-control: rgba(255, 255, 255, 0.1);
  --overlay-control-strong: rgba(255, 255, 255, 0.15);
  --color-on-overlay-muted: #eeeeee;

  /* Typography. --font-serif is declared for headings adopted in later phases. */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;

  /* Type scale — adopted incrementally as surfaces are (re)built in later phases. */
  --fs-body: 1rem;
  --fs-h1: 2rem;
  --fs-h2: 1.5rem;
  --fs-h3: 1.15rem;

  /* Spacing scale — adopted incrementally as surfaces are (re)built. */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2.5rem;

  /* Shape. */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --radius-pill: 999px;
  --container-width: 900px;  /* content column (kept narrow for readability) */
  --container-wide: 1280px;  /* header/full-width bands — more room for the nav */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  line-height: 1.5;
  color: var(--color-text);
}

/* Skip link — off-screen until focused, so keyboard users can jump past the
   header straight to the content. */
.skip-link {
  position: absolute;
  left: 0;
  top: 0;
  transform: translateY(-120%);
  background: var(--color-accent);
  color: var(--color-text-inverse);
  padding: 0.5rem 0.9rem;
  border-radius: 0 0 var(--radius) 0;
  text-decoration: none;
  z-index: 100;
}
.skip-link:focus {
  transform: translateY(0);
}

/* Explicit, on-brand keyboard-focus ring (M5.11/D119) — the browser default
   outline is easy to lose against the brand's light-blue/white backgrounds.
   --color-text-blue checked at ≥3:1 (WCAG 1.4.11) against every background
   the ring can land on (white, --color-primary, --color-primary-light, the
   nav/gallery-card highlight tints) — --color-primary-dark failed several of
   those. :focus-visible (not :focus) so a mouse click doesn't draw the ring,
   only keyboard/assistive-tech navigation does. */
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--color-text-blue);
  outline-offset: 2px;
}

/* Present for screen readers, invisible on screen — e.g. a page-hero's <h1>
   when the editor turns off the overlay text (M5.2b). The clip-based
   technique (not display:none) keeps it in the accessibility tree. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* Sticky top header with the brand and primary navigation. Mobile-first: the
   nav is a full-width column below the brand row; the desktop media query lays
   it out inline. The `.js` rules hide the nav behind the hamburger only when
   JavaScript is present, so without JS the links stay visible (see nav.js). */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-primary);
  border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
  /* Wider than the content column so the tabs fit on one line; this shrinks the
     left/right auto margins that were forcing the nav to wrap. */
  max-width: var(--container-wide);
  margin: 0 auto;
  /* Smaller than before (was 0.6rem 1rem) — the bigger logo (M5.2b) left the
     row just barely too tight to fit brand + every tab on one line; this
     (and the smaller, non-viewport-scaling gap below) frees exactly the
     width that was pushing the nav onto its own line. */
  padding: 0.625rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  /* Fluid size; kept on one line so the parish name never breaks. */
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.2rem);
  white-space: nowrap;
  text-decoration: none;
  color: var(--color-text);
}

.brand__logo {
  height: 4.2rem;
  width: auto;
}

.nav-toggle {
  display: none; /* hidden by default and without JS; shown on mobile once JS loads */
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  border-radius: var(--radius);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.js .nav-toggle {
  display: inline-flex;
}

.site-nav {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.js .site-nav {
  display: none;
}
.js body.nav-open .site-nav {
  display: flex;
}

.site-nav a {
  text-decoration: none;
  color: var(--color-text);
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  /* Fixed section tabs stay on a single line (no mid-phrase break). */
  white-space: nowrap;
  font-size: clamp(0.9rem, 0.82rem + 0.35vw, 1.02rem);
}

.site-nav a:hover {
  background: var(--color-hover);
}

.site-nav a.active {
  color: var(--color-nav-active-fg);
  font-weight: 600;
  background: var(--color-nav-active-bg);
}

/* Static-page tabs (О приходе, Контакты, …) can carry long titles: let those
   wrap across lines within a sensible width instead of forcing one very wide
   tab, while the fixed section tabs above stay on one line. */
.site-nav a.nav-page {
  white-space: normal;
  max-width: 16rem;
}

main {
  max-width: var(--container-width);
  margin: 0 auto;
  /* Extra bottom padding — content was sitting right against the footer. */
  padding: 1rem 1.5rem var(--space-6);
}

/* PageHero: "photo + section title" banner (M5.3/D115). The image is real
   content (a photo of the section/item), so it is a real <img alt="…">, not a
   CSS background — a dark gradient overlay keeps the title readable over any
   photo. Falls back to a plain token-coloured band with dark text when there
   is no photo (page_hero missing, or the item has no cover). */
.page-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  min-height: clamp(140px, 10vw + 100px, 220px);
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-surface));
}

.page-hero__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-hero__overlay {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: var(--space-4) 1.5rem;
}

.page-hero:not(.page-hero--no-image) .page-hero__overlay {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0) 75%);
}

.page-hero__title {
  max-width: var(--container-width);
  margin: 0 auto;
  font-size: clamp(1.4rem, 1.15rem + 1.1vw, var(--fs-h1));
  color: var(--color-text-inverse);
}

.page-hero--no-image {
  align-items: center;
  min-height: clamp(100px, 6vw + 70px, 150px);
}

/* Per-image opt-outs (M5.2b): show the photo uncropped/at full height, and/or
   drop the gradient — e.g. a homepage hero with no title over it at all.
   Selector specificity matches (and so, by source order, overrides) the
   ":not(.page-hero--no-image)" gradient rule above. */
.page-hero.page-hero--no-gradient .page-hero__overlay {
  background: none;
}

.page-hero--fit {
  min-height: 0;
}

.page-hero--fit .page-hero__image {
  position: static;
  height: auto;
  object-fit: initial;
  display: block;
}

.page-hero--fit .page-hero__overlay {
  position: absolute;
  inset: auto 0 0 0;
}

.page-hero--no-image .page-hero__title {
  color: var(--color-text);
}

/* Weekly schedule: one card per day, always 7 (empty days included, D113). */
.schedule {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.schedule-day {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-4);
  background: var(--color-primary-light);
}

.schedule-day__heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  font-size: var(--fs-h3);
}

.schedule-day__date {
  color: var(--color-text-muted);
}

.schedule-day__weekday {
  font-weight: 700;
  color: var(--color-text-blue);
}

/* Sunday is highlighted, not just labeled (D113). */
.schedule-day--sunday {
  border-color: var(--color-sunday);
}

.schedule-day--sunday .schedule-day__weekday {
  color: var(--color-sunday);
}

.schedule-day__feast {
  font-style: italic;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-2);
}

.schedule-day__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.schedule-day__empty {
  color: var(--color-text-muted);
  margin: 0;
}

/* Liturgical day-of info (M5.5/D114): fasting name + saints/feast commemorated. */
.schedule-day__fasting {
  display: inline-block;
  margin: 0 0 var(--space-2);
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-pill);
  /* A stronger tone than the card's own background (--color-primary-light),
     so the badge still stands out against it. */
  background: var(--color-primary);
  color: var(--color-primary-dark);
  font-size: 0.85rem;
}

.schedule-day__commemoration {
  color: var(--color-text-muted);
  font-style: italic;
  margin: 0 0 var(--space-3);
}

/* When there are more than two commemoration lines, .schedule-day__commemoration
   is a <details> element instead of a plain <div> — a native, JS-free
   disclosure (D3 holds: no framework/scripting needed for a show/hide toggle). */
.schedule-day__commemoration summary {
  cursor: pointer;
}

.schedule-day__more-hint {
  font-style: normal;
  font-size: 0.85em;
}

.schedule-day__commemoration-rest {
  margin-top: var(--space-2);
}

/* An editor's note (M5.5a, owner's call): always visible, never collapsed
   into the commemoration's "show more" disclosure above. Not italic, so it
   reads as an addition from the parish rather than more source text. */
.schedule-day__editor-note {
  border-left: 3px solid var(--color-accent);
  padding-left: var(--space-2);
  margin: 0 0 var(--space-3);
  color: var(--color-text);
}

/* Apostle/Gospel readings of the day (M5.5b) — shown unconditionally,
   regardless of whether any service is scheduled that day. */
.schedule-day__reading {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-3);
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.schedule-attribution {
  margin-top: var(--space-3);
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

/* Content articles (news / pages) */
.article .cover {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
}

.article__title {
  margin: 0 0 var(--space-2);
  font-size: clamp(1.4rem, 1.15rem + 1.1vw, var(--fs-h1));
}

.article .meta {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* News list card (M5.6): cover on the left, title + meta + excerpt on the
   right. Every card is the same fixed height regardless of title length or
   excerpt length (owner's call, to match a reference layout) — the cover
   stretches to that same height, and the title/excerpt clip to a fixed
   number of lines (`-webkit-line-clamp`) instead of growing the card. */
.news-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.news-card {
  display: flex;
  gap: var(--space-4);
  height: 8rem;
  overflow: hidden;
  text-decoration: none;
  color: var(--color-text);
}

.news-card__cover {
  flex: 0 0 auto;
  display: block;
  height: 100%;
}

.news-card__cover img {
  width: 10rem;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

.news-card__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.news-card__title {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-h3);
  color: var(--color-text-blue);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-card__meta {
  margin: 0 0 var(--space-2);
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.news-card__excerpt {
  margin: 0;
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Global footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-primary);
  padding: 1.5rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  /* --color-text-muted on this background is only 3.32:1 — fails WCAG AA
     (D33/M5.11 contrast audit). --color-text on --color-primary is 9.9:1. */
  color: var(--color-text);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer .muted {
  /* .muted's own --color-text-muted fails contrast on this background too —
     inherit the footer's already-fixed colour instead of a second token. */
  color: inherit;
}

.site-footer p {
  margin: 0.25rem 0;
}

.site-footer a {
  color: var(--color-text-blue);
}

.footer-columns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  width: 100%;
  text-align: left;
}

.footer-column {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.footer-social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-badge {
  max-width: 100%;
  max-height: 9.5rem;
  width: auto;
  height: auto;
}

.muted {
  color: var(--color-text-muted);
}

.preview-notice {
  background: var(--color-notice-bg);
  border: 1px solid var(--color-notice-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--color-notice-text);
}

/* Galleries: index of galleries and the per-gallery photo grid. */
.gallery-index {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.gallery-index li {
  /* The card (the <a> below) fills the whole grid cell, so every card in a
     row is the same height and the click/hover area covers all of it. */
  display: flex;
}

/* Gallery card (M5.7): the whole card is a single link (cover + title + date)
   so a click anywhere on it — not just the image or title — opens the
   gallery. Styled after .schedule-day (same border/background tokens); the
   hover behaves like .site-nav a's (swaps the card's background), but with
   its own owner-chosen colour instead of --color-hover. */
.gallery-card {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-4);
  background: var(--color-primary-light);
  text-decoration: none;
  color: var(--color-text);
}

.gallery-card:hover {
  background: #d4ebfe; /* owner-specified hex, distinct from --color-hover */
}

.gallery-card__cover {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin: 0 0 var(--space-2);
}

.gallery-card__title {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-h3);
  color: var(--color-text-blue);
  /* Never let a long, unbroken title (e.g. one long word) run past the
     card's (and so the cover's) width. */
  overflow-wrap: anywhere;
}

.gallery-card__date {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* Clergy card (M5.7/D29): horizontal — photo left, everything else right —
   unlike .gallery-card's vertical layout (owner's call: this list is short,
   so a wide card reads better than a grid of tiles). Styled after
   .schedule-day (same border/background tokens as the other M5 cards). */
.clergy-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.clergy-card {
  display: flex;
  gap: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-4);
  background: var(--color-primary-light);
}

.clergy-card__photo {
  flex: 0 0 auto;
  width: 9rem;
  height: 9rem;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

/* A mourning border for a clergy member whose death_date is set (owner's
   call) — independent of is_active, which controls list visibility. */
.clergy-card__photo--deceased {
  border: 3px solid #000;
}

.clergy-card__body {
  flex: 1 1 auto;
  min-width: 0;
}

.clergy-card__name {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-h3);
}

.clergy-card__bio {
  margin: 0 0 var(--space-2);
  color: var(--color-text);
}

.clergy-card__facts {
  list-style: none;
  padding: 0;
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* The label word ("Дата рождения:" etc.) is a shade darker than the value
   next to it (owner's call), so the fact list is easier to scan. */
.clergy-card__fact-label {
  color: var(--color-text);
}

/* Education entered as several lines renders as a bulleted sub-list rather than
   one run-on sentence (owner's call). Needs its own list-style because the
   parent .clergy-card__facts deliberately has none. */
.clergy-card__education {
  list-style: disc;
  margin: var(--space-1) 0 0;
  padding-left: 1.25rem;
}

/* Shrine card (M5.8/D117): horizontal — portrait photo left, everything else
   right — like .clergy-card, but with its own background. */
.shrine-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.shrine-card {
  display: flex;
  gap: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-4);
  background: #f0e2e2; /* owner-specified hex */
}

/* The trigger button needs `.photo-trigger`'s reset (border/padding/
   background/cursor, defined below), but that rule's own `width: 100%;
   height: 100%` would stretch it to fill the card — the compound selector
   guarantees this fixed size wins regardless of the two rules' order below. */
.shrine-card__photo-trigger.photo-trigger {
  flex: 0 0 auto;
  /* Without this, the flex container's default `align-items: stretch`
     grows the photo to match the body's height once the description
     <details> is opened (owner's call: keep it at its collapsed size). */
  align-self: flex-start;
  width: 9rem;
  height: auto;
  aspect-ratio: 3 / 4;
}

.shrine-card__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.shrine-card__body {
  flex: 1 1 auto;
  min-width: 0;
}

.shrine-card__title {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-h3);
  color: var(--color-text-blue);
}

/* The native <summary> marker sits above a line-clamped block instead of
   inline with its first line (owner's call: it should read like the
   schedule day's commemoration disclosure, arrow beside the text). Replaced
   with our own ::before arrow, which — unlike the native marker — is part of
   the same clamped box, so it flows inline with the first line. */
.shrine-card__description summary {
  cursor: pointer;
  list-style: none;
}

.shrine-card__description summary::-webkit-details-marker {
  display: none;
}

.shrine-card__description summary::before {
  content: "▸ ";
  /* The ▸/▾ glyph doesn't fill its em-box the way the browser's own native
     marker does (which this replaces, see above) — sized up to read the
     same as that native triangle in the schedule day's card. */
  font-size: 1.3em;
  font-weight: 700;
}

.shrine-card__description[open] summary::before {
  content: "▾ ";
}

/* Collapsed to ~2 lines via CSS line-clamp (owner's call) — unlike the
   schedule day's commemoration <details> (D3), description is free text, not
   a known list of lines, so there is no server-side "first two lines" slice
   to reuse; opening removes the clamp and shows the full text. */
.shrine-card__description:not([open]) summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Extra photos (ShrineImage) shown small and centered under the
   description — distinct from the one portrait `shrine.image` on the left. */
.shrine-card__extra-images {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.shrine-card__extra-image-trigger.photo-trigger {
  flex: 0 0 auto;
  width: auto;
  height: 4rem;
}

.shrine-card__extra-image {
  height: 100%;
  width: auto;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.donation-methods {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.donation-methods__title {
  margin-bottom: 1rem;
  font-weight: 700;
}

.donation-methods__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.donation-method {
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.donation-method__title {
  margin: 0 0 0.6rem;
  line-height: 1.3;
  /* Reserve space for 2 lines so steps/QR start at the same height across
     cards, whether a method's title takes one line or two. */
  min-height: 2.6em;
}

.donation-method__steps {
  list-style: none;
  counter-reset: donation-step;
  margin: 0;
  padding: 0;
}

.donation-method__steps li {
  counter-increment: donation-step;
  position: relative;
  padding-left: 1.75rem;
  margin-bottom: 0.5rem;
}

.donation-method__steps li::before {
  content: counter(donation-step);
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 1px solid var(--color-primary-dark);
  color: var(--color-primary-dark);
  font-size: 0.75rem;
  font-weight: 700;
}

.donation-method__qr-link {
  display: block;
  width: 6rem;
  margin: 0.75rem auto 0;
}

.donation-method__qr {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.photo-grid figure {
  margin: 0;
}
.photo-grid img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}
.photo-grid figcaption {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.article-photos {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: var(--space-4);
}
.article-photos figure {
  margin: 0;
  width: 160px;
}
.article-photos img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}
.article-photos figcaption {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: center;
}


/* Desktop: lay the navigation out inline in the header and drop the hamburger.
   The header row no longer sets `justify-content` (default packs items from
   the start, right after the brand) — with `flex-wrap` left at its base
   `wrap`, if a narrow desktop window ever runs out of room, the *whole* nav
   drops to its own row below the brand as one unit, instead of individual
   tabs being squeezed and breaking apart mid-row. */
@media (min-width: 680px) {
  .nav-toggle,
  .js .nav-toggle {
    display: none;
  }
  .site-nav,
  .js .site-nav {
    display: flex;
    flex-basis: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    /* Fluid gap between tabs; whole tabs wrap to a second line if crowded. */
    gap: 0.25rem clamp(0.5rem, 0.1rem + 1vw, 1.25rem);
  }
}

/* Gallery photo-grid trigger button: reset default button chrome so it looks
   exactly like the plain <img> it replaces (M4.1 Slice C). */
.photo-trigger {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

/* Fullscreen photo lightbox (M4.1 Slice C). Built once by static/js/lightbox.js
   and toggled with the `hidden` attribute. */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
}
/* Without this, `.lightbox`'s own `display: flex` above ties in specificity
   with the browser's built-in `[hidden] { display: none }` rule and wins by
   source order, so the `hidden` attribute stops actually hiding the element —
   the higher-specificity attribute+class selector here is what makes it win. */
.lightbox[hidden] {
  display: none;
}
body.lightbox-open {
  overflow: hidden;
}
.lightbox-figure {
  margin: 0;
  /* A fixed box (not just a cap) so a small photo is enlarged to fill it
     too, and — since the image below always fills this box exactly — a
     caption longer than a small photo can no longer widen the figure past
     the image and leave it stranded off-centre. */
  width: 90vw;
  height: 80vh;
  text-align: center;
}
.lightbox-image {
  display: block;
  width: 100%;
  height: 100%;
  /* Scales a small photo up and a large one down, preserving its aspect
     ratio (letterboxed within the figure box), never distorted. */
  object-fit: contain;
}
.lightbox-caption {
  margin-top: 0.5rem;
  color: var(--color-on-overlay-muted);
  font-size: 0.9rem;
}
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  border: 0;
  background: var(--overlay-control);
  color: var(--color-text-inverse);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
}
.lightbox-close {
  top: 1rem;
  right: 1rem;
}
.lightbox-prev {
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}
.lightbox-next {
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}
.lightbox-download {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--overlay-control-strong);
  color: var(--color-text-inverse);
  text-decoration: none;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .lightbox-prev,
  .lightbox-next {
    width: 2rem;
    height: 2rem;
    font-size: 1.4rem;
  }

  /* Phone layout for the two horizontal cards (owner's call): the photo and the
     heading keep sharing the top row, but the prose below them spans the whole
     card instead of staying trapped in the narrow right-hand column — on a
     360px screen that column is barely 170px wide. Desktop keeps the flex
     layout above untouched.

     `display: contents` on the body is what makes this possible without
     changing the markup: it dissolves the wrapper so its children become grid
     items of the card itself. Safe here specifically because that wrapper is a
     plain <div> carrying no semantics, so removing its box takes nothing out of
     the accessibility tree. */
  .shrine-card,
  .clergy-card {
    display: grid;
    grid-template-columns: 9rem 1fr;
    align-items: start;
  }

  .shrine-card__body,
  .clergy-card__body {
    display: contents;
  }

  .shrine-card__photo-trigger.photo-trigger,
  .clergy-card__photo {
    grid-column: 1;
    grid-row: 1;
  }

  .shrine-card__title,
  .clergy-card__name {
    grid-column: 2;
    grid-row: 1;
  }

  /* The full width, both collapsed and expanded: letting only the open state
     span the card would make it jump sideways on every toggle. */
  .shrine-card__description,
  .shrine-card__extra-images,
  .clergy-card__bio,
  .clergy-card__facts {
    grid-column: 1 / -1;
  }
}

/* Public filter chips — one row per facet (gallery categories, gallery years,
   news categories). Generic names since the same markup now serves more than
   one kind of facet. */
.chip-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 1.25rem;
}
.chip {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--color-chip-border);
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  color: var(--color-text-muted);
  text-decoration: none;
}
.chip:hover {
  border-color: var(--color-chip-border-hover);
}
.chip.is-active {
  background: var(--color-chip-active);
  border-color: var(--color-chip-active);
  color: var(--color-text-inverse);
}

/* Homepage (M5.10/D116): each composed section gets a heading + a "see all"
   link to that section's own full page, so the teaser never dead-ends. */
.home-section {
  margin: 0 0 var(--space-6);
}

.home-section__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
}

.home-section__header h2 {
  margin: 0;
  font-size: var(--fs-h2);
  color: var(--color-text-blue);
}

.home-section__link {
  color: var(--color-primary-dark);
  text-decoration: none;
  white-space: nowrap;
}

.home-section__link:hover {
  text-decoration: underline;
}

.home-section .schedule {
  margin: 0;
}
