/* ───────────────────────────────────────────────────────────
   Our Bible Moments — immersive prayer + library shared styles
   Prayer/sanctuary: a luminous relic floating in a cathedral void (WebGL).
   ─────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --void:       #04030a;
  --ink:        #08070d;
  --ink-2:      #14111f;
  --cream:      #F7F0DF;
  --cream-soft: #cdc2a9;
  --gold:       #E7BE63;
  --gold-deep:  #B8860B;
  --gold-dim:   rgba(231, 190, 99, 0.5);
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Cormorant Garamond', Georgia, serif;
  background: var(--ink);
  color: var(--cream);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ───────── Top brand bar ───────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 8;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(15px, env(safe-area-inset-top)) 20px 14px;
  background: linear-gradient(180deg, rgba(4,3,10,0.6), transparent);
  pointer-events: none;
}
.brand-link {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--cream);
  font-family: 'Cinzel', serif; font-size: 11px; font-weight: 500; letter-spacing: 0.24em; text-transform: uppercase;
  padding-left: 0.24em; opacity: 0.78; transition: opacity 0.25s;
}
.brand-link:hover { opacity: 1; }
.brand-link .mark { color: var(--gold); font-family: 'Cormorant Garamond', serif; font-size: 15px; }
.topbar .nav-link { font-size: 12.5px; letter-spacing: 0.06em; }

/* ════════════ CINEMATIC SANCTUARY (prayer / sanctuary) ════════════ */
body[data-page="prayer"] { background: var(--void); }

.scene { position: relative; z-index: 1; }

/* the relic floats in a void band at the top — ALWAYS visible while you read.
   Both the image (here) and the prayer (below) stay on screen together. */
.hero { position: relative; height: 49vh; height: 49dvh; min-height: 300px; max-height: 620px; }
#light { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
.hero::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 80% at 50% 44%, transparent 42%, rgba(4,3,10,0.5) 84%, var(--void) 100%),
    linear-gradient(180deg, transparent 70%, var(--void) 100%);
}
/* no-WebGL fallback: the full 9:16 art, glowing, melting into the void */
.relic-fallback { display: none; }
body.no-gl #light { display: none; }
body.no-gl .relic-fallback {
  display: block; position: absolute; inset: 0; margin: auto; height: 100%; max-width: 100%; width: auto; object-fit: contain; z-index: 0;
  -webkit-mask-image: radial-gradient(ellipse 72% 70% at 50% 46%, #000 50%, transparent 92%);
          mask-image: radial-gradient(ellipse 72% 70% at 50% 46%, #000 50%, transparent 92%);
}

/* the prayer sits in the void directly below the relic — image + words together */
.prayer-block { position: relative; z-index: 1; max-width: 640px; margin: 0 auto; padding: 2vh 28px 130px; text-align: center; background: var(--void); }
.prayer-block { opacity: 0; transform: translateY(10px); transition: opacity 1.1s ease 0.5s, transform 1.1s ease 0.5s; }
body.lit .prayer-block { opacity: 1; transform: none; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 13px; font-family: 'Cinzel', serif;
  font-size: 10px; font-weight: 500; letter-spacing: 0.4em; text-transform: uppercase; color: var(--gold);
  margin-bottom: 15px; padding-left: 0.4em;
}
.eyebrow::before, .eyebrow::after { content: ''; width: 24px; height: 1px; background: linear-gradient(to right, transparent, var(--gold-dim)); }
.eyebrow::after { background: linear-gradient(to left, transparent, var(--gold-dim)); }
.title {
  font-family: 'Cormorant Garamond', serif; font-size: clamp(36px, 8vw, 64px);
  font-weight: 600; line-height: 1.04; letter-spacing: 0.004em; color: var(--cream);
  text-shadow: 0 2px 50px rgba(0,0,0,0.9), 0 1px 6px rgba(0,0,0,0.7);
}
.reference {
  font-family: 'EB Garamond', serif; font-style: italic; font-size: clamp(15px, 3.6vw, 20px);
  letter-spacing: 0.02em; color: var(--gold); margin-top: 12px; text-shadow: 0 1px 14px rgba(0,0,0,0.8);
}
.eyebrow { margin-bottom: 14px; }
.divider { display: flex; align-items: center; justify-content: center; gap: 14px; color: var(--gold); opacity: 0.65; margin: 0 auto 28px; max-width: 200px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: linear-gradient(to right, transparent, var(--gold-dim), transparent); }
.divider span { font-size: 12px; letter-spacing: 0.3em; }
.prayer {
  font-family: 'Cormorant Garamond', serif; font-size: clamp(19px, 4.2vw, 28px);
  font-weight: 500; line-height: 1.56; letter-spacing: 0.004em; color: var(--cream-soft);
  max-width: 27em; margin: 0 auto; text-wrap: balance; text-shadow: 0 1px 22px rgba(0,0,0,0.7);
}
.prayer::first-letter { font-size: 1.06em; color: var(--gold); }
.prayer .w { transition: color 0.4s ease, text-shadow 0.4s ease, opacity 0.4s ease; opacity: 0.6; }
.prayer .w.spoken { color: var(--cream); opacity: 0.92; }
.prayer .w.active { color: #fff; opacity: 1; text-shadow: 0 0 24px rgba(231,190,99,0.95), 0 0 4px rgba(255,255,255,0.6); }
.amen { font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: 0.34em; text-transform: uppercase; color: var(--gold); opacity: 0.78; margin-top: 30px; }

/* floating controls on a soft bottom fade */
.controls { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); z-index: 9; display: flex; gap: 10px; transition: opacity 0.4s ease, transform 0.2s; }
.play, .share {
  display: inline-flex; align-items: center; gap: 11px; padding: 13px 24px 13px 20px;
  border: 1px solid var(--gold-dim); border-radius: 999px; background: rgba(10,8,18,0.74);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); color: var(--cream);
  font-family: 'Cinzel', serif; font-size: 12px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase;
  cursor: pointer; box-shadow: 0 10px 34px rgba(0,0,0,0.55); transition: border-color 0.25s, background 0.25s, transform 0.2s;
}
.play:hover, .share:hover { border-color: var(--gold); background: rgba(231,190,99,0.16); transform: translateY(-2px); }
.share { padding: 13px 18px; }
.play svg, .share svg { width: 16px; height: 16px; }
.play .icon-pause, .play .label-pause { display: none; }
.play.playing .icon-play, .play.playing .label-play { display: none; }
.play.playing .icon-pause, .play.playing .label-pause { display: inline; }
body[data-page="prayer"]::after {
  content: ''; position: fixed; left: 0; right: 0; bottom: 0; height: 150px; z-index: 7; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(4,3,10,0.82) 72%, var(--void)); transition: opacity 0.4s ease;
}
body.at-end .controls { opacity: 0; pointer-events: none; }
body.at-end[data-page="prayer"]::after { opacity: 0; }

