@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:wght@400;600&display=swap');

/* ========== Theme Tokens ========== */
:root {
  --bg: #f7f7f8;
  --card: #ffffff;
  --ink: #191919;
  --muted: #6b7280;      /* neutral-500 */
  --line: #e5e7eb;       /* neutral-200 */
  --accent: #0f1115;     /* soft orange to echo your logo */
  --accent-ink: #ffffff;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0,0,0,.06);
  --shadow-hover: 0 12px 28px rgba(0,0,0,.08);
  --gap: 20px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a21;
    --ink: #f5f5f5;
    --muted: #a3a9b7;
    --line: #232732;
    --accent: #0f1115;
    --accent-ink: #ffffff;
    --shadow: none;
    --shadow-hover: none;
  }
}

/* Base */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'EB Garamond', serif;
  margin: 0;
  padding: 24px;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* Header */
header {
  text-align: center;
  margin: 12px 0 28px;
}
.logo {
  max-height: 120px;
  margin-bottom: 8px;
}
h1 {
  font-size: clamp(2.2rem, 3vw, 3rem);
  margin: 0;
  font-weight: 600;
  letter-spacing: .3px;
}

/* Card/Section */
section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: var(--gap);
  overflow: clip; /* avoids scrollbars on animation edges */
  transition: box-shadow .25s ease, transform .2s ease;
}
section:hover {
  box-shadow: var(--shadow-hover);
}

/* Accordion button */
.collapsible {
  appearance: none;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 18px 22px;
  font-size: 1.25rem; /* a bit smaller = calmer */
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;       /* centered header */
  cursor: pointer;
  /* remove heavy line; we'll draw a light divider between sections instead */
  border-bottom: 0;
  transition: background-color .2s ease;
  text-align: center;

  /* keep chevron on the right while text is centered */
  position: relative;
  padding-right: 46px; /* room for chevron on the right */
}

.collapsible:hover { background: rgba(0,0,0,.025); }
.collapsible:active { background: rgba(0,0,0,.04); }

/* Keyboard focus */
.collapsible:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent), transparent 70%);
  outline-offset: 2px;
  border-radius: calc(var(--radius) - 2px);
}

/* Chevron (stick it to the right so label stays centered) */
.collapsible::after {
  content: '';
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .2s ease;
  opacity: .85;

  position: absolute;
  right: 22px;
  top: 50%;
  translate: 0 -50%;
}

/* Use .active or aria-expanded="true" from your JS */
.collapsible.active,
.collapsible[aria-expanded="true"] {
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent), transparent 92%);
}
.collapsible.active::after,
.collapsible[aria-expanded="true"]::after {
  transform: rotate(45deg); /* chevron points up when open */
}

/* Panel content */
.content {
  display: grid; /* for smooth max-height animation without layout thrash */
  grid-template-rows: 0fr;
  transition: grid-template-rows .28s ease, padding .2s ease;
  padding: 0 22px;
  text-align: center; /* center panel text */
}
.content > div {
  overflow: hidden; /* inner wrapper to animate height neatly */

  /* Centered card treatment */
  max-width: 640px;
  margin: 1rem auto;
  padding: 1.5rem;
  background-color: var(--card);
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  border: 1px solid rgba(0,0,0,.06);
  text-align: center;
}
.content.open {
  grid-template-rows: 1fr;
  padding: 20px 22px 22px;
}

/* Typography inside panels */
.content h3 {
  margin: 0 0 8px;
  font-weight: 600;
}
.content p,
.content h3,
.content a {
  line-height: 1.7;
  letter-spacing: .2px;
  color: var(--ink);
  text-align: center; /* center text */
}

