:root {
  --ink: #2a2233;
  --ink-soft: #5a5266;
  --purple: #5a3fa0;
  --purple-dark: #3a2e6b;
  --gold: #85652f; /* 5.2:1 on --bg (the previous #b8925a was 2.8:1) */
  --bg: #fdfbf7;
  --bg-alt: #f3eef8;
  --card: #ffffff;
  --border: #e4ddef;
  --radius: 14px;
  --serif: 'Frank Ruhl Libre', Georgia, serif;
  --sans: 'Heebo', Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Accessibility helpers */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  top: -100px;
  inset-inline-start: 12px;
  z-index: 100;
  background: var(--purple-dark);
  color: #fff;
  padding: 10px 18px;
  border-radius: 0 0 10px 10px;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 0; }
main:focus { outline: none; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible,
[tabindex="-1"]:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

.narrow { max-width: 760px; }

h1, h2, h3 { font-family: var(--serif); margin: 0 0 0.5em; color: var(--purple-dark); }

.section-title {
  font-size: 1.8rem;
  position: relative;
  padding-bottom: 14px;
  margin-bottom: 1.2em;
}
.section-title::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 56px;
  height: 3px;
  background: var(--gold);
  border-radius: 2px;
}

.body-text { font-size: 1.05rem; color: var(--ink-soft); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(253, 251, 247, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.logo {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--purple-dark);
  text-decoration: none;
}
.main-nav { display: flex; align-items: center; gap: 26px; }
.main-nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
}
.main-nav a:hover { color: var(--purple); }
.nav-cta {
  background: var(--purple);
  color: #fff !important;
  padding: 8px 18px;
  border-radius: 999px;
}
.nav-cta:hover { background: var(--purple-dark); }

.hero {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 56px;
  align-items: center;
  padding: 64px 24px 80px;
}
.hero-cover img {
  width: 100%;
  border-radius: 10px;
  box-shadow: 0 24px 48px -18px rgba(58, 46, 107, 0.45);
}
.eyebrow {
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.03em;
  margin: 0 0 6px;
}
/* Everything in the hero text column is centered, like the book cover. */
.hero-text { text-align: center; }
/* Title lines styled like the cover: bold, dark-brown ink, upright. */
.hero-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #291b0e;
  margin-bottom: 0.15em;
}
.hero-subtitle {
  font-family: var(--serif);
  font-style: normal;
  font-weight: 700;
  color: #291b0e;
  font-size: 2.6rem;
  line-height: 1.25;
  margin: 0 0 14px;
}
.hero-author { font-size: 1.15rem; color: var(--ink-soft); margin: 0 0 20px; }
.hero-pitch { font-size: 1.05rem; color: var(--ink-soft); max-width: 46ch; margin-inline: auto; }
.hero-actions { display: flex; justify-content: center; align-items: flex-start; gap: 14px; margin-top: 24px; flex-wrap: wrap; }
.buy-cta { display: flex; flex-direction: column; align-items: center; }
/* Handwritten red callouts under the buy button (pre-sale, launch price). Red #d6201a on the page background is 4.98:1. */
.hand-note {
  margin-top: 6px;
  font-family: 'Gveret Levin', 'Amatic SC', cursive;
  font-size: 1.7rem;
  line-height: 1.1;
  color: #d6201a;
  transform: rotate(-4deg);
}
.hand-note.hidden { display: none; }

.btn {
  display: inline-block;
  padding: 13px 26px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.98rem;
  border: 2px solid transparent;
  cursor: pointer;
  font-family: var(--sans);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-dark); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--purple); border-color: var(--purple); }
.btn-ghost:hover { background: var(--bg-alt); }
.btn-large { width: 100%; font-size: 1.05rem; padding: 15px 26px; }
.btn-small { padding: 8px 16px; font-size: 0.88rem; }

/* The order button is an image (images/payment.png), not a text button. */
.pay-image-btn {
  display: block;
  width: min(100%, 560px);
  margin: 6px auto 0;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.pay-image-btn img { display: block; width: 100%; height: auto; border-radius: 10px; }
.pay-image-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 60, 130, 0.28); }
.pay-image-btn:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
.pay-image-btn:disabled { opacity: 0.55; cursor: progress; transform: none; box-shadow: none; }

.promo-row { display: flex; gap: 10px; }
.promo-row input {
  flex: 1;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.98rem;
}
.promo-row .btn { flex-shrink: 0; }

.section { padding: 72px 0; }
.alt-bg { background: var(--bg-alt); }

.book-facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-top: 32px;
  padding: 0;
}
.book-facts > div {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.book-facts dd { line-height: 1.4; }
.book-facts dt { font-size: 0.82rem; color: var(--ink-soft); margin: 0 0 6px; }
.book-facts dd { margin: 0; font-weight: 700; color: var(--purple-dark); }

.author-contact {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.author-contact h3 {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--purple-dark);
  margin: 0 0 12px;
}
.author-contact ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
}
.author-contact a { color: var(--purple); text-decoration: underline; text-underline-offset: 3px; }

.author-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 48px;
  align-items: center;
}
.author-photo img {
  width: 100%;
  border-radius: 50%;
  aspect-ratio: 1;
  object-fit: cover;
  box-shadow: 0 18px 36px -16px rgba(58, 46, 107, 0.35);
}

.reviews-list {
  display: grid;
  gap: 18px;
  margin-bottom: 32px;
}
.review-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.review-card .stars { color: var(--gold); letter-spacing: 2px; margin-bottom: 6px; }
.review-card .review-name { font-weight: 700; color: var(--purple-dark); }
.review-card p { margin: 8px 0 0; color: var(--ink-soft); }
.reviews-empty { color: var(--ink-soft); font-style: italic; }

