/* ==========================================================================
   The Grace MBC — installable web app
   ========================================================================== */

:root {
  --wine-950: #1f000c;
  --wine-900: #2e0513;
  --wine-800: #45001b;
  --wine-600: #6a2b3e;
  --wine-400: #91374f;
  --wine-100: #f3e6ea;
  --gold: #d4a857;
  --gold-soft: #e9cf98;
  --cream: #f7f3ee;
  --card: #ffffff;
  --line: #ebe3dc;
  --ink: #1e1417;
  --ink-soft: #6b5c60;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bar-h: 56px;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 0, 12, 0.06), 0 8px 24px -12px rgba(31, 0, 12, 0.22);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; min-height: 100%;
  font-family: var(--font-body); font-size: 16px; line-height: 1.55; color: var(--ink);
  background: var(--wine-950);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
img, svg, iframe { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Home ---------- */
.home { position: relative; min-height: 100svh; color: #fff; isolation: isolate; overflow-x: hidden; }
.slides { position: fixed; inset: 0; z-index: -2; background: var(--wine-950); }
.slides img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transform: scale(1.08); transition: opacity 1.6s ease, transform 9s linear;
}
.slides img.is-active { opacity: 1; transform: scale(1); }
.home::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(31, 0, 12, 0.72) 0%, rgba(31, 0, 12, 0.55) 35%, rgba(31, 0, 12, 0.82) 100%);
}

.home-top {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.1); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  text-decoration: none;
}
.icon-btn svg { width: 22px; height: 22px; }

.home-brand { text-align: center; padding: 4px 16px 18px; }
.home-brand img { width: 92px; margin: 0 auto 14px; filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.35)); }
.next-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 0.8rem; font-weight: 700; text-decoration: none; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.next-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex: none; }
.next-pill.is-live i { background: #ff4d4d; box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.6); animation: live 1.6s infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 8px rgba(255, 77, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); } }

.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 4px;
  max-width: 460px; margin: 0 auto; padding: 4px 12px calc(var(--safe-bottom) + 110px);
}
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 10px;
  min-height: 104px; padding: 16px 4px 12px; border-radius: 18px; text-decoration: none; color: #fff;
  transition: background 0.2s, transform 0.2s var(--ease);
}
.tile:active { transform: scale(0.94); background: rgba(255, 255, 255, 0.1); }
@media (hover: hover) { .tile:hover { background: rgba(255, 255, 255, 0.08); } }
.tile svg { width: 38px; height: 38px; stroke-width: 1.5; }
.tile span {
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; text-align: center; line-height: 1.2;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

/* Set Your House in Order (Homegoing360) */
.grid { padding-bottom: 20px; }
.house-card {
  max-width: 436px; margin: 8px auto calc(var(--safe-bottom) + 110px); padding: 22px 20px 20px;
  border-radius: 20px; text-align: center;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
@media (max-width: 460px) { .house-card { margin-left: 12px; margin-right: 12px; } }
.house-card__icon { width: 52px; height: 52px; margin: 0 auto 10px; border-radius: 16px; display: grid; place-items: center; background: rgba(212, 168, 87, 0.18); color: var(--gold); }
.house-card__icon svg { width: 28px; height: 28px; }
.house-card h2 { font-family: var(--font-display); font-weight: 500; font-size: 1.45rem; margin: 0 0 8px; }
.house-card p { margin: 0 0 16px; font-size: 0.92rem; line-height: 1.5; color: rgba(255, 255, 255, 0.85); }

.sermon-row[aria-current="true"] { background: #fbf4e6; }
.btn.is-ready { animation: ready-pulse 2s infinite; }
@keyframes ready-pulse { 0% { box-shadow: 0 0 0 0 rgba(212, 168, 87, 0.6); } 70% { box-shadow: 0 0 0 14px rgba(212, 168, 87, 0); } 100% { box-shadow: 0 0 0 0 rgba(212, 168, 87, 0); } }
.give-note { display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; padding: 14px 16px; border-radius: var(--radius); background: #fbf4e6; border: 1px solid #f0dfb8; }
.give-note svg { width: 22px; height: 22px; flex: none; color: var(--wine-400); margin-top: 1px; }
.give-note p { margin: 0; font-size: 0.92rem; color: var(--ink-soft); }
.give-note strong { color: var(--wine-800); }

/* Install banner */
.install {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--safe-bottom) + 12px); z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px;
  background: var(--cream); color: var(--ink); border-radius: 18px; box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.5);
  max-width: 480px; margin: 0 auto; animation: slideup 0.5s var(--ease);
}
.install img { width: 44px; height: 44px; border-radius: 11px; flex: none; }
.install div { flex: 1; min-width: 0; font-size: 0.85rem; line-height: 1.35; }
.install strong { display: block; font-size: 0.95rem; }
.install .x { background: none; border: 0; padding: 8px; color: var(--ink-soft); }
.install .x svg { width: 18px; height: 18px; }
@keyframes slideup { from { transform: translateY(30px); opacity: 0; } }

/* ---------- Inner pages ---------- */
.page { min-height: 100svh; background: var(--cream); animation: pagein 0.35s var(--ease); }
@keyframes pagein { from { opacity: 0; transform: translateX(18px); } }
.bar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 48px 1fr 48px; align-items: center;
  height: calc(var(--bar-h) + var(--safe-top)); padding: var(--safe-top) 4px 0;
  background: var(--wine-950); color: #fff;
}
.bar h1 {
  margin: 0; text-align: center; font-family: var(--font-body); font-size: 0.82rem; font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar .icon-btn { background: transparent; }
.content { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(var(--safe-bottom) + 40px); }

.hero {
  position: relative; margin: -16px -16px 16px; height: 190px; overflow: hidden; background: var(--wine-900); color: #fff;
  display: flex; align-items: flex-end; padding: 20px;
}
.hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 20%, rgba(31, 0, 12, 0.85)); }
.hero > div { position: relative; z-index: 1; }
.hero h2 { font-family: var(--font-display); font-weight: 500; font-size: 1.7rem; line-height: 1.1; margin: 0 0 4px; }
.hero p { margin: 0; opacity: 0.85; font-size: 0.92rem; }

