/* Ecclesia Theme - Theological Elegant Vintage Design */

:root {
  --ec-parchment: #F7F1E0;
  --ec-ink: #1B1B1B;
  --ec-gold: #C6A15B;
  --ec-claret: #4A2C2A;
  --ec-indigo: #1F2A44;
  --ec-sage: #7C8A6A;
  --ec-amber: #B6862C;
}

/* Base theme hook - does not override unless .theme-ecclesia on <body> */
body.theme-ecclesia {
  /* Map existing app vars to ecclesia palette (conservative to avoid breaking UI) */
  --background: var(--ec-parchment);
  --text-primary: var(--ec-ink);
  --text-secondary: rgba(27, 27, 27, 0.7);
  --secondary: #F2EEE2; /* soft parchment */
  --accent: rgba(198, 161, 91, 0.35);
  --gold-leaf: var(--ec-gold);
  /* keep brand primary close to current brown for minimal disruption */
  --primary: #6D4C41;
}

/* Candlelight dark mode */
body.theme-ecclesia.theme-candle {
  --background: #15120E;
  --text-primary: #E9E2CF;
  --text-secondary: rgba(233, 226, 207, 0.72);
  --secondary: #1D1913;
  --accent: rgba(198, 161, 91, 0.25);
  --gold-leaf: #D1B06B;
  --primary: #8B5E3C;
  background-color: var(--background);
  color: var(--text-primary);
}

/* Paper texture and gentle vignette */
body.theme-ecclesia {
  background-color: var(--background);
  color: var(--text-primary);
  background-image: radial-gradient(1200px 600px at 50% -10%, rgba(198,161,91,0.08), rgba(0,0,0,0) 60%),
    radial-gradient(1600px 800px at 50% 120%, rgba(74,44,42,0.08), rgba(0,0,0,0) 60%);
  background-attachment: fixed;
}

/* Gentle grain overlay */
body.theme-ecclesia::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(0deg, rgba(0,0,0,0.02), rgba(0,0,0,0.02) 1px, transparent 1px, transparent 2px);
  opacity: 0.6;
  mix-blend-mode: multiply;
  z-index: 0;
}

/* Gold foil text effect */
.gold-text {
  background: linear-gradient(135deg, #8E6B2E, #D1B06B 35%, #F4E2B5 55%, #A07B32 75%, #E2C77E);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 0 rgba(0,0,0,0.0), 0 0 1px rgba(0,0,0,0.12);
}

/* Illuminated initial letter (opt-in) */
.enable-initial .illuminated p:first-of-type::first-letter,
.enable-initial .illuminated .prose p:first-of-type::first-letter {
  initial-letter: 2.5;
  font-weight: 700;
  color: var(--ec-claret);
  padding-right: 0.1em;
}

/* Motion safety toggle */
.motion-off *, .motion-off *::before, .motion-off *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* Remove no-longer-used FAB & panel styles by neutralizing their display */
.ec-fab, .ec-panel { display: none !important; }

/* Page transitions (route-like fades) */
.page-enter { opacity: 0; transform: translateY(6px); }
.page-enter-active { opacity: 1; transform: translateY(0); transition: opacity 280ms ease, transform 280ms ease; }
.page-exit { opacity: 1; }
.page-exit-active { opacity: 0; transform: translateY(-6px); transition: opacity 220ms ease, transform 220ms ease; }

/* Enhance citation tooltip aesthetics */
.citation-tooltip {
  border-radius: 10px;
  border-width: 1.5px;
  border-color: rgba(209,176,107,0.9) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.2) !important;
}
.citation-tooltip.show { opacity: 1; }

/* Gold hover for citations */
.citation:hover { filter: brightness(1.04) saturate(1.02); }

/* Gold divider */
.gold-divider { height: 1px; background: linear-gradient(90deg, rgba(0,0,0,0), rgba(198,161,91,0.7), rgba(0,0,0,0)); margin: 8px 0; }

/* Candlelight header/footer soft glow */
body.theme-ecclesia.theme-candle .header-bg,
body.theme-ecclesia.theme-candle .footer-bg {
  background: linear-gradient(to bottom, rgba(209,176,107,0.06), rgba(0,0,0,0));
}

/* Hero section */
.ec-hero {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(360px, 48vh, 620px);
  padding: 48px 16px;
  margin: 8px auto 12px auto;
  max-width: 1100px;
  overflow: hidden;
  border-radius: 18px;
}

