/* ==========================================================================
   Oratory Adoration — Public Schedule Widget · Modern design (production)
   --------------------------------------------------------------------------
   Ported from design/prototypes/widget-modern.html (approved v2):
   sans-serif UI type, compact hour cards, dark-wood header band over a
   full-width Monstrance photo strip, gold kicker, three-pill legend,
   segmented filter, AA-compliant gold CTAs. Status colors are the real
   Monstrance tokens (also documented in static/css/tokens.css).
   Self-contained: no external stylesheet dependencies.

   Privacy-safe: no personal names, contacts, or attendance data exposed —
   GP-10 / SRS 13.2.
   ========================================================================== */

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

:root {
  /* Brand — Monstrance palette (mirrors static/css/tokens.css) */
  --gold: #B8944A;
  --gold-soft: #D4AF6A;
  --gold-deep: #8B6508;
  --wood: #2B1D14;
  --wood-soft: #4A3C32;
  --cream: #F5EDE0;
  --parchment: #E8DCC0;
  --ink: #2B1D14;
  --ink-dim: #5C4F42;
  --line: #D9C97A;
  --line-soft: #E5DCC8;
  /* Status — green / amber / terracotta / gray */
  --success: #3A6B4A;
  --success-bg: #EAF0E8;
  --warning: #C9A63E;
  --warning-bg: #F5EDD8;
  --danger: #B5493A;
  --danger-bg: #F9E9E5;
  --muted: #8B7D6B;
  --muted-bg: #EFEDEA;
  /* Surfaces — approved Modern variant values */
  --page-bg: #F5F0E3;
  --card-bg: #FDFAF2;
  /* Legacy aliases — widget.js still reads/overrides these:
     --primary-color / --font-family / --border-radius via ?primary=
     ?font= ?radius= URL params (applyTheme), and the kiosk back link
     injects var(--primary-color) / var(--primary-dark) inline styles. */
  --primary-color: #B8944A;
  --primary-dark: #8B6508;
  --font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --border-radius: 10px;
  /* Shape & motion */
  --radius: 6px;
  --radius-lg: 10px;
  --dur-fast: 160ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* ── Page layout ──────────────────────────────────────────────── */

.page {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 16px;
}

.widget {
  width: 100%;
  max-width: 520px;
  min-width: 260px;
  background: var(--card-bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--border-radius, var(--radius-lg));
  box-shadow: 0 6px 24px rgba(43, 29, 20, 0.12);
  overflow: hidden;
}

/* ── Header: wide Monstrance strip over the dark-wood band ────── */

.widget-header {
  background: var(--wood);
  overflow: hidden;                    /* clips the zoomed hero image */
}

/* Full-width photo strip; decorative (alt="") — the image is pre-cropped
   (bottom 35% removed) so the monstrance fills the frame without any
   transform overlap onto the band below. */
.header-hero {
  display: block;
  width: 100%;
  height: 110px;
  object-fit: cover;
  object-position: var(--hero-position, center 38%);
  border-bottom: 2px solid var(--gold);
}

.header-band {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px 14px;
}

/* Gold-monochrome crest beside the chapel name — decorative (aria-hidden) */
.band-crest {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  object-fit: contain;
}

/* Chapel opt-in (theme key ``crest_badge``): a faint light halo frames
   the mark so it reads as a badge on the dark band instead of floating.
   Applied only when the template adds the ``crest-badged`` class. */
.band-crest.crest-badged {
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  padding: 6px;
}

.band-text {
  flex: 1 1 auto;   /* grow to fill the row, natural width as the basis */
  min-width: 0;     /* allow wrapping below content width on narrow iframes */
}

.widget-header .kicker {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-soft);          /* 7.9:1 on wood — AA */
}

.widget-header h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--cream);              /* 14:1 on wood — AA */
}

.widget-header .tagline-ref {
  display: block;
  font-size: 0.72em;
  font-weight: 600;
  opacity: 1;
  color: var(--gold-soft);
  margin-top: 2px;
}

.session-note {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--gold-soft);
}

/* Chapel opt-in (theme key ``small_tagline``): tighter type so long
   taglines wrap more compactly. Applied only when the template adds
   the ``small-tagline`` class. */
