/* ==========================================================================
   三江庙 大普公 (San Jiang Temple) - Design System & Global Stylesheet
   All sizes, colors, typography, and spacing are defined in :root.
   No hardcoded hex or pixel values exist below the token block.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&family=Noto+Serif+SC:wght@600;700;900&family=Noto+Sans:ital,wght@0,400;0,600;0,700;1,400&family=Noto+Serif:wght@600;700&display=swap');

/* --------------------------------------------------------------------------
   1. Design System Tokens (:root)
   -------------------------------------------------------------------------- */
:root {
  /* Colors - Dignified, high-contrast traditional temple palette */
  --color-primary: #8B1E1E;            /* Cinnabar Temple Red */
  --color-primary-dark: #621212;       /* Deep Crimson */
  --color-primary-light: #FDF4F4;      /* Soft Rose Tint */
  --color-accent: #B8860B;             /* Temple Gold */
  --color-accent-dark: #7A5900;        /* Bronze Gold */
  --color-accent-light: #FEFAED;       /* Pale Gold Background */
  
  --color-bg: #FAF8F5;                 /* Warm Parchment / Stone White */
  --color-surface: #FFFFFF;            /* Pure Surface White */
  --color-surface-alt: #F3EFE8;        /* Soft Warm Grey/Tan */
  --color-surface-dark: #2B211B;       /* Deep Wood Dark */
  --color-hero-ground: #1A1410;        /* Hero video box ground — what shows before the first frame; darker than --color-surface-dark */
  --color-surface-glass: rgba(255, 255, 255, 0.1); /* White at 10% — the translucent card on the dark hero */
  
  --color-text: #1C1917;               /* High Contrast Charcoal Black (>12:1) */
  --color-text-muted: #4A443F;         /* Readable Medium Dark (>7:1) */
  --color-text-light: #FAF8F5;        /* Light Text for Dark Surfaces */
  --color-text-gold: #D4AF37;          /* Bright Gold Accent Text */

  --color-border: #E0D8CB;             /* Muted Warm Border */
  --color-border-dark: #B8AC99;        /* Stronger Border */
  --color-border-accent: #D4AF37;      /* Gold Border Accent */
  --color-border-subtle: rgba(224, 216, 203, 0.2);      /* --color-border at 20%: hairline on the dark footer */
  --color-border-accent-soft: rgba(212, 175, 55, 0.5);  /* --color-border-accent at 50%: gold hairline on the dark hero */

  --color-focus: #1E40AF;              /* High-visibility Blue Focus Ring */
  --color-focus-bg: #EFF6FF;           /* Focus background tint */

  /* Typography Families */
  --font-zh-sans: 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-zh-serif: 'Noto Serif SC', 'Songti SC', serif;
  --font-en-sans: 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-en-serif: 'Noto Serif', Georgia, serif;

  /* Default Active Typography Variables (Fallback) */
  --font-body: var(--font-zh-sans);
  --font-heading: var(--font-zh-serif);
  --line-height-body: 1.8;
  --line-height-heading: 1.4;
  --letter-spacing-body: 0.03em;
  --letter-spacing-heading: 0.04em;

  /* Font Scale - Mobile First (Min body size >= 17px) */
  --font-size-sm: 0.9375rem;          /* 15px */

  /* Brand lockup type. Mobile-first: these are the phone values. The brand is
     a wordmark, not body copy, so it is not bound by the 17px mobile body-text
     floor. English rises to 19/15px at 76rem; 中文 rises earlier, at
     --brand-zh-fullsize-min. */
  --font-size-brand-title: 1rem;      /* 16px */
  --font-size-brand-subtitle: 0.8125rem; /* 13px */

  /* Width at which the 中文 brand steps up to 19/15px. Below it the 15px
     subtitle cannot hold "San Jiang Temple" on one line and the name breaks
     mid-phrase. Measured crossover is 364px; this carries 8px of margin,
     because real Safari text metrics differ from Chromium and that difference
     has caught this header twice.
     NOTE: a media query prelude cannot read a custom property — `@media
     (min-width: var(--x))` is invalid CSS — so the literal in the query below
     must be kept equal to this token by hand. */
  --brand-zh-fullsize-min: 372px;

  /* Width at which the English brand steps up to 19/15px AND its two name
     halves go back inline, so "San Jiang Temple Tai Por Kong" reads as one
     line. Both flip together: the halves only fit on one line once the type
     they are set in has room for the whole string. At 19px the string measures
     299.70px, and the brand column is viewport minus 240.59px of chrome, so it
     is reached at 541px; this carries 8px of margin for real-Safari metrics.
     Higher than --brand-zh-fullsize-min because on /en/ pages the English name
     is the 19px title, while on 中文 pages it is the 15px subtitle.
     NOTE: a media query prelude cannot read a custom property, so the literal
     in the query below must be kept equal to this token by hand. */
  --brand-en-fullsize-min: 549px;
  --font-size-body: 1.0625rem;        /* 17px - Mobile body baseline */
  --font-size-body-lg: 1.1875rem;     /* 19px */
  --birthday-featured-type-scale: 1.3; /* Featured dates, names and column headers: +30%. */
  --birthday-featured-font-size: calc(var(--font-size-body) * var(--birthday-featured-type-scale));
  --font-size-h4: 1.25rem;            /* 20px */
  --font-size-h3: 1.4375rem;          /* 23px */
  --font-size-h2: 1.75rem;            /* 28px */
  --font-size-h1: 2.25rem;            /* 36px */
  --font-size-hero: 2.625rem;         /* 42px */

  /* Spacing Scale */
  --space-3xs: 0.25rem;               /* 4px */
  --space-2xs: 0.375rem;              /* 6px */
  --space-xs: 0.5rem;                 /* 8px */
  --space-sm: 0.75rem;                /* 12px */
  --space-md: 1rem;                   /* 16px */
  --space-lg: 1.5rem;                 /* 24px */
  --space-xl: 2rem;                   /* 32px */
  --space-2xl: 3rem;                  /* 48px */
  --space-3xl: 4.5rem;                /* 72px */

  /* Structural Dimensions */
  --footer-contact-min-width: 15rem; /* Room for the phone label and number together. */
  --container-max-width: 76rem;       /* ~1216px */
  --nav-container-min-height: 4.25rem; /* 68px — the floor under .nav-container. With the header's 2px border it is what makes the 中文 desktop header 70px: that brand block is only 64px tall */
  --touch-target-min: 2.75rem;        /* 44px - Touch accessibility */
  --measure-prose: 36em;              /* ~36 Chinese chars / ~72 Latin chars per line */
  --z-header: 1000;                   /* the always-visible header */
  --z-skip-link: 1100;                /* above --z-header */
  --z-hero-band: 2;                   /* the pinned hero band on a portrait phone: above the hero text that scrolls beneath it, below --z-header */

  /* Label column in .ritual-fact. Sized from the longest label each language
     actually uses, measured at the label's own 17px/600:
       中文  今年犯太岁生肖          122.57px -> 8.5rem  (136px)  ya-taisui.html
       EN    "Stationery collection" ~174.56px -> 11.5rem (184px)  candidate only
     Both carry the 8px real-Safari margin CLAUDE.md asks for: 13.43px spare in
     中文, 9.44px in English. One value cannot serve both — 8.5rem truncates the
     English, and 11.5rem strands 48px of empty column on every Chinese page.
     Overridden for English in section 2, the same lang-attribute mechanism as
     the nav and brand. The English figure is still derived from candidate
     labels the 负责人 has not approved; see BUILD-PLAN Phase 3's prelude. */
  --ritual-label-col: 8.5rem;         /* 136px — 今年犯太岁生肖 is 122.57px at 17px */
  --border-emphasis-width: 0.25rem;   /* 4px - accent edge on emphasised blocks */
  --hero-height-collapsed: 68vh;      /* hero runway when there is nothing to scrub */

  /* Scroll runway for the scrubbing hero — the distance the video is mapped
     over. ONE value for both breakpoints; it replaces 300vh (desktop) and
     250vh (mobile), which differed backwards for the primary audience: the
     phone, where people most often arrive, paid the longer wait to reach the
     title and the opening hours.

     FLOOR: progress() in hero-scroll-video.js divides by
     `offsetHeight - innerHeight`, so the scrub distance is the runway MINUS
     one viewport. At or below 100vh that is zero, the guard returns 0, and
     both the scrub and the hero-complete toggle are silently disabled —
     the page still looks fine, the video simply never moves.

     TUNING: the clip is 355 frames at 30fps, GOP 12 (keyframes every 0.4s).
     What governs smoothness is pixels of scroll per video frame. 200vh gives
     2.38 px/frame at 390x844 and 2.25 at 1216x800, which still reads as a
     scrub. 150vh gives ~1.2, where one ordinary scroll step jumps ~50 frames
     and the hero flickers between distant moments rather than animating.

     NOT USED on a portrait phone: its opening composition stays pinned over
     --hero-mobile-scrub-distance instead. See --hero-band-aspect. */
  --hero-runway: 200vh;

  /* Shape of the hero on a portrait phone (max-width 600px, portrait): a band
     the full width of the screen. 16:9 is the video's own shape, so the whole
     frame shows uncropped. The band plays hero-480.mp4, at 1.5 device pixels
     per source pixel on a 428px phone; the full-height box showed a cropped
     strip at 2.27. */
  --hero-band-aspect: 16 / 9;
  /* One stable viewport of scrolling completes the portrait-phone video. */
  --hero-mobile-scrub-distance: 100svh;

  /* Focal point for the static hero poster, NOT 50% 50%. object-fit: cover
     crops vertically once the box is wider than ~1.77:1, and the collapsed box
     is only 68vh tall, so it reaches that ratio on any wide-short viewport. At
     50% the 大普公 plaque loses its top there — measured 22 source px at
     1440x760 and 58.5 at 844x390 (a phone in landscape). 25% clears it by
     41.7 and 60 source px respectively, and is a no-op on portrait phones,
     where the crop is horizontal and this axis is never read.
     This value is tuned to where the 大普公 plaque sits in
     assets/hero-poster.jpg (1600x900, plaque top at 0.158 of frame height).
     Re-derive it if the poster frame is ever replaced — the annual update
     swaps photos, and a differently-framed poster makes 25% silently wrong. */
  --hero-poster-focus: 50% 25%;

  /* Replaceable fortune-stick illustration in the page header. */
  --fortune-sticks-image-width: 22rem;
  --fortune-sticks-desktop-image-width: 18rem;

  /* Border Radii */
  --radius-sm: 0.375rem;              /* 6px */
  --radius-md: 0.625rem;              /* 10px */
  --radius-lg: 1rem;                  /* 16px */
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.08);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.1);
  --shadow-lg: 0 10px 28px rgba(28, 25, 23, 0.12);
  --shadow-hero: 0 6px 20px rgba(0, 0, 0, 0.4);        /* under the hero video box, over the dark ground */
  --shadow-hero-map: 0 4px 12px rgba(0, 0, 0, 0.35);   /* the map frame inside the hero card */
  --shadow-brand-logo: 0 2px 6px rgba(0, 0, 0, 0.15);  /* the round logo in the header */
  --text-shadow-hero: 0 2px 4px rgba(0, 0, 0, 0.4);    /* the hero title over the video */

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  /* Shared ritual and Fortune Sticks page redesign. */
  --ritual-v2-page-top: 26px;
  --ritual-v2-page-side: 20px;
  --ritual-v2-page-bottom: 34px;
  --ritual-v2-title-size: 34px;
  --ritual-v2-title-leading: 1.4;
  --ritual-v2-title-gap: 18px;
  --ritual-v2-title-mark-width: 5px;
  --ritual-v2-title-mark-height: 26px;
  --ritual-v2-title-mark-radius: 3px;
  --ritual-v2-title-mark-gap: 10px;
  --ritual-v2-caption-gap: 11px;
  --ritual-v2-caption-size: 19px;
  --ritual-v2-caption-leading: 1.7;
  --ritual-v2-card-radius: 12px;
  --ritual-v2-card-edge: 4px;
  --ritual-v2-card-padding: 20px;
  --ritual-v2-card-gap: 16px;
  --ritual-v2-first-card-gap: 26px;
  --ritual-v2-heading-size: 23px;
  --ritual-v2-heading-leading: 1.5;
  --ritual-v2-body-size: var(--font-size-body);
  --ritual-v2-body-leading: 1.85;
  --ritual-v2-neutral-offset: 3px;
  --ritual-v2-list-inset: 20px;
  --ritual-v2-list-item-inset: 2px;
  --ritual-v2-zodiac-size: 21px;
  --ritual-v2-date-size: var(--ritual-v2-heading-size);
  --ritual-v2-date-leading: 1.7;
  --ritual-v2-ritual-date-leading: 1.6;
  --ritual-v2-date-prefix: "至 ";
  --ritual-v2-lunar-leading: 1.75;
  --ritual-v2-lunar-gap: 5px;
  --ritual-v2-status-gap: 13px;
  --ritual-v2-status-y: 3px;
  --ritual-v2-status-x: 9px;
  --ritual-v2-fee-gap: 18px;
  --ritual-v2-price-size: 31px;
  --ritual-v2-price-spacing: -.03em;
  --ritual-v2-price-unit-gap: 5px;
  --ritual-v2-note-gap: 14px;
  --ritual-v2-note-padding: 10px;
  --ritual-v2-check-size: 22px;
  --ritual-v2-check-leading: 18px;
  --ritual-v2-schedule-label: 4.5em;
  --ritual-v2-action-gap: 25px;
  --ritual-v2-button-height: 52px;
  --ritual-v2-secondary-height: 48px;
  --ritual-v2-button-radius: 8px;
  --ritual-v2-button-gap: 10px;
  --ritual-v2-desktop-top: 38px;
  --ritual-v2-desktop-title: 44px;
  --ritual-v2-desktop-title-mark: 34px;
  --ritual-v2-desktop-heading: 26px;
  --ritual-v2-desktop-date: var(--ritual-v2-desktop-heading);
  --ritual-v2-desktop-caption: 20px;
  --ritual-v2-photo-width: 400px;
  --ritual-v2-zodiac-width: 460px;
  --ritual-v2-stationery-width: 270px;
  --ritual-v2-actions-width: 656px;
  --ritual-v2-single-action-width: 344px;
  --ritual-v2-statue-ratio: 3 / 4;
  --ritual-v2-wenchang-ratio: 3 / 4;
  --ritual-v2-huye-ratio: 2602 / 3470;
  --ritual-v2-fortune-sticks-ratio: 1;
  --ritual-v2-icon-font: Arial, sans-serif;

}

