/* ===========================================================================
   AttenBot Landing v2 — Heritage Ledger
   Tokens sourced from brand-marketing/brand-book/BRAND_BOOK.md (Paper & Ink)
   + WA chat extensions carried over from the archived GROK 05.html.
   Spec §13 amendment A10 enumerates these.
   =========================================================================== */

:root {
  /* Brand palette */
  --paper:        #FBF7EE;
  --paper-edge:   #EFE8D6;
  --paper-deep:   #E7DFCB;
  --ink:          #1A1612;
  --ink-soft:     #4A4338;
  --ink-mute:     #918874;
  --wa-green:     #25D366;
  --wa-green-deep:#1FAF54;
  --wa-dark:      #075E54;
  --wa-dark-2:    #054C44;
  --gold:         #FFD700;
  --accent-green: #3E5F4E;

  /* WhatsApp chat tokens */
  --chat-bg:      #ECE5DD;
  --bubble-in:    #FFFFFF;
  --bubble-out:   #D9FDD3;
  --tick-blue:    #53BDEB;

  /* Typography */
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body:    'Manrope', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* Spacing & radii */
  --radius-phone: 38px;
  --radius-bubble: 12px;
  --shadow-phone: 0 28px 60px -16px rgba(26, 22, 18, 0.32),
                  0 6px 12px -6px rgba(26, 22, 18, 0.12);
  --shadow-soft:  0 6px 18px -6px rgba(26, 22, 18, 0.18);

  /* Layout */
  --header-h: 64px;
  --phone-w-stage: 360px;
  --content-max: 1240px;
}

/* ──────────── Reset / base ──────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background:
    url("paper-noise.svg"),
    radial-gradient(ellipse at top, rgba(37, 211, 102, 0.04) 0%, transparent 55%),
    var(--paper);
  background-repeat: repeat, no-repeat, no-repeat;
  background-size: 320px 320px, 100% 100%, 100% 100%;
  background-attachment: fixed, fixed, fixed;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; }
em { font-style: italic; }
code, .mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--paper-edge);
  padding: 0.08em 0.4em;
  border-radius: 4px;
  color: var(--ink);
}

a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--wa-dark); }

.skip-link {
  position: absolute;
  left: 12px;
  top: -100px;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  z-index: 100;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 12px; }

/* ──────────── Sticky header ──────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--wa-dark);
  color: var(--paper);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15), 0 6px 14px -8px rgba(0, 0, 0, 0.18);
  backdrop-filter: saturate(120%);
}
.site-header__inner {
  max-width: var(--content-max);
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.site-header__meta { display: flex; flex-direction: column; line-height: 1.15; }
.site-header__name { font-size: 17px; font-weight: 600; }
.site-header__status {
  font-size: 12.5px;
  color: rgba(251, 247, 238, 0.78);
}
.site-header nav {
  margin-left: auto;
  display: flex;
  gap: 22px;
}
.site-header nav a {
  color: var(--paper);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  opacity: 0.9;
}
.site-header nav a:hover { opacity: 1; }

/* AB monogram avatar */
.ab-mark {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-green);
  color: var(--paper);
  display: inline-grid;
  place-items: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  letter-spacing: 0.5px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.ab-mark--sm { width: 30px; height: 30px; font-size: 14px; }

/* ──────────── Hero ──────────── */
.hero {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 96px 24px 80px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 64px;
  align-items: center;
}
.hero__copy h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(40px, 5vw, 64px);
  line-height: 1.05;
  margin: 0 0 24px;
  letter-spacing: -0.01em;
}
.hero__copy h1 em {
  color: var(--accent-green);
  font-style: italic;
}
.hero__tagline {
  font-size: 19px;
  color: var(--ink-soft);
  max-width: 50ch;
  margin: 0 0 32px;
}
.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 36px;
}
.hero__bullets {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.hero__bullets li::before {
  content: "—";
  color: var(--accent-green);
  margin-right: 10px;
}

/* ──────────── Buttons ──────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
/* Primary CTA: WA-dark background with white text. The "WhatsApp green"
   token (#25D366) only meets ~2:1 against white — fails WCAG AA. We keep
   the green as accent (FAB, hover wash) but the button itself ships dark. */
.btn--primary {
  background: var(--wa-dark);
  color: #fff;
  box-shadow: 0 6px 14px -4px rgba(7, 94, 84, 0.42);
}
.btn--primary:hover {
  background: var(--wa-dark-2);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -8px rgba(7, 94, 84, 0.55);
}
.btn--primary::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--wa-green);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.3);
}
.btn--ghost {
  color: var(--ink);
  border-color: var(--ink);
  background: transparent;
}
.btn--ghost:hover {
  background: var(--ink);
  color: var(--paper);
}
.btn--xl { padding: 18px 32px; font-size: 17px; }