.session-note.small-tagline {
  font-size: 0.75rem;
  line-height: 1.45;
}

/* Banner sign-in shortcut — two-line gold-outline pill on the right of
   the chapel name/tagline (server-hidden when the kiosk opens the page
   with ?kiosk=1).  flex:none shrink-wraps the pill; .band-text's
   flex-grow fills the space between.  No auto margins — they would soak
   up the free space before flex-grow sees it. */
.band-signin {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6px 12px;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  text-align: center;
  line-height: 1.25;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.band-signin-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--cream);              /* 14:1 on wood — AA */
}

.band-signin-sub {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--gold-soft);          /* 7.9:1 on wood — AA */
}

.band-signin:hover {
  background: color-mix(in srgb, var(--gold) 22%, transparent);
  border-color: var(--gold-soft);
}

.band-signin:active {
  transform: scale(0.97);
}

.band-signin:focus-visible {
  outline: 2px solid var(--gold-soft);
  outline-offset: 2px;
}

/* ── Legend: slim status pills ────────────────────────────────── */

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--line-soft);
}

/* Gentle one-tap banner (occasional-adorers "give_hour" landing):
   soft gold card above the legend nudging the visitor toward a
   recurring signup — no buttons, just the schedule below. */
.nudge-banner {
  margin: 12px 16px 0;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--gold-soft, #e0c78a);
  background: #fbf4e2;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: center;
}

.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--ink);                /* 11–14:1 on tinted bg — AA */
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-pill--covered    { background: var(--success-bg); border-color: var(--success); }
.legend-pill--covered .legend-dot    { background: var(--success); }
.legend-pill--one-person { background: var(--warning-bg); border-color: var(--warning); }
.legend-pill--one-person .legend-dot { background: var(--warning); }
.legend-pill--uncovered  { background: var(--danger-bg);  border-color: var(--danger); }
.legend-pill--uncovered .legend-dot  { background: var(--danger); }
.legend-pill--closed     { background: var(--muted-bg);   border-color: var(--muted); }
.legend-pill--closed .legend-dot     { background: var(--muted); }

/* ── Instruction + segmented filter (Modern segmented control) ── */

.widget-instruction {
  margin: 0;
  padding: 10px 20px 2px;
  text-align: center;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--ink-dim);            /* 7.6:1 on card — AA */
}

.filter {
  padding: 12px 20px 2px;
}

.filter-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.segmented {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--parchment);
}

.segmented label {
  flex: 1;
  padding: 8px 6px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: center;
  color: var(--ink-dim);            /* 6.9:1 on parchment — AA */
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.segmented label:hover {
  background: color-mix(in srgb, var(--gold) 16%, transparent);
}

.segmented input:checked + label {
  background: var(--wood);
  color: var(--cream);              /* 14:1 — AA */
  font-weight: 600;
}

.segmented input:focus-visible + label {
  outline: 2px solid var(--gold-deep);
  outline-offset: 2px;
}

/* ── Schedule: day sections + hour cards ──────────────────────── */

.schedule {
  padding: 12px 20px 6px;
}

.day {
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--line-soft);
}

.day:last-child {
  border-bottom: none;
}

.day-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.day-accent {
  width: 4px;
  height: 20px;
  border-radius: 2px;
  background: var(--gold);
  flex-shrink: 0;
}

.day-name {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
}

.day-date {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-dim);        /* 6.8:1 on card — AA */
}

.hours {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
}

.hours li {
  display: flex;
}

/* ── Hour card (time label + two-spot capacity bar) ───────────── */

.hour {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);                /* 11–14:1 on every tinted bg — AA */
  text-decoration: none;
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              filter var(--dur-fast) var(--ease-out);
}

.hour-time {
  white-space: nowrap;
}

.hour-spots {
  display: flex;
  gap: 3px;
  width: 100%;
  min-width: 44px;
}

.spot {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--line-soft);
}

.hour-afford {
  margin-top: auto;
}

/* ── Status variants (real tokens palette) ────────────────────── */

.hour--covered {
  background: var(--success-bg);
  border-color: var(--success);
}
.hour--covered .spot--filled { background: var(--success); }

.hour--one-person {
  background: var(--warning-bg);
  border-color: var(--warning);
}
.hour--one-person .spot--filled { background: var(--warning); }

