/* forty2.works — self-contained, system fonts, dark-mode aware */

:root {
  --bg: #fbfaf8;
  --bg-alt: #f2f0ec;
  --fg: #1a1c22;
  --fg-soft: #4b4f5a;
  --border: #e3e0da;
  --card: #ffffff;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --invert-bg: #17181f;
  --invert-fg: #f5f5f2;
  --shadow: 0 1px 3px rgba(20, 22, 30, .07), 0 8px 24px rgba(20, 22, 30, .06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --bg-alt: #151823;
    --fg: #eceef2;
    --fg-soft: #a3a8b5;
    --border: #262b38;
    --card: #181c28;
    --accent: #7c7cf0;
    --accent-hover: #9a9af5;
    --accent-soft: #23264a;
    --invert-bg: #eceef2;
    --invert-fg: #14161d;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.wrap.narrow { max-width: 760px; }
.center { text-align: center; }

h1 { font-size: clamp(2.1rem, 5.5vw, 3.4rem); line-height: 1.12; letter-spacing: -.02em; font-weight: 800; }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); letter-spacing: -.015em; font-weight: 750; margin-bottom: .5rem; }
h3 { font-size: 1.08rem; font-weight: 650; margin-bottom: .5rem; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 28px; height: 60px; }
.brand, .brand-sm {
  font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em;
  color: var(--fg); text-decoration: none;
}
.brand sup, .brand-sm sup { color: var(--accent); font-size: .72em; }
.site-nav { display: flex; gap: 20px; margin-left: auto; }
.site-nav a { color: var(--fg-soft); text-decoration: none; font-size: .94rem; font-weight: 500; }
.site-nav a:hover { color: var(--fg); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: none;
  padding: 10px 20px; font-size: .96rem;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
@media (prefers-color-scheme: dark) {
  .btn-primary { color: #0f1117; }
}
.btn-ghost { border-color: var(--border); color: var(--fg); background: transparent; }
.btn-ghost:hover { border-color: var(--fg-soft); }
.btn-invert { background: var(--invert-fg); color: var(--invert-bg); }
.btn-invert:hover { opacity: .92; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; border-radius: 12px; }
.btn-sm { padding: 8px 16px; font-size: .88rem; }

/* focus rings (keyboard) */
a:focus-visible, button:focus-visible, summary:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* nav link underline micro-interaction */
.site-nav a { position: relative; }
.site-nav a::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: -4px; height: 2px;
  background: var(--accent); border-radius: 2px;
  transition: right .25s ease;
}
.site-nav a:hover::after, .site-nav a:focus-visible::after { right: 0; }

/* hero */
.hero { padding: 96px 0 72px; position: relative; overflow: hidden; }
.hero-grid {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr);
  gap: 56px; align-items: center; position: relative; z-index: 1;
}
.hero-visual img {
  display: block; width: 100%; height: auto;
  border-radius: 22px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 64px rgba(79, 70, 229, .28), var(--shadow);
}
@media (prefers-color-scheme: dark) {
  .hero-visual img { box-shadow: 0 24px 64px rgba(124, 124, 240, .22), var(--shadow); }
}

/* hero animated background blobs (transform-only, GPU-cheap) */
.hero-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; will-change: transform; }
.blob-a {
  width: 560px; height: 560px; top: -180px; right: -120px;
  background: radial-gradient(circle at center, rgba(79, 70, 229, .16), transparent 65%);
}
.blob-b {
  width: 480px; height: 480px; bottom: -220px; left: -160px;
  background: radial-gradient(circle at center, rgba(103, 232, 249, .10), transparent 65%);
}
@media (prefers-color-scheme: dark) {
  .blob-a { background: radial-gradient(circle at center, rgba(124, 124, 240, .18), transparent 65%); }
  .blob-b { background: radial-gradient(circle at center, rgba(103, 232, 249, .08), transparent 65%); }
}
.eyebrow {
  display: inline-block; font-size: .82rem; font-weight: 650; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 6px 14px; margin-bottom: 22px;
}
.lead { font-size: 1.18rem; color: var(--fg-soft); max-width: 640px; margin: 22px 0 30px; }
.cta-row { display: flex; gap: 14px; flex-wrap: wrap; }
.cta-row.center { justify-content: center; margin-top: 36px; }
.hero-note { margin-top: 16px; font-size: .88rem; color: var(--fg-soft); }