/* --------------------------------------------------------------------------
   2. Language Specific Line Height & Letter Spacing Overrides
   -------------------------------------------------------------------------- */
html[lang="zh"] {
  --font-body: var(--font-zh-sans);
  --font-heading: var(--font-zh-serif);
  --line-height-body: 1.8;            /* Chinese characters need generous leading */
  --line-height-heading: 1.4;
  --letter-spacing-body: 0.03em;
  --letter-spacing-heading: 0.05em;
}

html[lang="en"] {
  --font-body: var(--font-en-sans);
  --font-heading: var(--font-en-serif);
  --ritual-label-col: 11.5rem;       /* 184px — longest candidate ~174.56px at 17px */
  --line-height-body: 1.6;            /* English baseline leading */
  --line-height-heading: 1.25;
  --letter-spacing-body: 0.01em;
  --letter-spacing-heading: -0.01em;
}

/* --------------------------------------------------------------------------
   3. Base Element Reset & Typography
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 100%;                     /* 16px browser base */
  scroll-behavior: auto;               /* smooth breaks cross-page #id loads; see CLAUDE.md */
  -webkit-text-size-adjust: 100%;
}


/* Suppress horizontal bounce without replacing the page scroller.
   The standard chain value preserves overscroll navigation. */
@supports (overscroll-behavior-x: chain) {
  html {overscroll-behavior-x:chain}
}