/* closing — calm app invite + a single quiet link onward */
.after { position: relative; z-index: 1; background: linear-gradient(180deg, transparent, var(--void) 22%); }
.invite { text-align: center; padding: 60px 22px 30px; }
.invite-flourish { color: var(--gold); font-size: 20px; margin-bottom: 14px; opacity: 0.8; }
.invite h2 { font-family: 'Cormorant Garamond', serif; font-size: clamp(25px, 5.6vw, 34px); font-weight: 600; line-height: 1.2; margin-bottom: 10px; }
.invite-sub { font-family: 'EB Garamond', serif; font-style: italic; font-size: 16.5px; color: var(--cream-soft); max-width: 26em; margin: 0 auto 30px; }
.app-ctas { display: flex; flex-direction: column; align-items: stretch; gap: 13px; max-width: 360px; margin: 0 auto; }
.app-cta {
  display: flex; align-items: center; gap: 15px; padding: 13px 17px; border-radius: 17px; text-decoration: none; color: var(--cream);
  background: rgba(255,255,255,0.05); border: 1px solid rgba(231,190,99,0.2); transition: border-color 0.25s, background 0.25s, transform 0.2s;
}
.app-cta:hover { border-color: var(--gold); background: rgba(231,190,99,0.1); transform: translateY(-2px); }
.app-cta img { width: 52px; height: 52px; flex-shrink: 0; border-radius: 13px; box-shadow: 0 0 0 1px rgba(231,190,99,0.25), 0 6px 16px rgba(0,0,0,0.4); }
.app-cta .tx { text-align: left; line-height: 1.3; }
.app-cta .tx b { font-family: 'Cinzel', serif; font-size: 13.5px; font-weight: 600; letter-spacing: 0.04em; display: block; }
.app-cta .tx span { font-family: 'EB Garamond', serif; font-style: italic; font-size: 14px; color: var(--cream-soft); }
.app-cta .arrow { margin-left: auto; color: var(--gold); opacity: 0.7; font-size: 18px; }
.more-link { display: inline-block; margin: 34px 0 0; font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); text-decoration: none; border-bottom: 1px solid var(--gold-dim); padding-bottom: 4px; transition: color 0.2s, border-color 0.2s; }
.more-link:hover { color: #fff; border-color: var(--gold); }
.home-link { display: block; margin-top: 22px; font-family: 'Cinzel', serif; font-size: 9.5px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--cream-soft); text-decoration: none; opacity: 0.6; transition: color 0.2s, opacity 0.2s; }
.home-link:hover { color: var(--gold); opacity: 1; }
.colophon { font-family: 'Cinzel', serif; font-size: 9px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--cream-soft); opacity: 0.4; padding: 40px 0 90px; text-align: center; }