/* stats */
.stats { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--bg-alt); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 28px; padding: 36px 24px; }
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; color: var(--accent); white-space: nowrap; }
.stat-label { font-size: .88rem; color: var(--fg-soft); margin-top: 4px; }

/* sections */
.section { padding: 84px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-lead { color: var(--fg-soft); font-size: 1.08rem; max-width: 680px; margin-bottom: 40px; }

.cards { display: grid; gap: 20px; }
.cards.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
@media (hover: hover) {
  .card:hover {
    transform: translateY(-4px);
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
    box-shadow: 0 4px 8px rgba(20, 22, 30, .08), 0 16px 40px rgba(79, 70, 229, .14);
  }
}
.card-img {
  display: block; width: calc(100% + 52px); max-width: calc(100% + 52px); height: auto;
  margin: -26px -26px 18px; border-radius: var(--radius) var(--radius) 0 0;
}
.card p, .card li { color: var(--fg-soft); font-size: .96rem; }
.card ul { padding-left: 20px; display: grid; gap: 8px; margin-top: 10px; }
.step-num {
  width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; margin-bottom: 14px;
}
.tag {
  display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  border-radius: 6px; padding: 3px 8px; margin-right: 8px; vertical-align: 2px;
}
.tag-ai { background: var(--accent-soft); color: var(--accent); }
.tag-human { background: rgba(16, 163, 127, .12); color: #0f9d76; }
.hybrid-note {
  margin-top: 32px; padding: 20px 24px; border-left: 3px solid var(--accent);
  background: var(--card); border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--fg-soft); font-size: .98rem;
}

/* FAQ — padding lives on the summary so the whole visible row is the tap target (>=44px) */
#faq details {
  border: 1px solid var(--border); border-radius: 12px; background: var(--card);
  margin-bottom: 12px;
}
#faq summary {
  cursor: pointer; font-weight: 600; list-style: none; position: relative;
  padding: 16px 48px 16px 20px;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
#faq summary::-webkit-details-marker { display: none; }
#faq summary::after {
  content: "+"; position: absolute; right: 20px; top: 14px;
  color: var(--accent); font-weight: 700; font-size: 1.2rem; line-height: 1.4;
}
#faq details[open] summary::after { content: "\2212"; }
#faq details p { padding: 0 20px 16px; color: var(--fg-soft); font-size: .96rem; }

/* final CTA */
.final-cta { background: var(--invert-bg); color: var(--invert-fg); padding: 84px 0; }
.final-cta .section-lead { color: color-mix(in srgb, var(--invert-fg) 70%, transparent); margin: 12px auto 28px; }