/* iPhone/iPad WebKit fallback. The user confirmed scrolling, edge-swipe
   Back/Forward and pinch zoom on iPhone Safari on 26 October 2026.
   Prefer chain when WebKit implements it; keep vertical behaviour unchanged. */
@supports (-webkit-touch-callout: none) {
  @supports not (overscroll-behavior-x: chain) {
    html {overscroll-behavior-x:none}
  }
}

body {
  font-family: var(--font-body);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  letter-spacing: var(--letter-spacing-body);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Focus Indicator Rule - Visible Keyboard Accessibility */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
  background-color: var(--color-focus-bg);
}

/* On the dark surfaces the global tint above fails twice: its pale background
   sits under light link text (1.03:1 while focused) and its blue ring is 1.8:1
   against the surround. These links keep their own background and take a gold
   ring instead — 7.47:1 on the footer, and 4.94:1 at worst against the hero
   card (measured at 320, 768 and 1440). */
.site-footer a:focus-visible,
.hero-meta-link:focus-visible {
  outline-color: var(--color-text-gold);
  background-color: transparent;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: var(--line-height-heading);
  letter-spacing: var(--letter-spacing-heading);
  color: var(--color-primary-dark);
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }
h4 { font-size: var(--font-size-h4); }

p {
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-dark);
}

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

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* --------------------------------------------------------------------------
   4. Layout Containers & Grid Utilities
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

@media (min-width: 48rem) {
  .container {
    padding-left: var(--space-xl);
    padding-right: var(--space-xl);
  }
}

.main-content {
  flex: 1 0 auto;
}

/* The skip link's target. main is not a .section, so it gets none of the
   scroll-margin-top below; without this the jump aligns main's top with the
   viewport edge, under the always-visible header. main is the first thing after
   the header, so the margin cannot be fully honoured (that would need a negative
   scroll) and main settles flush below the header — which is the point.

   tabindex="-1" lets the jump move focus into main. The global :focus-visible
   rule would draw a ring and tint the whole page, so it is switched off here
   only; main is not interactive. */
#main-content {
  scroll-margin-top: calc(var(--header-h, 100px) + var(--space-md));
}

.main-content:focus-visible {
  outline: none;
  background-color: transparent;
}

/* scroll-margin-top keeps an anchored section clear of the always-visible
   header. Every nav and footer item is an anchor now, so without this each one
   drops its target heading underneath the header.

   --header-h is written by js/main.js and is exact at both breakpoints (70px
   desktop, 100px once the nav collapses). The 100px fallback is the mobile
   value on purpose: if JS has not run, over-shooting is harmless while
   under-shooting hides the heading. The header's height varies by language and
   width (measured 66–126px), so it is read, never assumed from a token. */
.section {
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-2xl);
  border-bottom: 1px solid var(--color-border);
  scroll-margin-top: calc(var(--header-h, 100px) + var(--space-md));
}

.section:last-of-type {
  border-bottom: none;
}

.section-alt {
  background-color: var(--color-surface-alt);
}

.section-header {
  margin-bottom: var(--space-xl);
  position: relative;
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--color-primary-dark);
  margin-bottom: var(--space-xs);
}

.section-title::before {
  content: "";
  display: inline-block;
  width: 0.375rem;
  height: 1.5rem;
  background-color: var(--color-accent);
  border-radius: var(--radius-sm);
}

.section-subtitle {
  color: var(--color-text-muted);
  font-size: var(--font-size-body);
}

/* --------------------------------------------------------------------------
   5. Top Bar & Navigation Bar (Bilingual Dual-Length Support)
   -------------------------------------------------------------------------- */
/* Skip link (WCAG 2.4.1 Bypass Blocks). Parked above the viewport rather than
   display:none, so it stays focusable and in the accessibility tree; revealed
   on focus. position:fixed takes it out of flow, so it cannot shift the layout.
   The reveal rule must out-rank the global :focus-visible tint, which would
   otherwise paint a pale blue behind white text. a:hover recolours links to
   --color-primary-dark, which is this link's own background, hence the
   colour-only hover rule. The top transition falls under the global
   prefers-reduced-motion block. */
.skip-link {
  position: fixed;
  top: calc(var(--touch-target-min) * -2);
  left: var(--space-sm);
  z-index: var(--z-skip-link);
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target-min);
  padding: var(--space-xs) var(--space-md);
  background-color: var(--color-primary-dark);
  color: var(--color-surface);
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: top var(--transition-fast);
}

.skip-link:focus,
.skip-link:focus-visible {
  top: var(--space-sm);
  background-color: var(--color-primary-dark);
  color: var(--color-surface);
}

.skip-link:hover {
  color: var(--color-surface);
}

/* Always visible, constant height. The header never hides on scroll and never
   shrinks — see js/main.js block 3. There is deliberately no .is-hidden rule
   and no transform transition: nothing moves this element. */
.site-header {
  background-color: var(--color-surface);
  border-bottom: 2px solid var(--color-accent);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  box-shadow: var(--shadow-sm);
}

/* Main Navigation Bar Layout */
.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--nav-container-min-height);
  gap: var(--space-md);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: var(--color-text);
  padding-top: var(--space-xs);
  padding-bottom: var(--space-xs);
  min-width: 0;                          /* flex children default to min-width: auto,
                                            which refuses to shrink below content
                                            width and pushes the page sideways on a
                                            phone. Same fix as .contact-grid's
                                            minmax(0, 1fr). */
}

.brand-text-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* The brand lockup is identical in both languages: the same two lines, the
   same faces, only the order swaps. It therefore pins the SC faces directly
   instead of using --font-heading/--font-body, which html[lang="en"] re-points
   to the Latin Noto faces. The block is sized by its content — never give it a
   fixed width.

   Neither line is nowrap here. Both lines wrap by default so the brand can
   shrink on a phone; nowrap is reinstated at 76rem below, where there is room
   for it. */
.brand-title {
  font-family: var(--font-zh-serif);
  font-weight: 700;
  font-size: var(--font-size-brand-title);
  line-height: 1.2;
  color: var(--color-primary-dark);
}

.brand-subtitle {
  font-family: var(--font-zh-sans);
  font-weight: 400;
  font-size: var(--font-size-brand-subtitle);
  color: var(--color-text-muted);
  line-height: 1.2;
}

/* "San Jiang Temple Tai Por Kong" is two halves. Below 76rem each is its own
   block, so the break falls between them rather than wherever the line happens
   to run out — it used to split after "Tai" in English and after "Por" in
   Chinese. Deliberately NOT nowrap: a half that still cannot fit must wrap
   inside itself, because horizontal page overflow is the failure being avoided.
   At 76rem they go back inline and the name reads as one line. */
.brand-name-part {
  display: block;
}

@media (min-width: 76rem) {
  .brand-name-part {
    display: inline;
  }
}

