/* Version: V1 */
/* Meta version: 1.2.0 */
/* ═══════════════════════════════════════════════════════
   NEW HEALING PATH — Master Stylesheet
   /includes/css/styles.css
   Based on the Preserve Their Voice master stylesheet, with
   the recording/MP3 features removed.
   All values use CSS custom properties for whitelabel override
   via each subdomain's localstyle.css
═══════════════════════════════════════════════════════ */

/* ── CSS Custom Properties (Override in localstyle.css) ── */
/* Version: V1 */
:root {
  /* Layout Heights */
  --header-height: 20dvh;
  /* .app-main fills whatever's left: calc(100dvh - header-height).
     The footer is no longer its own fixed-height zone — it's in-flow
     content at the bottom of Home's scrollable button grid. */

  /* Colors — Primary */
  --color-primary: #2b5797;
  --color-primary-dark: #1e3f6f;
  --color-primary-light: #4a7bc5;
  --color-primary-pale: #e8f0fb;

  /* Colors — Header
     headerBgColor1/2 from Look and Feel are written onto these two
     variables at runtime (mainscript.js) — the gradient itself and
     everything else that derives from --color-primary stays put. */
  --color-header-bg-start: var(--color-primary);
  --color-header-bg-end: var(--color-primary-dark);
  --color-header-title: #ffffff;
  --color-header-subtitle: rgba(255,255,255,.80);
  --color-header-sub-bg: #f2f5f8;
  --color-header-sub-text: var(--color-primary-dark);
  --color-header-sub-border: #d0d8e2;
  /* Home button — the inverse of the header/Back button: light
     background instead of the header's dark gradient, with the
     header's own color used for the text/icon/border instead of
     white. --color-header-bg-start is what applyLookAndFeel() writes
     a client's headerBgColor1 onto, so this follows whatever color a
     client picks for their header, same as Back already does. */
  --color-home-btn-bg: #ffffff;
  --color-home-btn-text: var(--color-header-bg-start);
  --color-home-btn-border: var(--color-header-bg-start);

  /* Colors — Home's featured btn10 (Look and Feel h10BgColor1/2,
     written onto these two variables at runtime) */
  --color-h10-bg-start: var(--color-primary);
  --color-h10-bg-end: var(--color-primary-dark);
  --color-h10-text: #ffffff;

  /* Colors — Footer */
  --color-footer-bg: var(--color-white);
  --color-footer-border: var(--color-border);

  /* Colors — Page Title Bar */
  --color-title-bar-bg: var(--color-white);
  --color-title-bar-text: var(--color-primary-dark);
  --color-title-bar-border: var(--color-border-light);

  /* Colors — Grid Buttons */
  --color-grid-btn-bg: var(--color-white);
  --color-grid-btn-border: var(--color-border-light);
  --color-grid-btn-text: var(--color-text);
  --color-grid-btn-icon-bg: var(--color-primary-pale);
  --color-grid-btn-icon: var(--color-primary);

  /* Colors — Accent */
  --color-accent: #8b3040;
  --color-accent-light: #b04050;
  --color-accent-pale: #f9eced;

  /* Colors — Action (green for safe-to-press buttons) */
  --color-action: #2d7d52;
  --color-action-light: #3a9e68;

  /* Colors — Neutral */
  --color-white: #ffffff;
  --color-bg: #f0f4f8;
  --color-bg-alt: #e4eaf0;
  --color-border: #c8d4e0;
  --color-border-light: #dde5ed;

  /* Colors — Text */
  --color-text: #1e2d40;
  --color-text-body: #374a5e;
  --color-text-muted: #6a7f96;
  --color-text-faint: #a0b0c0;

  /* Colors — Status */
  --color-success: #2d7d52;
  --color-warning: #a06820;
  --color-danger: #b82d20;

  /* Typography */
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Roboto Condensed', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, serif;

  --fs-xs: 1rem;
  --fs-sm: 1.15rem;
  --fs-base: 1.2rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.35rem;
  --fs-2xl: 1.65rem;
  --fs-3xl: 2rem;
  --fs-footer-meta: 0.9rem;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;

  /* Border Radius */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --radius-round: 50%;

  /* Layout — the title bar's grid reserves this exact width on both
     sides (see .page-title-bar): the left column for the real Back
     button, the right column as a matching counterweight so the
     title's home column is genuinely centered under the bar. Sized
     generously around the button's real content (28px icon + 2px gap
     + ~34px "BACK" text + 10px padding + 4px border ≈ 78px) so the
     button never wraps or clips. If the button's own icon/text/padding
     ever changes, update this to match — the two aren't automatically
     linked, since CSS can't measure an element's real width before
     the grid using it is laid out. */
  --back-btn-width: 84px;
  --radius-pill: 99px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(30,45,64,.06);
  --shadow-md: 0 4px 16px rgba(30,45,64,.10);
  --shadow-lg: 0 6px 24px rgba(30,45,64,.14);

  /* Button Grid */
  --grid-gap: 10px;
  --btn-grid-radius: 12px;

  /* Safe Areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Splash Screen */
  --splash-bg: #ffffff;
}


