/* Library page */

body.library { background: var(--bg); }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--burgundy-deep);
  border-bottom: 1px solid rgba(201, 162, 74, 0.35);
  color: #efe3cc;
}

.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.brand-mark { width: 18px; height: 26px; filter: invert(72%) sepia(41%) saturate(560%) hue-rotate(5deg) brightness(92%); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-church { font-family: var(--font-sans); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-name { font-family: var(--font-display); font-size: 22px; font-weight: 500; }

.topbar-actions { display: flex; gap: 6px; flex: none; }
.link-btn { text-decoration: none; }
.link-btn {
  background: none;
  border: 1px solid rgba(201, 162, 74, 0.4);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--gold-soft);
  cursor: pointer;
  white-space: nowrap;
}

/* Hero */
.hero {
  background:
    radial-gradient(ellipse at 50% 100%, rgba(110, 20, 35, 0.9), transparent 70%),
    var(--burgundy-deep);
  padding: 28px var(--gutter) 0;
  overflow: hidden;
}

.hero-arch {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
  min-height: 360px;
  border-radius: 400px 400px 0 0;
  border: 1px solid rgba(201, 162, 74, 0.5);
  border-bottom: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 85%, rgba(255, 196, 110, 0.45), transparent 45%),
    radial-gradient(ellipse at 50% 30%, rgba(201, 162, 74, 0.18), transparent 60%),
    linear-gradient(180deg, #2a0810 0%, #4a0f1a 55%, #6e1423 100%);
  box-shadow: inset 0 0 0 8px rgba(201, 162, 74, 0.07);
}

/* Church photo fills the whole hero; the arch becomes a gilded window onto it */
.hero.has-photo {
  background:
    linear-gradient(180deg, rgba(30, 6, 10, 0.55) 0%, rgba(30, 6, 10, 0.25) 45%, rgba(62, 10, 19, 0.85) 100%),
    url("../img/hero.jpg") center 35% / cover no-repeat,
    var(--burgundy-deep);
}
.hero.has-photo .hero-arch {
  background:
    radial-gradient(ellipse at 50% 55%, rgba(30, 6, 10, 0.55), rgba(30, 6, 10, 0.2) 70%),
    linear-gradient(180deg, rgba(42, 8, 16, 0.25), rgba(62, 10, 19, 0.6));
  border-color: rgba(227, 204, 143, 0.75);
  -webkit-backdrop-filter: blur(1.5px);
  backdrop-filter: blur(1.5px);
}
.hero.has-photo .hero-glow { opacity: 0.6; }

.hero-glow {
  position: absolute;
  inset: auto 0 0 0;
  height: 60%;
  background:
    radial-gradient(circle at 30% 100%, rgba(255, 190, 90, 0.35), transparent 30%),
    radial-gradient(circle at 70% 100%, rgba(255, 190, 90, 0.3), transparent 28%),
    radial-gradient(circle at 50% 100%, rgba(255, 210, 120, 0.4), transparent 35%);
  animation: flicker 6s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes flicker {
  0% { opacity: 0.85; }
  40% { opacity: 1; }
  70% { opacity: 0.9; }
  100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) { .hero-glow { animation: none; } }

.hero-content { position: relative; padding: 48px 24px 56px; color: #fbf6ea; }

.eyebrow {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-soft);
}

.hero h1 {
  margin: 6px 0 10px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(48px, 13vw, 84px);
  line-height: 0.95;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.4);
}

.hero-sub { margin: 0 auto; max-width: 26ch; font-size: 19px; color: #e8d6bb; font-style: italic; }

.ornament { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 22px; }
.ornament span { height: 1px; width: 60px; background: linear-gradient(90deg, transparent, var(--gold)); }
.ornament span:last-child { background: linear-gradient(270deg, transparent, var(--gold)); }
.ornament img { width: 14px; height: 20px; filter: invert(72%) sepia(41%) saturate(560%) hue-rotate(5deg) brightness(92%); }

/* Shelves */
.shelves { max-width: 980px; margin: 0 auto; padding: 40px var(--gutter) 24px; }

.shelf-head { text-align: center; margin-bottom: 28px; }
.shelf-head h2 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 34px; color: var(--accent); }
.shelf-head p { margin: 4px 0 0; color: var(--ink-soft); font-style: italic; }

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  column-gap: 0;
  row-gap: 44px;
}

.shelf-loading, .shelf-empty { grid-column: 1 / -1; text-align: center; color: var(--ink-soft); font-style: italic; }

.slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 12px;
}

/* Timber plank under each book. Slots sit edge to edge so planks join up. */
.plank {
  align-self: stretch;
  margin: 0 -12px;
  height: 16px;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.05) 0 2px, transparent 2px 22px),
    linear-gradient(180deg, #8a5a32 0%, #6b4223 45%, #4a2c16 100%);
  box-shadow: 0 10px 18px -6px rgba(40, 18, 6, 0.55);
}