.loading {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: var(--void); font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold);
  transition: opacity 0.8s ease; animation: loadout 0.6s ease 4s forwards;
}
.loading.gone { opacity: 0; pointer-events: none; }
@keyframes loadout { to { opacity: 0; visibility: hidden; } }

/* ════════════ LIBRARY index ════════════ */
.ambient { position: fixed; inset: -6%; z-index: -4; width: 112%; height: 112%; object-fit: cover; filter: blur(80px) saturate(1.15) brightness(0.3); opacity: 0; transition: opacity 2s ease; }
.ambient.in { opacity: 1; }
.ambient-tint { position: fixed; inset: 0; z-index: -3; pointer-events: none; background: linear-gradient(180deg, rgba(8,7,13,0.4) 0%, rgba(8,7,13,0.15) 40%, rgba(8,7,13,0.7) 100%); }
.lib { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 0 20px 40px; }
.lib-hero { text-align: center; padding: 116px 12px 26px; }
.lib-hero .eyebrow { margin-bottom: 16px; }
.lib-hero h1 { font-family: 'Cormorant Garamond', serif; font-size: clamp(34px, 7vw, 56px); font-weight: 600; line-height: 1.08; margin-bottom: 12px; text-shadow: 0 2px 30px rgba(0,0,0,0.5); }
.lib-hero p { font-family: 'EB Garamond', serif; font-style: italic; font-size: clamp(16px, 3.6vw, 20px); color: var(--cream-soft); max-width: 32em; margin: 0 auto; }
.filters { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; margin: 26px auto 32px; max-width: 880px; }
.filter {
  font-family: 'Cinzel', serif; font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--cream-soft);
  cursor: pointer; padding: 8px 15px; border-radius: 999px; border: 1px solid rgba(231,190,99,0.25); background: rgba(255,255,255,0.04);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.filter:hover { color: var(--cream); border-color: var(--gold-dim); }
.filter.active { color: var(--ink); background: var(--gold); border-color: var(--gold); font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.card { display: flex; flex-direction: column; text-decoration: none; color: var(--cream); background: rgba(255,255,255,0.04); border: 1px solid rgba(231,190,99,0.16); border-radius: 16px; overflow: hidden; transition: border-color 0.25s, transform 0.2s, box-shadow 0.25s; }
.card:hover { border-color: var(--gold-dim); transform: translateY(-4px); box-shadow: 0 16px 36px rgba(0,0,0,0.5); }
.card-art { position: relative; aspect-ratio: 9 / 12; overflow: hidden; background: var(--ink-2); }
.card-art img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.5s ease; }
.card:hover .card-art img { transform: scale(1.05); }
.card-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(8,7,13,0.85)); }
.card-need { position: absolute; top: 10px; left: 10px; z-index: 1; font-family: 'Cinzel', serif; font-size: 8.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); background: rgba(8,7,13,0.6); border: 1px solid var(--gold-dim); padding: 4px 9px; border-radius: 999px; }
.card-body { padding: 14px 15px 17px; }
.card-title { font-family: 'Cormorant Garamond', serif; font-size: 20px; font-weight: 600; line-height: 1.18; margin-bottom: 4px; }
.card-ref { font-family: 'EB Garamond', serif; font-style: italic; font-size: 14px; color: var(--gold); opacity: 0.9; }
.card.hide { display: none; }
.card.beyond { display: none; }
.lib-empty { text-align: center; color: var(--cream-soft); font-style: italic; padding: 40px; grid-column: 1 / -1; }
.load-more-wrap { text-align: center; padding: 38px 0 10px; }
.load-more {
  font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--cream);
  cursor: pointer; padding: 13px 30px; border-radius: 999px; border: 1px solid var(--gold-dim); background: rgba(255,255,255,0.05);
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.load-more:hover { border-color: var(--gold); background: rgba(231,190,99,0.12); transform: translateY(-2px); }
.load-count { display: block; margin-top: 14px; font-family: 'EB Garamond', serif; font-style: italic; font-size: 14px; color: var(--cream-soft); opacity: 0.7; }

@media (prefers-reduced-motion: reduce) { .prayer-block, .ambient { transition: opacity 0.4s; } }
