/* ===========================================================================
   RealPortal marketing/demo pages — shared stylesheet for /demo/buyer and
   /demo/agency.

   Design tokens below are the SAME names/values as protected-pages/buyers/
   app.html (the "today's buyer chat redesign" reference) — same palette,
   same Fraunces/Inter pairing, same spacing scale, same radius/shadow/ease —
   extended (not replaced) with a larger type scale for marketing headlines
   and a dark-mode variant, since these are the two things that page never
   needed. This is deliberate: these pages should read as the same product
   family, not a separate site.
   =========================================================================== */

:root {
  --ink: #14181c;
  --ink-2: #3c4650;
  --muted: #6b7580;
  --line: #e6e3dd;
  --line-2: #f0eeea;
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-2: #f5f4f0;
  --accent: #00875f;
  --accent-dark: #016b4c;
  --accent-soft: #e9f4ef;
  --danger: #b3261e;
  --warn: #8a5a05;

  /* Original chat-app scale, kept for anything reused verbatim (e.g. the
     fake chat bubbles in the buyer standout section, so they look exactly
     like the real product, not a mockup of it). */
  --t-micro: 11px; --t-xs: 12.5px; --t-sm: 13.5px; --t-base: 15px;
  --t-msg: 15.5px; --t-lg: 17px; --t-title: 21px;

  /* Marketing-scale additions — same family, bigger stops. */
  --t-h1: clamp(2.4rem, 5.5vw + 1rem, 4.6rem);
  --t-h2: clamp(1.7rem, 2.6vw + 1rem, 2.6rem);
  --t-h3: clamp(1.2rem, 1.1vw + 1rem, 1.5rem);
  --t-lead: clamp(1.05rem, .6vw + .9rem, 1.25rem);

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --s7: 48px; --s8: 64px; --s9: 96px;

  --radius: 14px; --radius-lg: 20px; --radius-xl: 28px;
  --shadow-sm: 0 1px 2px rgba(20,24,28,.05);
  --shadow-md: 0 4px 16px rgba(20,24,28,.08);
  --shadow-lg: 0 -8px 40px rgba(20,24,28,.16);
  --shadow-card: 0 1px 3px rgba(20,24,28,.06), 0 1px 2px rgba(20,24,28,.04);
  --ease: cubic-bezier(.22,.61,.36,1);

  --container: 1160px;
}

/* Dark mode — same accent/serif identity, inverted ground. No in-app toggle
   exists anywhere in this codebase yet, so this follows the OS preference,
   same as any other prefers-color-scheme-only implementation. */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2f1ee;
    --ink-2: #c7cad0;
    --muted: #8b93a0;
    --line: #2a2f36;
    --line-2: #23272d;
    --bg: #0d1013;
    --surface: #14181c;
    --surface-2: #1a1e23;
    --accent: #1fb87d;
    --accent-dark: #17a06c;
    --accent-soft: #103428;
    --shadow-card: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: var(--t-base)/1.6 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

.serif { font-family: 'Fraunces', Georgia, serif; }
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; letter-spacing: -0.01em; margin: 0; color: var(--ink); }
p { margin: 0; }
a { color: inherit; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--s5); }
@media (max-width: 640px) { .container { padding: 0 var(--s4); } }

section { padding: var(--s9) 0; }
@media (max-width: 640px) { section { padding: var(--s7) 0; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; font-family: inherit; font-size: var(--t-base); font-weight: 600;
  border-radius: 11px; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s var(--ease), color .15s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease);
  border: 0;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 9px 16px; font-size: var(--t-sm); border-radius: 9px; }
.btn-lg { padding: 15px 28px; font-size: var(--t-lg); border-radius: 13px; }

/* ---- Hero (cinematic) --------------------------------------------------- */
.hero {
  position: relative; padding: var(--s9) 0 var(--s8);
  background: radial-gradient(120% 100% at 50% 0%, var(--accent-soft) 0%, transparent 55%), var(--bg);
  overflow: hidden;
}
.hero .container { text-align: center; }
.hero .eyebrow {
  display: inline-block; font-size: var(--t-xs); font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: var(--s4);
}
.hero h1 { font-size: var(--t-h1); line-height: 1.04; max-width: 16ch; margin: 0 auto; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lead {
  font-size: var(--t-lead); color: var(--ink-2); max-width: 46ch; margin: var(--s5) auto 0;
  line-height: 1.55;
}
.hero .cta-row { display: flex; justify-content: center; gap: var(--s3); margin-top: var(--s6); flex-wrap: wrap; }

/* Scroll-linked hero visual. --p is a 0..1 progress value written by demo.js
   from a scroll listener (rAF-throttled) — transform/opacity ONLY, so this
   never triggers layout while scrolling. Reduced motion disables the
   scroll-link entirely (see demo.js) and this becomes a static resting
   state. */
.hero-visual {
  margin: var(--s8) auto 0; max-width: 880px; position: relative;
  transform: translateY(calc(var(--p, 0) * -18px)) scale(calc(1 - var(--p, 0) * .08));
  opacity: calc(1 - var(--p, 0) * .55);
  will-change: transform, opacity;
}
@media (prefers-reduced-motion: reduce) { .hero-visual { transform: none !important; opacity: 1 !important; } }

/* ---- Scroll reveal ------------------------------------------------------- */
[data-reveal] {
  opacity: 0; transform: translateY(28px) scale(.98);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  will-change: transform, opacity;
}
[data-reveal].in-view { opacity: 1; transform: translateY(0) scale(1); }
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; transition: none; }
}