.book {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  max-width: 150px;
  aspect-ratio: 2 / 3;
  border-radius: 2px 5px 5px 2px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow:
    inset 4px 0 6px -2px rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(255, 255, 255, 0.1),
    6px 8px 14px -4px rgba(30, 10, 5, 0.55);
  transform-origin: bottom center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.book:hover, .book:focus-visible {
  transform: translateY(-6px) rotate(-1deg);
  box-shadow:
    inset 4px 0 6px -2px rgba(0, 0, 0, 0.45),
    10px 16px 24px -6px rgba(30, 10, 5, 0.6);
}

.book img { width: 100%; height: 100%; object-fit: cover; }

/* Generated cover, used until real cover art is supplied */
.cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, 0.12), transparent 60%),
    var(--cover-bg, var(--burgundy));
  color: var(--cover-ink, #f6e7c4);
}
.cover::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid var(--cover-trim, var(--gold));
  outline: 1px solid var(--cover-trim, var(--gold));
  outline-offset: -5px;
  opacity: 0.8;
  pointer-events: none;
}
.cover-cross { width: 16px; height: 22px; background: var(--cover-trim, var(--gold)); -webkit-mask: url("../img/cross.svg") center / contain no-repeat; mask: url("../img/cross.svg") center / contain no-repeat; margin-top: 8px; }
.cover-title { font-family: var(--font-display); font-weight: 600; font-size: 19px; line-height: 1.1; padding: 0 4px; }
.cover-author { font-family: var(--font-sans); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.85; margin-bottom: 6px; }