/* Links */
a { color: color-mix(in srgb, var(--accent), #3366cc 50%); }
a:hover { text-decoration: underline; }

/* Prayer text block */
.prayer-text {
  white-space: pre-line;
  margin-top: 8px;
}

/* Muted helper text / reading time */
.meta {
  color: var(--muted);
  font-size: .95rem;
}

/* Divider between sections (instead of header bottom border) */
section + section {
  border-top: 1px solid var(--line);
}

/* Fade-in for content */
.content.open > div {
  animation: cardFadeIn .28s ease-out;
}
@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  section, .collapsible, .content {
    transition: none !important;
  }
  .content.open > div { animation: none !important; }
}

/* Dark mode explicit inner card colors and hover tweaks */
@media (prefers-color-scheme: dark) {
  .content > div {
    background-color: #1f2430;                 /* lighter than section bg */
    border: 1px solid rgba(255,255,255,.08);
    box-shadow:
      0 0 0 1px rgba(255,255,255,.05),
      0 10px 24px rgba(0,0,0,.45);
  }
  .collapsible:hover { background: rgba(255,255,255,.03); }
  .collapsible.active,
  .collapsible[aria-expanded="true"] {
    background: rgba(249, 115, 22, 0.10);
  }
}

/* --- Safety net: high-specificity overrides to beat earlier rules --- */
section > .collapsible { justify-content: center !important; text-align: center !important; border-bottom: 0 !important; padding-right: 46px !important; position: relative !important; }
section > .collapsible::after { opacity: .95 !important; right: 22px !important; }
.content { text-align: center !important; }
.content > div { max-width: 640px !important; margin: 1rem auto !important; padding: 1.5rem !important; border-radius: 12px !important; }
/* --- Fix pill-looking links inside panels --- */
.content a {
  display: inline;              /* no block width */
  padding: 0;                   /* remove button padding */
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  text-decoration: underline;   /* plain link look */
  color: inherit;               /* match text color */
}

/* If an inherited utility is forcing a button look via classes, hard reset: */
.content a[class*="btn"],
.content a[class*="button"],
.content a[role="button"] {
  all: unset;
  cursor: pointer;
  color: inherit;
  text-decoration: underline;
}

/* Tighten section spacing a bit so it doesn’t feel so airy */
section { padding-bottom: 6px; }
.content.open { padding: 16px 22px 18px; }
/* FIX: stop the inner card from showing while collapsed */
.content {
  overflow: hidden; /* prevents the "pill" from poking out */
}

/* No vertical margin on the inner card unless the panel is open */
.content > div {
  margin: 0 auto !important;          /* center, but no top/bottom margin when closed */
}

.content.open > div {
  margin: 1rem auto !important;       /* add the comfy margin only when open */
}

/* Optional: also soften the closed-state look */
.content:not(.open) > div {
  box-shadow: none;                    /* no shadow while closed */
  border-color: transparent;           /* hairline disappears when closed */
  opacity: 0;                          /* fully hidden; animation restores on open */
}
.content.open > div { opacity: 1; }
/* --- Compact the sections --- */
section {
  border-radius: 12px;          /* was 14px */
  margin-bottom: 16px;          /* was var(--gap) */
}

/* Header (accordion button) — shorter & tighter */
section > .collapsible {
  padding: 12px 18px;           /* was 18–20px */
  font-size: 1.125rem;          /* was 1.25rem */
}

/* Panel container padding when open — less vertical space */
.content.open {
  padding: 12px 18px 14px;      /* was 20px 22px 22px */
}

/* Inner card — smaller radius, less padding, tighter margins */
.content.open > div {
  max-width: 560px;             /* was 600–640px */
  margin: 0.5rem auto;          /* was 1rem auto */
  padding: 1rem 1.25rem;        /* was 1.5rem */
  border-radius: 10px;          /* was 12px */
  box-shadow: 0 4px 12px rgba(0,0,0,.10);
}

/* Tighten headings inside panels */
.content h3 {
  margin: 0 0 6px;              /* was 0 0 8px */
}

/* Slightly smaller line-height for compact look */
.content p,
.content a {
  line-height: 1.6;             /* was 1.7 */
}

/* Optional: reduce container side padding on small screens */
@media (max-width: 640px) {
  .container { padding: 0 12px 36px; }
  section > .collapsible { padding: 12px 14px; }
  .content.open { padding: 10px 14px 12px; }
  .content.open > div { padding: 0.875rem 1rem; }
}
/* HARD-COLLAPSE closed panels */
.content {
  overflow: hidden;
  min-height: 0;
}
.content:not(.open) {
  height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}
.content:not(.open) > div {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  box-shadow: none !important;
  height: 0 !important;
  min-height: 0 !important;
  opacity: 0 !important;
}

/* Compact headers */
section > .collapsible {
  padding: 10px 16px !important;
  font-size: 1.1rem !important;
}

/* Compact when open, too (but not cramped) */
.content.open {
  padding: 10px 16px 12px !important;
}
.content.open > div {
  max-width: 560px !important;
  margin: 0.5rem auto !important;
  padding: 0.875rem 1rem !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 10px rgba(0,0,0,.12) !important;
  opacity: 1 !important;
  height: auto !important;
}