/* footer */
.site-footer { border-top: 1px solid var(--border); padding: 36px 0 28px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand-sm { font-size: 1.1rem; margin-right: 12px; }
.tagline { color: var(--fg-soft); font-size: .88rem; }
.footer-links { display: flex; gap: 18px; align-items: center; color: var(--fg-soft); font-size: .88rem; }
.footer-links a { color: var(--fg-soft); }
.legal { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.legal h3 { font-size: .88rem; margin: 14px 0 6px; color: var(--fg); }
.legal p { font-size: .8rem; color: var(--fg-soft); margin-bottom: 6px; }

/* chat widget */
.chat-fab {
  position: fixed; right: 22px; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(20, 22, 30, .25);
  transition: transform .15s, background .15s;
}
.chat-fab:hover { transform: scale(1.06); background: var(--accent-hover); }
@media (prefers-color-scheme: dark) { .chat-fab { color: #0f1117; } }

.chat-panel {
  position: fixed; right: 22px; bottom: 22px; z-index: 70;
  width: 380px; max-width: calc(100vw - 24px); height: 520px; max-height: calc(100dvh - 44px);
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 12px 48px rgba(10, 12, 20, .3);
  overflow: hidden;
}
.chat-panel[hidden] { display: none; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--accent); color: #fff;
}
@media (prefers-color-scheme: dark) { .chat-head { color: #0f1117; } }
.chat-title { font-weight: 800; font-size: 1.05rem; }
.chat-sub { font-size: .78rem; opacity: .85; }
.chat-close {
  background: none; border: none; color: inherit; font-size: 1.7rem; line-height: 1;
  cursor: pointer; border-radius: 10px;
  width: 44px; height: 44px; margin: -6px -10px -6px 0;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.chat-close:hover { background: rgba(255, 255, 255, .18); }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg {
  max-width: 85%; padding: 10px 14px; border-radius: 14px;
  font-size: .93rem; white-space: pre-wrap; overflow-wrap: break-word;
}
.msg.bot { background: var(--bg-alt); border: 1px solid var(--border); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.user { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
@media (prefers-color-scheme: dark) { .msg.user { color: #0f1117; } }
.msg.pending { opacity: .6; }
.chat-input {
  display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); background: var(--card);
}
.chat-input textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--fg); font: inherit; font-size: .93rem;
  padding: 10px 12px; max-height: 120px;
}
.chat-input textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

/* responsive */
@media (max-width: 900px) {
  .cards.three { grid-template-columns: 1fr; }
  .cards.two { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .hero-visual { max-width: 340px; margin: 0 auto; width: 100%; }
  /* iOS Safari zooms the page when focusing inputs < 16px — keep the chat input at 16px */
  .chat-input textarea { font-size: 16px; }
}

/* touch devices: bigger hit areas for the nav + footer links (no visual change on pointer devices) */
@media (pointer: coarse) {
  .site-nav a { padding: 10px 2px; margin: -10px -2px; }
  .footer-links a, .footer-inner .tagline a { display: inline-block; padding: 10px 2px; margin: -10px -2px; }
  .brand { padding: 10px 10px; margin: -10px -10px; }
  .site-header .btn-sm { padding: 11px 18px; }
}

@media (max-width: 640px) {
  .wrap { padding: 0 20px; }
  .site-nav { display: none; }
  /* nav is hidden, so push the CTA to the right edge ourselves */
  .header-inner { justify-content: space-between; }
  .site-header .btn-sm { padding: 11px 18px; font-size: .92rem; }

  /* hero: tighter rhythm, natural headline wrap, thumb-sized CTAs */
  .hero { padding: 44px 0 48px; }
  .desktop-br { display: none; }
  h1 { font-size: 1.9rem; }
  .eyebrow {
    font-size: .7rem; letter-spacing: .03em; padding: 5px 12px;
    border-radius: 12px; line-height: 1.5; margin-bottom: 18px;
  }
  .lead { font-size: 1.05rem; margin: 16px 0 24px; }
  .cta-row { flex-direction: column; }
  .cta-row .btn { width: 100%; }
  .cta-row.center { margin-top: 28px; }
  .hero-note { margin-top: 14px; }
  /* the tall portrait illustration would eat a full screen — square-crop it */
  .hero-visual { max-width: 300px; }
  .hero-visual img {
    aspect-ratio: 1 / 1; object-fit: cover; object-position: center 30%;
    box-shadow: 0 14px 36px rgba(79, 70, 229, .22), var(--shadow);
  }
  .hero-grid { gap: 36px; }

  /* stats: drop the doubled horizontal inset, tighten */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 22px 18px; padding: 30px 0; }
  .stat-value { font-size: 1.35rem; }

  .section { padding: 56px 0; }
  .section-lead { font-size: 1.02rem; margin-bottom: 28px; }

  .card { padding: 20px; }
  .card-img { width: calc(100% + 40px); max-width: calc(100% + 40px); margin: -20px -20px 16px; }
  .hybrid-note { padding: 16px 18px; margin-top: 26px; }

  .final-cta { padding: 64px 0; }

  .footer-inner { flex-direction: column; align-items: flex-start; gap: 10px; }

  /* chat: bottom sheet with safe-area padding */
  .chat-fab { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .chat-panel {
    left: 0; right: 0; bottom: 0; width: auto; max-width: none;
    height: min(88dvh, 640px); max-height: none;
    border-radius: 18px 18px 0 0; border-bottom: none;
    border-left: none; border-right: none;
  }
  .chat-input { padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- motion layer (F2W-5) ---------- */

/* anchored sections shouldn't hide under the sticky header */
section[id], footer .legal { scroll-margin-top: 76px; }

.stat-value .count { font-variant-numeric: tabular-nums; }

/* everything below only for users who are OK with motion */
@media (prefers-reduced-motion: no-preference) {

  /* hero entrance (pure CSS, ends visible — safe without JS) */
  .hero-copy > * { animation: rise .7s cubic-bezier(.22, .8, .3, 1) both; }
  .hero-copy .eyebrow { animation-delay: .05s; }
  .hero-copy h1 { animation-delay: .15s; }
  .hero-copy .lead { animation-delay: .28s; }
  .hero-copy .cta-row { animation-delay: .4s; }
  .hero-copy .hero-note { animation-delay: .5s; }
  .hero-visual { animation: heroImg 1s cubic-bezier(.22, .8, .3, 1) .2s both; }
  @keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
  @keyframes heroImg { from { opacity: 0; transform: translateY(20px) scale(.97); } to { opacity: 1; transform: none; } }

  /* hero background drift */
  .blob-a { animation: driftA 26s ease-in-out infinite alternate; }
  .blob-b { animation: driftB 34s ease-in-out infinite alternate; }
  @keyframes driftA { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(-70px, 50px, 0) scale(1.15); } }
  @keyframes driftB { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(60px, -40px, 0) scale(1.1); } }

  /* scroll-reveal: hidden state only when fx.js confirmed it will reveal (html.fx) */
  .fx [data-reveal] {
    opacity: 0; transform: translateY(18px);
    transition: opacity .6s cubic-bezier(.22, .8, .3, 1), transform .6s cubic-bezier(.22, .8, .3, 1);
  }
  .fx [data-reveal].is-visible { opacity: 1; transform: none; }
  .fx [data-reveal-delay="1"] { transition-delay: .1s; }
  .fx [data-reveal-delay="2"] { transition-delay: .2s; }
  .fx [data-reveal-delay="3"] { transition-delay: .3s; }

  /* micro-interactions */
  .btn { transition: background .15s, color .15s, border-color .15s, transform .18s ease, box-shadow .18s ease; }
  .btn-primary:hover, .btn-invert:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(79, 70, 229, .3); }
  .btn:active { transform: translateY(1px); box-shadow: none; }

  /* chat FAB attention pulse */
  .chat-fab { animation: fabPulse 3.2s ease-out infinite; }
  @keyframes fabPulse {
    0% { box-shadow: 0 6px 20px rgba(20, 22, 30, .25), 0 0 0 0 rgba(79, 70, 229, .4); }
    60% { box-shadow: 0 6px 20px rgba(20, 22, 30, .25), 0 0 0 16px rgba(79, 70, 229, 0); }
    100% { box-shadow: 0 6px 20px rgba(20, 22, 30, .25), 0 0 0 0 rgba(79, 70, 229, 0); }
  }

  /* FAQ answer fade-in */
  #faq details[open] p { animation: faqIn .3s ease both; }
  @keyframes faqIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

  /* chat panel pop */
  .chat-panel:not([hidden]) { animation: chatIn .28s cubic-bezier(.22, .8, .3, 1) both; }
  @keyframes chatIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
