/* ==========================================================================
   Rich or King? — site.css
   Vanilla CSS. Every colour, font and spacing value is a custom property
   in :root so the palette can be retuned in one place.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  --navy: #182640;
  --navy-grad: radial-gradient(ellipse at 50% 40%, #222F48 0%, #1A2740 70%, #182640 100%);
  --gold: #C4963E;
  --gold-hover: #B0842F;
  --parchment: #F5F2EA;
  --parchment-deep: #EDE8DC;
  --ink: #222222;
  --ink-soft: #4A4A4A;
  --white: #FFFFFF;
  --error: #9B1C1C;               /* 6.4:1 on parchment — passes AA */
  --navy-text-soft: rgba(255,255,255,0.78);

  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;

  --text-body: 1.125rem;          /* 18px desktop */
  --measure: 68ch;
  --track-eyebrow: 0.18em;

  --radius: 8px;
  --header-h: 76px;
  --header-h-compact: 56px;
  --container: 1200px;
  --gutter: clamp(1.25rem, 4vw, 3rem);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 320ms;
}

/* ---------- 2. Fonts ----------
   Loaded from Google Fonts in index.html (preconnect + display=swap), subset to
   the six weights used. To self-host instead (recommended before launch, see
   README "Fonts"): drop the .woff2 files into assets/fonts/, uncomment the
   @font-face rules below and remove the Google Fonts <link> tags.

@font-face { font-family: "Playfair Display"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/playfair-display-700.woff2") format("woff2"); }
@font-face { font-family: "Playfair Display"; font-style: normal; font-weight: 900; font-display: swap; src: url("../fonts/playfair-display-900.woff2") format("woff2"); }
@font-face { font-family: "Playfair Display"; font-style: italic; font-weight: 400; font-display: swap; src: url("../fonts/playfair-display-italic-400.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/poppins-400.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/poppins-500.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/poppins-600.woff2") format("woff2"); }
*/

/* ---------- 3. Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.6;
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}
img, svg, canvas { display: block; max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.02; margin: 0 0 0.5em; color: inherit; }
p { margin: 0 0 1.1em; max-width: var(--measure); }
a { color: var(--gold); text-decoration: none; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; box-shadow: 0 0 0 6px var(--navy); border-radius: 4px; }
.on-navy :focus-visible { box-shadow: 0 0 0 6px var(--white); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 1rem; top: -4rem; background: var(--navy); color: var(--white); padding: 0.6rem 1rem; border-radius: var(--radius); z-index: 100; }
.skip-link:focus { top: 1rem; }

.container { width: min(100% - 2 * var(--gutter), var(--container)); margin-inline: auto; }
.section { padding-block: clamp(4rem, 9vw, 7.5rem); }
.section--parchment { background: var(--parchment); }
.section--navy { background: var(--navy); color: var(--white); }

/* ---------- 4. Type ---------- */
.eyebrow {
  font-family: var(--font-body); font-weight: 600; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: var(--track-eyebrow);
  color: var(--gold); margin: 0 0 1.25rem;
}
.h-display { font-size: clamp(3rem, 8vw, 6.25rem); font-weight: 900; line-height: 0.96; letter-spacing: -0.01em; }
.h-section { font-size: clamp(2rem, 4.2vw, 3.25rem); line-height: 1.02; margin-bottom: 1.5rem; }
.gold { color: var(--gold); }
.italic-serif { font-family: var(--font-display); font-style: italic; font-weight: 400; }
.lede { font-size: clamp(1.125rem, 1.6vw, 1.375rem); line-height: 1.5; }
.small { font-size: 0.875rem; color: var(--ink-soft); }
.on-navy .small { color: var(--navy-text-soft); }

/* Text links — animated underline, never a second button style */
.link {
  position: relative; color: var(--gold); font-weight: 500; display: inline-block;
}
.link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1.5px;
  background: currentColor; transform: scaleX(0); transform-origin: left;
  transition: transform var(--dur) var(--ease-out);
}
.link:hover::after, .link:focus-visible::after { transform: scaleX(1); }

