/* St. Mary Hyde Park worship-aid shelf + flipbook viewer */

:root {
  --ink: #231f20;
  --ink-soft: #5a5552;
  --ink-faint: #8a847c;
  --cream: #f4efe6;
  --cream-dark: #e8e1d4;
  --paper: #fffcf7;
  --rule: #d4cbbd;
  --bronze: #8a7348;
  --bronze-soft: #a89060;
  --shadow: rgba(35, 31, 32, 0.16);
  --serif: "Cormorant Garamond", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --viewer-bg: #2f2b27;
  --viewer-bar: rgba(22, 20, 18, 0.82);
  --focus: #8a7348;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--serif);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.5;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Shelf ---------- */

body.shelf {
  background:
    radial-gradient(1200px 500px at 50% -80px, rgba(255, 255, 255, 0.7), transparent 70%),
    var(--cream);
}

.shelf-wrap {
  width: min(1080px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 2.5rem 0 4rem;
}

.masthead {
  text-align: center;
  padding-bottom: 1.75rem;
}

.masthead .logo {
  width: 88px;
  height: 88px;
  display: block;
  margin: 0 auto 1rem;
}

.masthead .parish {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink);
}

.masthead .place {
  margin: 0.15rem 0 0;
  font-size: 0.95rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.masthead hr {
  border: 0;
  border-top: 1px solid var(--rule);
  width: min(16rem, 60%);
  margin: 1.5rem auto 1.25rem;
}

.masthead h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.masthead .lede {
  margin: 0.6rem auto 0;
  max-width: 34rem;
  font-size: 1.15rem;
  font-style: italic;
  font-weight: 400;
  color: var(--ink-soft);
}

.section {
  margin-top: 2.25rem;
}

.section h2 {
  margin: 0 0 1.15rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--bronze);
  text-align: center;
}

.grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem 1.75rem;
}

@media (min-width: 720px) {
  .grid {
    gap: 2.4rem 2.25rem;
  }
}

.card {
  width: 100%;
  max-width: 220px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.card .cover-wrap {
  width: 100%;
  aspect-ratio: 396 / 612;
  background: var(--paper);
  border-radius: 0 4px 4px 0;
  box-shadow:
    1px 0 0 rgba(35, 31, 32, 0.08),
    3px 0 0 rgba(255, 252, 247, 0.9),
    4px 0 0 rgba(35, 31, 32, 0.1),
    0 10px 24px var(--shadow);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
}

.card:hover .cover-wrap,
.card:focus-visible .cover-wrap {
  transform: translateY(-4px);
  box-shadow:
    1px 0 0 rgba(35, 31, 32, 0.08),
    3px 0 0 rgba(255, 252, 247, 0.9),
    4px 0 0 rgba(35, 31, 32, 0.1),
    0 16px 32px rgba(35, 31, 32, 0.2);
}

.card img.cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--paper);
}

.card .meta {
  margin-top: 0.85rem;
}

.card .title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.card .subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-soft);
}

.footer-note {
  margin: 3.5rem 0 0;
  text-align: center;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-faint);
}

.footer-note p {
  margin: 0;
}

.status {
  text-align: center;
  color: var(--ink-soft);
  font-style: italic;
  padding: 3rem 1rem;
}

.empty-shelf {
  text-align: center;
  color: var(--ink-soft);
  font-style: italic;
}

/* ---------- Viewer ---------- */

body.viewer {
  background: var(--viewer-bg);
  color: #f4efe6;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.75rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.85rem;
  background: var(--viewer-bar);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 20;
  min-height: 3.1rem;
}

.toolbar a.back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  color: #f4efe6;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.35rem;
  white-space: nowrap;
}

.toolbar a.back:hover {
  color: #fff;
}

.toolbar .book-title {
  flex: 1 1 auto;
  min-width: 8rem;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar .book-title span.sub {
  font-style: italic;
  font-weight: 400;
  color: rgba(244, 239, 230, 0.7);
  margin-left: 0.55rem;
  font-size: 1rem;
}

.tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}

.page-readout {
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  min-width: 4.5rem;
  text-align: center;
  color: rgba(244, 239, 230, 0.9);
}

input.scrub {
  width: 7rem;
  accent-color: var(--bronze-soft);
  height: 1.1rem;
}

.icon-btn {
  appearance: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f4efe6;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.icon-btn[aria-disabled="true"],
.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.icon-btn svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stage {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0.75rem 2.4rem 1.1rem;
}

.book-host {
  position: relative;
}

#book {
  margin: 0 auto;
}

/* Soft paper shadow under the open book */
.book-host.is-ready {
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.45));
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  appearance: none;
  background: rgba(0, 0, 0, 0.28);
  border: 0;
  color: #f4efe6;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  opacity: 0.7;
}

.nav-arrow:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.45);
}

.nav-arrow.prev { left: 0.4rem; }
.nav-arrow.next { right: 0.4rem; }

.nav-arrow svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.loader,
.error-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: rgba(244, 239, 230, 0.85);
  text-align: center;
  pointer-events: none;
}

.loader[hidden],
.error-msg[hidden] {
  display: none;
}

.loader .spin {
  width: 1.6rem;
  height: 1.6rem;
  border: 2px solid rgba(244, 239, 230, 0.25);
  border-top-color: #f4efe6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader p,
.error-msg p {
  margin: 0;
  font-style: italic;
  font-size: 1.15rem;
}

.error-msg a {
  color: var(--bronze-soft);
  pointer-events: auto;
}

body.viewer.loading .book-host,
body.viewer.loading .nav-arrow {
  visibility: hidden;
}

/* Fullscreen: let the stage fill the display */
body.viewer:fullscreen,
body.viewer:-webkit-full-screen {
  height: 100%;
}

@media (max-width: 640px) {
  .toolbar .book-title span.sub { display: none; }
  .stage { padding: 0.5rem 0.4rem 0.85rem; }
  .nav-arrow { display: none; }
  input.scrub { width: 4.5rem; }
  .shelf-wrap { width: calc(100% - 1.5rem); padding-top: 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .card .cover-wrap { transition: none; }
  .loader .spin { animation: none; }
}

/* HTML-mode flip pages: keep the empty cover half transparent */
#book,
.stf__parent,
.stf__wrapper,
.stf__block {
  background: transparent;
}

.st-page {
  overflow: hidden;
  background: #fff;
}

.st-page img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

#pages-source {
  display: none;
}