/* The 中文 name is 三江庙 大普公: a temple and a deity, with a space between
   them. Chinese text may break between any two characters, so at 320px the
   line ran out inside the deity's name and left 公 alone on the next line.
   keep-all allows a break only at the space, so the two names stay whole. The
   中文 name is the title on 中文 pages and the subtitle on English ones, hence
   two selectors. */
html[lang="zh"] .brand-title,
html[lang="en"] .brand-subtitle {
  word-break: keep-all;
}

/* 中文 steps up to the full 19/15px at --brand-zh-fullsize-min (372px), well
   below the nav breakpoint, because its subtitle only needs 131.54px to hold
   "San Jiang Temple" and the column reaches that at 364px.

   English has NO equivalent phone-width step, deliberately. Its name sits in
   the 19px title, which needs 169.48px and does not get it until a 411px
   viewport — past every common phone (360/375/390/402 all miss it), so a step
   there would almost never fire. At 16px the wanted break already holds from
   384px, so English reads correctly on a phone at the smaller size and takes
   19px at 76rem with the rest of the desktop header. */
@media (min-width: 372px) {              /* keep equal to --brand-zh-fullsize-min */
  html[lang="zh"] {
    --font-size-brand-title: 1.1875rem;  /* 19px */
    --font-size-brand-subtitle: var(--font-size-sm); /* 15px */
  }
}

/* English steps later, and steps two things at once: the type AND the name
   halves going inline. Below this the brand is 16/13px on three lines, which
   is what a phone has room for. At and above it the name sits on one line and
   the brand is two, matching the desktop lockup and 中文.

   Only 中文's step is type alone — its name halves stay stacked until 76rem,
   because on a 中文 page the English name is the secondary line and stacking it
   costs nothing. Don't fold the two languages into one rule; they are stepping
   different things for different reasons.

   Both languages now reach full size below 76rem, so the 76rem :root step
   further down is a backstop for a document with no lang attribute. */
@media (min-width: 549px) {              /* keep equal to --brand-en-fullsize-min */
  html[lang="en"] {
    --font-size-brand-title: 1.1875rem;  /* 19px */
    --font-size-brand-subtitle: var(--font-size-sm); /* 15px */
  }

  html[lang="en"] .brand-name-part {
    display: inline;
  }
}

/* Desktop only. Two things happen at 76rem, both because the header stops
   being width-constrained once the nav leaves the hamburger:
     - each brand line is held to one line;
     - the brand steps up to its full 19/15px.
   Below this the title must be free to wrap and to sit smaller, or a 360px
   phone gets a five-line title and a 168px fixed header. Not scoped by lang —
   it applies to both. */
@media (min-width: 76rem) {
  :root {
    --font-size-brand-title: 1.1875rem;    /* 19px */
    --font-size-brand-subtitle: var(--font-size-sm);
  }

  .brand-title,
  .brand-subtitle {
    white-space: nowrap;
  }

  /* min-width: 0 above lets the brand shrink on a phone, which is what stops
     it forcing horizontal overflow there. On desktop the opposite is wanted:
     the nav is beside it and would otherwise take the brand's width under
     flex-shrink, leaving a nowrap title painting outside its own box. Two
     constraints, two scopes. */
  .brand-link {
    flex-shrink: 0;
  }
}

/* Action Controls (Lang Switcher & Mobile Menu Toggle) */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Language Switcher Button.
   Only the TARGET language shows, at every width — "EN" on a 中文 page, "中文"
   on an English one. Naming the destination is what the control is for; naming
   the language you are already reading adds width and no information, and that
   width is contested by the nav in the same header row. The switch itself stays
   visible at every size and never moves into the hamburger. The aria-label
   names the action, so it reads correctly on its own.

   The current-language half is hidden, not deleted, so the two-language form
   stays recoverable: delete the display: none below and it returns. */
.lang-switch-label {
  /* The whole label is ONE flex item. Left as bare text nodes, .lang-switch-btn
     being inline-flex would blockify the inner span into a third flex item and
     add its gaps to the button's width. */
  white-space: nowrap;
}

.lang-switch-secondary {
  display: none;
}

.lang-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-xs) var(--space-sm);
  min-height: var(--touch-target-min);
  background-color: var(--color-accent-light);
  color: var(--color-accent-dark);
  border: 1.5px solid var(--color-accent);
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: var(--font-size-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.lang-switch-btn:hover {
  background-color: var(--color-accent);
  color: var(--color-surface);
}

/* Mobile Nav Toggle Button */
.menu-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  padding: var(--space-xs);
  background-color: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  cursor: pointer;
}

.menu-toggle-btn svg {
  width: 1.5rem;
  height: 1.5rem;
}

/* The icons read aria-expanded, which is the single source of truth for whether
   the menu is open. No JS writes display on them and no inline style attribute
   sets it, so these rules are never outranked and the icon cannot desync from
   the menu — whichever of the three close paths ran. */
.menu-toggle-btn[aria-expanded="false"] .icon-menu,
.menu-toggle-btn[aria-expanded="true"] .icon-close {
  display: block;
}

.menu-toggle-btn[aria-expanded="false"] .icon-close,
.menu-toggle-btn[aria-expanded="true"] .icon-menu {
  display: none;
}

/* Primary Nav Menu. Fixed under the header, so its top and its room below are
   both read from --header-h (written by js/main.js): the header is 72–126px on
   a phone depending on language and width, and a fixed 68px here left the open
   menu covering the lower part of it. The 100px fallback is the mobile value,
   as for .section's scroll-margin-top. */
.primary-nav {
  position: fixed;
  top: var(--header-h, 100px);
  left: 0;
  right: 0;
  background-color: var(--color-surface);
  border-bottom: 3px solid var(--color-primary);
  padding: var(--space-md);
  box-shadow: var(--shadow-lg);
  display: none;                          /* Hidden by default on mobile */
  max-height: calc(100vh - var(--header-h, 100px));
  overflow-y: auto;
}

.primary-nav.is-active {
  display: block;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: var(--touch-target-min);
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
  border-radius: var(--radius-md);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  transition: all var(--transition-fast);
}

.nav-link:hover, .nav-link.is-current {
  background-color: var(--color-primary-light);
  color: var(--color-primary-dark);
  border-color: var(--color-primary);
}

/* Desktop Navigation Adaptations
   --------------------------------------------------------------------------
   Both languages leave the hamburger at 76rem — the value of
   --container-max-width. Above it the container is pinned at 1216px, so the
   space beside the brand block is constant and each language has exactly one
   desktop layout: English two rows, Chinese one. Below it neither fits and
   both collapse.

   English shares the Chinese breakpoint rather than a smaller one because
   between 64rem and 76rem it rendered three rows: at 1024px only 456.3px is
   free beside the brand, against the 634.3px its fuller row needs. Two rows or
   a hamburger, never three.

   Scoped by the lang attribute on <html> — the same mechanism as the
   line-height and letter-spacing overrides in section 2.

   The two blocks below are deliberately parallel. Their only difference is
   white-space. Change one and change the other. */