/* ---------- 5. Button — one primary style ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
  background: var(--gold); color: var(--white);
  font-family: var(--font-body); font-weight: 600; font-size: 1rem; line-height: 1;
  padding: 1rem 1.6rem; border: 0; border-radius: var(--radius);
  text-decoration: none; white-space: nowrap;
  transition: background var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
  box-shadow: 0 1px 2px rgba(24,38,64,0.18);
}
.btn:hover { background: var(--gold-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(24,38,64,0.22); }
.btn:active { transform: translateY(0); }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.7; cursor: progress; transform: none; }
.btn--sm { padding: 0.7rem 1.1rem; font-size: 0.875rem; }
.btn--block { width: 100%; }
.spinner {
  width: 1.1em; height: 1.1em; border: 2px solid rgba(255,255,255,0.45);
  border-top-color: var(--white); border-radius: 50%; display: none;
  animation: spin 0.8s linear infinite;
}
.btn[aria-busy="true"] .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 6. Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.94); backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid rgba(24,38,64,0.08);
  transition: height var(--dur) var(--ease-out);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: var(--header-h); transition: height var(--dur) var(--ease-out); }
.site-header.is-compact .container { height: var(--header-h-compact); }
.wordmark {
  font-family: var(--font-body); font-weight: 600; font-size: 0.8rem;
  letter-spacing: var(--track-eyebrow); text-transform: uppercase; color: var(--navy);
}
.nav { display: flex; align-items: center; gap: 2rem; }
.nav a:not(.btn) { color: var(--navy); font-weight: 500; font-size: 0.95rem; }
.nav a:not(.btn)::after { background: var(--gold); }
.nav-toggle {
  display: none; background: none; border: 0; padding: 0.5rem; color: var(--navy);
  width: 44px; height: 44px; align-items: center; justify-content: center;
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  content: ""; display: block; width: 22px; height: 2px; background: currentColor; position: relative;
  transition: transform var(--dur) var(--ease-out), opacity var(--dur);
}
.nav-toggle span::before { position: absolute; top: -7px; }
.nav-toggle span::after { position: absolute; top: 7px; }
.nav-toggle[aria-expanded="true"] span { background: transparent; }
.nav-toggle[aria-expanded="true"] span::before { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span::after { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 899px) {
  .nav-toggle { display: inline-flex; }
  .nav { position: absolute; left: 0; right: 0; top: 100%; background: var(--white);
    flex-direction: column; align-items: flex-start; gap: 0; padding: 0.5rem var(--gutter) 1.25rem;
    border-bottom: 1px solid rgba(24,38,64,0.08); box-shadow: 0 12px 24px rgba(24,38,64,0.08);
    display: none; }
  .nav.is-open { display: flex; }
  .nav a:not(.btn) { padding: 0.75rem 0; font-size: 1.05rem; }
  .nav .btn { display: none; }                /* the compact bar keeps its own gold button */
  .header-cta { display: inline-flex; }
}
@media (min-width: 900px) { .header-cta { display: none; } }