.hour--uncovered {
  background: var(--danger-bg);
  border-color: var(--danger);
  border-width: 2px;
}
.hour--uncovered .spot--filled { background: var(--danger); }

.hour--closed {
  background: var(--muted-bg);
  border-color: var(--muted);
  color: var(--ink-dim);            /* 6.8:1 — AA */
  font-weight: 500;
}

/* ── Affordances ─────────────────────────────────────────────────
   Covered hours: whole card is a link (the signup cap is gone), no
                  visible note — the coverage state is the spots bar's
                  job and the aria-label announces the signup action.
   One person:    whole card is a link; the quiet "Sign up →" label is
                  hidden by default and revealed on hover / keyboard
                  focus, together with a subtle underline on the card.
   Uncovered:     loud solid terracotta chip — white on #B5493A (5.3:1 AA).
   Closed / non-link needy: muted note.                            */

.hour-afford--note {
  font-size: 0.66rem;
  font-weight: 500;
  color: var(--ink-dim);
}

.hour-afford--quiet {
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--ink);
}

/* Hidden until the card itself is hovered or focused (mouse or
   keyboard — plain :focus keeps it deterministic for mouse users too).
   The link's aria-label still announces the signup affordance. */
.hour--one-person.hour--link .hour-afford--quiet {
  display: none;
}

.hour--one-person.hour--link:hover .hour-afford--quiet,
.hour--one-person.hour--link:focus .hour-afford--quiet {
  display: inline-block;
}

.hour--one-person.hour--link:hover,
.hour--one-person.hour--link:focus {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1.5px;
  text-decoration-color: var(--warning);
}

.hour-afford--danger {
  font-size: 0.66rem;
  font-weight: 600;
  color: #FFFFFF;                   /* 5.3:1 on danger — AA */
  background: var(--danger);
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

/* ── "Sub requested" badge ───────────────────────────────────────
   An uncovered hour whose zero coverage is solely the regular
   adorer's substitute request — the hour is real and joinable, and
   the badge says why it is empty.  Muted amber pill (warning tokens)
   so it reads as an active request rather than a coverage gap. */

.hour-badge--sub {
  align-self: flex-start;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-dim);            /* 6.8:1 on the amber pill — AA */
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}

/* ── Interactive hour cards ───────────────────────────────────── */

.hour--link {
  cursor: pointer;
}

.hour--link:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(43, 29, 20, 0.14);
}

.hour--one-person.hour--link:hover {
  filter: brightness(0.97);
}

.hour--covered.hour--link:hover {
  filter: brightness(0.97);
}

.hour--uncovered.hour--link:hover {
  filter: brightness(0.95);
}

.hour--link:focus-visible {
  outline: 2px solid var(--gold-deep);
  outline-offset: 2px;
}

.filter-empty {
  padding: 24px 4px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

/* ── Loading / error / empty states ───────────────────────────── */

.widget-loading {
  padding: 48px 24px 36px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.875rem;
}

.widget-loading::before {
  content: "";
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 14px;
  border: 2.5px solid var(--line);
  border-top-color: var(--primary-color, var(--gold));
  border-radius: 50%;
  animation: oratory-spin 0.8s linear infinite;
}

@keyframes oratory-spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  animation: loading-fade 1.6s ease-in-out infinite;
}

@keyframes loading-fade {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

.widget-error {
  padding: 40px 20px;
  text-align: center;
  color: var(--danger);
  font-size: 0.875rem;
}

.widget-error p {
  margin-bottom: 14px;
}

.widget-error button {
  padding: 9px 28px;
  background: var(--wood);
  color: var(--cream);              /* 14:1 — AA */
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.widget-error button:hover {
  background: var(--wood-soft);
}

.widget-error button:focus-visible {
  outline: 2px solid var(--gold-deep);
  outline-offset: 2px;
}

.widget-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.widget-empty-sub {
  display: block;
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--ink-dim);
  opacity: 0.75;
}

/* ── Show more hours ──────────────────────────────────────────── */

.widget-more {
  text-align: center;
  padding: 2px 20px 12px;
}

.widget-more button {
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--ink-dim);
  background: transparent;
  border: none;
  border-bottom: 1.5px solid transparent;
  cursor: pointer;
  padding: 6px 12px;
  transition: color var(--dur-fast) var(--ease-out),
              border-bottom-color var(--dur-fast) var(--ease-out);
}