.section-title {
  font-size: 0.75rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--wine-400);
  margin: 24px 4px 10px;
}
.section-title:first-child { margin-top: 4px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card + .card { margin-top: 12px; }
.card-pad { padding: 16px; }
.card h3 { margin: 0 0 4px; font-size: 1.05rem; line-height: 1.3; }
.card p { margin: 0; color: var(--ink-soft); font-size: 0.93rem; }
.muted { color: var(--ink-soft); font-size: 0.88rem; }

.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left;
}
.list li:last-child .row, .row:last-child { border-bottom: 0; }
.row .ic {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--wine-100); color: var(--wine-800);
}
.row .ic svg { width: 20px; height: 20px; }
.row .tx { flex: 1; min-width: 0; }
.row .tx strong { display: block; font-weight: 700; line-height: 1.3; }
.row .tx small { display: block; color: var(--ink-soft); font-size: 0.85rem; line-height: 1.35; }
.row .chev { width: 18px; height: 18px; color: #b9aaae; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: 999px; border: 2px solid transparent;
  background: var(--wine-800); color: #fff; font-weight: 700; font-size: 0.95rem; text-decoration: none;
  transition: transform 0.2s var(--ease), opacity 0.2s; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; }
.btn-block { display: flex; width: 100%; }
.btn-gold { background: var(--gold); color: var(--wine-950); }
.btn-outline { background: transparent; color: var(--wine-800); border-color: var(--wine-800); }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.btn-row .btn { flex: 1 1 auto; }

.banner-link {
  display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--radius);
  background: var(--wine-800); color: #fff; text-decoration: none; font-weight: 800; font-size: 0.85rem;
  letter-spacing: 0.08em; text-transform: uppercase; box-shadow: var(--shadow);
}
.banner-link svg { width: 22px; height: 22px; flex: none; }
.banner-link span { flex: 1; }

/* Media cards (news, sermons) */
.media { display: block; text-decoration: none; color: inherit; }
.media-img { position: relative; aspect-ratio: 16 / 9; background: var(--wine-900); overflow: hidden; }
.media-img img { width: 100%; height: 100%; object-fit: cover; }
.play {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.9); color: var(--wine-900); display: grid; place-items: center;
}
.play svg { width: 22px; height: 22px; margin-left: 3px; }
.date-tag { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--wine-400); margin-bottom: 4px; }

.sermon-row { display: grid; grid-template-columns: 124px 1fr; gap: 12px; padding: 10px; align-items: center; text-decoration: none; color: inherit; }
.sermon-row .media-img { border-radius: 10px; }
.sermon-row .play { width: 36px; height: 36px; margin: -18px 0 0 -18px; }
.sermon-row .play svg { width: 14px; height: 14px; margin-left: 2px; }
.sermon-row h3 { font-size: 0.95rem; margin: 0 0 4px; }