/* ---- Section headers ------------------------------------------------------ */
.section-head { text-align: center; max-width: 640px; margin: 0 auto var(--s7); }
.section-head .eyebrow { display: block; font-size: var(--t-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: var(--s3); }
.section-head h2 { font-size: var(--t-h2); line-height: 1.15; }
.section-head p { color: var(--muted); margin-top: var(--s3); font-size: var(--t-lead); }

/* ---- Feature grid (data-driven — see demo.js renderFeatureGrid) --------- */
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s5); }
@media (max-width: 920px) { .feature-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .feature-grid { grid-template-columns: 1fr; } }

.feature-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: var(--s5); box-shadow: var(--shadow-card);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.feature-card .icon {
  width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center; font-size: 21px; margin-bottom: var(--s4);
}
.feature-card h3 { font-size: var(--t-h3); margin-bottom: var(--s2); }
.feature-card p { color: var(--muted); font-size: var(--t-sm); line-height: 1.6; }
.feature-card .demo-chip {
  display: inline-block; margin-top: var(--s3); font-size: var(--t-micro); font-weight: 600;
  color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px;
  letter-spacing: .02em;
}

/* ---- Feature-card mini demos (data-driven — see demo.js DEMO_RENDERERS) -
   Each type below is a small, reusable illustrative widget so 26 feature
   cards share ~10 building blocks instead of 26 bespoke animations. All
   content passed into these is fictional (see the FEATURES/PILLAR_* arrays
   in buyer.html / agency.html) — the "Illustrative example" note above each
   grid covers the whole set rather than repeating a disclaimer 26 times. */
.feature-demo {
  margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line);
  min-height: 40px;
}