.slot-label { margin-top: 14px; text-align: center; max-width: 150px; }
.slot-title { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 600; line-height: 1.15; }
.slot-meta { display: block; font-family: var(--font-sans); font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.slot-progress { display: block; font-family: var(--font-sans); font-size: 12px; color: var(--accent); margin-top: 4px; }

/* Install prompt */
.app-fab {
  position: fixed;
  z-index: 40;
  inset-inline-end: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 16px 0 12px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: var(--burgundy);
  color: #fbf6ea;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(40, 8, 12, 0.35);
  cursor: pointer;
}
.app-fab[hidden], .app-sheet[hidden], .app-sheet [hidden] { display: none; }
.app-fab svg { width: 22px; height: 22px; }

.app-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 6, 8, 0);
  transition: background 0.25s ease;
}
.app-sheet.open { background: rgba(20, 6, 8, 0.5); }
.app-card {
  position: relative;
  width: min(560px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 20px 18px calc(14px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0;
  background: var(--bg-raised);
  color: var(--ink);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.3);
  transform: translateY(100%);
  transition: transform 0.28s ease;
}
.app-sheet.open .app-card { transform: none; }
@media (min-width: 700px) {
  .app-sheet { align-items: center; }
  .app-card { border-radius: 22px; }
}
@media (prefers-reduced-motion: reduce) { .app-sheet, .app-card { transition: none; } }
.app-x { position: absolute; top: 8px; inset-inline-end: 8px; width: 44px; height: 44px; border: 0; background: none; font-size: 28px; line-height: 1; color: var(--ink-soft); cursor: pointer; }
.app-head { display: flex; gap: 12px; align-items: center; padding-inline-end: 36px; }
.app-icon { flex: none; width: 52px; height: 52px; border-radius: 12px; box-shadow: 0 4px 12px rgba(40, 10, 10, 0.25); }
.app-title { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 26px; line-height: 1.05; color: var(--accent); }
.app-lede { margin: 2px 0 0; font-size: 15px; line-height: 1.35; color: var(--ink-soft); }

.app-tabs { display: flex; gap: 4px; margin: 16px 0 14px; padding: 4px; border-radius: 999px; background: color-mix(in srgb, var(--ink-soft) 14%, transparent); }
.app-tabs button { flex: 1; min-height: 40px; border: 0; border-radius: 999px; background: none; font-family: var(--font-sans); font-size: 15px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.app-tabs button[aria-selected="true"] { background: var(--burgundy); color: #fbf6ea; box-shadow: 0 2px 8px rgba(40, 8, 12, 0.25); }

.app-now { width: 100%; margin-bottom: 14px; }
.phones { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.phone { margin: 0; text-align: center; }
.ph-screen {
  position: relative;
  height: 210px;
  margin: 0 auto;
  max-width: 132px;
  border: 6px solid #1c1c1e;
  border-radius: 22px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}
.ph-screen::before { content: ""; position: absolute; top: 5px; left: 50%; width: 34px; height: 6px; margin-left: -17px; border-radius: 6px; background: #1c1c1e; z-index: 2; }
.ph-screen.dim { background: #b9b4ab; }
.ph-page { padding: 22px 10px 0; }
.ph-page span { display: block; height: 7px; margin: 0 0 8px; border-radius: 4px; background: #e6dccb; }
.ph-page span.short { width: 60%; }
.ph-bar { display: flex; align-items: center; justify-content: space-around; height: 30px; background: #f2f2f4; color: #8a8a8f; font-style: normal; }
.ph-bar i { font-style: normal; font-size: 13px; }
.ios-bar { position: absolute; left: 0; right: 0; bottom: 0; border-top: 1px solid #ddd; }
.and-bar { margin-top: 16px; justify-content: space-between; padding: 0 6px; }
.and-bar .url { flex: 1; height: 14px; margin-inline-end: 6px; border-radius: 8px; background: #e1e1e6; }
.ph-bar b { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px; }
.ph-bar svg { width: 16px; height: 16px; }
.ph-sheet { position: absolute; left: 6px; right: 6px; bottom: 6px; padding: 4px; border-radius: 12px; background: #fff; }
.ph-menu { position: absolute; top: 44px; inset-inline-end: 6px; width: 86%; padding: 4px; border-radius: 10px; background: #fff; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25); }
.ph-sheet .row, .ph-menu .row { display: flex; align-items: center; gap: 5px; min-height: 26px; padding: 0 6px; border-radius: 6px; font-family: var(--font-sans); font-size: 10px; color: #333; text-align: start; }
.ph-sheet .row svg, .ph-menu .row svg { width: 13px; height: 13px; flex: none; }
.hit { background: #0a84ff !important; color: #fff !important; box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3); animation: hitpulse 1.6s ease-in-out infinite; }
@keyframes hitpulse { 50% { box-shadow: 0 0 0 6px rgba(10, 132, 255, 0.12); } }
@media (prefers-reduced-motion: reduce) { .hit { animation: none; } }
.phone figcaption { display: flex; gap: 6px; align-items: flex-start; justify-content: center; margin-top: 10px; font-family: var(--font-sans); font-size: 14px; font-weight: 600; line-height: 1.3; text-align: start; }
.phone .n { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12px; }
.app-hint { margin: 12px 0 0; font-family: var(--font-sans); font-size: 13px; line-height: 1.4; color: var(--ink-soft); }
.app-chrome { margin-bottom: 6px; }
.app-chrome .app-hint { margin: 0 0 6px; text-align: center; }
a.app-now { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.show-steps { display: block; margin: 0 auto 4px; min-height: 44px; padding: 0 12px; border: 0; background: none; font-family: var(--font-sans); font-size: 14px; color: var(--burgundy); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.install-later { display: block; margin: 6px auto 0; min-height: 44px; padding: 0 12px; border: 0; background: none; font-family: var(--font-sans); font-size: 14px; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Footer */
.foot { margin-top: 24px; background: var(--burgundy-deep); color: #e8d6bb; text-align: center; }

.foot-band {
  height: 140px;
  background:
    linear-gradient(180deg, var(--bg) 0%, transparent 100%),
    radial-gradient(circle at 20% 80%, rgba(255, 190, 90, 0.35), transparent 18%),
    radial-gradient(circle at 50% 85%, rgba(255, 200, 110, 0.4), transparent 20%),
    radial-gradient(circle at 80% 80%, rgba(255, 190, 90, 0.35), transparent 18%),
    linear-gradient(180deg, #4a0f1a, var(--burgundy-deep));
}
.foot-band.has-photo {
  height: 220px;
  background:
    linear-gradient(180deg, var(--bg) 0%, transparent 45%, rgba(62, 10, 19, 0.9) 100%),
    url("../img/footer.jpg") center / cover no-repeat;
}

.foot-inner { padding: 8px var(--gutter) max(32px, env(safe-area-inset-bottom)); }
.foot-cross { width: 20px; height: 28px; margin: 0 auto 12px; filter: invert(72%) sepia(41%) saturate(560%) hue-rotate(5deg) brightness(92%); }
.foot-quote { margin: 0 auto; max-width: 30ch; font-family: var(--font-display); font-size: 21px; line-height: 1.3; }
.foot-quote span { font-family: var(--font-sans); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-soft); }
.foot-small { margin: 18px 0 0; font-family: var(--font-sans); font-size: 12px; color: #9c8670; }

@media (min-width: 700px) {
  .hero-arch { min-height: 440px; }
  .shelf { grid-template-columns: repeat(auto-fit, minmax(190px, 230px)); justify-content: center; }
  .book, .slot-label { max-width: 170px; }
  .cover-title { font-size: 22px; }
}

.foot-signout {
  margin-top: 16px;
  padding: 8px 16px;
  border: 1px solid rgba(201, 162, 74, 0.35);
  border-radius: 999px;
  background: none;
  color: var(--gold-soft);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
}
.topbar-actions { align-items: center; }

