/* =========================================================
   WellNest — Sleep Supplement Starter Guide
   Print-ready PDF stylesheet + Screen preview styles
   ========================================================= */

/* ─── Google Fonts fallback (SVG text rendering) ─── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600;9..40,700&display=swap');

/* ─── Variables ─── */
:root {
  --sleep:       #4338ca;
  --sleep-light: #818cf8;
  --sleep-pale:  #eef2ff;
  --gut:         #15803d;
  --gut-light:   #4ade80;
  --gut-pale:    #f0fdf4;
  --gold:        #c9a86c;
  --ink:         #1a1714;
  --ink-light:   #4a4540;
  --ink-muted:   #9c9590;
  --cream:       #faf8f5;
  --white:       #ffffff;

  --ff-display:  'Cormorant Garamond', Georgia, serif;
  --ff-body:     'DM Sans', system-ui, sans-serif;

  --page-w: 794px;   /* A4 width at 96dpi */
  --page-h: 1123px;  /* A4 height at 96dpi */
  --page-pad: 52px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--ff-body);
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink);
  background: #e5e3df;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: var(--sleep); }
ul { list-style: none; }

/* ─── DOWNLOAD BAR (screen only) ─── */
.download-bar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--ink);
  padding: 0.75rem 2rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.download-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 900px;
  margin: 0 auto;
}
.back-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--ff-body);
  transition: color 0.2s;
}
.back-link:hover { color: #fff; }
.dl-bar-logo {
  height: 32px;
  width: auto;
  background: white;
  padding: 4px 10px;
  border-radius: 6px;
}
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  background: linear-gradient(135deg, var(--sleep-light), var(--sleep));
  color: #fff;
  border: none;
  border-radius: 100px;
  font-family: var(--ff-body);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(67,56,202,0.4);
  transition: all 0.2s;
  letter-spacing: 0.02em;
}
.btn-download:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(67,56,202,0.5);
}

/* ─── PDF PAGES ─── */
.pdf-page {
  width: var(--page-w);
  min-height: var(--page-h);
  background: var(--white);
  margin: 1.5rem auto;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 40px rgba(0,0,0,0.18);
}

/* ══════════════════════════════════════
   COVER PAGE
══════════════════════════════════════ */
.cover-page {
  background: linear-gradient(160deg, #1e1b4b 0%, #312e81 45%, #1e3a5f 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--page-pad);
}

/* Background decorative shapes */
.cover-bg-shapes { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cover-shape { position: absolute; border-radius: 50%; filter: blur(70px); }
.cover-shape-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(129,140,248,0.25), transparent);
  top: -100px; right: -100px;
}
.cover-shape-2 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, rgba(74,222,128,0.12), transparent);
  bottom: 80px; left: -80px;
}
.cover-shape-3 {
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(201,168,108,0.18), transparent);
  top: 50%; left: 40%;
}

.cover-content {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.5rem;
}

.cover-brand {
  margin-bottom: 0.5rem;
}
.cover-logo {
  height: 48px;
  width: auto;
  background: white;
  padding: 6px 14px;
  border-radius: 8px;
}

.cover-badge {
  display: inline-block;
  background: var(--gold);
  color: #fff;
  font-family: var(--ff-body);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  padding: 0.35rem 1rem;
  border-radius: 100px;
  width: fit-content;
}

.cover-title {
  font-family: var(--ff-display);
  font-size: 56px;
  font-weight: 700;
  color: #fff;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.cover-title em {
  font-style: italic;
  color: var(--sleep-light);
}

.cover-tagline {
  font-size: 14px;
  color: rgba(255,255,255,0.72);
  line-height: 1.7;
  max-width: 52ch;
}

.cover-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.cover-divider::before, .cover-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.15);
}
.cover-moon { font-size: 1.5rem; }

.toc-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.4);
  margin-bottom: 0.75rem;
}
.toc-items { display: flex; flex-direction: column; gap: 0.55rem; }
.toc-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}
.toc-num {
  font-family: var(--ff-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--sleep-light);
  opacity: 0.6;
  min-width: 32px;
  line-height: 1;
}

.cover-footer {
  position: relative;
  z-index: 1;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-align: center;
  letter-spacing: 0.05em;
}

