/* ============================================================
   Deanna Rossi — Free Reads
   Black & gold legacy · Playfair Display + Inter
   ============================================================ */

:root {
  /* palette */
  --black: #0f0e0b;
  --surface: #16140e;
  --surface-2: #1a1812;
  --hairline: #2a261c;
  --hairline-2: #3a3526;
  --gold: #c9a227;
  --gold-bright: #e8c352;
  --gold-on-light: #7d5e0e;
  --cream: #f4f1ea;
  --paper: #f4f1ea;
  --paper-line: #e3ddd0;
  --ink: #1c1a14;
  --muted: #a39e90;
  --muted-2: #8a8578;
  --danger: #e5484d;

  /* type */
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* motion (Emil-style strong curves) */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: clip;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--cream);
  /* one page-wide gold aura, fading smoothly — no section seams */
  background:
    radial-gradient(
      1200px 780px at 50% -220px,
      rgba(201, 162, 39, 0.09),
      rgba(201, 162, 39, 0.045) 38%,
      rgba(201, 162, 39, 0.018) 58%,
      rgba(201, 162, 39, 0) 76%
    )
    no-repeat,
    var(--black);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

a { color: inherit; }

img { max-width: 100%; display: block; }

.wrap { max-width: 1020px; margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 760px; margin: 0 auto; padding: 0 20px; }

/* ---- header ------------------------------------------------ */
.site-header {
  border-bottom: 1px solid var(--hairline);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  min-height: 64px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { height: 30px; width: auto; }
.header-links { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 12px; }
.header-links a {
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  white-space: nowrap;
  padding: 6px 2px;
  transition: color 180ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .header-links a:hover { color: var(--gold-bright); }
}

/* ---- type helpers ------------------------------------------ */
.kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 12px;
}
h1, h2, .serif { font-family: var(--serif); font-weight: 500; }
h1 { font-size: clamp(34px, 5.4vw, 54px); line-height: 1.12; margin: 0 0 14px; }
h2 { font-size: clamp(26px, 4vw, 36px); line-height: 1.15; margin: 0 0 10px; }
.sub { font-size: 17px; color: var(--muted); max-width: 560px; margin: 0 auto 30px; }
.gold-rule {
  width: 56px; height: 1px; background: var(--gold);
  border: none; margin: 26px auto;
}

/* ---- buttons ------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 26px;
  border: none;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 160ms var(--ease-out), background 180ms var(--ease-out),
    color 180ms var(--ease-out), border-color 180ms var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}
.btn-gold {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #14120c;
}
.btn-ghost { background: transparent; color: var(--gold-bright); border: 1.5px solid var(--hairline-2); }
@media (hover: hover) and (pointer: fine) {
  .btn-gold:hover { background: var(--gold-bright); }
  .btn-ghost:hover { border-color: var(--gold); }
}
.btn-gold:focus-visible { outline-color: var(--cream); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* on light (reader) surfaces */
.on-light .btn-ghost { color: var(--ink); border-color: #cfc7b4; }
@media (hover: hover) and (pointer: fine) {
  .on-light .btn-ghost:hover { border-color: var(--gold-on-light); }
}

/* ---- landing hero ------------------------------------------- */
.hero { text-align: center; padding: 76px 0 30px; }
.hero .sub { margin-bottom: 0; }

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 22px;
  max-width: 820px;
  margin: 48px auto 84px;
  padding: 0 20px;
}
.book-card {
  background: linear-gradient(165deg, #1b1810, var(--surface) 55%);
  border: none;
  border-radius: 14px;
  padding: 34px 28px 30px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 220ms var(--ease-out), box-shadow 260ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .book-card:hover {
    transform: translateY(-3px);
    box-shadow:
      0 0 0 1px rgba(201, 162, 39, 0.28),
      0 0 36px rgba(201, 162, 39, 0.18),
      0 0 90px rgba(201, 162, 39, 0.1);
  }
}
.book-card:focus-within {
  box-shadow:
    0 0 0 1px rgba(201, 162, 39, 0.28),
    0 0 36px rgba(201, 162, 39, 0.18);
}
.book-card img.cover { height: 240px; width: auto; margin-bottom: 22px; }
.book-card h2 { font-size: 26px; margin: 0 0 8px; }
.book-card .free-note {
  font-size: 12px; font-weight: 600; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--gold); margin: 0 0 12px;
}
.book-card p.blurb { font-size: 14.5px; color: var(--muted); margin: 0 0 24px; flex: 1; }

/* ---- gate ---------------------------------------------------- */
.gate {
  min-height: calc(100dvh - 65px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 0 72px;
}
.gate img.cover { height: 250px; width: auto; margin: 0 auto 30px; }
.gate-chapter {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--gold-bright);
  margin: -4px 0 4px;
  letter-spacing: 0.02em;
}
.gate-chapter:empty { display: none; }
.gate-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 620px;
  margin: 0 auto;
}
.gate-form .field { flex: 1 1 180px; text-align: left; }
.gate-form label {
  display: block; font-size: 12.5px; font-weight: 500;
  color: var(--muted); margin: 0 0 6px 2px;
}
.gate-form input {
  width: 100%;
  min-height: 48px;
  padding: 12px 15px;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--cream);
  background: var(--surface-2);
  border: 1.5px solid var(--hairline-2);
  border-radius: 8px;
  transition: border-color 180ms var(--ease-out);
}
.gate-form input::placeholder { color: var(--muted-2); }
.gate-form input:focus { border-color: var(--gold); outline: none; }
.gate-form input[aria-invalid="true"] { border-color: var(--danger); }
.gate-form .submit-wrap { flex: 1 1 100%; margin-top: 6px; }
.gate-form .btn { width: 100%; max-width: 380px; }
.form-error {
  display: none;
  font-size: 13.5px;
  color: var(--danger);
  margin: 10px 0 0;
}
.form-error.visible { display: block; }
.fine { font-size: 12.5px; color: var(--muted-2); max-width: 460px; margin: 18px auto 0; }
.fine a { color: var(--muted); }

