/* =========================================================================
   ChapterCanvas — fine-press editorial theme
   Fraunces (display) + Newsreader (body) · cream paper · ink · ember
   ========================================================================= */

:root {
  --paper:      #F4EBD7;   /* page background */
  --paper-2:    #EFE4CB;   /* deeper bands */
  --surface:    #FBF6E9;   /* cards / pages */
  --ink:        #241F18;   /* primary text */
  --ink-soft:   #5B5346;   /* secondary text */
  --ink-faint:  #8B8068;   /* tertiary / lines */
  --ember:      #BF4E27;   /* accent */
  --ember-deep: #9C3C1B;
  --gold:       #B98A3E;   /* secondary accent */
  --line:       #D9CCAF;   /* hairlines */

  --shadow-sm: 0 2px 8px -4px rgba(54, 38, 20, .35);
  --shadow-md: 0 22px 48px -28px rgba(54, 38, 20, .50);
  --shadow-lg: 0 40px 80px -40px rgba(54, 38, 20, .55);

  --maxw: 1160px;
  --radius: 14px;
  --ease: cubic-bezier(.22, .61, .36, 1);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body:    "Newsreader", Georgia, "Times New Roman", serif;
}

/* ----------------------------- 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: clamp(1.0625rem, 0.98rem + 0.4vw, 1.1875rem);
  line-height: 1.7;
  font-weight: 400;
  color: var(--ink);
  background-color: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Subtle paper grain overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body > * { position: relative; z-index: 1; }

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

a { color: var(--ember-deep); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ember); }

::selection { background: var(--ember); color: var(--surface); }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.08; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }

/* ----------------------------- helpers ----------------------------- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: clamp(1.25rem, 4vw, 2.5rem); }
.container.narrow { max-width: 760px; }
.center { text-align: center; }

.visually-hidden, .skip-link {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link:focus {
  position: fixed; top: 1rem; left: 1rem; width: auto; height: auto;
  clip: auto; margin: 0; padding: .6rem 1rem; z-index: 100;
  background: var(--ink); color: var(--surface); border-radius: 8px;
}

/* ----------------------------- buttons ----------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: .5ch;
  font-family: var(--font-body); font-size: 1.02rem; font-weight: 500;
  line-height: 1; padding: .85em 1.5em; border-radius: 9px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform .25s var(--ease), background-color .25s var(--ease),
              color .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.btn-sm { padding: .6em 1.1em; font-size: .95rem; }
.btn-primary { background: var(--ember); color: var(--surface); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--ember-deep); color: var(--surface); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--ink); transform: translateY(-2px); }

/* ----------------------------- header ----------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 72px; }

.brand { display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ink); }
.logo-mark { width: 40px; height: 40px; color: var(--ink); overflow: visible; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 1.4rem; letter-spacing: -0.02em; }
.brand-name-accent { color: var(--ember); }

.nav { display: flex; align-items: center; }
.nav-menu { display: flex; align-items: center; gap: clamp(1rem, 2.5vw, 2.1rem); list-style: none; margin: 0; padding: 0; }
.nav-menu a:not(.btn) {
  font-size: 1rem; color: var(--ink-soft); text-decoration: none; font-weight: 400;
  position: relative; transition: color .2s var(--ease);
}
.nav-menu a:not(.btn)::after {
  content: ""; position: absolute; left: 0; bottom: -5px; width: 100%; height: 1.5px;
  background: var(--ember); transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease);
}
.nav-menu a:not(.btn):hover { color: var(--ink); }
.nav-menu a:not(.btn):hover::after { transform: scaleX(1); }

.nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: 0; cursor: pointer; padding: 8px; }
.nav-toggle span { display: block; width: 24px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .3s var(--ease), opacity .3s var(--ease); }

/* logo brushstroke draw-on animation */
.logo-stroke { stroke-dasharray: 100; stroke-dashoffset: 100; animation: draw 1.1s var(--ease) .25s forwards; }
.logo-spark { opacity: 0; animation: spark .4s var(--ease) 1.25s forwards; }
@keyframes draw  { to { stroke-dashoffset: 0; } }
@keyframes spark { to { opacity: 1; } }

