/* Heart of the Homily - optional extras (archive, share, Spanish draft, about, newsletter, resume, consent).
   Everything here is scoped to .x-* classes / #x-* ids so it cannot affect the core page. */

:root {
  --x-gold-text: #7a5c14;      /* >= 4.5:1 on cream */
  --x-muted: #5f5d52;          /* >= 4.5:1 on cream */
  --x-btn-bg: var(--green, #1c4633);
  --x-btn-fg: #fffdf7;
  --x-card: var(--surface-glass, rgba(255, 253, 247, 0.82));
  --x-line: var(--line, rgba(28, 70, 51, 0.14));
  --x-ink: var(--ink, #1e3327);
  --x-ink-soft: var(--ink-soft, #42544a);
  --x-focus: #2a5c43;
  --x-warn-bg: #fdf3d6;
  --x-warn-fg: #5b4410;
  --x-warn-line: #b08a3c;
}
:root[data-theme="green"] {
    --x-gold-text: #e0bf73;
    --x-muted: #b3bdae;
    --x-btn-bg: #dce8d8;
    --x-btn-fg: #0d2016;
    --x-focus: #cfa856;
    --x-warn-bg: #2b2410;
    --x-warn-fg: #f1dfae;
    --x-warn-line: #cfa856;
  }

.x-section {
  max-width: 880px;
  margin: 40px auto;
  padding: 24px 20px;
  box-sizing: border-box;
  color: var(--x-ink);
  font-family: var(--sans, "Jost", system-ui, sans-serif);
  background: var(--x-card);
  border: 1px solid var(--x-line);
  border-radius: 20px;
  box-shadow: var(--shadow-sm, 0 8px 20px -10px rgba(20, 51, 37, 0.22));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.x-section[hidden] { display: none; }
@media (min-width: 700px) { .x-section { padding: 32px 36px; } }

.x-section h2 {
  margin: 0 0 6px;
  font-family: var(--serif, "Cormorant Garamond", Georgia, serif);
  font-weight: 600;
  font-size: clamp(1.6rem, 4.5vw, 2.1rem);
  line-height: 1.15;
  color: var(--x-ink);
}
.x-section p { margin: 0 0 12px; line-height: 1.6; color: var(--x-ink-soft); font-size: 1rem; }
.x-kicker { font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--x-gold-text); font-weight: 500; }

/* Buttons */
.x-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; min-width: 44px; padding: 10px 20px;
  border-radius: 999px; border: 1px solid transparent;
  background: var(--x-btn-bg); color: var(--x-btn-fg);
  font: 500 0.95rem/1.2 var(--sans, "Jost", system-ui, sans-serif);
  cursor: pointer; text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.x-btn:hover { box-shadow: var(--shadow-sm, 0 8px 20px -10px rgba(20, 51, 37, 0.3)); transform: translateY(-1px); }
.x-btn:active { transform: none; }
.x-btn--ghost { background: transparent; color: var(--x-ink); border-color: var(--x-line); }
.x-btn--ghost:hover { background: rgba(28, 70, 51, 0.06); }
[data-theme="green"] .x-btn--ghost:hover { background: rgba(236, 229, 211, 0.08); }

.x-btn:focus-visible, .x-chip:focus-visible, .x-field input:focus-visible,
.x-search:focus-visible, .x-link:focus-visible, .x-lang button:focus-visible,
.x-row-play:focus-visible {
  outline: 3px solid var(--x-focus); outline-offset: 2px;
}

/* Archive */
.x-search-wrap { margin: 14px 0 10px; }
.x-search-wrap label { display: block; font-size: 0.85rem; color: var(--x-muted); margin-bottom: 6px; }
.x-search {
  width: 100%; box-sizing: border-box; min-height: 48px; padding: 10px 16px;
  border: 1px solid var(--x-line); border-radius: 14px;
  background: var(--surface, #fffdf7); color: var(--x-ink);
  font: 400 1rem var(--sans, "Jost", system-ui, sans-serif);
}
.x-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.x-chip {
  min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--x-line); background: transparent; color: var(--x-ink);
  font: 500 0.9rem var(--sans, "Jost", system-ui, sans-serif); cursor: pointer;
}
.x-chip[aria-pressed="true"] { background: var(--x-btn-bg); color: var(--x-btn-fg); border-color: transparent; }
.x-status { font-size: 0.85rem; color: var(--x-muted); margin: 4px 0 10px; min-height: 1.2em; }
.x-list { list-style: none; margin: 0; padding: 0; }
.x-row {
  display: grid; grid-template-columns: 48px 1fr; gap: 14px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--x-line);
}
.x-row:first-child { border-top: 0; }
.x-row-play {
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--x-btn-bg); color: var(--x-btn-fg);
  display: inline-flex; align-items: center; justify-content: center;
}
.x-row-play svg { width: 18px; height: 18px; fill: currentColor; margin-left: 2px; }
.x-row-title { margin: 0; font-family: var(--serif, Georgia, serif); font-size: 1.2rem; line-height: 1.25; font-weight: 600; color: var(--x-ink); }
.x-row-meta { margin: 2px 0 0; font-size: 0.85rem; color: var(--x-muted); }
.x-tag { color: var(--x-gold-text); font-weight: 500; }
.x-more { margin-top: 14px; }

/* Share */

/* Language toggle + badge */
#x-lang-slot { position: absolute; top: 10px; right: 10px; z-index: 40; }
.x-lang { display: inline-flex; border: 1px solid var(--x-line); border-radius: 999px; overflow: hidden; background: var(--x-card); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.x-lang button {
  min-height: 44px; min-width: 44px; padding: 0 14px; border: 0; background: transparent;
  color: var(--x-ink); font: 500 0.85rem var(--sans, "Jost", system-ui, sans-serif); letter-spacing: 0.08em; cursor: pointer;
}
.x-lang button[aria-pressed="true"] { background: var(--x-btn-bg); color: var(--x-btn-fg); }
.x-draft-badge {
  position: fixed; top: 8px; left: 8px; z-index: 60; max-width: calc(100vw - 150px);
  padding: 6px 12px; border-radius: 10px; border: 1px solid var(--x-warn-line);
  background: var(--x-warn-bg); color: var(--x-warn-fg);
  font: 500 0.72rem/1.3 var(--sans, "Jost", system-ui, sans-serif); pointer-events: none;
}
.x-draft-badge[hidden] { display: none; }
.x-intro-note { margin: 8px 0 0; font-size: 0.85rem; color: var(--x-muted); font-style: italic; }
.x-intro-note[hidden] { display: none; }

/* Pills above player (resume / Spanish listen) */
#x-pills { max-width: 880px; margin: 12px auto; padding: 0 20px; display: flex; flex-wrap: wrap; gap: 10px; box-sizing: border-box; }
#x-pills:empty { display: none; }
.x-pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 18px;
  border-radius: 999px; border: 1px solid var(--x-warn-line);
  background: var(--x-card); color: var(--x-ink); cursor: pointer;
  font: 500 0.92rem/1.25 var(--sans, "Jost", system-ui, sans-serif); text-align: left;
}
.x-pill:hover { background: rgba(176, 138, 60, 0.12); }
.x-pill:focus-visible { outline: 3px solid var(--x-focus); outline-offset: 2px; }
.x-pill[hidden] { display: none; }

/* About */
.x-bio-placeholder {
  margin: 14px 0; padding: 16px; border: 2px dashed var(--x-warn-line); border-radius: 14px;
  background: var(--x-warn-bg); color: var(--x-warn-fg); font-size: 0.95rem;
}
.x-link { color: var(--x-gold-text); font-weight: 500; text-underline-offset: 3px; }

/* Newsletter */
.x-placeholder-tag {
  display: inline-block; margin: 6px 0 12px; padding: 4px 10px; border-radius: 8px;
  border: 1px solid var(--x-warn-line); background: var(--x-warn-bg); color: var(--x-warn-fg);
  font: 600 0.72rem/1.3 var(--sans, "Jost", system-ui, sans-serif); letter-spacing: 0.06em; text-transform: uppercase;
}
.x-form { display: grid; gap: 12px; max-width: 460px; }
.x-field label { display: block; font-size: 0.9rem; margin-bottom: 6px; color: var(--x-ink); }
.x-field input[type="email"] {
  width: 100%; box-sizing: border-box; min-height: 48px; padding: 10px 16px;
  border: 1px solid var(--x-line); border-radius: 14px; background: var(--surface, #fffdf7); color: var(--x-ink);
  font: 400 1rem var(--sans, "Jost", system-ui, sans-serif);
}
.x-check { display: flex; align-items: flex-start; gap: 10px; font-size: 0.9rem; color: var(--x-ink-soft); min-height: 44px; }
.x-check input { width: 24px; height: 24px; margin: 10px 0 0; flex: none; accent-color: var(--green, #1c4633); }
.x-check label { padding-top: 10px; }
.x-form-msg { font-size: 0.95rem; color: var(--x-ink); font-weight: 500; margin: 4px 0 0; }

/* Consent bar */
#x-consent-slot { position: static; }
.x-consent {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 70;
  max-width: 720px; margin: 0 auto; box-sizing: border-box;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 14px 16px; border-radius: 16px; border: 1px solid var(--x-line);
  background: var(--surface, #fffdf7); color: var(--x-ink);
  box-shadow: var(--shadow-md, 0 18px 38px -16px rgba(20, 51, 37, 0.3));
  font: 400 0.9rem/1.45 var(--sans, "Jost", system-ui, sans-serif);
  transition: bottom 0.2s ease;
}
.x-consent[hidden] { display: none; }
.x-consent p { margin: 0; flex: 1 1 260px; color: var(--x-ink); }
.x-consent .x-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.x-consent a { color: var(--x-gold-text); font-weight: 500; }
.x-consent a:focus-visible { outline: 3px solid var(--x-focus); outline-offset: 2px; }

.x-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .x-btn, .x-consent { transition: none; }
  .x-btn:hover { transform: none; }
}

/* v4 compact layout */
html[data-variant="expanded"] .core-only { display: none !important; }
html[data-variant="expanded"] main > section { padding-top: 28px; }
html[data-variant="expanded"] .x-section {
  margin: 28px auto 0; padding: 18px 16px; border-radius: 16px;
}
@media (min-width: 700px) { html[data-variant="expanded"] .x-section { padding: 22px 28px; } }
html[data-variant="expanded"] .x-section h2 { font-size: clamp(1.35rem, 4vw, 1.7rem); margin-bottom: 4px; }
html[data-variant="expanded"] .x-section p { margin-bottom: 8px; line-height: 1.5; font-size: 0.95rem; }
html[data-variant="expanded"] #x-archive { padding-top: 18px; }
html[data-variant="expanded"] .x-row { grid-template-columns: 44px 1fr; gap: 12px; padding: 8px 0; }
html[data-variant="expanded"] .x-row-play { width: 44px; height: 44px; }
html[data-variant="expanded"] .x-row-title { font-size: 1.1rem; }
html[data-variant="expanded"] .x-browse { margin-top: 10px; width: 100%; }
html[data-variant="expanded"] .x-more { margin-top: 10px; }
.x-archive-tools[hidden], .x-status[hidden] { display: none; }
.x-archive-tools .x-search-wrap { margin: 8px 0 6px; }
.x-archive-tools .x-chips { margin: 6px 0 8px; gap: 6px; }
.x-browse:focus-visible, .x-more:focus-visible { outline: 3px solid var(--x-focus); outline-offset: 2px; }

/* About: one heading + one paragraph with inline parish link */
html[data-variant="expanded"] #x-about p { margin-bottom: 0; }

/* Newsletter: compact inline row */
.x-nl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 8px; }
.x-nl-head h2 { margin: 0 !important; }
.x-nl-head .x-placeholder-tag { margin: 0; padding: 2px 8px; font-size: 0.64rem; }
.x-form--inline { max-width: none; gap: 6px; }
.x-nl-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.x-nl-row .x-field { flex: 1 1 200px; min-width: 0; }
.x-nl-row .x-field input[type="email"] { min-height: 44px; }
.x-nl-row .x-btn { flex: 0 0 auto; }
.x-form--inline .x-check { font-size: 0.8rem; min-height: 0; align-items: center; }
.x-form--inline .x-check input { width: 20px; height: 20px; margin: 0; }
.x-form--inline .x-check label { padding-top: 0; }
.x-form--inline .x-check { min-height: 44px; }
.x-form--inline .x-check label { min-height: 44px; display: flex; align-items: center; flex: 1; }
.x-form--inline .x-check input { width: 24px; height: 24px; }
.x-nl-row .x-field input:focus-visible { outline: 3px solid var(--x-focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .x-browse { transition: none; } }
.x-more[hidden], .x-browse[hidden] { display: none !important; }

/* Archive tabs: segmented control separating Daily homilies / The Thursday Deposit / Sunday conversation */
.x-tabs {
  display: flex; gap: 4px; padding: 4px; margin: 10px 0 8px;
  background: rgba(28, 70, 51, 0.07); border: 1px solid var(--x-line); border-radius: 16px;
}
[data-theme="green"] .x-tabs { background: rgba(236, 229, 211, 0.07); }
.x-tab {
  flex: 1 1 0; min-width: 0; min-height: 44px; padding: 6px 8px; border: 0; border-radius: 12px;
  background: transparent; color: var(--x-ink); cursor: pointer; text-align: center;
  font: 500 0.88rem/1.2 var(--sans, "Jost", system-ui, sans-serif);
}
.x-tab[hidden] { display: none; }
.x-tab[aria-selected="true"] { background: var(--x-btn-bg); color: var(--x-btn-fg); box-shadow: var(--shadow-sm, none); }
.x-tab:focus-visible, .x-panel:focus-visible { outline: 3px solid var(--x-focus); outline-offset: 2px; }
.x-panel[hidden], .x-empty[hidden] { display: none; }
.x-empty { margin: 10px 0 !important; color: var(--x-muted) !important; }
@media (min-width: 700px) { .x-tab { font-size: 0.98rem; } }

/* Video sections: compact portrait player, centered; text beside it on wide screens */
.x-video-item { display: grid; gap: 10px; justify-items: center; text-align: center; }
.x-video-item + .x-video-item { margin-top: 18px; }
.x-video-copy h2 { margin-bottom: 4px; }
.x-video-copy p { margin: 0 auto; max-width: 46ch; }
.x-video-fig { margin: 0; width: 100%; max-width: 320px; }
.x-video-fig video {
  display: block; width: 100%; height: auto; aspect-ratio: var(--x-vr, 3 / 4);
  border-radius: 16px; background: #0d2016; border: 1px solid var(--x-line);
  box-shadow: var(--shadow-md, 0 18px 38px -16px rgba(20, 51, 37, 0.24));
}
.x-video-fig video:focus-visible { outline: 3px solid var(--x-focus); outline-offset: 3px; }
/* Phones: direct-to-camera stays first and prominent but narrower; the lower film sits beside its text */
@media (max-width: 699px) {
  #x-video-featured .x-video-fig { max-width: 250px; }
  #x-video-featured .x-video-item { gap: 8px; }
  #x-video-about .x-video-item { grid-template-columns: 124px minmax(0, 1fr); gap: 14px; align-items: center; justify-items: stretch; text-align: left; }
  #x-video-about .x-video-fig { max-width: 124px; order: -1; }
  #x-video-about .x-video-copy p { margin: 0; max-width: none; }
  html[data-variant="expanded"] #x-video-featured, html[data-variant="expanded"] #x-video-about { padding: 14px 14px; margin-top: 20px; }
  html[data-variant="expanded"] main > #x-video-featured, html[data-variant="expanded"] main > #x-video-about { padding-top: 14px; }
}
@media (min-width: 700px) {
  .x-video-item { grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: center; justify-items: stretch; text-align: left; }
  .x-video-copy p { margin: 0; max-width: none; }
  .x-video-fig { max-width: 300px; justify-self: end; }
  #x-video-about .x-video-item { grid-template-columns: 300px minmax(0, 1fr); }
  #x-video-about .x-video-fig { justify-self: start; order: -1; }
}
.x-section a.x-link { display: inline-flex; align-items: center; min-height: 44px; }


/* ===== R4 polish ===== (frosted glass for consent bar + language toggle; spring presses) */
.x-consent {
  background: var(--glass-bg, var(--surface, #14301f));
  -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
  border-color: var(--glass-border, var(--x-line));
  box-shadow: var(--shadow-md), var(--glass-hi, none);
}
.x-lang {
  background: var(--glass-bg, var(--x-card));
  -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
  border-color: var(--glass-border, var(--x-line));
  box-shadow: var(--glass-hi, none);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .x-consent, .x-lang { background: var(--glass-solid, var(--surface, #14301f)); }
}
.x-btn { transition-duration: 0.28s; transition-timing-function: var(--spring, ease); }
.x-btn:active, .x-chip:active, .x-lang button:active { transform: scale(0.96); }
.x-chip { transition: transform 0.28s var(--spring, ease), background 0.2s ease; }
@media (prefers-reduced-motion: reduce) {
  .x-btn:active, .x-chip:active, .x-lang button:active { transform: none; }
  .x-chip { transition: none; }
}

/* ===== R4 polish: archive now-playing + consent link target ===== */
.x-row { grid-template-columns: 48px 1fr auto; }
.x-row .x-eq { display: none; }
.x-row.playing .x-eq { display: flex; }
.x-row.playing .x-row-title { color: var(--x-gold-text); }
.x-consent a { display: inline-flex; align-items: center; min-height: 44px; }

/* R4 fix: keep the playing-row equalizer on the same line, at the right */
html[data-variant="expanded"] .x-row { grid-template-columns: 44px minmax(0, 1fr) auto; }
.x-row > div { min-width: 0; }
.x-row .x-eq { margin-left: auto; flex-shrink: 0; align-self: center; }


/* R5: language toggle - clean cream pill, active half deep green (cream theme) */
:root:not([data-theme="green"]) .x-lang { background: rgba(255, 253, 247, 0.95); border-color: rgba(28, 70, 51, 0.22); }
:root:not([data-theme="green"]) .x-lang button { background: transparent; color: var(--green, #1c4633); }
:root:not([data-theme="green"]) .x-lang button[aria-pressed="true"] { background: var(--green, #1c4633); color: #fffdf7; }
/* rows with show-notes previews: keep play + equalizer beside the title, even when the notes are expanded */
.x-row { align-items: start; }
.x-row .x-row-play { margin-top: 2px; }
.x-row .x-eq { align-self: start; margin-top: 16px; }
