/*
 * reader.css — Shangazi Books
 * Chapter intro reader styles
 * Typography: EB Garamond (serif body), Inter (UI)
 * Colour palette: near-black body, deep red accents, grey chapter numbers
 */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --ink:        #141414;
  --ink-soft:   #3a3a3a;
  --muted:      #6b7280;
  --red:        #c0392b;
  --red-hover:  #a93226;
  --chapter-no: #b0b0b0;
  --rule:       #e0ddd8;
  --bg:         #faf9f7;
  --surface:    #ffffff;
  --gold:       #d4a017;
  --teal:       #1AABB5;
}

html {
  font-size: 17px;
  scroll-behavior: smooth;
}

body {
  font-family: 'EB Garamond', Georgia, serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.75;
}

/* ── CHAPTER INTRO LAYOUT ── */
.chapter-intro {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 28px 80px;
}

/* ── CHAPTER HEADER ── */
.chapter-header {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--rule);
}

.chapter-label {
  display: block;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--chapter-no);
  margin-bottom: 14px;
}

.chapter-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 12px;
}

.chapter-subtitle {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.5;
  font-style: normal;
}

/* ── BODY TEXT ── */
.chapter-body {
  margin-bottom: 48px;
}

.body-text {
  font-size: 1.05rem;
  line-height: 1.82;
  color: var(--ink-soft);
  margin-bottom: 1.4em;
}

.body-text:first-child {
  font-size: 1.12rem;
  color: var(--ink);
}

/* ── SECTION LABELS ── */
.section-label {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--red);
  margin: 2em 0 0.8em;
}

/* ── HARD CUTOFF ── */
.cutoff-paragraph {
  font-style: italic;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1.7;
  padding-left: 20px;
  border-left: 3px solid var(--red);
  margin-top: 2em;
  margin-bottom: 0;
}

/* ── CTA ── */
.chapter-cta {
  border-top: 1px solid var(--rule);
  padding-top: 36px;
  text-align: center;
}

.cta-sub {
  margin-top: 14px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
}
.cta-sub a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 500;
}
.cta-sub a:hover { text-decoration: underline; }

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

/* ── PREFACE specific ── */
.preface-label {
  display: block;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}

/* ── PAYWALL GATE ── */

/* Wraps the content that gets hidden */
.paywall-content {
  position: relative;
  overflow: hidden;
  max-height: 220px;   /* ~2 lines visible before fade */
  transition: max-height 0.4s ease;
}

/* The gradient fade overlay */
.paywall-content::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 180px;
  background: linear-gradient(
    to bottom,
    rgba(250, 249, 247, 0) 0%,
    rgba(250, 249, 247, 0.85) 40%,
    rgba(250, 249, 247, 1) 100%
  );
  pointer-events: none;
}

/* When unlocked — remove fade */
.paywall-content.unlocked {
  max-height: none;
}
.paywall-content.unlocked::after {
  display: none;
}

/* Gate card — sits below the fade */
.paywall-gate-card {
  background: #fff;
  border: 1px solid #e5e5e0;
  border-radius: 12px;
  padding: 32px 28px;
  text-align: center;
  margin: 0 0 48px;
  box-shadow: 0 2px 24px rgba(0,0,0,0.07);
}

.gate-eyebrow {
  font-family: 'Inter', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.gate-heading {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 6px;
}

.gate-sub {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

/* Primary CTA — buy */
.btn-gate-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: var(--red);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
  margin-bottom: 12px;
}
.btn-gate-primary:hover  { background: var(--red-hover); }
.btn-gate-primary:active { transform: scale(0.98); }

/* Price badge on primary button */
.gate-price {
  font-size: 0.78rem;
  font-weight: 500;
  opacity: 0.85;
  margin-left: 4px;
}

/* Secondary CTA — free chapter */
.gate-secondary {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}
.gate-secondary a,
.gate-secondary button {
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  font-family: inherit;
}
.gate-secondary a:hover,
.gate-secondary button:hover { text-decoration: underline; }

/* Gate divider */
.gate-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}
.gate-divider::before,
.gate-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e5e0;
}
.gate-divider span {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  color: var(--muted);
}

/* Inline email gate (shown after "get free chapter" click) */
.inline-email-gate {
  display: none;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.inline-email-gate.visible { display: flex; }

.inline-email-gate input {
  width: 100%;
  padding: 12px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  border: 1.5px solid #d0d0d0;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
  text-align: left;
}
.inline-email-gate input:focus { border-color: var(--teal); }

.btn-gate-free {
  width: 100%;
  padding: 12px 24px;
  background: var(--teal);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-gate-free:hover { background: #158f98; }
.btn-gate-free:disabled { background: #9dd4d8; cursor: not-allowed; }

.gate-free-spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn-gate-free.loading .gate-free-spinner { display: block; }
.btn-gate-free.loading .gate-free-label   { display: none; }

.gate-free-note {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  color: var(--muted);
}

.gate-free-alert {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  padding: 8px 12px;
  border-radius: 6px;
  display: none;
  text-align: left;
}
.gate-free-alert.error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; display: block; }
.gate-free-alert.success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; display: block; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .chapter-intro { padding: 32px 20px 64px; }
  .chapter-title { font-size: 1.6rem; }
  .body-text { font-size: 1rem; line-height: 1.78; }
  .paywall-gate-card { padding: 24px 20px; }
}