/* spinner inside the submit button */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(20, 18, 12, 0.3);
  border-top-color: #14120c;
  border-radius: 50%;
  display: none;
  animation: spin 600ms linear infinite;
}
.btn.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- reader -------------------------------------------------- */
.reader { display: none; background: var(--paper); color: var(--ink); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--black);
  color: var(--cream);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 20px;
}
.topbar .back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted); text-decoration: none;
  min-height: 44px; padding: 0 4px;
  transition: color 180ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .topbar .back:hover { color: var(--gold-bright); }
}
.topbar .book-title { font-family: var(--serif); font-size: 15px; }
.topbar .progress-label { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.progress-track { height: 3px; background: var(--surface-2); }
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--gold);
  transition: width 400ms var(--ease-in-out);
}

.chapter-head { text-align: center; padding: 44px 20px 8px; }
.chapter-head .kicker { color: var(--gold-on-light); margin-bottom: 8px; }
.chapter-head h2 { color: var(--ink); }

.pages { max-width: 715px; margin: 0 auto; padding: 12px 16px 8px; }
.page-img {
  width: 100%;
  height: auto;
  margin: 18px 0;
  background: #fff;
  border: 1px solid var(--paper-line);
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(28, 26, 20, 0.07);
}

.reader-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 715px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

/* chapter crossfade */
.chapter-content { transition: opacity 150ms var(--ease-out); }
.chapter-content.switching { opacity: 0; }

/* ---- end-of-chapter block (inside the cream reader) ----------- */
.end-block-wrap { padding: 26px 16px 72px; }
.end-block {
  max-width: 640px;
  margin: 0 auto;
  background: var(--black);
  color: var(--cream);
  border: none;
  border-radius: 16px;
  padding: 44px 28px 40px;
  text-align: center;
  box-shadow: 0 0 46px rgba(201, 162, 39, 0.22), 0 0 110px rgba(201, 162, 39, 0.08);
}
.end-block h2 { color: var(--cream); }
.end-block .sub { font-size: 15.5px; }
.end-block .locked-list { max-width: 380px; }
.on-light .end-block .btn-ghost { color: var(--gold-bright); border-color: var(--hairline-2); }
@media (hover: hover) and (pointer: fine) {
  .on-light .end-block .btn-ghost:hover { border-color: var(--gold); }
}

/* ---- already-claimed screen ----------------------------------- */
.paywall {
  min-height: calc(100dvh - 65px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 72px 0;
}
.lock-badge {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 24px;
}
.locked-list { max-width: 400px; margin: 30px auto 34px; text-align: left; }
.locked-list .locked-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  margin: 8px 0;
  font-size: 14.5px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
}
.locked-list .locked-item svg { flex: none; color: var(--muted-2); }
.locked-list .locked-item.highlight {
  color: var(--gold-bright);
  border-color: var(--gold);
  background: var(--surface-2);
}
.locked-list .locked-item.highlight svg { color: var(--gold); }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.tertiary-link { font-size: 13.5px; color: var(--muted); margin-top: 22px; }
.tertiary-link a { color: var(--gold-bright); text-decoration-color: var(--hairline-2); }

/* ---- footer -------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--hairline);
  text-align: center;
  font-size: 12.5px;
  color: var(--muted-2);
  padding: 30px 20px 40px;
  line-height: 1.8;
}
.site-footer .wordmark {
  font-family: var(--serif);
  letter-spacing: 0.14em;
  color: var(--gold);
  font-size: 14px;
  margin-bottom: 8px;
}
.reader ~ .site-footer { display: none; }

/* ---- view switching ------------------------------------------ */
.gate, .reader, .paywall { display: none; }
body[data-view="gate"] .gate { display: flex; }
body[data-view="reader"] .reader { display: block; }
body[data-view="claimed"] .paywall { display: flex; }

/* gentle entrance for gate → reader */
.reader-enter { animation: fadeUp 280ms var(--ease-out); }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- reduced motion ------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .book-card, .chapter-content, .paywall-inner { transition: none; }
  .btn:active { transform: none; }
  .reader-enter { animation: none; }
  .paywall-inner { transform: none; }
  .progress-fill { transition: none; }
}

/* ---- small screens ------------------------------------------- */
@media (max-width: 540px) {
  .header-links { gap: 4px 14px; font-size: 11px; }
  .header-links a:last-child { display: none; }
  .hero { padding-top: 54px; }
  .gate img.cover { height: 200px; }
  .book-card img.cover { height: 200px; }
  .topbar .book-title { display: none; }
  .reader-nav .btn { flex: 1; padding: 12px 10px; font-size: 14px; }
}