/* ---------- 7. Hero ---------- */
.hero {
  position: relative; background: var(--navy); background-image: var(--navy-grad);
  color: var(--white); overflow: hidden;
  min-height: calc(100svh - var(--header-h));
  display: flex; align-items: center;
}
.hero__dust { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.hero .container {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 35fr 65fr; gap: clamp(2rem, 5vw, 5rem);
  align-items: center; padding-block: clamp(2.5rem, 6vw, 5rem);
}
.hero__book { position: relative; }
.hero__copy { position: relative; }
.hero__copy .eyebrow { margin-bottom: 1.5rem; }
.hero__sub { font-size: clamp(1.25rem, 2.2vw, 1.75rem); color: var(--white); margin: 0.75rem 0 1.5rem; }
.hero__oneliner { color: var(--navy-text-soft); }
.hero__actions { display: flex; align-items: center; flex-wrap: wrap; gap: 1.5rem; margin: 2rem 0 1rem; }
.hero__reassure { color: var(--navy-text-soft); font-size: 0.875rem; margin: 0; }
.hero__coin-wrap {
  display: grid; justify-items: center; gap: 0.75rem;
  margin-top: 2.5rem; margin-left: auto; width: min(100%, 320px);
}
.hero__book-caption { text-align: center; margin-top: 0.75rem; color: var(--gold); font-size: 0.75rem; letter-spacing: var(--track-eyebrow); text-transform: uppercase; font-weight: 600; }

/* 3D stages: canvas mounts inside; fallback shown until WebGL is ready */
.stage { position: relative; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage__fallback { transition: opacity var(--dur); }
.stage.is-live .stage__fallback { opacity: 0; pointer-events: none; }
.stage--book { aspect-ratio: 4 / 5; max-width: 420px; margin-inline: auto; }
.stage--coin { width: 220px; height: 220px; }

.coin-button {
  background: none; border: 0; padding: 0; border-radius: 50%; display: block;
  cursor: pointer; width: 220px; height: 220px;
}
.coin-button:focus-visible { outline-offset: 6px; }
.coin-result { text-align: center; min-height: 3.6em; }
.coin-result__text {
  margin: 0 0 0.35rem; color: var(--white); font-size: 1rem; line-height: 1.5;
  opacity: 0; transform: translateY(6px); transition: opacity 480ms var(--ease-out), transform 480ms var(--ease-out);
}
.coin-result.is-shown .coin-result__text { opacity: 1; transform: none; }
.coin-result .link { opacity: 0; transition: opacity 480ms var(--ease-out) 160ms; }
.coin-result.is-shown .link { opacity: 1; }
.coin-tally { font-size: 0.8rem; color: var(--navy-text-soft); margin: 0.25rem 0 0; }

@media (max-width: 899px) {
  :root { --text-body: 1rem; }                 /* 16px minimum on mobile */
  .hero { min-height: 0; }
  .hero .container { grid-template-columns: 1fr; gap: 1.5rem; padding-block: 1.5rem 3rem; }
  .stage--book { max-width: 150px; aspect-ratio: 5 / 6; }
  .hero__copy .eyebrow { margin-bottom: 0.75rem; }
  .hero__sub { margin: 0.5rem 0 0.75rem; }
  .hero__oneliner { font-size: 1rem; margin-bottom: 0.5rem; }
  .hero__actions { margin: 1rem 0 0.5rem; gap: 1rem; }
  .hero__coin-wrap { margin: 1.5rem auto 0; }
  .hero__dust { display: none; }
}

/* ---------- 8. Proof strip ---------- */
.proof { background: var(--parchment); border-block: 1px solid rgba(24,38,64,0.06); }
.proof p { max-width: none; text-align: center; margin: 0; padding: 1.1rem 0; font-size: 0.9rem; font-weight: 500; color: var(--navy); letter-spacing: 0.01em; }
.proof .sep { color: var(--gold); margin-inline: 0.6em; }
.count { font-variant-numeric: tabular-nums; }
@media (max-width: 899px) { .proof p { font-size: 0.8rem; line-height: 1.8; } .proof .sep { margin-inline: 0.4em; } }

/* ---------- 9. About the book ---------- */
.book-grid { display: grid; grid-template-columns: 60fr 40fr; gap: clamp(2.5rem, 6vw, 6rem); align-items: start; }
.pullquote {
  font-family: var(--font-display); font-style: italic; font-weight: 400;
  font-size: clamp(1.75rem, 3.2vw, 2.5rem); line-height: 1.15; color: var(--gold);
  margin: 2.5rem 0; padding-left: 1.25rem; border-left: 2px solid var(--gold); max-width: 22ch;
}
.pullquote cite { display: block; font-family: var(--font-body); font-style: normal; font-size: 0.8rem; color: var(--ink-soft); margin-top: 0.75rem; letter-spacing: 0.04em; }
.inside {
  background: var(--parchment); border-radius: var(--radius); padding: clamp(1.5rem, 3vw, 2.5rem);
  position: sticky; top: calc(var(--header-h-compact) + 1.5rem);
}
.inside h3 { font-size: 1.5rem; margin-bottom: 1.25rem; color: var(--navy); }
.inside ol { list-style: none; margin: 0; padding: 0; counter-reset: ch; }
.inside li {
  display: grid; grid-template-columns: 2.4rem 1fr; gap: 0.5rem; align-items: baseline;
  padding: 0.6rem 0; border-top: 1px solid rgba(24,38,64,0.08); font-size: 0.95rem; line-height: 1.4;
  opacity: 0; transform: translateY(8px); transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out);
}
.inside li.is-in { opacity: 1; transform: none; }
.inside li::before { counter-increment: ch; content: counter(ch, decimal-leading-zero); font-family: var(--font-display); font-weight: 700; color: var(--gold); font-size: 1.15rem; }
.pub-note { margin-top: 1.25rem; }
@media (max-width: 899px) { .book-grid { grid-template-columns: 1fr; } .inside { position: static; } }

/* ---------- 10. Reserve ---------- */
.reserve-card {
  perspective: 1600px;
}
.reserve-card__inner {
  position: relative; transform-style: preserve-3d;
  transition: transform 520ms var(--ease-out);
}
.reserve-card.is-flipped .reserve-card__inner { transform: rotateY(180deg); }
.reserve-face {
  background: var(--parchment); border-radius: var(--radius); backface-visibility: hidden;
  box-shadow: 0 24px 64px rgba(24,38,64,0.10);
}
.reserve-face--front { display: grid; grid-template-columns: 40fr 60fr; gap: clamp(2rem, 4vw, 4rem); padding: clamp(1.5rem, 4vw, 3.5rem); }
.reserve-face--back {
  position: absolute; inset: 0; transform: rotateY(180deg);
  display: grid; place-items: center; padding: clamp(1.5rem, 4vw, 3.5rem); text-align: center;
}
.reserve-face--back .inner { max-width: 44ch; }
.reserve-face--back h3 { font-size: clamp(1.75rem, 3vw, 2.5rem); color: var(--navy); }
.reserve-intro h2 { color: var(--navy); }
.reserve-intro .headshot { width: 96px; height: 96px; margin-bottom: 1.25rem; }
.share { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.5rem; margin-top: 1.5rem; }

.form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; }
.field { display: grid; gap: 0.35rem; }
.field--full { grid-column: 1 / -1; }
.field label { font-size: 0.875rem; font-weight: 500; color: var(--navy); }
.field .req { color: var(--gold); }
.field input, .field select {
  font: inherit; font-size: 1rem; padding: 0.8rem 0.9rem; border-radius: var(--radius);
  border: 1px solid rgba(24,38,64,0.25); background: var(--white); color: var(--ink); width: 100%;
  min-height: 48px;
}
.field select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'><path d='M1 1l6 6 6-6' fill='none' stroke='%23182640' stroke-width='1.6'/></svg>"); background-repeat: no-repeat; background-position: right 0.9rem center; padding-right: 2.4rem; }
.field input:focus, .field select:focus { border-color: var(--navy); outline: none; box-shadow: 0 0 0 3px rgba(196,150,62,0.35); }
.field.is-invalid input { border-color: var(--error); }
.field .error { font-size: 0.8rem; color: var(--error); min-height: 1.2em; margin: 0; }
.field--check { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: 0.7rem; }
.field--check input { width: 20px; height: 20px; min-height: 0; margin-top: 0.2rem; accent-color: var(--gold); flex: none; }
.field--check label { font-weight: 400; color: var(--ink); font-size: 0.95rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.form__submit { grid-column: 1 / -1; margin-top: 0.5rem; }
.form__privacy { grid-column: 1 / -1; margin: 0.25rem 0 0; }
.form__status { grid-column: 1 / -1; margin: 0; }
.form__status.is-error { color: var(--error); background: rgba(155,28,28,0.06); padding: 0.9rem 1rem; border-radius: var(--radius); }
.form__status.is-error a { color: var(--error); text-decoration: underline; font-weight: 500; }

@media (max-width: 899px) {
  .reserve-face--front { grid-template-columns: 1fr; }
  .reserve-intro { order: 2; }                    /* form first on mobile */
  .reserve-form { order: 1; }
  .reserve-intro .headshot { display: none; }
  .form { grid-template-columns: 1fr; }
}

/* ---------- 11. About the author ---------- */
.about-grid { display: grid; grid-template-columns: 30fr 70fr; gap: clamp(2rem, 5vw, 5rem); align-items: start; }
.headshot {
  position: relative; width: 100%; max-width: 320px; aspect-ratio: 1; border-radius: 50%;
  overflow: hidden; box-shadow: 0 0 0 3px var(--gold), 0 0 0 5px var(--white);
}
.headshot img { width: 100%; height: 100%; object-fit: cover; }
.headshot::after { content: ""; position: absolute; inset: 0; background: var(--gold); opacity: 0.07; mix-blend-mode: multiply; pointer-events: none; }
.about-grid h2 { color: var(--navy); font-size: clamp(1.75rem, 3.4vw, 2.75rem); }
.descriptor { color: var(--gold); font-weight: 500; margin: -0.5rem 0 1.5rem; }
.about-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; margin-top: 1.5rem; }
@media (max-width: 899px) { .about-grid { grid-template-columns: 1fr; } .headshot { max-width: 200px; } }