/* ----------------------------- hero ----------------------------- */
.hero { padding-block: clamp(3rem, 7vw, 6rem) clamp(3.5rem, 8vw, 7rem); }
.hero-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: clamp(2rem, 5vw, 4.5rem); align-items: center; }
.hero-copy, .hero-visual { min-width: 0; }

.eyebrow {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: .6ch;
  font-size: .82rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 500; margin-bottom: 1.4rem;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ember); box-shadow: 0 0 0 0 var(--ember); animation: pulse 2.4s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ember) 55%, transparent); } 70%,100% { box-shadow: 0 0 0 9px transparent; } }

.hero-title { font-size: clamp(2.2rem, 1.4rem + 4.2vw, 4.7rem); letter-spacing: -0.025em; margin-bottom: 1.5rem; overflow-wrap: break-word; text-wrap: balance; }
.hero-title em { font-style: italic; font-weight: 500; color: var(--ember); }
.hero-lede { font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.35rem); color: var(--ink-soft); max-width: 36ch; margin-bottom: 2rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .9rem; margin-bottom: 1.5rem; }
.hero-note { font-size: .95rem; color: var(--ink-faint); }

/* hero load stagger */
.hero-copy .reveal { opacity: 0; transform: translateY(18px); animation: rise .8s var(--ease) forwards; }
.hero-copy .reveal:nth-child(1) { animation-delay: .05s; }
.hero-copy .reveal:nth-child(2) { animation-delay: .15s; }
.hero-copy .reveal:nth-child(3) { animation-delay: .25s; }
.hero-copy .reveal:nth-child(4) { animation-delay: .35s; }
.hero-copy .reveal:nth-child(5) { animation-delay: .45s; }
.hero-visual.reveal { opacity: 0; transform: translateY(24px); animation: rise 1s var(--ease) .35s forwards; }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }

/* ----------------------------- page card (demo) ----------------------------- */
.hero-visual { perspective: 1200px; }
.page-card {
  position: relative; margin: 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px;
  padding: clamp(1.6rem, 3vw, 2.4rem) clamp(1.6rem, 3vw, 2.6rem) clamp(1.8rem, 3vw, 2.4rem);
  box-shadow: var(--shadow-lg); transform: rotate(1.6deg);
  transition: transform .5s var(--ease), box-shadow .5s var(--ease);
}
.page-card::before { /* second sheet behind, peeking left + bottom for depth */
  content: ""; position: absolute; inset: 16px 12px -18px -16px; z-index: -1;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  transform: rotate(-3deg); box-shadow: var(--shadow-md);
}
.hero-visual:hover .page-card { transform: rotate(0deg) translateY(-4px); }

.page-tag {
  position: absolute; top: -14px; right: 18px;
  background: var(--ink); color: var(--surface);
  font-family: var(--font-body); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase;
  padding: .45em .9em; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.page-folio { text-align: center; color: var(--ink-faint); font-style: italic; font-size: .9rem; margin-bottom: 1rem; letter-spacing: .1em; }
.page-prose { font-size: 1.02rem; line-height: 1.75; color: var(--ink); }
.dropcap {
  float: left; font-family: var(--font-display); font-weight: 600; font-size: 3.1em;
  line-height: .78; padding: .04em .12em 0 0; color: var(--ember);
}
.page-illustration { margin: 1.25rem 0; }
.page-illustration svg {
  width: 100%; height: auto; background:
    radial-gradient(120% 90% at 70% 20%, color-mix(in srgb, var(--ember) 9%, transparent), transparent 60%),
    var(--paper);
  border: 1px solid var(--line); border-radius: 4px;
}
.page-illustration figcaption { text-align: center; font-style: italic; font-size: .82rem; color: var(--ink-faint); margin-top: .5rem; }

/* ----------------------------- sections ----------------------------- */
.section { padding-block: clamp(3.5rem, 8vw, 6.5rem); }
.section-head { max-width: 640px; margin-bottom: clamp(2.2rem, 4vw, 3.2rem); }
.section.center .section-head, .center .section-head { margin-inline: auto; }

.chapter-label {
  font-family: var(--font-body); font-size: .8rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--ember); font-weight: 500; margin-bottom: 1rem;
  display: flex; align-items: center; gap: .9rem;
}
.chapter-label::after { content: ""; flex: 0 0 56px; height: 1px; background: var(--gold); }
.chapter-label.center { justify-content: center; }
.chapter-label.center::before { content: ""; flex: 0 0 56px; height: 1px; background: var(--gold); }

