/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold:        #c9a84c;
  --gold-light:  #e8d5a3;
  --cream:       #f5f0e8;
  --deep:        #0e0820;
  --overlay:     rgba(8, 4, 18, 0.35);
  --card-bg:     rgba(12, 6, 28, 0.82);
  --text:        #f0ead8;
  --text-muted:  #b8a98a;
  --accent:      #7b5ea7;
  --radius:      16px;
  --transition:  0.35s ease;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Lato', sans-serif;
  background: var(--deep);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Slideshow ── */
#slideshow {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  opacity: 0;
  transition: opacity 2s ease-in-out;
}

.slide.active { opacity: 1; }

#slideshow-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: var(--overlay);
}

/* ── App Shell ── */
#app {
  position: relative;
  z-index: 2;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Screens ── */
.screen {
  display: none;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.screen.active { display: flex; }

/* ── Top Bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  gap: 12px;
  background: rgba(8, 4, 18, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(201, 168, 76, 0.2);
  flex-shrink: 0;
}

.top-bar-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--gold-light);
  flex: 1;
  text-align: center;
}

#saint-display {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}

#saint-date {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#saint-name {
  font-family: 'Playfair Display', serif;
  font-size: 0.85rem;
  color: var(--gold-light);
  cursor: pointer;
  line-height: 1.2;
}

#saint-name:hover { text-decoration: underline; }

/* Language toggle */
#lang-toggle, .lang-btn-small {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-family: 'Lato', sans-serif;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

#lang-toggle:hover, .lang-btn-small:hover {
  background: var(--gold);
  color: var(--deep);
}

/* ── Home Screen ── */
.home-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 28px;
  gap: 40px;
  text-align: center;
}

.title-block { display: flex; flex-direction: column; gap: 10px; }

.site-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.site-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 600;
  color: #fff;
  line-height: 1.1;
  text-shadow: 0 2px 24px rgba(0,0,0,0.9), 0 0 40px rgba(0,0,0,0.7);
}

.mysteries-label {
  font-size: 0.85rem;
  color: var(--gold-light);
  font-style: italic;
  margin-top: 4px;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 320px;
}

.btn-primary {
  background: var(--gold);
  color: var(--deep);
  border: none;
  border-radius: var(--radius);
  padding: 18px 28px;
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 24px rgba(201, 168, 76, 0.35);
}

.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: var(--cream);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  padding: 16px 28px;
  font-family: 'Lato', sans-serif;
  font-size: 0.95rem;
  font-weight: 300;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background var(--transition);
}

.btn-secondary:hover { background: rgba(255,255,255,0.14); }

/* Saint bio bar */
#saint-bio-bar {
  background: rgba(8, 4, 18, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(201,168,76,0.15);
  padding: 14px 24px;
  flex-shrink: 0;
}

#saint-bio {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  font-style: italic;
  text-align: center;
}

/* ── Rosary Screen ── */
.btn-back {
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
}

/* Progress bar sits just below top bar */
#rosary-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  flex-shrink: 0;
}

#progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
}

#progress-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Spacer lets background show through */
.rosary-spacer { flex: 1; }

/* ── Rosary Card (bottom sheet) ── */
.rosary-card {
  background: rgba(10, 5, 22, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(201, 168, 76, 0.22);
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  max-height: 108px;
  transition: max-height 0.42s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.rosary-card.expanded {
  max-height: 68vh;
  overflow-y: auto;
}

/* Drag pip / toggle */
.card-toggle {
  width: 100%;
  background: transparent;
  border: none;
  padding: 12px 0 6px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card-pip {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: rgba(201, 168, 76, 0.35);
  transition: background 0.2s, width 0.2s;
}

.card-toggle:hover .card-pip { background: rgba(201, 168, 76, 0.6); }

/* Compact single-line label (collapsed only) */
.step-compact {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rosary-card.expanded .step-compact { display: none; }
.rosary-card:not(.expanded) .step-type,
.rosary-card:not(.expanded) .prayer-title,
.rosary-card:not(.expanded) .step-counter { display: none; }

/* Summary (always visible) */
.card-summary {
  padding: 2px 22px 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Detail (visible when expanded) */
.card-detail {
  padding: 0 22px 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-type {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--gold);
}

.prayer-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}

.step-instruction {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
}

.prayer-text {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  line-height: 1.9;
  color: var(--cream);
}

.prayer-text--large { font-size: 1.1rem; }

.step-counter {
  font-size: 0.75rem;
  color: var(--gold);
  letter-spacing: 0.06em;
}

/* ── Word highlighting ── */
.word {
  display: inline;
  border-radius: 3px;
  padding: 0 1px;
  transition: background 0.08s, color 0.08s;
}

.word.active {
  background: rgba(201, 168, 76, 0.38);
  color: #fff;
}

/* ── Rosary Controls ── */
.rosary-controls {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 24px 14px;
  background: rgba(8,4,18,0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(201,168,76,0.15);
  flex-shrink: 0;
  gap: 12px;
}

.ctrl-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--cream);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform 0.1s;
}

.ctrl-btn:active { transform: scale(0.93); }

.ctrl-btn--audio {
  width: 54px;
  height: 54px;
  font-size: 1.2rem;
  background: var(--gold);
  color: var(--deep);
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(201,168,76,0.4);
}

.ctrl-btn--audio.playing {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(123,94,167,0.5);
}

/* ── Library Screen ── */
.library-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

#library-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.library-category {
  background: var(--card-bg);
  border: 1px solid rgba(201,168,76,0.18);
  border-radius: var(--radius);
  overflow: hidden;
}

.library-category-header {
  padding: 16px 20px;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--gold-light);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(201,168,76,0.1);
}

.library-category-icon { font-size: 1.2rem; }

.library-prayer-item {
  padding: 14px 20px;
  font-size: 0.92rem;
  color: var(--cream);
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s;
}

.library-prayer-item:last-child { border-bottom: none; }
.library-prayer-item:hover { background: rgba(255,255,255,0.05); }
.library-prayer-item::after { content: '›'; color: var(--text-muted); font-size: 1.2rem; }

/* ── Prayer Detail ── */
.prayer-detail-main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px;
}

/* ── Saint Detail ── */
#saint-detail-bio { padding-top: 8px; }

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.3); border-radius: 2px; }

/* ── Meditation block inside rosary card ── */
.mystery-block {
  border-left: 2px solid var(--gold);
  padding-left: 16px;
  margin-top: 8px;
}

.mystery-block .virtue-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin-bottom: 6px;
}

.mystery-block .meditation-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen.active { animation: fadeIn 0.3s ease; }

/* ── Large screens ── */
@media (min-width: 600px) {
  #app { max-width: 480px; margin: 0 auto; }
  #slideshow-overlay { background: rgba(8,4,18,0.38); }
}