/* ═══ TOAST NOTIFICATION ════════════════════════════ */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 40, 55, 0.92);
  color: #fff;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  text-align: center;
  max-width: 90%;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* ═══ SPLASH SCREEN ═════════════════════════════════
   Simplified to a single full-bleed hero image — no text,
   no logo, no tagline. The client's image controls 100% of
   what's shown; this just fills the screen with it. */
.splash-screen {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  z-index: 9999;
  background: var(--splash-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 100dvh;
  max-height: var(--real-vh, 100dvh);
  overflow: hidden;
  transition: opacity 0.5s ease;
}

.splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.splash-hero {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  margin: 0 auto;
  display: block;
}


/* ═══ RESET & BASE ═══════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--color-bg);
  font-family: var(--font-body);
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}


/* ═══ APP SHELL ══════════════════════════════════════ */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: var(--real-vh, 100dvh);
  max-width: 500px;
  margin: 0 auto;
  background: var(--color-bg);
  overflow: hidden;
  position: relative;
}


/* ═══ HEADER ═════════════════════════════════════════ */
.app-header {
  flex-shrink: 0;
  height: var(--header-height);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 20;
}

/* Top row: Title + Home button — 10dvh */
.header-title-area {
  flex-shrink: 0;
  height: 10dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--safe-top) 6px 0;
  text-align: center;
  background: linear-gradient(170deg, var(--color-header-bg-start) 0%, var(--color-header-bg-end) 100%);
  position: relative;
}

.header-title {
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 7vw, 2.5rem);
  font-weight: 700;
  color: var(--color-header-title);
  line-height: 1.05;
  text-shadow: 0 1px 3px rgba(0,0,0,.15);
  white-space: nowrap;
  margin-right: 9.5dvh;
}

.header-subtitle {
  font-family: var(--font-heading);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(0.6rem, 2.4vw, 0.8rem);
  color: rgba(255,255,255,.80);
  margin-top: 1px;
  line-height: 1.1;
  white-space: nowrap;
}

/* Bottom row: Logo fills subheader — white bg, no padding */
.header-sub {
  flex: 1;
  height: 10dvh;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #ffffff;
  border-left: 1.5px solid var(--color-border);
  border-right: 1.5px solid var(--color-border);
  border-bottom: 1.5px solid var(--color-border);
  position: relative;
}

.header-logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  height: 100%;
}

.header-logo {
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: 0;
}

/* Home button — centered vertically in full header, not just title area.
   Colors are the inverse of the header/Back button (light background,
   header's own color for border/text/icon) via --color-home-btn-* —
   see their definitions in :root above. Previously this read
   --color-grid-btn-bg for its background instead of --color-home-btn-bg,
   which (combined with --color-home-btn-text also being white) made the
   button render white-on-white with only its border visible. */
.btn-home {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 9.5dvh;
  aspect-ratio: 1 / 1;
  padding: 0;
  background: var(--color-home-btn-bg);
  border: 2px solid var(--color-home-btn-border);
  border-radius: var(--radius-sm);
  color: var(--color-home-btn-text);
  font-family: var(--font-body);
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  z-index: 25;
}