.section-title { font-size: clamp(1.9rem, 1.4rem + 2.2vw, 3rem); margin-bottom: 1rem; max-width: 18ch; }
.center .section-title, .quote-band .section-title { margin-inline: auto; }
.section-lede { font-size: clamp(1.08rem, 1rem + 0.4vw, 1.25rem); color: var(--ink-soft); max-width: 52ch; }
.center .section-lede { margin-inline: auto; }

/* ----------------------------- how it works ----------------------------- */
.how { background: var(--paper-2); border-block: 1px solid var(--line); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(1.5rem, 3vw, 2.8rem); counter-reset: step; }
.step { position: relative; padding-top: 1.5rem; border-top: 2px solid var(--ink); }
.step-num { display: block; font-family: var(--font-display); font-size: 2.6rem; font-weight: 600; color: var(--ember); line-height: 1; margin-bottom: .9rem; }
.step-title { font-size: 1.5rem; margin-bottom: .6rem; }
.step p { color: var(--ink-soft); font-size: 1.02rem; }

/* ----------------------------- features ----------------------------- */
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(1rem, 2vw, 1.5rem); }
.feature {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1.4rem, 2.4vw, 1.9rem); box-shadow: var(--shadow-sm);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease);
}
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--gold); }
.feature h3 { font-size: 1.32rem; margin-bottom: .55rem; }
.feature h3::before { content: ""; display: block; width: 28px; height: 3px; background: var(--ember); border-radius: 2px; margin-bottom: .9rem; }
.feature p { color: var(--ink-soft); font-size: 1rem; }

/* ----------------------------- quote band ----------------------------- */
.quote-band { background: var(--ink); color: var(--paper); text-align: center; }
.quote-band .chapter-label { color: var(--gold); }
.quote-band .chapter-label::before, .quote-band .chapter-label::after { background: color-mix(in srgb, var(--gold) 55%, transparent); }
.ethos-quote {
  font-family: var(--font-display); font-style: italic; font-weight: 400;
  font-size: clamp(1.6rem, 1.1rem + 2.6vw, 2.8rem); line-height: 1.25;
  max-width: 20ch; margin: 1rem auto 1.4rem; letter-spacing: -0.01em;
  color: var(--surface);
}
.ethos-sub { color: color-mix(in srgb, var(--paper) 78%, transparent); max-width: 50ch; margin-inline: auto; font-size: 1.1rem; }