/* English: two rows. */
@media (min-width: 76rem) {
  html[lang="en"] .menu-toggle-btn {
    display: none;
  }

  html[lang="en"] .primary-nav {
    position: static;
    display: block;
    padding: 0;
    box-shadow: none;
    border-bottom: none;
    background: transparent;
    max-height: none;
  }

  html[lang="en"] .nav-list {
    flex-direction: row;
    flex-wrap: wrap;                     /* two rows: 9 labels, 1197.8px, 648.3px available */
    justify-content: space-between;      /* applies per flex line, so each row
                                            justifies independently and both sit
                                            flush to the nav's left and right
                                            edges. The rows carry 4 and 5 items,
                                            so their gaps are not equal to each
                                            other — that is inherent, not a bug. */
    align-items: center;
    /* Row and column gaps are set apart. The column gap stays as the minimum
       spacing space-between must honour. The row gap goes to zero because the
       second row is what makes the English header taller than the Chinese one,
       and every pixel here is header height on a bar that is always on screen.
       The links keep 8px of their own vertical padding, so the two rows still
       read as separate. */
    row-gap: 0;
    column-gap: var(--space-xs);
  }

  html[lang="en"] .nav-link {
    background: transparent;
    border: none;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-sm);
    white-space: normal;
    text-align: center;
    min-height: auto;
    border-radius: var(--radius-sm);
  }

  html[lang="en"] .nav-link:hover,
  html[lang="en"] .nav-link.is-current {
    background-color: var(--color-primary-light);
    color: var(--color-primary-dark);
    text-decoration: none;
  }

  html[lang="en"] .nav-link.is-current {
    font-weight: 700;
    border-bottom: 2px solid var(--color-primary);
    border-radius: 0;
  }
}

/* Chinese: one row — 683.3px of labels against a ~718.2px ceiling.
   flex-wrap is wrap, not nowrap, deliberately. Above 76rem the container is
   pinned at 1216px, so the space beside the brand block never changes and only
   content growth can pass that ceiling. Under nowrap that growth becomes
   horizontal page overflow; under wrap it becomes a second row. Cosmetic beats
   a defect.
   Do not change --container-max-width to tune either breakpoint; change the
   queries. */
@media (min-width: 76rem) {
  html[lang="zh"] .menu-toggle-btn {
    display: none;
  }

  html[lang="zh"] .primary-nav {
    position: static;
    display: block;
    padding: 0;
    box-shadow: none;
    border-bottom: none;
    background: transparent;
    max-height: none;
  }

  html[lang="zh"] .nav-list {
    flex-direction: row;
    flex-wrap: wrap;                     /* one row at 683.3px; ceiling ~718.2px */
    align-items: center;
    gap: var(--space-xs);
  }

  html[lang="zh"] .nav-link {
    background: transparent;
    border: none;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-sm);
    white-space: nowrap;
    text-align: center;
    min-height: auto;
    border-radius: var(--radius-sm);
  }

  html[lang="zh"] .nav-link:hover,
  html[lang="zh"] .nav-link.is-current {
    background-color: var(--color-primary-light);
    color: var(--color-primary-dark);
    text-decoration: none;
  }

  html[lang="zh"] .nav-link.is-current {
    font-weight: 700;
    border-bottom: 2px solid var(--color-primary);
    border-radius: 0;
  }
}

/* --------------------------------------------------------------------------
   6. Hero Section
   -------------------------------------------------------------------------- */
.hero-banner {
  background-color: var(--color-surface-dark);
  color: var(--color-text-light);
  padding-top: 0;
  padding-bottom: var(--space-2xl);
  position: relative;
  background-image: linear-gradient(135deg, var(--color-surface-dark), var(--color-primary-dark));
}

.hero-sticky-wrapper {
  position: relative;
  width: 100%;
  height: var(--hero-runway);
}

/* Static-poster fallback: no video, so there is nothing to scrub through and
   the tall scroll runway would be several screens of dead space. Applied by
   hero-scroll-video.js showStaticFallback(). Two classes beat the single-class
   rules above at every width, so this holds inside the media query too. */
.hero-sticky-wrapper.is-collapsed {
  height: var(--hero-height-collapsed);
}

/* The collapsed wrapper is 68vh but .hero-canvas-container is a fixed 100vh,
   so the container overhung its own parent by 32vh and painted over the h1
   and .hero-lead that follow it in flow. Sticky could not save it: the
   element was taller than its containing block, so it never stuck and the
   overlap was constant at every scroll position. Collapse the container with
   the wrapper. */
.hero-sticky-wrapper.is-collapsed .hero-canvas-container {
  height: var(--hero-height-collapsed);
}

/* The fallback image sits in the same stacking slot as the video, so it needs
   to honour [hidden] — .hero-scroll-canvas sets display: block, which would
   otherwise override the user-agent [hidden] rule and show it permanently. */
#hero-static-poster[hidden] {
  display: none;
}

/* Overrides object-position: center from .hero-scroll-canvas, which both the
   <video> and this <img> carry. Deliberately scoped to the poster by id: the
   <video> keeps centre, because at 100vh its box discards far less of the
   frame and its plaque is never cut. See --hero-poster-focus. */
#hero-static-poster {
  object-position: var(--hero-poster-focus);
}

.hero-canvas-container {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: var(--color-hero-ground);
  border-bottom: 2px solid var(--color-accent);
  box-shadow: var(--shadow-hero);
}

.hero-scroll-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  user-select: none;
  touch-action: pan-y;
}

.hero-scroll-canvas:active {
  cursor: grabbing;
}

@media (max-width: 48rem) {
  .hero-scroll-canvas {
    width: 100%;
    height: 100%;
    max-height: none;
  }
}

/* These grouping boxes only acquire layout on a portrait phone. Desktop and
   landscape keep the original full-height video and scroll geometry. */
.hero-mobile-runway,
.hero-mobile-stage {
  display: contents;
}

/* Portrait phone: the hero is a 16:9 band. Pin the entire opening composition
   while the video scrubs, then release the image AND text together. The extra
   distance is below the stage, so it never appears as a blank screen.
   Without video (reduced motion, data saver or error), use normal document flow.
   THIS PRELUDE MUST EQUAL BAND_QUERY in js/hero-scroll-video.js. */
@media (max-width: 600px) and (orientation: portrait) {
  .hero-mobile-runway,
  .hero-mobile-stage {
    display: block;
  }

  .hero-banner.has-scroll-video .hero-mobile-runway {
    height: calc(var(--hero-stage-height) + var(--hero-mobile-scrub-distance));
  }

  .hero-banner.has-scroll-video .hero-mobile-stage {
    position: sticky;
    top: var(--header-h, 100px);
  }

  .hero-sticky-wrapper,
  .hero-sticky-wrapper.is-collapsed {
    position: relative;
    top: auto;
    height: auto;
    margin-bottom: var(--space-lg);
  }

  .hero-canvas-container,
  .hero-sticky-wrapper.is-collapsed .hero-canvas-container {
    position: relative;
    top: auto;
    height: auto;
    aspect-ratio: var(--hero-band-aspect);
  }
}

.hero-content h1 {
  color: var(--color-text-gold);
  font-size: var(--font-size-hero);
  margin-bottom: var(--space-md);
  text-shadow: var(--text-shadow-hero);
}

.hero-lead {
  font-size: var(--font-size-body-lg);
  line-height: var(--line-height-body);
  color: var(--color-surface-alt);
  margin-bottom: var(--space-lg);
}

/* Links inside the hero meta card sit on the dark hero ground, so they need the
   pale accent rather than the body link colour, and an underline to stay
   distinguishable without relying on colour alone. */
.hero-meta-link {
  color: var(--color-accent-light);
  text-decoration: underline;
}

.hero-meta-card {
  background-color: var(--color-surface-glass);
  backdrop-filter: blur(4px);
  border: 1px solid var(--color-border-accent-soft);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.hero-meta-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  align-items: center;
}

@media (min-width: 48rem) {
  .hero-meta-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.hero-info-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.hero-map-frame {
  width: 100%;
  height: 180px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--color-border-accent-soft);
  box-shadow: var(--shadow-hero-map);
  background-color: var(--color-surface-dark);
}

.hero-map-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.meta-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  font-size: var(--font-size-body);
}