.review-form-wrap { border-top: 1px solid var(--border); padding-top: 28px; }
.review-form { margin-top: 20px; max-width: 520px; }
/* The reCAPTCHA badge is hidden; the page carries the notice Google requires instead (.recaptcha-note). */
.grecaptcha-badge { visibility: hidden; }
.recaptcha-note { font-size: 0.82rem; margin-top: 12px; }
.payment-option.hidden, .review-form.hidden, .credit-card-note.hidden, .bundle-offers.hidden, .bundle-note.hidden, .launch-badge.hidden, .form-fieldset.hidden { display: none; }

.payment-result.hidden, #paymentRetry.hidden, #paymentDownload.hidden { display: none; }
#paymentDownload:disabled { opacity: 0.7; cursor: progress; }
.payment-result {
  margin: 0 0 20px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--ink);
  text-align: center;
  font-weight: 600;
}
.payment-result p { margin: 0 0 8px; }
.payment-result #paymentRetry { margin-top: 4px; }
.payment-result.success { background: #e8f6ec; border-color: #b9e0c5; color: #1a6b36; }
.payment-result.error { background: #fff0ef; border-color: #f3c7c3; color: #8a1f17; }

.launch-badge {
  display: inline-block;
  margin: 0 0 14px;
  padding: 8px 16px;
  background: #e8f6ec;
  border: 1px solid #b9e0c5;
  border-radius: 999px;
  color: #1a6b36;
  font-weight: 600;
  font-size: 0.95rem;
}

.bundle-offers {
  display: inline-block;
  margin: 0 0 18px;
  padding: 8px 16px;
  background: #fff4da;
  border: 1px solid #ecd8a0;
  border-radius: 999px;
  color: #6b4c12;
  font-weight: 600;
  font-size: 0.95rem;
}
.bundle-note { margin: -8px 0 16px; font-weight: 600; color: var(--purple-dark); }

.form-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px 26px;
  margin: 0 0 22px;
}
/* An email address is typed left-to-right, but the field itself sits on the right like the others. */
#email { direction: ltr; text-align: right; }
.form-fieldset legend {
  font-family: var(--serif);
  color: var(--purple-dark);
  padding: 0 8px;
  font-size: 1.05rem;
}

.form-row { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 0.9rem; font-weight: 600; color: var(--ink); }
.form-row input, .form-row select, .form-row textarea {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.98rem;
  background: #fff;
  color: var(--ink);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: 2px solid var(--purple);
  outline-offset: 1px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.three { grid-template-columns: 2fr 1fr 1fr; }

.form-note { font-size: 0.85rem; color: var(--ink-soft); margin: -6px 0 14px; }
.form-status { min-height: 1.4em; font-size: 0.92rem; margin-top: 10px; }
.form-status.success { color: #1a7a3c; }
.form-status.error { color: #b3261e; }

.payment-options { display: grid; gap: 12px; }
.payment-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  background: #fff;
}
.payment-option input { margin-top: 4px; }
.payment-option strong { display: block; color: var(--purple-dark); }
.payment-option small { color: var(--ink-soft); }

.credit-card-note {
  margin-top: 14px;
  background: #f4f0fb;
  border: 1px dashed var(--purple);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.9rem;
  color: var(--purple-dark);
}

.order-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1.1rem;
  padding: 16px 4px;
  border-top: 1px solid var(--border);
  margin-bottom: 20px;
}
.order-total strong { font-size: 1.5rem; color: var(--purple-dark); }

.buy-section { background: linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%); }

.site-footer {
  text-align: center;
  padding: 30px 0 40px;
  color: var(--ink-soft);
  font-size: 0.88rem;
}
.site-footer p { margin: 0 0 6px; }
.site-footer a { color: var(--purple); text-decoration: underline; text-underline-offset: 3px; }

/* Hint under a field */
.form-hint { color: var(--ink-soft); font-size: 0.82rem; }

/* Order summary shown as real text in the payment confirmation (the accessible version of the PDF) */
.receipt-summary { margin: 12px auto 14px; max-width: 420px; text-align: start; font-weight: 500; }
.receipt-summary.hidden { display: none; }
.receipt-summary div { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; border-bottom: 1px solid rgba(0, 0, 0, 0.12); }
.receipt-summary dt { font-weight: 400; }
.receipt-summary dd { margin: 0; font-weight: 700; }

/* Plain text pages (accessibility statement) */
.legal h2 { font-size: 1.35rem; margin-top: 1.8em; }
.legal ul { color: var(--ink-soft); padding-inline-start: 1.4em; }
.legal li { margin-bottom: 6px; }
.legal a { color: var(--purple); text-decoration: underline; text-underline-offset: 3px; }
.legal .updated { color: var(--ink-soft); font-size: 0.92rem; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; text-align: center; padding-top: 40px; }
  .hero-cover { max-width: 260px; margin: 0 auto; }
  .hero-pitch { margin: 0 auto; }
  .hero-actions { justify-content: center; }
  .author-grid { grid-template-columns: 1fr; text-align: center; }
  .author-photo img { max-width: 220px; margin: 0 auto; }
  .book-facts { grid-template-columns: repeat(2, 1fr); }
  .main-nav { gap: 14px; font-size: 0.88rem; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
}

/* No flash of out-of-date text. The page ships with the text and prices as of the last deploy; the admin portal can change them any time
   and they arrive from Firestore a moment after the page loads. Until then the marked elements are not painted (app.js removes the classes
   from <html> once the live data is in). The animation is a failsafe: after 3 seconds everything shows, whatever happens. */
html.content-loading [data-live],
html.price-loading [data-live-price] { visibility: hidden; animation: live-reveal 0s linear 3s forwards; }
@keyframes live-reveal { to { visibility: visible; } }
