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

:root {
  --cream:    #faf7f2;
  --parchment:#f2ece0;
  --gold:     #b8922a;
  --gold-lt:  #d4a843;
  --brown:    #4a3728;
  --brown-lt: #6b5344;
  --text:     #2c2016;
  --text-muted: #7a6555;
  --border:   #d9ccbb;
  --white:    #ffffff;
  --shadow:   0 2px 12px rgba(74,55,40,.12);
  --radius:   10px;
}

html { scroll-behavior: smooth; }

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 100px; /* room for player bar */
}

/* ── Header ── */
header {
  background: linear-gradient(160deg, var(--brown) 0%, #2a1a0e 100%);
  color: var(--cream);
  text-align: center;
  padding: 3rem 1rem 2.5rem;
  position: relative;
  overflow: hidden;
}
header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--gold), var(--gold-lt), var(--gold));
}
.header-inner { max-width: 680px; margin: 0 auto; }
.cross { font-size: 2.4rem; color: var(--gold-lt); margin-bottom: .5rem; }
h1 { font-size: 2.6rem; font-weight: normal; letter-spacing: .04em; margin-bottom: .3rem; }
.subtitle { font-size: 1rem; color: #c9b99a; letter-spacing: .08em; text-transform: uppercase; margin-bottom: .5rem; }
.memorial-note { font-size: .9rem; color: #9e8972; font-style: italic; }

/* ── Tabs ── */
.tabs {
  display: flex;
  justify-content: center;
  gap: .5rem;
  padding: 1.2rem 1rem .4rem;
  background: var(--cream);
  border-bottom: 2px solid var(--border);
}
.tab {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: .5rem 1.6rem;
  font-family: inherit;
  font-size: .95rem;
  color: var(--brown-lt);
  cursor: pointer;
  transition: all .15s;
}
.tab:hover { border-color: var(--gold); color: var(--gold); }
.tab.active {
  background: var(--brown);
  border-color: var(--brown);
  color: var(--cream);
}

/* ── Toolbar ── */
.toolbar {
  max-width: 1500px;
  margin: 1rem auto .4rem;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
#search {
  flex: 1;
  padding: .55rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-family: inherit;
  font-size: .95rem;
  background: var(--white);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
#search:focus { border-color: var(--gold); }
#count-label { font-size: .85rem; color: var(--text-muted); white-space: nowrap; }

/* ── Main / panels ── */
main { max-width: 1500px; margin: 0 auto; padding: 0 1rem 2rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-desc { color: var(--text-muted); font-style: italic; font-size: .92rem; margin: .8rem 0 1.2rem; }

/* ── Sermon grid ── */
.sermon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

/* ── Sermon card ── */
.sermon-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1rem;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.sermon-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--gold);
}
.sermon-card .card-date {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gold);
  font-family: system-ui, sans-serif;
}
.sermon-card .card-title {
  font-size: 1rem;
  font-weight: bold;
  color: var(--brown);
  line-height: 1.35;
}
.sermon-card .card-excerpt {
  font-size: .87rem;
  color: var(--text-muted);
  line-height: 1.55;
  flex: 1;
}
.sermon-card .card-footer {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .4rem;
}
.card-badge {
  font-size: .7rem;
  font-family: system-ui, sans-serif;
  padding: .15rem .55rem;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.badge-original { background: #e8f0e8; color: #3a6b3a; }
.badge-generated { background: #f0e8f4; color: #6b3a8a; }
.badge-no-audio { background: #f0ece4; color: #8a7055; }
.card-play-btn {
  margin-left: auto;
  background: var(--brown);
  color: var(--cream);
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: .85rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.card-play-btn:hover { background: var(--gold); }
.card-play-btn.no-audio { background: var(--border); cursor: default; color: var(--text-muted); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-style: italic;
}
.empty-state code {
  font-style: normal;
  background: var(--parchment);
  padding: .1rem .4rem;
  border-radius: 4px;
  font-size: .85rem;
}

/* ── Player bar (fixed bottom) ── */
.player-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--brown);
  color: var(--cream);
  padding: .6rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 100;
  box-shadow: 0 -2px 16px rgba(0,0,0,.3);
  transition: transform .2s;
}
.player-bar.hidden { transform: translateY(110%); }
.player-info { flex: 1; min-width: 0; }
#player-title { display: block; font-weight: bold; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#player-date { font-size: .78rem; color: #c9b99a; font-family: system-ui, sans-serif; }
#audio-el { flex: 2; min-width: 0; max-width: 480px; height: 34px; }
#player-close {
  background: none;
  border: none;
  color: #c9b99a;
  font-size: 1.1rem;
  cursor: pointer;
  padding: .2rem .4rem;
}
#player-close:hover { color: var(--cream); }

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-content {
  position: relative;
  background: var(--white);
  border-radius: var(--radius);
  max-width: 680px; width: calc(100% - 2rem);
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.35);
}
.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none;
  font-size: 1.3rem; cursor: pointer;
  color: var(--text-muted);
}
.modal-close:hover { color: var(--text); }
.modal-header { margin-bottom: 1.2rem; }
.modal-content h2 { font-size: 1.4rem; color: var(--brown); margin-bottom: .3rem; }
.modal-date { font-size: .82rem; color: var(--gold); text-transform: uppercase; letter-spacing: .07em; font-family: system-ui, sans-serif; }
.modal-gospel { font-size: .9rem; color: var(--text-muted); font-style: italic; margin-top: .3rem; }
.modal-body {
  font-size: .97rem; line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
  margin-bottom: 1.4rem;
}
.modal-body.no-transcript {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 2rem 0;
}
.modal-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ── Buttons ── */
.btn {
  padding: .55rem 1.2rem;
  border-radius: 50px;
  border: none;
  font-family: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: background .12s, opacity .12s;
}
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: var(--brown); color: var(--cream); }
.btn-primary:not(:disabled):hover { background: var(--brown-lt); }
.btn-secondary { background: var(--parchment); color: var(--brown); border: 1.5px solid var(--border); }
.btn-secondary:not(:disabled):hover { border-color: var(--gold); }

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1.4rem 1rem;
  font-size: .82rem;
  color: var(--text-muted);
  font-style: italic;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ── Visitor counter (old-school) ── */
.visitor-counter {
  margin-top: 1.2rem;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-style: normal;
}
.vc-label {
  font-family: 'Courier New', Courier, monospace;
  font-size: .78rem;
  color: var(--text-muted);
  letter-spacing: .04em;
}
.vc-digits {
  display: inline-block;
  background: #000;
  color: #00ff66;
  font-family: 'Courier New', Courier, monospace;
  font-weight: bold;
  font-size: 1rem;
  padding: .25rem .55rem;
  letter-spacing: .15em;
  border: 2px inset #444;
  border-radius: 3px;
  text-shadow: 0 0 4px rgba(0, 255, 102, .6);
  box-shadow: inset 0 0 8px rgba(0, 255, 102, .15);
}

/* ── Responsive ── */
@media (max-width: 540px) {
  h1 { font-size: 2rem; }
  .sermon-grid { grid-template-columns: 1fr; }
  .modal-content { padding: 1.4rem; }
  #audio-el { max-width: 200px; }
}
