:root {
  --bg: #f7f3ec;
  --bg-soft: #fbf8f2;
  --surface: #ffffff;
  --ink: #14201f;
  --ink-soft: #5b6663;
  --ink-faint: #666d69; /* darkened from #8a928f to clear WCAG AA (4.5:1) on cream/white */
  --rule: #e3dbcc;
  --accent: #1c2a5a;
  --accent-deep: #131e44;
  --accent-soft: #e8ebf3;
  --periwinkle: #b4bbd9;
  --gold: #8a6620; /* darkened from #b78a4a so the eyebrow label clears AA on cream */
  --user: #efe7d6;
  --shadow: 0 1px 2px rgba(20, 30, 30, 0.04), 0 8px 32px rgba(20, 30, 30, 0.06);
  --max: 680px;

  --display: "Source Serif Pro", Georgia, "Times New Roman", serif;
  --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-feature-settings: "ss01", "ss02", "calt", "liga";
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* When the chat is active, lock the viewport so only the transcript scrolls.
   For all other states, allow normal page scroll so long hero copy is reachable. */
body.is-chat {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* The HTML `hidden` attribute must beat our flex rules below. */
[hidden] {
  display: none !important;
}

.page {
  flex: 1 1 auto;
  min-height: 0;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px 32px;
  display: flex;
  flex-direction: column;
}

body.is-chat .page {
  padding-bottom: 12px;
}

.page__header {
  flex: 0 0 auto;
  padding-bottom: 18px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.brand__logo {
  display: block;
  height: 56px;
  width: auto;
  max-width: 260px;
}

.brand__sub {
  font-family: var(--ui);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-faint);
}

/* Generic state container */
.state {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.state h1 {
  margin: 0 0 12px;
}

.state p {
  color: var(--ink-soft);
  margin: 0 0 14px;
}

.muted {
  color: var(--ink-faint);
  font-family: var(--ui);
  font-size: 14px;
}

/* Hero typography shared by intro / error / completed */
.hero__title {
  font-family: var(--display);
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.08;
  color: var(--ink);
  margin: 0 0 20px;
}

.hero__eyebrow {
  font-family: var(--ui);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin: 0 0 14px;
}

.hero__body p {
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 16px;
}

.hero__body p:last-child {
  margin-bottom: 0;
}

.hero__expect {
  list-style: none;
  padding: 18px 22px;
  margin: 28px 0;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero__expect li {
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--accent-deep);
  position: relative;
  padding-left: 18px;
}

.hero__expect li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  align-self: flex-start;
  font-family: var(--ui);
  background: var(--accent);
  color: white;
  border: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 16px 30px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(19, 30, 68, 0.12), 0 12px 28px rgba(19, 30, 68, 0.22);
  transition: transform 120ms ease-out, background 120ms ease-out, box-shadow 160ms ease-out;
  -webkit-tap-highlight-color: transparent;
}

.cta:hover {
  background: var(--accent-deep);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(19, 30, 68, 0.16), 0 18px 36px rgba(19, 30, 68, 0.28);
}

.cta:active {
  transform: translateY(1px);
}

/* Primary CTA emphasis — heavier and bolder, with three layered micro-motions:
   a breathing gold glow (resting attention), a periodic shine sweep (premium
   catch-the-eye), and an arrow nudge. All paused under prefers-reduced-motion. */
.cta--primary {
  position: relative;
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.015em;
  padding: 17px 34px;
}

/* Shine sweep element */
.cta--primary::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 55%;
  height: 100%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, 0.32) 50%, transparent 100%);
  transform: translateX(-180%) skewX(-12deg);
  pointer-events: none;
}

@keyframes ctaArrow {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(6px); }
}

@keyframes ctaGlow {
  0%, 100% {
    box-shadow: 0 2px 4px rgba(19, 30, 68, 0.12), 0 12px 28px rgba(19, 30, 68, 0.22),
      0 0 0 0 rgba(138, 102, 32, 0);
  }
  50% {
    box-shadow: 0 4px 8px rgba(19, 30, 68, 0.16), 0 16px 34px rgba(19, 30, 68, 0.30),
      0 0 0 7px rgba(138, 102, 32, 0.16);
  }
}