/* ----------------------------- faq ----------------------------- */
.faq-list { border-top: 1px solid var(--line); }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-item summary {
  list-style: none; cursor: pointer; padding: 1.25rem 2.5rem 1.25rem 0; position: relative;
  font-family: var(--font-display); font-size: clamp(1.15rem, 1rem + 0.5vw, 1.4rem); font-weight: 500;
  color: var(--ink); transition: color .2s var(--ease);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary:hover { color: var(--ember); }
.faq-item summary::after {
  content: "+"; position: absolute; right: .2rem; top: 50%; transform: translateY(-50%);
  font-size: 1.6rem; color: var(--ember); transition: transform .3s var(--ease); font-family: var(--font-body);
}
.faq-item[open] summary::after { transform: translateY(-50%) rotate(45deg); }
.faq-item p { padding-bottom: 1.4rem; color: var(--ink-soft); max-width: 62ch; }

/* ----------------------------- waitlist ----------------------------- */
.waitlist {
  background:
    radial-gradient(80% 120% at 50% -10%, color-mix(in srgb, var(--ember) 12%, transparent), transparent 55%),
    var(--paper-2);
  border-top: 1px solid var(--line);
}
.waitlist .section-title { font-size: clamp(2rem, 1.5rem + 2.4vw, 3.1rem); }
.waitlist-form {
  display: flex; gap: .7rem; max-width: 480px; margin: 2rem auto .9rem; flex-wrap: wrap;
}
.waitlist-form input {
  flex: 1 1 240px; font-family: var(--font-body); font-size: 1.05rem;
  padding: .85em 1.1em; border-radius: 9px; border: 1px solid var(--ink-faint);
  background: var(--surface); color: var(--ink); transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.waitlist-form input::placeholder { color: var(--ink-faint); }
.waitlist-form input:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ember) 22%, transparent); }
.waitlist-form .btn { flex: 0 0 auto; }
.form-status { min-height: 1.4em; font-size: .98rem; color: var(--ember-deep); font-style: italic; }
.form-status.error { color: var(--ember); }

/* ----------------------------- footer ----------------------------- */
.site-footer { background: var(--ink); color: var(--paper); padding-block: clamp(2.5rem, 5vw, 3.5rem); }
.footer-inner { display: flex; justify-content: space-between; align-items: flex-start; gap: 2rem; flex-wrap: wrap; }
.footer-brand { display: flex; align-items: center; gap: .9rem; }
.logo-mark-sm { width: 44px; height: 44px; color: var(--paper); overflow: visible; }
.footer-name { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; }
.footer-tag { color: color-mix(in srgb, var(--paper) 70%, transparent); font-size: .98rem; font-style: italic; }
.footer-meta { text-align: right; color: color-mix(in srgb, var(--paper) 72%, transparent); font-size: .92rem; line-height: 1.9; }
.footer-meta a { color: var(--paper); }
.footer-meta a:hover { color: var(--gold); }

/* ----------------------------- scroll reveal ----------------------------- */
.section .reveal { opacity: 0; transform: translateY(26px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.section .reveal.is-visible { opacity: 1; transform: none; }
.steps .reveal:nth-child(2), .feature-grid .reveal:nth-child(2), .feature-grid .reveal:nth-child(5) { transition-delay: .08s; }
.steps .reveal:nth-child(3), .feature-grid .reveal:nth-child(3), .feature-grid .reveal:nth-child(6) { transition-delay: .16s; }

/* ----------------------------- responsive ----------------------------- */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-visual { order: -1; max-width: 440px; margin-inline: auto; }
  .page-card { transform: rotate(0.6deg); }
  .hero-visual:hover .page-card { transform: translateY(-4px); }
  .steps { grid-template-columns: 1fr; gap: 2rem; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  .nav-toggle { display: flex; }
  .nav-menu {
    position: absolute; top: 100%; right: 0; left: 0;
    flex-direction: column; align-items: flex-start; gap: 1.2rem;
    background: var(--paper); border-bottom: 1px solid var(--line);
    padding: 1.5rem clamp(1.25rem, 4vw, 2.5rem) 2rem;
    transform: translateY(-12px); opacity: 0; pointer-events: none;
    transition: transform .3s var(--ease), opacity .3s var(--ease);
  }
  .nav-menu.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .nav-menu .btn { margin-top: .4rem; }
  .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .feature-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; }
  .footer-meta { text-align: left; }
}

/* ----------------------------- reduced motion ----------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
  .hero-copy .reveal, .hero-visual.reveal, .section .reveal { opacity: 1; transform: none; }
  .logo-stroke { stroke-dashoffset: 0; }
  .logo-spark { opacity: 1; }
  .status-dot { animation: none; }
}