.btn-home:hover {
  opacity: 0.85;
}

.btn-home:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-home svg {
  width: 38px;
  height: 38px;
  fill: none;
  /* Matches the button's own text color (the header's color) rather
     than the generic grid-icon color, so the icon isn't a mismatched
     hue against the rest of the now-inverted button. */
  stroke: var(--color-home-btn-text);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* ═══ MAIN CONTENT AREA ═════════════════════════════ */
.app-main {
  flex: 1;
  min-height: 0;
  height: calc(100dvh - var(--header-height));
  height: calc(var(--real-vh, 100dvh) - var(--header-height));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: height 0.4s cubic-bezier(.32,.72,0,1);
  border-left: 1.5px solid var(--color-border);
  border-right: 1.5px solid var(--color-border);
}

/* Page title bar */
.page-title-bar {
  flex-shrink: 0;
  padding: 0px;
  background: var(--color-title-bar-bg);
  border-bottom: 1.5px solid var(--color-title-bar-border);
  min-height: 32px;
  /* 2-column grid: a fixed-width left column sized to the Back button,
     and everything else in the second column. Inside that second
     column, .page-title-row centers the title under the WHOLE bar (not
     just within this column) for any title that fits comfortably —
     see .page-title-row for how. */
  display: grid;
  grid-template-columns: var(--back-btn-width) 1fr;
  align-items: center;
}

.page-title-row {
  /* Lives in the second grid column (everything after the Back
     button's column) — see .page-title-bar. justify-content: center
     centers the PAIR (title + spacer) as a unit within this column.
     Because the spacer's width (see .page-title-spacer) exactly
     matches the button's column width, centering that pair produces
     the exact same visual result as centering the title alone under
     the WHOLE bar — the spacer is standing in for the button's own
     width on the right, so the two sides balance. This only holds
     while the pair actually fits within this column; once a longer
     title forces the pair to overflow, the spacer shrinks (flex-
     shrink) to make room, and only past that point does the title's
     centered position drift right — a graceful cost paid only by
     long titles, not every title. */
  display: flex;
  align-items: center;
  justify-content: center;
  grid-column: 2;
  min-width: 0;
}

.page-title {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--color-title-bar-text);
  /* Natural size — NOT flex:1/growing. It sits at whatever width its
     own text needs; .page-title-row's justify-content:center is what
     positions the (title + spacer) pair, not this element growing to
     fill space itself. white-space:nowrap keeps it on one line for as
     long as there's room, matching how the spacer is meant to give up
     its space first; min-width:0 lets it still shrink/wrap if a title
     is long enough that even a fully-collapsed spacer isn't enough. */
  white-space: nowrap;
  min-width: 0;
  text-align: center;
}

.page-title-spacer {
  /* Starts matching the Back button's column width exactly — this
     equality is what makes justify-content:center on the pair (see
     .page-title-row) equivalent to centering the title under the
     whole bar. Shrinks toward 0 first, before the title itself is
     ever forced to wrap. */
  flex-basis: var(--back-btn-width);
  flex-shrink: 1;
  flex-grow: 0;
  min-width: 0;
}

/* Back button for sub-pages — dark bg, white text (opposite of Home) */
.btn-back {
  /* A genuine grid item in the title bar's fixed-width left column
     (see .page-title-bar), not floating over the content the way it
     used to via position:absolute — that's what caused it to visually
     sit on top of the title instead of being a true neighbor with its
     own reserved space. justify-self: center sits it in the middle of
     that column's horizontal space, rather than flush against the
     column's left edge. */
  grid-column: 1;
  justify-self: center;
  background: linear-gradient(135deg, var(--color-header-bg-start), var(--color-header-bg-end));
  border: 2px solid var(--color-header-bg-end);
  cursor: pointer;
  padding: 0px 6px 0px 4px;
  color: var(--color-header-title);
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.btn-back:hover {
  opacity: 0.85;
}

.btn-back:active {
  transform: scale(0.95);
}

.btn-back svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--color-header-title);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-back-text {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-header-title);
}