/* chat */
.fd-chat { display: flex; flex-direction: column; gap: 6px; }
.fd-chat-tag { font-size: var(--t-micro); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.fd-bubble {
  max-width: 88%; padding: 6px 10px; border-radius: 12px; font-size: var(--t-xs); line-height: 1.4;
  opacity: 0; transform: translateY(6px); transition: opacity .4s var(--ease), transform .4s var(--ease);
}
.fd-bubble.in-view { opacity: 1; transform: translateY(0); }
.fd-bubble.fd-ai, .fd-bubble.fd-agency { align-self: flex-start; background: var(--surface-2); color: var(--ink); }
.fd-bubble.fd-buyer { align-self: flex-end; background: var(--accent); color: #fff; }

/* steps */
.fd-steps { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 2px; }
.fd-step {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px;
  background: var(--surface-2); font-size: var(--t-micro); font-weight: 600; color: var(--muted);
  opacity: 0; transform: translateY(6px) scale(.95); transition: opacity .4s var(--ease), transform .4s var(--ease), color .4s var(--ease), background .4s var(--ease);
}
.fd-step.in-view { opacity: 1; transform: translateY(0) scale(1); color: var(--ink); background: var(--accent-soft); }
.fd-step-icon { font-size: var(--t-sm); }
.fd-step-arrow {
  color: var(--line); font-size: var(--t-xs); opacity: 0; transition: opacity .3s var(--ease), color .3s var(--ease);
}
.fd-step-arrow.in-view { opacity: 1; color: var(--muted); }

/* counter / stat */
.fd-counter, .fd-stat {
  display: flex; align-items: baseline; gap: 8px;
  opacity: 0; transform: translateY(6px); transition: opacity .4s var(--ease), transform .4s var(--ease);
}
.fd-counter { opacity: 1; transform: none; } /* the number itself animates; the row doesn't need to */
.fd-stat.in-view { opacity: 1; transform: none; }
.fd-counter-n, .fd-stat-v { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 1.3rem; color: var(--accent); }
.fd-counter-l, .fd-stat-l { font-size: var(--t-xs); color: var(--muted); }

/* checklist */
.fd-checklist { display: flex; flex-direction: column; gap: 6px; }
.fd-check {
  display: flex; align-items: center; gap: 7px; font-size: var(--t-xs); color: var(--muted);
  opacity: 0; transform: translateX(-6px); transition: opacity .35s var(--ease), transform .35s var(--ease), color .35s var(--ease);
}
.fd-check.in-view { opacity: 1; transform: none; color: var(--ink-2); }
.fd-check-mark {
  flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700;
}

/* badges */
.fd-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.fd-badge {
  font-size: var(--t-micro); font-weight: 600; color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px;
  opacity: 0; transform: scale(.9); transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.fd-badge.in-view { opacity: 1; transform: scale(1); }

/* compare (mini) */
.fd-compare { display: flex; gap: var(--s2); }
.fd-compare-card {
  flex: 1; background: var(--surface-2); border-radius: 10px; padding: 8px 10px;
  opacity: 0; transform: translateY(6px); transition: opacity .4s var(--ease), transform .4s var(--ease);
}
.fd-compare-card.in-view { opacity: 1; transform: none; }
.fd-compare-l { font-size: var(--t-micro); color: var(--muted); font-weight: 600; }
.fd-compare-v { font-size: var(--t-xs); font-weight: 600; color: var(--ink); margin-top: 2px; }

/* toggle (before/after) */
.fd-toggle {
  position: relative; min-height: 40px;
  opacity: 0; transition: opacity .4s var(--ease);
}
.fd-toggle.in-view { opacity: 1; }
.fd-toggle-state {
  position: absolute; inset: 0; display: flex; align-items: center; gap: 8px;
  opacity: 0; transition: opacity .5s var(--ease);
}
.fd-toggle.in-view .fd-before { opacity: 1; }
.fd-toggle.in-view.after .fd-before { opacity: 0; }
.fd-toggle.in-view.after .fd-after { opacity: 1; }
.fd-toggle-l { font-size: var(--t-micro); color: var(--muted); font-weight: 600; }
.fd-toggle-v { font-size: var(--t-xs); font-weight: 700; color: var(--ink); }
.fd-after .fd-toggle-v { color: var(--accent); }

/* photo placeholder — deliberately abstract, never a fabricated real photo */
.fd-photo { opacity: 0; transform: scale(.97); transition: opacity .4s var(--ease), transform .4s var(--ease); }
.fd-photo.in-view { opacity: 1; transform: none; }
.fd-photo-ph {
  height: 54px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
}
.fd-photo-cap { font-size: var(--t-micro); color: var(--muted); margin-top: 4px; }

/* live toast */
.fd-toast {
  display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-size: var(--t-xs); color: var(--ink-2);
  opacity: 0; transform: translateY(6px); transition: opacity .4s var(--ease), transform .4s var(--ease);
}
.fd-toast.in-view { opacity: 1; transform: none; }
.fd-toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.fd-toast.in-view .fd-toast-dot { animation: fdPulse 1.6s ease-in-out infinite; }
@keyframes fdPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .fd-toast.in-view .fd-toast-dot { animation: none; } }
/* Blanket reduced-motion override for every fd-* widget above: demo.js
   still calls play(true) synchronously (so the content appears at all —
   reduced motion means no animation, not no content), but the CSS
   transitions/animations that would otherwise run once are fully disabled
   here, same contract as .hero-visual and [data-reveal] above. */
@media (prefers-reduced-motion: reduce) {
  .fd-bubble, .fd-step, .fd-step-arrow, .fd-counter, .fd-stat, .fd-check,
  .fd-badge, .fd-compare-card, .fd-photo, .fd-toast {
    opacity: 1 !important; transform: none !important; transition: none !important; animation: none !important;
  }
  /* .fd-toggle is two overlapping absolutely-positioned states — forcing
     both to opacity:1 would show them stacked/garbled, so only the
     transition duration is removed here; play(true) already adds both
     .in-view and .after synchronously, and the existing class-based rules
     below correctly show only the "after" state, just without a fade. */
  .fd-toggle, .fd-toggle-state { transition: none !important; }
}

/* ---- Pillar grouping (agency page) --------------------------------------- */
.pillar { margin-bottom: var(--s8); }
.pillar:last-child { margin-bottom: 0; }
.pillar-head { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s5); }
.pillar-head .num {
  font-family: 'Fraunces', Georgia, serif; font-size: var(--t-h3); font-weight: 600; color: var(--accent);
}
.pillar-head h3 { font-size: var(--t-h2); }

/* ---- Comparison table (data-driven — see demo.js renderComparisonTable) -
   Desktop: .compare-head + each .compare-row is its OWN 3-column grid
   sharing the same column widths, so everything still lines up like one
   table even though rows are independent elements (needed so mobile can
   restyle a row into a self-contained card without fighting a single
   giant grid). Mobile: each .compare-row becomes a bordered card; the
   shared head hides (redundant once every row carries its own column
   labels via .col-tag) and .col-tag makes "RealPortal" / "Traditional
   portals" explicit text on every value, not just position — this is the
   fix for the old mobile view reading as a disconnected list. */
.compare-wrap { max-width: 880px; margin: 0 auto; }
.compare-table {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-card);
}
.compare-head, .compare-row {
  display: grid; grid-template-columns: 1.1fr 1fr 1fr;
}
.compare-row { border-top: 1px solid var(--line); }
.compare-head .hd { font-size: var(--t-xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: var(--s4); background: var(--surface-2); }
.compare-head .hd.us { color: var(--accent); }
.compare-head .hd.them { color: var(--muted); }
.compare-row .cell {
  padding: var(--s4); font-size: var(--t-sm); line-height: 1.5;
  display: flex; align-items: center; gap: 8px;
}
.compare-row .cell.label { font-weight: 600; color: var(--ink); }
.compare-row .cell.us { color: var(--ink-2); background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.compare-row .cell.them { color: var(--muted); }
.compare-row .col-tag { display: none; } /* desktop: the shared header already gives column context */
.compare-row .mark { flex: 0 0 auto; font-size: var(--t-sm); }
.compare-row .mark.yes { color: var(--accent); }
.compare-row .mark.no { color: var(--muted); }

@media (max-width: 700px) {
  .compare-head { display: none; }
  .compare-row {
    display: block; border: 1px solid var(--line); border-radius: var(--radius);
    margin-bottom: var(--s3); border-top: 1px solid var(--line); overflow: hidden;
  }
  .compare-row:last-child { margin-bottom: 0; }
  .compare-row .cell.label {
    padding: var(--s3) var(--s4); background: var(--surface-2); font-size: var(--t-base);
  }
  .compare-row .cell.us, .compare-row .cell.them {
    padding: var(--s3) var(--s4); align-items: flex-start; flex-direction: column; gap: 2px;
    border-top: 1px solid var(--line);
  }
  .compare-row .cell.us { border-left: 3px solid var(--accent); }
  .compare-row .cell.them { border-left: 3px solid var(--line); }
  .compare-row .col-tag {
    display: block; font-size: var(--t-micro); font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  }
  .compare-row .cell.us .col-tag { color: var(--accent); }
  .compare-row .cell.them .col-tag { color: var(--muted); }
  .compare-row .val { display: flex; align-items: center; gap: 6px; }
}

/* ---- Fake-chat mock (buyer standout section) ---------------------------- */
.chat-mock {
  max-width: 480px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); overflow: hidden;
}
.chat-mock .chat-head {
  padding: var(--s4); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: var(--s2);
  font-weight: 600; font-size: var(--t-sm); color: var(--muted);
}
.chat-mock .chat-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.chat-mock .chat-body { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s3); min-height: 280px; }
.chat-bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 16px; font-size: var(--t-msg); line-height: 1.45;
  opacity: 0; transform: translateY(10px);
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
.chat-bubble.in-view { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { .chat-bubble { opacity: 1; transform: none; transition: none; } }
.chat-bubble.buyer { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.chat-bubble.ai { align-self: flex-start; background: var(--surface-2); color: var(--ink); border-bottom-left-radius: 6px; }
.chat-mock .fake-note { text-align: center; font-size: var(--t-micro); color: var(--muted); padding: var(--s3); border-top: 1px solid var(--line); }

/* ---- Fake dashboard mock (agency hero visual) ---------------------------- */
.dash-mock {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); overflow: hidden; text-align: left;
}
.dash-mock .dash-bar { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); display: flex; gap: 6px; }
.dash-mock .dash-bar span { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dash-mock .dash-body { padding: var(--s5); display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); }
.dash-mock .dash-stat { background: var(--surface-2); border-radius: var(--radius); padding: var(--s4); }
.dash-mock .dash-stat .n { font-family: 'Fraunces', Georgia, serif; font-size: 1.7rem; font-weight: 600; color: var(--accent); }
.dash-mock .dash-stat .l { font-size: var(--t-xs); color: var(--muted); margin-top: 4px; }
@media (max-width: 560px) { .dash-mock .dash-body { grid-template-columns: 1fr; } }

.fake-tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-micro); font-weight: 600;
  color: var(--muted); letter-spacing: .04em; text-transform: uppercase;
}
.fake-tag::before { content: '●'; color: var(--warn); font-size: 8px; }

/* ---- Closing CTA band ----------------------------------------------------- */
.closing {
  text-align: center; padding: var(--s9) 0; background: var(--surface-2);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.closing h2 { font-size: var(--t-h2); }
.closing .cta-row { margin-top: var(--s5); }

.demo-footer { padding: var(--s6) 0; text-align: center; color: var(--muted); font-size: var(--t-sm); }
.demo-footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.demo-footer a:hover { color: var(--accent); }