/* Stained glass background (soft and performant) */
.ec-hero-bg {
  position: absolute;
  inset: -8%;
  background:
    radial-gradient(800px 400px at 20% 10%, rgba(79, 96, 133, 0.22), transparent 60%),
    radial-gradient(900px 420px at 80% 0%, rgba(122, 68, 66, 0.18), transparent 60%),
    radial-gradient(600px 400px at 10% 100%, rgba(124, 138, 106, 0.18), transparent 60%),
    radial-gradient(700px 500px at 100% 90%, rgba(198,161,91,0.18), transparent 60%),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.06) 2px, transparent 2px, transparent 10px);
  filter: saturate(0.9) contrast(0.98);
  z-index: 1;
}

/* Light shafts */
.ec-rays {
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 200deg at 50% -10%, rgba(255,236,200,0.45), rgba(255,236,200,0) 35%)
              ,conic-gradient(from 210deg at 30% -20%, rgba(255,236,200,0.30), rgba(255,236,200,0) 30%);
  mix-blend-mode: screen;
  opacity: 0.55;
  animation: ec-rotate-slow 24s linear infinite;
  z-index: 2;
}

@keyframes ec-rotate-slow { to { transform: rotate(360deg); } }

/* Gold frame */
.ec-hero-frame {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  padding: 1px;
  background: linear-gradient(120deg, rgba(142,107,46,0.8), rgba(244,226,181,0.5), rgba(160,123,50,0.8));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; /* Safari */
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude; /* Others */
  z-index: 3;
}

/* Content */
.ec-hero-content { position: relative; z-index: 4; text-align: center; max-width: 820px; padding: 0 12px; }
.ec-mark { font-size: clamp(36px, 6vw, 72px); line-height: 1; margin-bottom: 10px; color: var(--primary); text-shadow: 0 2px 10px rgba(0,0,0,0.12); }
.ec-title { font-family: 'Noto Serif TC', serif; font-size: clamp(28px, 6.2vw, 56px); letter-spacing: 0.06em; font-weight: 700; }
.ec-subtitle { margin-top: 10px; color: var(--text-secondary); font-size: clamp(14px, 2.4vw, 18px); line-height: 1.85; max-width: 680px; margin-left: auto; margin-right: auto; }

/* Entrance transition */
.ec-enter { animation: ec-fade-up 520ms ease both; }
@keyframes ec-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ec-rays { animation: none; }
  .ec-enter { animation: none; }
}

/* Candlelight adjustments */
body.theme-ecclesia.theme-candle .ec-hero-bg { filter: saturate(0.85) brightness(0.9) contrast(0.95); }
body.theme-ecclesia.theme-candle .ec-rays { opacity: 0.5; }

/* Candle sweep transition */
.ec-sweep {
  position: fixed; inset: 0; pointer-events: none; z-index: 60; display: none;
}
.ec-sweep.active { display: block; }
.ec-sweep::before {
  content: ""; position: absolute; inset: 0; 
  background: radial-gradient(120% 80% at -10% 0%, rgba(255,226,170,0.0), rgba(255,226,170,0.22) 40%, rgba(0,0,0,0) 70%),
              linear-gradient(90deg, rgba(0,0,0,0), rgba(255,240,205,0.28) 35%, rgba(0,0,0,0) 70%);
  filter: blur(2px) saturate(1.05);
  transform: translateX(-100%);
  animation: ec-sweep 620ms ease;
}
@keyframes ec-sweep { to { transform: translateX(120%); } }

/* Gold fade mask for section entrances */
.gold-fade { position: relative; overflow: hidden; }
.gold-fade::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(120deg, rgba(244,226,181,0.35), rgba(0,0,0,0) 35%);
  transform: translateX(-20%);
  opacity: 0; transition: opacity 420ms ease, transform 420ms ease;
}
.gold-fade.gold-in::after { opacity: 1; transform: translateX(0); }

/* Elegant blockquote */
blockquote.ec-quote {
  position: relative; margin: 20px auto; padding: 18px 18px 18px 22px; max-width: 780px;
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.35));
  border: 1px solid rgba(198,161,91,0.45);
  border-radius: 14px;
  box-shadow: 0 10px 22px rgba(0,0,0,0.12);
}
blockquote.ec-quote::before {
  content: "\201C"; position: absolute; left: 12px; top: -6px; font-size: 44px; color: rgba(198,161,91,0.8);
}
blockquote.ec-quote footer { margin-top: 10px; color: var(--text-secondary); font-size: 0.9em; }

/* Iconic divider */
.ec-divider { display: grid; place-items: center; margin: 18px auto; }
.ec-divider .line { height: 1px; width: 100%; max-width: 760px; background: linear-gradient(90deg, transparent, rgba(198,161,91,0.8), transparent); }
.ec-divider .icon { margin-top: -10px; background: var(--background); padding: 0 8px; color: var(--primary); }