/* ═══ BUTTON GRID ════════════════════════════════════ */
.btn-grid-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: safe center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Fallback for browsers that don't support 'safe center' */
@supports not (align-items: safe center) {
  .btn-grid-wrap {
    align-items: flex-start;
  }
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--grid-gap);
  width: 100%;
  max-width: 420px;
  /* .btn-grid is itself a flex item of .btn-grid-wrap — same default
     min-width:auto gotcha as .grid-btn below, one level up. Without
     this, the grid container could refuse to shrink below its
     content's natural width even before the individual .grid-btn
     fix gets a chance to matter. */
  min-width: 0;
}

.grid-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 1 / 1;
  background: var(--color-grid-btn-bg);
  border: 2px solid var(--color-grid-btn-border);
  border-radius: var(--btn-grid-radius);
  cursor: pointer;
  transition: all 0.18s;
  padding: 4px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--color-grid-btn-text);
  font-family: var(--font-body);
  -webkit-user-select: none;
  user-select: none;
  /* A grid item's default min-width is "auto", which means it will
     never shrink below its own content's natural, unwrapped size —
     even inside a repeat(3, 1fr) track. A button with a wide-aspect
     icon image or a long label can silently force its whole column
     wider than its fair 1fr share, dragging the entire row past
     .btn-grid's own max-width and overflowing the viewport. This is
     exactly what caused Home's grid to stay correctly contained while
     a sub-page's grid (with a different button's image/label content)
     overflowed — both grids share identical CSS; only the content
     differed enough to expose the missing constraint. min-width: 0
     is the standard fix — it allows the item to shrink down to (and
     below) its content's natural size when the grid needs it to,
     which is what actually lets width:100% on .grid-btn-img and
     word-break on .grid-btn-label do their jobs. */
  min-width: 0;
}

.grid-btn:hover {
  border-color: var(--color-primary-light);
  background: var(--color-primary-pale);
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}

.grid-btn:active {
  transform: scale(0.97);
}

.grid-btn.hidden {
  display: none;
}

.grid-btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-grid-btn-icon-bg);
  border-radius: var(--radius-sm);
  color: var(--color-grid-btn-icon);
}

/* Icon image — replaces SVG when provided */
.grid-btn-img {
  width: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.grid-btn-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--color-grid-btn-icon);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.grid-btn-label {
  /* Fluid sizing, matching the same clamp() pattern already used for
     .header-title/.header-subtitle rather than a discontinuous
     breakpoint jump — around 0.94rem at the iPhone SE's 375px width,
     scaling down further on anything narrower and up to the original
     fixed 1.125rem by ~450px and wider, where it matches today's
     behavior exactly. The 0.75rem floor is a safety minimum rather
     than a size any current real phone width actually reaches. */
  font-size: clamp(0.75rem, 4vw, 1.125rem);
  font-weight: 700;
  text-align: center;
  line-height: .95;
  color: var(--color-text);
  word-break: break-word;
  hyphens: auto;
}


/* Page content containers must fill available space for scrolling */
.page-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}


/* ═══ SCROLL FADE INDICATOR ══════════════════════════
   Shows a gradient fade + chevron at the bottom of scrollable areas
   to hint there's more content below. Hidden via JS when scrolled to bottom.
*/
.scroll-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: linear-gradient(transparent 0%, rgba(240,244,248,.85) 50%, var(--color-bg) 100%);
  pointer-events: none;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  transition: opacity 0.3s;
}

.scroll-fade.hidden {
  opacity: 0;
}

.scroll-fade-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  pointer-events: none;
}

.scroll-fade-label svg {
  width: 14px;
  height: 14px;
  stroke: var(--color-text-muted);
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  animation: scrollBounce 1.5s ease-in-out infinite;
}

@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

/* Make page-content containers position:relative for the fade overlay */
.page-content {
  position: relative;
}

/* The btn-grid-wrap needs to be the scroll parent */
.btn-grid-wrap {
  position: relative;
}