.meta-icon {
  color: var(--color-accent);
  flex-shrink: 0;
  margin-top: 0.2rem;
}

/* --------------------------------------------------------------------------
   7. Section Content Cards & Ritual Links
   -------------------------------------------------------------------------- */
.ritual-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 5px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-md);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.ritual-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.ritual-title-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}

/* Base raised to the 17px floor. The three registration badges already set
   --font-size-body via `.reg-status .badge-tag`, so they are unchanged; this
   only lifts badges used outside a registration block, which today means the
   two on index.html's 求签 and 问事 cards. */
.badge-tag {
  display: inline-block;
  padding: var(--space-3xs) var(--space-xs);
  background-color: var(--color-accent-light);
  color: var(--color-accent-dark);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-weight: 600;
}

/* justify-content + text-align matter only when the label is too long for the
   line and the button stretches to full width — which English labels do at
   320px and long Chinese ones do too. Without them the wrapped label sits
   ragged against the left edge and the button reads as a misdrawn box. No
   effect on labels that fit on one line, in either language. */
.btn-primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  min-height: var(--touch-target-min);
  background-color: var(--color-primary);
  color: var(--color-surface);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
  transition: background-color var(--transition-fast);
}

.btn-primary-link:hover {
  background-color: var(--color-primary-dark);
  color: var(--color-surface);
}

.btn-secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  min-height: var(--touch-target-min);
  background-color: var(--color-surface);
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
  transition: all var(--transition-fast);
}

.btn-secondary-link:hover {
  background-color: var(--color-primary-light);
  color: var(--color-primary-dark);
}

/* --------------------------------------------------------------------------
   8. Deity Birthday Tables (Mobile Responsive)
   -------------------------------------------------------------------------- */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  min-width: 28rem;
}

.data-table th,
.data-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-body);
}

.data-table th {
  background-color: var(--color-primary-dark);
  color: var(--color-text-light);
  font-family: var(--font-heading);
  font-weight: 700;
  white-space: nowrap;
}

/* Birthday calendars fit the phone width; swipe only scrolls vertically. */
@media (max-width: 48rem) {
  #sheming-qianqiu .table-wrapper {overflow:clip;touch-action:pan-y}
  #sheming-qianqiu .data-table {min-width:0;table-layout:fixed}
  #sheming-qianqiu .data-table th,
  #sheming-qianqiu .data-table td {padding:var(--space-sm) var(--space-xs);white-space:normal;overflow-wrap:anywhere}
  #sheming-qianqiu .data-table th:first-child {width:35%}
}

.data-table tr:nth-child(even) {
  background-color: var(--color-bg);
}

.data-table tr:hover {
  background-color: var(--color-primary-light);
}

.table-major-highlight {
  background-color: var(--color-accent-light) !important;
  font-weight: 700;
}

.table-major-highlight td {
  color: var(--color-primary-dark);
}

.lunar-month-header {
  background-color: var(--color-surface-alt);
  font-weight: 700;
  color: var(--color-accent-dark);
  border-top: 2px solid var(--color-border-dark);
}

/* Featured birthdays use the same 30% increase for data and table headers. */
#sheming-qianqiu .featured-birthdays {min-width:0;table-layout:fixed}
#sheming-qianqiu .featured-birthdays th,
#sheming-qianqiu .featured-birthdays td {
  font-size:var(--birthday-featured-font-size);white-space:normal;overflow-wrap:anywhere;
}
#sheming-qianqiu .featured-birthdays th:first-child {width:40%}
#sheming-qianqiu .featured-birthdays .birthday-date-part,
#sheming-qianqiu .featured-birthdays .birthday-event-name {display:inline-block;white-space:nowrap}

/* One chronological source: stacked on phones, first column then second on desktop. */
#sheming-qianqiu .birthday-calendar {
  display:grid;grid-template-columns:minmax(0,1fr);gap:var(--space-lg);margin-bottom:var(--space-lg);
}
#sheming-qianqiu .birthday-calendar .table-wrapper {min-width:0;margin-bottom:0;overflow:clip;touch-action:pan-y}
#sheming-qianqiu .birthday-calendar .data-table {min-width:0;table-layout:fixed}
#sheming-qianqiu .birthday-calendar th,
#sheming-qianqiu .birthday-calendar td {white-space:normal;overflow-wrap:anywhere}
#sheming-qianqiu .birthday-calendar th:first-child {width:35%}
#sheming-qianqiu .birthday-calendar .lunar-month-header {background-color:var(--color-surface-alt)}
@media(min-width:1000px) {
  #sheming-qianqiu .birthday-calendar {grid-template-columns:repeat(2,minmax(0,1fr));align-items:start}
}

/* --------------------------------------------------------------------------
   9. Dialysis Center & Donation Sections
   -------------------------------------------------------------------------- */
.donation-grid {
  display: grid;
  /* minmax(0, 1fr), not 1fr: the QR card's image wrapper is capped at 16rem,
     which with the card's padding and border gives it a 306px minimum. A bare
     1fr track cannot go below that, so at a 320px viewport the card painted
     2px past the page edge. See "Known platform traps" in CLAUDE.md. */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xl);
}

@media (min-width: 48rem) {
  .donation-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.bank-card {
  background-color: var(--color-surface);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
}

.bank-card-title {
  color: var(--color-primary-dark);
  font-size: var(--font-size-h3);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.bank-detail-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-top: var(--space-md);
  margin-bottom: var(--space-md);
}

.bank-detail-item {
  background-color: var(--color-bg);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

/* Raised from --font-size-sm to the 17px body floor at §3.5. This is the label
   set beside the account number — 银行名称 / 户名 / 账号 — read off a phone by
   someone about to type a bank transfer. index.html is its only consumer. */
.bank-detail-label {
  font-size: var(--font-size-body);
  color: var(--color-text-muted);
  display: block;
}

.bank-detail-value {
  font-weight: 700;
  font-size: var(--font-size-body-lg);
  color: var(--color-primary-dark);
  user-select: all;
}

.qr-image-wrapper img {
  max-width: min(100%, 432px);
  width: 100%;
  height: auto;
  display: block;
  margin-inline: auto;
}

.qr-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* The cap was 16rem, which clamped the 432x614 DuitNow PNG to 228px wide — a
   QR that has to survive being scanned off a phone screen. The image now sizes
   itself with min(100%, 432px): natural size wherever the column allows it,
   container width where it does not, and never upscaled past its own pixels.
   aspect-ratio is dropped with the cap — the PNG is portrait, not square, and a
   square box either letterboxed it or forced an overflow. */
.qr-image-wrapper {
  width: 100%;
  background-color: var(--color-surface);
  border: 2px solid var(--color-border-dark);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  margin-top: var(--space-sm);
  margin-bottom: var(--space-sm);
}

/* --------------------------------------------------------------------------
   10. Contact Section & Map Embed
   -------------------------------------------------------------------------- */
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xl);
}

@media (min-width: 52rem) {
  .contact-grid {
    grid-template-columns: 1fr 1.2fr;
  }
}

/* A plain raised panel: surface, hairline border, no accent edge.

   .ritual-block-key is the same shape PLUS the gold left edge, and §15 reserves
   that edge for the two blocks a ritual-page visitor came for. The homepage has
   no such blocks, but giving its panels the edge would make the marker mean two
   different things across the site, so they get the plain form.

   .contact-info-card was already exactly this rule and is folded in rather than
   duplicated — same declarations, one place to change them. */
.surface-panel,
.contact-info-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.contact-item {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-surface-alt);
}

.contact-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.contact-icon {
  color: var(--color-primary);
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.map-container {
  width: 100%;
  height: 100%;
  min-height: 20rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border-dark);
  box-shadow: var(--shadow-sm);
}