@keyframes ctaShine {
  0% { transform: translateX(-180%) skewX(-12deg); }
  16%, 100% { transform: translateX(260%) skewX(-12deg); }
}

@media (prefers-reduced-motion: no-preference) {
  .cta--primary {
    animation: ctaGlow 3s ease-in-out infinite;
  }
  .cta--primary::after {
    animation: ctaShine 5s ease-in-out infinite;
  }
  .cta--primary .cta__arrow {
    animation: ctaArrow 1.7s ease-in-out infinite;
  }
}

.cta--primary:hover {
  animation-play-state: paused;
}

.cta--primary:hover .cta__arrow {
  animation: none;
}

.cta:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cta__arrow {
  display: inline-block;
  transition: transform 120ms ease-out;
}

.cta:hover .cta__arrow {
  transform: translateX(2px);
}

.hero__fineprint {
  font-family: var(--ui);
  font-size: 13px;
  color: var(--ink-faint);
  margin: 16px 0 0;
  line-height: 1.5;
}

/* State-specific layouts */
.state--loading,
.state--error,
.state--completed,
.state--intro {
  justify-content: flex-start;
}

.state--chat {
  justify-content: flex-end;
  gap: 12px;
}

/* Chat transcript scrolls internally; composer stays anchored. */
.transcript {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 2px;
}

.bubble {
  padding: 14px 18px;
  border-radius: 16px;
  max-width: 92%;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 19px;
  line-height: 1.55;
}

.bubble--assistant {
  background: var(--surface);
  border: 1px solid var(--rule);
  align-self: flex-start;
  box-shadow: 0 1px 0 rgba(20, 30, 30, 0.02);
}

.bubble--user {
  background: var(--user);
  align-self: flex-end;
  font-family: var(--ui);
  font-size: 18px;
}

.bubble--assistant.is-streaming::after {
  content: "▌";
  display: inline-block;
  margin-left: 2px;
  opacity: 0.6;
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

.composer {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 14px;
  padding: 8px 8px 8px 14px;
  box-shadow: var(--shadow);
}

.composer textarea {
  flex: 1 1 auto;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--ui);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  padding: 6px 0;
  min-height: 40px;
  max-height: 160px;
}

.composer__send {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  align-self: stretch;
  transition: background 120ms ease-out;
  -webkit-tap-highlight-color: transparent;
}

.composer__send:hover {
  background: var(--accent-deep);
}

.composer__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat__footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 4px 0;
}

.composer__hint {
  font-family: var(--ui);
  font-size: 11px;
  color: var(--ink-faint);
  margin: 0;
}

.finish-btn {
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent-deep);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out;
  -webkit-tap-highlight-color: transparent;
}

.finish-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.finish-btn:active {
  transform: translateY(1px);
}

.finish-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.site-footer {
  flex: 0 0 auto;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 18px 24px 24px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--ui);
  font-size: 12px;
  color: var(--ink-faint);
}

.site-footer__copy {
  margin: 0;
}

.site-footer__nav a {
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
  /* Expand the tap area to 44px without changing the visual footer height.
     Underline via text-decoration (not border) so padding doesn't detach it. */
  display: inline-block;
  padding: 14px 2px;
  margin: -14px 0;
  transition: color 120ms ease-out, text-decoration-color 120ms ease-out;
}

.site-footer__nav a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

body.is-chat .site-footer {
  display: none;
}

@media (max-width: 520px) {
  .page {
    padding: 18px 18px 24px;
  }
  body.is-chat .page {
    padding: 14px 16px 12px;
  }
  .page__header {
    padding-bottom: 14px;
    margin-bottom: 20px;
  }
  .brand__logo {
    height: 44px;
  }
  .hero__title {
    font-size: clamp(28px, 8vw, 36px);
  }
  .hero__body p {
    font-size: 17px;
  }
  .hero__expect {
    padding: 16px 18px;
    margin: 22px 0;
  }
  .bubble {
    padding: 12px 15px;
    max-width: 100%;
    font-size: 18px;
  }
  .bubble--user {
    font-size: 17px;
  }
  .composer__hint {
    display: none;
  }
  .chat__footer {
    justify-content: flex-end;
  }
  .site-footer {
    padding: 14px 18px 20px;
  }
}