/* ---------- 12. Speaking ---------- */
.speaking { text-align: center; background-image: var(--navy-grad); }
.speaking blockquote { margin: 0 auto 2rem; max-width: 22ch; font-family: var(--font-display); font-weight: 700; font-size: clamp(1.9rem, 4.5vw, 3.5rem); line-height: 1.08; }
.speaking .link { font-size: 1.1rem; }

/* ---------- 13. Footer ---------- */
.site-footer { background: #111A2B; color: var(--navy-text-soft); font-size: 0.875rem; padding: 2.5rem 0; }
.site-footer .container { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 2rem; }
.site-footer p { margin: 0; }
.footer-links { display: flex; align-items: center; gap: 1.5rem; }
.footer-links a { color: var(--navy-text-soft); }
.footer-links a:hover { color: var(--white); }
.social { display: flex; gap: 0.75rem; }
.social a { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--navy-text-soft); border: 1px solid rgba(255,255,255,0.15); }
.social a:hover { color: var(--gold); border-color: var(--gold); }
.social svg { width: 18px; height: 18px; fill: currentColor; }

/* ---------- 14. Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem);
  background: var(--navy); color: var(--white); padding: 0.7rem 1.2rem; border-radius: var(--radius);
  font-size: 0.9rem; opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity var(--dur), transform var(--dur) var(--ease-out);
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 15. Secondary pages (thanks, privacy) ---------- */
.page { padding-block: clamp(3rem, 8vw, 6rem); }
.page--narrow .container { max-width: 44rem; }
.page h1 { color: var(--navy); font-size: clamp(2.25rem, 5vw, 3.5rem); }
.page h2 { color: var(--navy); font-size: 1.5rem; margin-top: 2rem; }

/* ---------- 16. Reveal (single entrance per section, no loops) ---------- */
.reveal { opacity: 0; transform: translateY(12px); transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out); }
.reveal.is-in { opacity: 1; transform: none; }

/* ---------- 17. Reduced motion — every animation on the page ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .reveal, .inside li { opacity: 1; transform: none; }
  .reserve-card__inner { transition: none; }
  .stage canvas { display: none; }
  .stage.is-live .stage__fallback { opacity: 1; }
  .coin-result__text, .coin-result .link { transition: none; }
}