.map-container iframe {
  width: 100%;
  height: 100%;
  min-height: 20rem;
  border: none;
}

/* --------------------------------------------------------------------------
   11. Footer
   -------------------------------------------------------------------------- */
.site-footer {
  background-color: var(--color-surface-dark);
  color: var(--color-text-light);
  border-top: 4px solid var(--color-accent);
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-xl);
  font-size: var(--font-size-body);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  margin-bottom: var(--space-2xl);
}

@media (min-width: 48rem) {
  .footer-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(var(--footer-contact-min-width), 1fr);
  }
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.footer-title {
  color: var(--color-text-gold);
  font-family: var(--font-heading);
  font-size: var(--font-size-h3);
}

/* Same declarations, separate names on purpose: .footer-contact carries the
   opening-hours line, which can change, .footer-tagline never does. */
/* Raised from --font-size-sm to the 17px body floor.

   Every type audit in this project enumerated `main` and the footer sits
   outside it, so these were never measured — they shipped at 15px on every
   page. .footer-contact carries the opening hours; the address and phone sit in
   .footer-links-list items, which take the footer's own body size. Those are
   the things a devotee standing outside is most likely to be squinting at. */
.footer-tagline,
.footer-contact {
  font-size: var(--font-size-body);
  color: var(--color-text-light);
}

.footer-heading {
  color: var(--color-text-gold);
  margin-bottom: var(--space-sm);
}

.footer-links-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* Keep each contact label, number and name intact; wrap between them on phones. */
.contact-method-label,.contact-number,.contact-name {white-space:nowrap}

.footer-links-list a {
  color: var(--color-text-light);
  text-decoration: none;
}

.footer-links-list a:hover {
  color: var(--color-text-gold);
  text-decoration: underline;
}

.footer-bottom {
  border-top: 1px solid var(--color-border-subtle);
  padding-top: var(--space-md);
  text-align: center;
  color: var(--color-text-light);
  font-size: var(--font-size-body);
}

.footer-bottom p {
  color: var(--color-text-light);
}

/* --------------------------------------------------------------------------
   12. Brand Logo, Hero Image & Section Placeholder Image Styles
   -------------------------------------------------------------------------- */
.brand-logo-img {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-accent);
  box-shadow: var(--shadow-brand-logo);
  flex-shrink: 0;
  background-color: var(--color-surface);
}

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

/* --------------------------------------------------------------------------
   14. Registration Block (windowed / enquiry only)

   The state is switched by hand, once a year, on the wrapper's
   data-registration attribute. No JavaScript reads it and no date is
   computed anywhere — lunar dates shift every year, so this is deliberate.

   "open" is the ONLY value that renders the open state (the trailing "i"
   makes that match case-insensitively, so OPEN and Open work too). Anything
   else — "closed", a typo, or a missing attribute — renders the closed state.
   A mis-edit therefore fails towards a shut registration rather than towards a
   live button pointing at a window that has already passed.

   See _template/registration-blocks.html for the markup and the annual-update
   note that goes above each wrapper.
   -------------------------------------------------------------------------- */
.reg-block {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 5px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  margin-top: var(--space-lg);
}

/* The closed card colour follows the same fail-safe as the content switch below:
   any value that is not "open" — "closed" or a typo — takes it. The attribute
   must be present, though: the enquiry-only block is a .reg-block with no
   data-registration at all, and it keeps the open card. */
.reg-block[data-registration]:not([data-registration="open" i]) {
  background-color: var(--color-surface-alt);
  border-left-color: var(--color-border-dark);
}

/* The state switch. These three rules are the entire mechanism. */
.reg-block .reg-state-closed {
  display: none;
}

.reg-block:not([data-registration="open" i]) .reg-state-open {
  display: none;
}

.reg-block:not([data-registration="open" i]) .reg-state-closed {
  display: block;
}

.reg-heading {
  font-family: var(--font-heading);
  font-size: var(--font-size-h3);
  color: var(--color-primary-dark);
  margin-bottom: var(--space-sm);
}