/* ═══ RITUAL IFRAME (action:"iframe") ════════════════
   Fills the entire page-content area below the header/back-button bar
   — the iframe's own document controls everything past that point.
   No border/scrollbar chrome of our own; whatever's inside the iframe
   handles its own layout and scrolling. */
.ritual-iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: var(--color-bg);
}


/* ═══ FOOTER (in-flow, Home page only) ═══════════════
   No longer a fixed-height bar of its own — this now sits at the
   bottom of #page-home's scrollable content, right after the button
   grid. On a short viewport with a lot of buttons, it simply scrolls
   out of view along with everything else; that's expected. */
.app-footer {
  flex-shrink: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  padding: var(--space-lg) var(--space-lg) calc(var(--space-md) + var(--safe-bottom));
}

/* Footer meta bar — copyright, version, about */
.footer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-footer-meta);
  font-weight: 700;
  color: var(--color-text-faint);
}

.footer-meta-sep {
  color: var(--color-border);
}

.footer-about-btn {
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: var(--fs-footer-meta);
  font-weight: 800;
  color: var(--color-primary);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}


/* ═══ FEATURED HOME BUTTON (btn10) ═══════════════════
   A normal grid button — same action system, same icon/label markup —
   just rendered 3 columns wide on its own row, with the icon on the
   left and label to the right instead of stacked. Uses the Look and
   Feel gradient (h10BgColor1/2) as its background. Set both colors the
   same to make it blend in and look like any other button. */
.grid-btn-featured {
  grid-column: 1 / -1;
  flex-direction: row;
  aspect-ratio: 3 / 1;
  justify-content: center;
  gap: 14px;
  min-height: 88px;
  background: linear-gradient(135deg, var(--color-h10-bg-start), var(--color-h10-bg-end));
  border-color: transparent;
  padding: 10px 18px;
}

.grid-btn-featured:hover {
  border-color: transparent;
  background: linear-gradient(135deg, var(--color-h10-bg-start), var(--color-h10-bg-end));
  filter: brightness(1.05);
}

.grid-btn-featured .grid-btn-icon,
.grid-btn-featured .grid-btn-img {
  flex-shrink: 0;
  /* Deliberately LARGER than btn1-9's icon — matching their exact size
     looked visually "off" inside the much bigger H10 banner (a small
     icon lost inside a tall bar reads as a sizing mistake to the eye,
     even though the numbers were technically consistent). Scaled up
     ~45% from that base size (right in the middle of a 40-50% bump)
     while still being calculated from the same real grid math — via
     calc() against --grid-gap — so it stays correct if the gap or
     grid max-width ever changes, rather than becoming a disconnected
     fixed number. Icons are recommended at 300x150 (2:1); height is
     left to follow that ratio naturally rather than forcing a square. */
  width: calc(((420px - 2 * var(--grid-gap)) / 3 - 8px) * 1.45);
  height: auto;
}

.grid-btn-featured .grid-btn-icon {
  /* The SVG placeholder (no icon set) still wants to be a small
     centered box, not scaled up to icon-image size. */
  width: 36px;
  height: 36px;
}

.grid-btn-featured .grid-btn-label {
  color: var(--color-h10-text);
  text-align: center;
  font-size: clamp(0.75rem, 5vw, 1.5rem);
}


/* ═══ MODALS ═════════════════════════════════════════ */
.modal-bd {
  position: fixed;
  inset: 0;
  background: rgba(30,45,64,.60);
  backdrop-filter: blur(5px);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
}

.modal-bd.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--color-white);
  border-radius: 22px;
  width: 100%;
  max-width: 360px;
  padding: 26px 22px 20px;
  transform: scale(0.94);
  transition: transform 0.3s cubic-bezier(.32,.72,0,1);
}

.modal-bd.open .modal {
  transform: scale(1);
}

.modal-icon {
  font-size: 2.4rem;
  text-align: center;
  display: block;
  margin-bottom: 8px;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 8px;
}

.modal-body {
  font-size: var(--fs-sm);
  color: var(--color-text-body);
  line-height: 1.6;
  text-align: center;
  margin-bottom: 18px;
}

.modal-body strong {
  color: var(--color-text);
}

.modal-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-modal-primary {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.14s;
}