/* ══════════════════════════════════════
   CONTENT PAGES
══════════════════════════════════════ */
.content-page {
  padding: var(--page-pad);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.page-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid var(--sleep-pale);
}
.chapter-num {
  font-family: var(--ff-display);
  font-size: 38px;
  font-weight: 600;
  color: var(--sleep-light);
  opacity: 0.5;
  line-height: 1;
  flex-shrink: 0;
}
.chapter-title {
  font-family: var(--ff-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.lead-text {
  font-size: 14px;
  color: var(--ink-light);
  line-height: 1.75;
  border-left: 3px solid var(--sleep-light);
  padding-left: 1rem;
}

.section-h3 {
  font-family: var(--ff-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.65rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #ede9e4;
}

p { color: var(--ink-light); line-height: 1.7; margin-bottom: 0.65rem; }
p:last-child { margin-bottom: 0; }
strong { color: var(--ink); }

/* Two-column layout */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  flex: 1;
}

/* Callout boxes */
.callout {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin: 0.75rem 0;
  font-size: 12px;
  line-height: 1.6;
}
.callout-icon { font-size: 1.25rem; flex-shrink: 0; margin-top: 1px; }
.callout--indigo { background: var(--sleep-pale); border-left: 3px solid var(--sleep-light); }
.callout--indigo strong { color: var(--sleep); }
.callout--warning { background: #fffbeb; border-left: 3px solid #f59e0b; }
.callout--warning strong { color: #92400e; }
.callout div { color: var(--ink-light); }

/* Sleep thieves */
.sleep-thieves { display: flex; flex-direction: column; gap: 0.55rem; }
.thief-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  background: var(--cream);
  border-radius: 7px;
  border: 1px solid #ede9e4;
}
.thief-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.thief-card strong { display: block; font-size: 12px; color: var(--ink); margin-bottom: 1px; }
.thief-card p { font-size: 11px; margin: 0; color: var(--ink-muted); line-height: 1.5; }

/* Ingredients grid */
.ingredients-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  flex: 1;
}
.ingredient-card {
  background: var(--cream);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  border: 1px solid #ede9e4;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ingredient-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.ingredient-icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.ingredient-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}
.evidence-badge {
  font-size: 10px;
  font-weight: 600;
}
.evidence-strong { color: #166534; }
.evidence-good { color: #1e40af; }
.evidence-moderate { color: #92400e; }

.ingredient-desc {
  font-size: 11.5px;
  color: var(--ink-light);
  line-height: 1.65;
  margin: 0;
}
.ingredient-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.4rem;
  border-top: 1px solid #ede9e4;
}
.meta-item {
  font-size: 10.5px;
  color: var(--sleep);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.meta-item i { font-size: 9px; opacity: 0.7; }

/* Stacks */
.stack-card {
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid transparent;
}
.stack--beginner { background: var(--sleep-pale); border-color: #c7d2fe; }
.stack--intermediate { background: #f5f3ff; border-color: #ddd6fe; }
.stack--advanced { background: #fdf4ff; border-color: #e9d5ff; }

.stack-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}
.stack-level {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--sleep);
}
.stack-label {
  font-size: 10px;
  color: var(--ink-muted);
}
.stack-items { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.5rem; }
.stack-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 12px;
  color: var(--ink);
}
.stack-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.stack-note {
  font-size: 11px;
  color: var(--ink-muted);
  font-style: italic;
  margin: 0;
}

/* Protocol timeline */
.protocol-timeline { display: flex; flex-direction: column; gap: 0; }
.protocol-step {
  display: flex;
  gap: 0.85rem;
  padding: 0.6rem 0;
  border-left: 2px solid var(--sleep-pale);
  padding-left: 0.85rem;
  margin-left: 2.5rem;
  position: relative;
}
.protocol-step::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 14px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--sleep-light);
  border: 2px solid white;
  box-shadow: 0 0 0 1px var(--sleep-light);
}
.proto-final::before { background: var(--sleep); }
.proto-final { border-left-color: var(--sleep); }

.proto-time {
  font-size: 10px;
  font-weight: 700;
  color: var(--sleep);
  min-width: 48px;
  flex-shrink: 0;
  padding-top: 2px;
  letter-spacing: 0.03em;
  position: absolute;
  left: -3.5rem;
}
.proto-content strong {
  display: block;
  font-size: 12px;
  color: var(--ink);
  margin-bottom: 1px;
}
.proto-content p { font-size: 11px; margin: 0; color: var(--ink-muted); line-height: 1.5; }

/* Dosage table */
.dosage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 1.5rem;
}
.dosage-table thead tr {
  background: var(--sleep);
  color: white;
}
.dosage-table th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.dosage-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #ede9e4;
  color: var(--ink-light);
  vertical-align: middle;
}
.dosage-table tbody tr:nth-child(even) td { background: var(--cream); }
.dosage-table td.safe { color: #166534; font-weight: 600; }
.dosage-table td.moderate { color: #92400e; font-weight: 600; }
.dosage-table td.caution { color: #9a3412; font-weight: 600; }

/* Top picks */
.picks-section { flex: 1; }
.picks-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}
.pick-card {
  background: var(--cream);
  border-radius: 10px;
  padding: 1rem;
  border: 1px solid #ede9e4;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.pick-card--featured {
  background: var(--sleep-pale);
  border-color: #c7d2fe;
}
.pick-rank {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.rank-num {
  font-family: var(--ff-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--sleep);
  line-height: 1;
}
.pick-rank--featured .rank-num { color: var(--sleep); }
.rank-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  text-transform: uppercase;
}
.pick-name {
  font-family: var(--ff-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.pick-brand { font-size: 10.5px; color: var(--ink-muted); }
.pick-stars { color: #f59e0b; font-size: 12px; letter-spacing: 1px; }
.pick-why { font-size: 11px; color: var(--ink-light); line-height: 1.6; margin: 0; }
.pick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: auto;
}
.pick-tags span {
  padding: 0.15rem 0.5rem;
  background: white;
  border: 1px solid #c7d2fe;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 600;
  color: var(--sleep);
}
.pick-card--featured .pick-tags span { background: white; }
.pick-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  padding-top: 0.4rem;
  border-top: 1px solid #ede9e4;
}
.pick-url {
  font-size: 10px;
  font-weight: 600;
  color: var(--sleep);
}

/* Page number footer */
.page-num {
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid #ede9e4;
  font-size: 10px;
  color: var(--ink-muted);
  text-align: center;
  letter-spacing: 0.04em;
}

/* ══════════════════════════════════════
   BACK COVER PAGE
══════════════════════════════════════ */
.back-cover-page {
  background: linear-gradient(160deg, #14532d 0%, #166534 50%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.back-cover-shapes { position: absolute; inset: 0; pointer-events: none; }
.bc-shape { position: absolute; border-radius: 50%; filter: blur(80px); }
.bc-shape-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(74,222,128,0.2), transparent);
  top: -80px; right: -80px;
}
.bc-shape-2 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(129,140,248,0.15), transparent);
  bottom: -60px; left: -60px;
}
.back-cover-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: var(--page-pad);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
}
.back-logo {
  height: 48px;
  width: auto;
  background: white;
  padding: 6px 14px;
  border-radius: 8px;
}
.back-title {
  font-family: var(--ff-display);
  font-size: 46px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.back-sub {
  font-size: 14px;
  color: rgba(255,255,255,0.72);
  max-width: 44ch;
  line-height: 1.7;
  margin: 0;
}
.back-url {
  font-family: var(--ff-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--gut-light);
  letter-spacing: 0.02em;
}
.back-divider {
  width: 60px;
  height: 2px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
}
.back-social p {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.65rem;
}
.back-social-links {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
}
.back-disclaimer {
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  max-width: 580px;
}
.back-disclaimer p {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  line-height: 1.6;
  margin-bottom: 0.35rem;
}
.back-disclaimer p:last-child { margin-bottom: 0; }
.back-disclaimer strong { color: rgba(255,255,255,0.6); }

/* ══════════════════════════════════════
   PRINT STYLES
══════════════════════════════════════ */
@media print {
  @page {
    size: A4;
    margin: 0;
  }

  html, body {
    width: 210mm;
    height: 297mm;
    background: white !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color-adjust: exact;
  }

  .no-print { display: none !important; }

  .pdf-page {
    width: 210mm;
    min-height: 297mm;
    height: 297mm;
    margin: 0;
    padding: 14mm 16mm;
    page-break-after: always;
    break-after: page;
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
  }

  .pdf-page:last-child { page-break-after: avoid; break-after: avoid; }

  /* Force background colours to print */
  .cover-page, .back-cover-page,
  .cover-shape, .bc-shape,
  .ingredient-icon, .dosage-table thead tr,
  .page-header, .stack-card, .callout {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Adjust spacing for print */
  .two-col { gap: 1.25rem; }
  .ingredients-grid { gap: 0.6rem; }
  .picks-grid { gap: 0.6rem; }
  .cover-page { padding: 14mm 16mm; }
  .content-page { padding: 12mm 16mm; gap: 0.85rem; }

  /* Prevent page breaks inside cards */
  .ingredient-card, .pick-card, .thief-card,
  .stack-card, .protocol-step { break-inside: avoid; }
}