/* ──────────── Phone frame ──────────── */
.phone {
  position: relative;
  width: 360px;
  max-width: 100%;
  margin: 0 auto;
  aspect-ratio: 360 / 720;
  background: var(--ink);
  border-radius: var(--radius-phone);
  /* Extra top padding so the notch sits entirely in the bezel and never
     overlaps the WA header inside the screen. */
  padding: 32px 12px 14px;
  box-shadow: var(--shadow-phone);
  isolation: isolate;
}
.phone__notch {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 96px;
  height: 18px;
  background: var(--ink);
  border-radius: 0 0 12px 12px;
  z-index: 3;
}
.phone__notch::after,
.phone__speaker {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
}
.phone__notch::after {
  width: 7px;
  height: 7px;
  right: 12px;
  top: 5px;
  border-radius: 50%;
}
.phone__speaker {
  width: 40px;
  height: 4px;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
}

.phone__screen {
  width: 100%;
  height: 100%;
  border-radius: calc(var(--radius-phone) - 12px);
  overflow: hidden;
  background: var(--chat-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* WA-style chat header inside the phone */
.wa-header {
  background: var(--wa-dark);
  color: var(--paper);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 14px;
  flex-shrink: 0;
}
.wa-header__back {
  font-size: 22px;
  line-height: 1;
  width: 18px;
  text-align: center;
}
.wa-header__meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  flex-grow: 1;
}
.wa-header__meta strong { font-size: 15px; font-weight: 600; }
.wa-header__meta small {
  font-size: 11px;
  color: rgba(251, 247, 238, 0.78);
}
.wa-header__icons {
  font-size: 14px;
  letter-spacing: 8px;
  opacity: 0.85;
}

/* ──────────── Chat window + bubbles ──────────── */
.chat-window {
  flex-grow: 1;
  /* Critical: `min-height: 0` lets the flex item shrink below its content
     height so overflow-y: auto actually triggers. Without this, the chat
     would grow to fit content and the auto-scroll-to-bottom call becomes a
     no-op. */
  min-height: 0;
  overflow-y: auto;
  padding: 16px 12px 12px;
  background-color: var(--chat-bg);
  background-image:
    url("paper-noise.svg"),
    radial-gradient(ellipse at center top, rgba(7, 94, 84, 0.04) 0%, transparent 60%);
  background-size: 240px 240px, 100% 100%;
  background-blend-mode: multiply, normal;
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* No smooth scroll inside the chat window — chat.js snaps to bottom on
     every bubble append, and a smooth animation would lag behind rapid
     appends, leaving the visible scroll position stuck near the top while
     content keeps piling up below the visible area. */
  scroll-behavior: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}
.chat-window::-webkit-scrollbar { width: 6px; }
.chat-window::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 6px;
}

.bubble {
  max-width: 78%;
  padding: 7px 10px 8px;
  border-radius: var(--radius-bubble);
  font-size: 14px;
  line-height: 1.42;
  color: #111B21;
  position: relative;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  animation: bubble-in 0.25s ease-out;
}
.bubble--in {
  background: var(--bubble-in);
  align-self: flex-start;
  border-top-left-radius: 4px;
}
.bubble--out {
  background: var(--bubble-out);
  align-self: flex-end;
  border-top-right-radius: 4px;
}
.bubble__meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  /* Darkened from 0.45 → 0.66 to meet WCAG AA (≥ 4.5:1) on both bubble fills. */
  color: rgba(0, 0, 0, 0.66);
  float: right;
  margin: 4px 0 -4px 8px;
  line-height: 1;
}
.bubble__ticks { color: var(--tick-blue); font-size: 12px; letter-spacing: -1px; }

.bubble strong, .bubble b { font-weight: 700; }
.bubble em, .bubble i { font-style: italic; }
.bubble .strike { text-decoration: line-through; }
.bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.scene-divider {
  align-self: center;
  background: rgba(225, 245, 254, 0.92);
  color: rgba(0, 0, 0, 0.55);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 8px;
  margin: 12px 0 6px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.1);
  letter-spacing: 0.02em;
  text-align: center;
}

.typing {
  background: var(--bubble-in);
  align-self: flex-start;
  border-radius: var(--radius-bubble);
  border-top-left-radius: 4px;
  padding: 10px 14px;
  display: inline-flex;
  gap: 4px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  animation: typing 1.2s infinite ease-in-out both;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ──────────── Chat stage ──────────── */
.chat-stage {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 80px 24px 80px;
}
.section-heading {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.1;
  margin: 0 0 12px;
  letter-spacing: -0.005em;
}
.section-heading em { color: var(--accent-green); font-style: italic; }
.section-lede {
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 56ch;
  margin: 0 0 56px;
}

.chat-stage__grid {
  display: grid;
  grid-template-columns: var(--phone-w-stage) 1fr;
  gap: 80px;
  align-items: start;
}
.chat-stage__phone {
  position: sticky;
  top: calc(var(--header-h) + 32px);
  height: min(720px, calc(100vh - var(--header-h) - 64px));
}
.phone--stage {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

.chat-stage__scenes {
  display: flex;
  flex-direction: column;
  gap: 120px;
}
.scene {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--paper-deep);
}
.scene:last-child { border-bottom: none; }
.scene__chapter {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-green);
  margin: 0 0 16px;
}
.scene__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1.15;
  margin: 0 0 20px;
  color: var(--ink);
}
.scene__copy {
  font-size: 17.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 52ch;
  margin: 0;
}