.reg-window {
  font-size: var(--font-size-body);
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.reg-window-gregorian {
  display: block;
  color: var(--color-text-muted);
}

.reg-status {
  margin-bottom: var(--space-xs);
}

/* The chip answers the visitor's actual question, so it does not shrink to
   the 15px label size the badge normally uses.

   A status this long cannot stay a compact pill at 320px — "Registration has
   closed for this year" is about twice the width of 本届报名已截止 — so it
   fills the line and wraps. Centring it lets it degrade into a deliberate
   status banner instead of a ragged bordered box. Chinese labels fit on one
   line and are unaffected. */
.reg-status .badge-tag {
  font-size: var(--font-size-body);
  text-align: center;
}

.reg-badge-closed {
  background-color: var(--color-surface);
  color: var(--color-text-muted);
  border-color: var(--color-border-dark);
}

.reg-cta {
  font-size: var(--font-size-body-lg);
}

.reg-note {
  font-size: var(--font-size-body);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.reg-enquiry-link {
  margin-top: var(--space-md);
}

/* --------------------------------------------------------------------------
   15. Ritual Page Body

   The shared body structure for all five ritual pages in both languages.
   Six blocks, always in this order:

     1. 页首        <section class="section ritual-header">   h1.section-title
                                                              + p.ritual-lede
     2. 简介        <section class="ritual-block">            h2.ritual-block-title
     3. 适合对象     <section class="ritual-block">            h2.ritual-block-title
     4. 举行时间     <section class="ritual-block ritual-block-key">
     5. 准备事项     <section class="ritual-block ritual-block-key">
     6. 报名 / 询问  <section class="ritual-block">            + reg block per type

   Blocks 4 and 5 are what people actually came for, so they carry
   .ritual-block-key: a raised card with a gold left edge. Nothing else on the
   page gets that treatment — if a third block takes it, none of them stand out
   any more.

   Every rule here is shared. A layout that breaks under the longer English
   labels gets fixed in this block, not patched on one page.
   -------------------------------------------------------------------------- */
.ritual-header {
  padding-bottom: var(--space-xl);
}

/* The 一句说明 that opens every ritual prompt — 求签's is 抽取签诗，请示神明指引.
   It sits directly under the h1 and is the line a ten-second visitor actually
   leaves with, so it is a step above body copy and held to the prose measure.
   Muted rather than full strength so it reads as a subtitle to the h1 instead
   of competing with it: 9.05:1 on --color-bg, past AA and AAA.
   Every ritual page has one. Don't improvise a per-page class for it. */
.ritual-lede {
  max-width: var(--measure-prose);
  font-size: var(--font-size-body-lg);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.ritual-body {
  padding-top: var(--space-xl);
}

.ritual-block {
  margin-bottom: var(--space-2xl);
}

.ritual-block:last-child {
  margin-bottom: 0;
}

.ritual-block-title {
  font-size: var(--font-size-h3);
  color: var(--color-primary-dark);
  margin-bottom: var(--space-sm);
}

/* A label for a list inside a ritual block — 惊蛰虎爷公's 注意事项. A bare h3
   computes to --font-size-h3, the same 23px as .ritual-block-title above it, so
   it would read as a second section title. One step down; colour, weight and
   the heading face come from the global h1–h6 rule. */
.ritual-sublabel {
  font-size: var(--font-size-body-lg);
  margin-bottom: var(--space-xs);
}

.ritual-text {
  max-width: var(--measure-prose);
  margin-bottom: var(--space-sm);
}

.ritual-text:last-child {
  margin-bottom: 0;
}

/* Make each consultation day/deity pair easy to spot at a glance. */
#wenshi .consultation-deities {display:grid;gap:var(--space-sm);margin:var(--space-md) 0;font-size:var(--font-size-body)}
#wenshi .consultation-deities>div {display:grid;grid-template-columns:minmax(0,1fr);align-items:center;gap:var(--space-sm);padding:var(--space-sm);border:1px solid var(--color-border);border-left:var(--space-3xs) solid var(--color-primary);border-radius:var(--radius-md);background:var(--color-primary-light)}
#wenshi .consultation-deities dt {justify-self:start;padding:var(--space-3xs) var(--space-xs);color:var(--color-surface);background:var(--color-primary);border-radius:var(--radius-sm);font-weight:700}
#wenshi .consultation-deities dd {margin:0;min-width:0;color:var(--color-primary-dark);font-size:var(--font-size-h3);font-weight:700;overflow-wrap:anywhere}
@media (min-width:48rem) {
  #wenshi .consultation-deities {grid-template-columns:repeat(2,minmax(0,1fr))}
}

/* Keep day/time together above the deity until both fit comfortably beside it. */
@media (min-width:64rem) {
  #wenshi .consultation-deities>div {grid-template-columns:max-content minmax(0,1fr)}
}

/* Keep the form's collection location together with its title. */
#xishen-zhongxin .application-form-notice {max-width:var(--measure-prose);margin-top:var(--space-lg);padding:var(--space-md);background:var(--color-accent-light);border:1px solid var(--color-accent);border-radius:var(--radius-md)}
#xishen-zhongxin .application-form-notice h3 {margin:0 0 var(--space-xs);font-family:var(--font-body);font-size:var(--font-size-body-lg);color:var(--color-primary-dark)}
#xishen-zhongxin .application-form-notice p {margin:0;font-size:var(--font-size-body)}
#xishen-zhongxin .application-form-notice strong {color:var(--color-primary-dark)}

/* A replaceable illustration beside the Fortune Sticks heading on desktop. */
.fortune-sticks-header>.container {display:grid;gap:var(--space-lg)}
.fortune-sticks-figure {width:100%;max-width:var(--fortune-sticks-image-width);margin:0 auto}
.fortune-sticks-figure picture {display:block}
.fortune-sticks-figure img {display:block;width:100%;height:auto;aspect-ratio:1;border-radius:var(--radius-md)}
.fortune-sticks-figure figcaption {margin-top:var(--space-xs);font-size:var(--font-size-body);text-align:center;color:var(--color-text-muted)}
@media (min-width:48rem) {
  .fortune-sticks-header>.container {grid-template-columns:minmax(0,1fr) var(--fortune-sticks-desktop-image-width);align-items:center}
}

/* Blocks 4 and 5 — the two the visitor came for. */
.ritual-block-key {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: var(--border-emphasis-width) solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

/* Label / value pairs inside 举行时间. Stacked on a phone so the value never
   gets squeezed into a two-character column; side by side once there is room. */
.ritual-facts {
  margin-bottom: var(--space-md);
}

.ritual-fact {
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--color-border);
}

.ritual-fact:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* Held to the 17px body floor like every other piece of copy on the page —
   a fact label is content, not chrome, and 今年犯太岁生肖 is the most-read
   string on the 压太岁 page. Size therefore no longer separates label from
   value; weight (600 vs 700) and colour (muted vs full) do. */
.ritual-fact-label {
  color: var(--color-text-muted);
  font-size: var(--font-size-body);
  font-weight: 600;
}

.ritual-fact-value {
  font-size: var(--font-size-body-lg);
  font-weight: 700;
  color: var(--color-text);
  /* This field holds dates, and CJK's default is to break between any two
     characters. Measured on the deployed 文昌 page: 3月16日 split into 3月 /
     16日 at 768px, and 公历 split into 公 / 历 at 360px — a date torn in half
     mid-scan by a devotee checking when to collect their 文具.
     keep-all forbids breaking inside a run of CJK, leaving the spaces already
     written into the string (" 至 ", " · ") as the only break opportunities,
     which is where these values are meant to fold.
     keep-all alone would make each space-delimited run atomic, and a run wider
     than its track would overflow. It does not, because overflow-wrap: anywhere
     below is the escape hatch: it permits a mid-run break exactly when a run
     cannot fit. Verified by injecting a space-free run far wider than the 235px
     track at 320px — it wrapped mid-run, page overflow stayed 0. The two
     declarations are a pair; removing either changes the other's behaviour.
     Measured at eight widths on both windowed pages: widest run 羊、牛、狗、鼠、龙
     at 175.59px against a 288px track, and 2027年3月10日 at 140.53px against
     235px. English is unaffected — keep-all produces identical line breaks to
     normal on Latin text, checked on all three /en/ pages. */
  word-break: keep-all;
  /* minmax(0, 1fr) lets the TRACK shrink; this lets the TEXT inside it break.
     Both are needed: without this a bare URL overflows its track anyway, and
     below 48rem .ritual-fact is not a grid at all, so the track fix cannot
     help there. "anywhere" rather than "break-word" because it also lowers the
     min-content contribution, which is what the track measures itself against. */
  overflow-wrap: anywhere;
}

/* Two things here are load-bearing.

   minmax(0, 1fr), not 1fr: a bare fr track cannot shrink below its content's
   min-content width, and the 报名 / 询问 content carries bare URLs
   (taiporkong.com/order, wa.link/mtstpp). One of those in a fact value would
   push the whole page sideways — the fourth time this construct has done that
   here. See "Known platform traps" in CLAUDE.md.

   The label column is a per-language token, not one shared value. It was 7rem,
   sized for 2-4 character Chinese labels, which cannot hold "Stationery
   collection" (154.02px). See --ritual-label-col. */
@media (min-width: 48rem) {
  .ritual-fact {
    display: grid;
    grid-template-columns: var(--ritual-label-col) minmax(0, 1fr);
    gap: var(--space-md);
    align-items: baseline;
  }
}

/* The one line on the page that corrects a likely misreading — e.g. that the
   temple is shut outside 7am–5pm. Loud enough to survive a ten-second scan. */
.ritual-callout {
  max-width: var(--measure-prose);
  padding: var(--space-sm) var(--space-md);
  background-color: var(--color-accent-light);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-weight: 600;
  margin-bottom: var(--space-md);
}

.ritual-list {
  max-width: var(--measure-prose);
  list-style: none;
  margin-bottom: var(--space-sm);
}

.ritual-list > li {
  position: relative;
  padding-left: var(--space-lg);
  margin-bottom: var(--space-sm);
}

.ritual-list > li:last-child {
  margin-bottom: 0;
}

.ritual-list > li::before {
  content: "・";
  content: "・" / "";
  position: absolute;
  left: 0;
  color: var(--color-accent-dark);
  font-weight: 700;
}

.ritual-enquiry-link {
  margin-top: var(--space-sm);
}

/* A single Gregorian date, held on one line.

   English dates contain spaces, so word-break: keep-all on .ritual-fact-value
   does nothing for them — at 390px the 文具领取 value broke "· 10 " / "March
   2027", splitting a date across lines in the one block that has to survive a
   ten-second scan. keep-all protects the CJK form because the date is a single
   unbroken run; the Latin form needs this instead.

   Wrap ONE date, never a range: "10 March 2027 to 16 March 2027" gets two
   spans so the line may still fold at " to ". An unbreakable string is exactly
   what the grid/flex auto-minimum trap feeds on, so anything wrapped here must
   be measured against its narrowest track — see "Known platform traps" in
   CLAUDE.md. Measured at 320px, where .ritual-fact is not a grid at all. */
.date-solid {
  white-space: nowrap;
}