.player { position: relative; aspect-ratio: 16 / 9; background: #000; margin: -16px -16px 16px; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Info grid */
.kv { display: grid; gap: 8px; margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--cream); font-size: 0.92rem; }
.kv div { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.kv code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; color: var(--wine-800); letter-spacing: 0.03em; }
.copy { border: 1px solid var(--line); background: #fff; color: var(--wine-800); border-radius: 999px; padding: 4px 12px; font-size: 0.75rem; font-weight: 800; }

.time-big { font-family: var(--font-display); font-size: 2rem; line-height: 1; color: var(--wine-800); margin: 2px 0 6px; }

/* Forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: 0.88rem; }
.field label small { font-weight: 500; color: var(--ink-soft); }
.field input, .field textarea, .field select {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 1rem;
}
.field textarea { min-height: 140px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--wine-600); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; margin-bottom: 16px; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--wine-800); flex: none; }

/* Bible */
.tabs { display: flex; gap: 6px; padding: 4px; background: #ece5de; border-radius: 12px; margin-bottom: 14px; }
.tabs button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 700; font-size: 0.9rem; color: var(--ink-soft); }
.tabs button[aria-selected="true"] { background: #fff; color: var(--wine-800); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.book-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.book-grid a {
  padding: 12px 14px; border-radius: 12px; background: #fff; text-decoration: none; font-weight: 600; font-size: 0.93rem;
  box-shadow: 0 1px 2px rgba(31, 0, 12, 0.06);
}
.ch-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.ch-grid a {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 12px; background: #fff; text-decoration: none;
  font-weight: 700; box-shadow: 0 1px 2px rgba(31, 0, 12, 0.06);
}
.ch-grid a.is-read { background: var(--wine-100); color: var(--wine-800); }
.reader { font-family: var(--font-display); font-size: var(--reader-size, 1.15rem); line-height: 1.75; color: var(--ink); }
.reader h2 { font-family: var(--font-display); font-weight: 500; font-size: 1.6rem; margin: 6px 0 14px; }
.reader p { margin: 0 0 4px; }
.reader sup { font-family: var(--font-body); font-size: 0.62em; font-weight: 800; color: var(--wine-400); margin-right: 4px; vertical-align: 0.4em; }
.reader .v { border-radius: 4px; cursor: pointer; transition: background 0.2s; }
.reader .v.is-picked { background: #f5e3b8; }
.reader-nav { display: flex; gap: 10px; margin-top: 28px; }
.reader-nav .btn { flex: 1; }
.font-ctl { display: flex; gap: 6px; }
.font-ctl button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 6px 12px; font-weight: 800; color: var(--wine-800); }

/* Reading plan */
.progress { height: 8px; border-radius: 8px; background: #ece5de; overflow: hidden; margin: 10px 0 4px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--wine-600), var(--gold)); border-radius: 8px; }
.plan-day { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.plan-day:last-child { border-bottom: 0; }
.plan-day input { width: 22px; height: 22px; accent-color: var(--wine-800); flex: none; }
.plan-day .tx { flex: 1; min-width: 0; }
.plan-day .tx strong { display: block; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--wine-400); }
.plan-day .tx a { font-weight: 700; text-decoration: none; }
.plan-day.is-today { background: #fbf4e6; }

/* Devotional */
.verse-card { background: var(--wine-800); color: #fff; border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.verse-card::after { content: "“"; position: absolute; right: 12px; top: -20px; font-family: var(--font-display); font-size: 9rem; color: rgba(212, 168, 87, 0.18); line-height: 1; }
.verse-card blockquote { margin: 0 0 12px; font-family: var(--font-display); font-size: 1.3rem; line-height: 1.45; position: relative; z-index: 1; }
.verse-card cite { font-style: normal; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-soft); }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty svg { width: 44px; height: 44px; margin: 0 auto 12px; color: #c9bcc0; }
.empty h3 { color: var(--ink); margin: 0 0 6px; }

.loading { display: grid; place-items: center; padding: 60px 0; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--wine-100); border-top-color: var(--wine-800); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: step; position: relative; padding: 10px 0 10px 38px; font-size: 0.95rem; min-height: 46px; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 9px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--wine-800); color: #fff; display: grid; place-items: center; font-size: 0.8rem; font-weight: 800;
}
.steps svg { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 24px); z-index: 100; transform: translate(-50%, 20px);
  background: var(--wine-950); color: #fff; padding: 11px 20px; border-radius: 999px; font-weight: 600; font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.35s var(--ease);
  max-width: calc(100% - 32px); text-align: center;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