.btn-modal-primary:hover {
  transform: scale(1.02);
}

.btn-modal-primary.danger {
  background: linear-gradient(135deg, #b82d20, var(--color-accent));
}

/* Matches the header's own Look and Feel colors (background gradient +
   text color) rather than a fixed hue — renamed from .navy since a
   client can set the header to any color, not just navy. Uses the same
   --color-header-* custom properties applyLookAndFeel() (mainscript.js)
   writes onto :root from a client's headerBgColor1/2/headerTextColor,
   the same ones .btn-back already reads — so this button always tracks
   whatever a client picked for their header, same as Back does. */
.btn-modal-primary.header-colors {
  background: linear-gradient(135deg, var(--color-header-bg-start), var(--color-header-bg-end));
  color: var(--color-header-title);
}

.btn-modal-primary.gold {
  background: linear-gradient(135deg, var(--color-warning), #c8882a);
}

.btn-modal-cancel {
  width: 100%;
  height: 44px;
  background: transparent;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-modal-cancel:hover {
  border-color: var(--color-primary-light);
  color: var(--color-primary);
}

/* ═══ BOTTOM SHEETS ══════════════════════════════════ */
.sheet-bd {
  position: fixed;
  inset: 0;
  background: rgba(30,45,64,.5);
  backdrop-filter: blur(3px);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-bd.open {
  opacity: 1;
  pointer-events: all;
}

.sheet {
  background: var(--color-white);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 88dvh;
  overflow-y: auto;
  padding-bottom: calc(16px + var(--safe-bottom));
  transform: translateY(40px);
  transition: transform 0.3s cubic-bezier(.32,.72,0,1);
}

.sheet-bd.open .sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 12px auto 0;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1.5px solid var(--color-bg-alt);
}

.sheet-title {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  color: var(--color-text);
  font-weight: 700;
}

.btn-sx {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-round);
  background: var(--color-bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-sx svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-text-muted);
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.sheet-body {
  padding: 16px 18px 4px;
}

.i-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.i-step {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.i-num {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-round);
  background: var(--color-primary);
  color: white;
  font-weight: 800;
  font-size: var(--fs-base);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.i-step p {
  font-size: var(--fs-base);
  color: var(--color-text-body);
  line-height: 1.45;
}

.i-step p strong {
  color: var(--color-text);
}

.offline-note {
  background: #fdf6e4;
  border: 1.5px solid rgba(160,104,32,.25);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-top: 12px;
  font-size: var(--fs-sm);
  color: var(--color-warning);
  font-weight: 700;
  line-height: 1.5;
}


/* ═══ MIC DENIED ═════════════════════════════════════ */
.mic-denied-bd {
  position: fixed;
  inset: 0;
  background: rgba(240,244,248,.97);
  z-index: 95;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.mic-denied-bd.show {
  display: flex;
}

.mic-denied-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.mic-denied-title {
  font-family: var(--font-heading);
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.mic-denied-body {
  font-size: var(--fs-base);
  color: var(--color-text-body);
  line-height: 1.65;
  max-width: 320px;
  margin-bottom: 20px;
}

.mic-steps {
  background: var(--color-white);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  text-align: left;
  width: 100%;
  max-width: 340px;
  margin-bottom: 16px;
}

.mic-steps p {
  font-size: var(--fs-sm);
  color: var(--color-text-body);
  line-height: 1.55;
  margin-bottom: 8px;
}

.mic-steps p:last-child {
  margin-bottom: 0;
}

.mic-steps strong {
  color: var(--color-text);
}

.btn-reload {
  height: 50px;
  padding: 0 2rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  border: none;
  border-radius: var(--radius-pill);
  color: white;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 800;
  cursor: pointer;
}


/* ═══ QR SHARE MODAL ═════════════════════════════════ */
.qr-share-modal .qr-big {
  width: clamp(160px, 50vw, 220px);
  height: clamp(160px, 50vw, 220px);
  border-radius: 12px;
  cursor: pointer;
  border: 3px solid var(--color-white);
  box-shadow: var(--shadow-lg);
  transition: transform 0.18s;
}

.qr-share-modal .qr-big:hover {
  transform: scale(1.04);
}

.qr-share-modal .qr-url {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  word-break: break-all;
  text-align: center;
  background: var(--color-bg);
  border-radius: 8px;
  padding: 7px 12px;
  margin-top: 2px;
}

/* ═══ VIDEO MODAL ════════════════════════════════════ */
.video-modal .modal {
  max-width: 98vw;
  width: 500px;
  padding: 8px 8px 12px;
  border-radius: 14px;
}

.video-modal .video-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  cursor: pointer;
}

/* Poster/thumbnail overlay for iOS */
.video-poster-overlay {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: opacity 0.3s;
  border-radius: var(--radius-sm);
}

.video-poster-overlay.hide {
  opacity: 0;
  pointer-events: none;
}

.video-play-circle {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-round);
  background: rgba(255,255,255,.18);
  border: 2.5px solid rgba(255,255,255,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.2s;
}

.video-play-circle:hover {
  transform: scale(1.1);
  background: rgba(255,255,255,.3);
}

.video-play-circle svg {
  width: 24px;
  height: 24px;
  fill: white;
  margin-left: 4px;
}

.video-modal .modal-title {
  font-size: var(--fs-lg);
  margin-bottom: 6px;
}

.video-modal .modal-btns {
  margin-top: 8px;
}

/* ═══ MEDIA MODAL — shared video/image/audio layout ══════
   The modal itself gets a real height ceiling relative to the
   viewport. Inside it, title + media + Directions button live in a
   scrollable content area; Close sits outside that area as its own
   flex child that never shrinks — so Close is always reachable no
   matter how tall the content above it gets. The media element itself
   is given room to shrink (flex + min-height:0 on the scroll
   container, a generous but not unbounded max-height on the media
   itself) so a normal-length title + normal media comfortably fits
   without scrolling in the common case, while a long title or a tall
   image gracefully falls back to internal scrolling instead of
   overflowing the modal or pushing Close off-screen. */
.media-modal-shell {
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
  padding: 8px 8px 12px;
}

.media-modal-shell > .modal-btns {
  flex-shrink: 0;
}

.media-modal-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#mediaModalTitle {
  flex-shrink: 0;
  width: 100%;
}

#mediaModalVideo {
  width: 100%;
  max-height: 70dvh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #000;
  flex-shrink: 1;
  min-height: 0;
}

#mediaModalImg {
  /* max-width (not width) — a small source image renders at its true,
     sharp resolution instead of being forcibly stretched up to fill
     the modal's width. object-fit:contain only governs how an
     element's CONTENT fits its box; it can't shrink the box itself,
     so a mandatory width:100% was overriding it for any image
     narrower than the modal. Still caps down large images exactly as
     before. */
  max-width: 100%;
  max-height: 70dvh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: transparent;
  flex-shrink: 1;
  min-height: 0;
}

/* Audio artwork — sized more like a real photo now that it may be used
   for a relevant image (e.g. a gravestone photo) rather than only a
   small album-cover square. Still capped so it can't dominate the
   modal, and still shrinks first if the scroll area gets tight. */
#mediaModalArtwork {
  width: 100%;
  max-width: 320px;
  max-height: 45dvh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  margin: 0 auto 10px;
  flex-shrink: 1;
  min-height: 0;
}

#mediaModalAudio {
  width: 100%;
  flex-shrink: 0;
  margin-top: 4px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
}

/* Directions button — styled to match Home's featured btn10 colors
   (Look and Feel h10BgColor1/2/h10TextColor), the same gradient a
   client already uses to make btn10 stand out, applied here too. */
.media-directions-btn {
  flex-shrink: 0;
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-h10-bg-start), var(--color-h10-bg-end));
  color: var(--color-h10-text);
  text-align: center;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: var(--fs-base);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s, box-shadow 0.14s;
}

.media-directions-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.media-directions-btn:active {
  transform: scale(0.98);
}


/* ═══ UTILITY ════════════════════════════════════════ */
.hidden { display: none !important; }
.visually-hidden { visibility: hidden; pointer-events: none; }