/* ──────────── Footer ──────────── */
.footer {
  background: linear-gradient(180deg, transparent 0%, var(--paper-edge) 60%);
  padding: 96px 24px 64px;
  text-align: center;
}
.footer__inner {
  max-width: 720px;
  margin: 0 auto;
}
.footer__headline {
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(34px, 4vw, 50px);
  line-height: 1.1;
  margin: 0 0 16px;
  color: var(--ink);
}
.footer__tagline {
  font-size: 18px;
  color: var(--ink-soft);
  margin: 0 0 36px;
}
.footer__contact-form {
  margin: 40px auto 24px;
  max-width: 520px;
  text-align: left;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid var(--paper-deep);
  border-radius: 18px;
  padding: 16px 24px;
}
.footer__contact-form summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15.5px;
  padding: 8px 4px;
  text-align: center;
}
.footer__contact-form[open] summary {
  margin-bottom: 12px;
  border-bottom: 1px solid var(--paper-deep);
  padding-bottom: 12px;
}
.footer__contact-form form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.footer__contact-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}
.footer__contact-form input,
.footer__contact-form textarea {
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--paper-deep);
  border-radius: 8px;
  color: var(--ink);
  resize: vertical;
}
.footer__contact-form input:focus,
.footer__contact-form textarea:focus {
  outline: 2px solid var(--accent-green);
  outline-offset: 1px;
}
.footer__form-note {
  font-size: 12.5px;
  color: var(--ink-mute);
  margin: 0;
  text-align: center;
}

.footer hr {
  border: none;
  border-top: 1px solid var(--paper-deep);
  margin: 40px auto 28px;
  max-width: 320px;
}
.footer__details {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  font-size: 14.5px;
  color: var(--ink-soft);
}
.footer__details strong { color: var(--ink); font-weight: 600; }

/* ──────────── Floating FAB ──────────── */
.wa-fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--wa-green);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 14px 28px -8px rgba(37, 211, 102, 0.55),
              0 0 0 0 rgba(37, 211, 102, 0.7);
  text-decoration: none;
  font-size: 26px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
  transition: opacity 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
  animation: fab-pulse 2.6s ease-in-out infinite;
}
.wa-fab[data-visible="true"] {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}
.wa-fab:hover {
  background: var(--wa-green-deep);
  box-shadow: 0 18px 36px -10px rgba(37, 211, 102, 0.7);
}
@keyframes fab-pulse {
  0% { box-shadow: 0 14px 28px -8px rgba(37, 211, 102, 0.55), 0 0 0 0 rgba(37, 211, 102, 0.45); }
  70% { box-shadow: 0 14px 28px -8px rgba(37, 211, 102, 0.55), 0 0 0 18px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 14px 28px -8px rgba(37, 211, 102, 0.55), 0 0 0 0 rgba(37, 211, 102, 0); }
}

/* ──────────── Hero phone chat sizing ──────────── */
.chat-window--hero { padding: 20px 12px; }

/* ──────────── Responsive: tablet (<1024px) — sticky disabled ──────────── */
@media (max-width: 1023px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 48px;
    padding-top: 64px;
    padding-bottom: 56px;
  }
  .hero__phone { max-width: 360px; margin: 0 auto; }

  .chat-stage__grid {
    grid-template-columns: 1fr;
    gap: 48px;
  }
  .chat-stage__phone {
    position: static;
    height: auto;
    max-width: 360px;
    margin: 0 auto;
  }
  .phone--stage {
    aspect-ratio: 360 / 720;
    height: auto;
    min-height: 680px;
  }
  .chat-stage__scenes {
    gap: 80px;
  }
  .scene { min-height: 0; padding-bottom: 0; }
  .chat-window {
    /* Disable internal scroll on mobile; let the phone grow tall and the page scroll. */
    overflow-y: visible;
    max-height: none;
  }
}

@media (max-width: 640px) {
  .hero { padding: 56px 20px 48px; }
  .hero__copy h1 { font-size: 38px; }
  .chat-stage, .footer { padding-left: 20px; padding-right: 20px; }
  .site-header__inner { padding: 0 16px; }
  .site-header nav { gap: 14px; }
  .site-header nav a { font-size: 14px; }
  .wa-fab { right: 18px; bottom: 18px; width: 54px; height: 54px; font-size: 22px; }
}

/* ──────────── Reduced motion ──────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
  }
  .typing span { animation: none; opacity: 0.6; }
  .wa-fab { animation: none; }
}