.widget-more button:hover {
  color: var(--gold-deep);
  border-bottom-color: var(--gold);
}

.widget-more button:focus-visible {
  outline: 2px solid var(--gold-deep);
  outline-offset: 2px;
  border-radius: 4px;
}

.widget-more button:disabled {
  color: var(--ink-dim);
  opacity: 0.5;
  cursor: default;
  border-bottom-color: transparent;
}

/* ── Bottom CTA stack (production-like buttons) ─────────────────
   .cta--gold-outline ≈ legacy .cta-button--sub    (gold border, tint hover)
   .cta--wood         ≈ legacy .cta-button--account (dark wood, gold hover) */

.cta-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 20px 4px;
}

.cta {
  display: block;
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.35;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.cta:active {
  transform: scale(0.97);
}

.cta:focus-visible {
  outline: 2px solid var(--gold-deep);
  outline-offset: 2px;
}

.cta-sub {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 1px;
}

.cta--gold-outline {
  background: var(--parchment);
  color: var(--wood);               /* 12:1 on parchment — AA */
  border: 1.5px solid var(--gold);
}

.cta--gold-outline:hover {
  background: color-mix(in srgb, var(--gold) 22%, transparent); /* production hover tint */
}

.cta--wood {
  background: var(--wood);
  color: var(--cream);              /* 14:1 on wood — AA */
  border: 1.5px solid var(--wood);
}

.cta--wood:hover {
  background: var(--wood-soft);     /* 8.6:1 on wood-soft — AA */
  border-color: var(--gold);        /* gold accent on hover */
}

/* ── Footer ───────────────────────────────────────────────────── */

.card-footer {
  padding: 14px 24px 20px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--ink-dim);
}

.card-footer p {
  margin: 0;
}

/* Production-style gold rule above the "last updated" line */
.footer-rule {
  height: 1px;
  background: var(--gold);
  margin: 0 auto 10px;
  width: 60%;
  max-width: 200px;
}

.updated {
  font-style: italic;
}

.card-footer .org-note {
  margin-top: 2px;
  color: #6B5B48;                /* 5.6:1 on cream — AA, no opacity trick */
}

/* Per-chapel contact links (address → Google Maps, then the website) */
.card-footer .footer-link {
  display: inline-block;
  margin: 2px 8px 0;
  color: #6B5B48;                /* matches org-note — AA on cream */
  text-decoration: underline;
}

.card-footer .footer-link:hover,
.card-footer .footer-link:focus-visible {
  color: var(--ink);
}

/* ── Utilities ────────────────────────────────────────────────── */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ── Phones: legend pills stay on one row ────────────────────── */

@media (max-width: 520px) {
  .legend {
    gap: 6px;
    padding: 12px 14px 10px;
  }

  .legend-pill {
    font-size: 0.64rem;
    padding: 3px 8px;
    gap: 5px;
  }

  .legend-dot {
    width: 7px;
    height: 7px;
  }
}

/* ── Small screens (min 260px iframe width) ───────────────────── */

@media (max-width: 380px) {
  .header-hero {
    height: 88px;
  }

  .header-band {
    padding: 20px;
    gap: 10px;                     /* crest + name + sign-in stay clear of each other */
    flex-wrap: wrap;               /* pill drops to its own row when space runs out */
  }

  .band-text {
    flex: 1 1 160px;               /* name keeps a readable line before wrapping */
  }

  .band-signin {
    padding: 5px 8px;
    margin-left: auto;             /* right-aligned on its own row */
  }

  .legend {
    padding: 12px 14px 10px;
  }

  .widget-instruction {
    padding: 10px 14px 2px;
  }

  .filter {
    padding: 12px 14px 2px;
  }

  .segmented label {
    padding: 8px 4px;
    font-size: 0.78rem;
  }

  .schedule {
    padding: 10px 14px 4px;
  }

  .hours {
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  }

  .cta-stack {
    padding: 10px 14px 4px;
  }

  .card-footer {
    padding: 12px 16px 16px;
  }
}

/* ── Reduced motion ───────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    transform: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
