/* ===== tokens ===== */
:root {
  --bg: #f6f2ea;
  --bg-alt: #fbf9f4;
  --ink: #1c1917;
  --ink-2: #57534e;
  --ink-3: #6c6660; /* muted, but >=4.5:1 on cream (WCAG AA small text) */
  --line: #e7e2d8;
  --accent: #d97706;
  --accent-deep: #9a3412;
  --font-sans: "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 14px;
  --shadow: 0 12px 32px rgba(28, 25, 23, .08);
  --maxw: 1080px;
}

/* ===== reset ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; }

/* ===== header / footer ===== */
.site-header {
  display: flex; align-items: center;
  max-width: var(--maxw); margin: 0 auto;
  padding: 22px 24px;
}

.site-footer {
  display: flex; justify-content: space-between; align-items: center;
  max-width: var(--maxw); margin: 64px auto 0;
  padding: 28px 24px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
}
.site-footer__note { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }

.wordmark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.wordmark__type { font-weight: 500; font-size: 15px; letter-spacing: .02em; }
.wordmark__type b { font-weight: 800; }

/* ===== shared section plumbing ===== */
.section {
  max-width: var(--maxw); margin: 0 auto;
  padding: 72px 24px;
}
.section__title { font-size: 28px; font-weight: 800; line-height: 1.5; }
.section__lede { color: var(--ink-2); font-size: 15px; margin-top: 10px; max-width: 38em; }

/* ===== hero ===== */
.hero {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center;
  max-width: var(--maxw); margin: 0 auto; padding: 56px 24px 64px;
}
.hero__title { font-size: 44px; font-weight: 800; line-height: 1.45; letter-spacing: -.01em; }
.hero__lede { margin-top: 18px; font-size: 15.5px; color: var(--ink-2); max-width: 30em; }
.hero__sub { margin-top: 14px; font-size: 13px; color: var(--ink-3); }
.hero__sub a { color: var(--accent-deep); }

/* ===== chat window ===== */
.chat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.chat__bar {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--bg-alt);
}
.chat__dot { width: 11px; height: 11px; border-radius: 50%; background: #e4ddd0; }
.chat__dot:nth-child(1) { background: #f0b4ab; }
.chat__dot:nth-child(2) { background: #f0d9a4; }
.chat__dot:nth-child(3) { background: #b5d4ad; }
.chat__title { margin-left: 8px; font-size: 12px; color: var(--ink-3); font-weight: 600; }
.chat__body { padding: 20px 20px 24px; min-height: 320px; }
.chat__msg--user { display: flex; justify-content: flex-end; }
.chat__msg--user .chat__q {
  background: var(--ink); color: #fafaf9;
  border-radius: 16px 16px 4px 16px; padding: 10px 16px;
  font-size: 14px; max-width: 85%;
  min-height: 1.8em;
}
.chat__turn { margin-top: 16px; }

.tool-chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg-alt);
  padding: 6px 12px; font-size: 11.5px; color: var(--ink-2);
  opacity: 0; transition: opacity .35s ease;
}
.tool-chip code { font-family: var(--font-mono); font-size: 11px; }
.tool-chip.is-running { opacity: 1; }
.tool-chip.is-running .tool-chip__gear { animation: spin 1.2s linear infinite; display: inline-block; }
.tool-chip.is-done { opacity: 1; }
.tool-chip.is-done .tool-chip__gear { color: var(--accent-deep); }
@keyframes spin { to { transform: rotate(360deg); } }

.answer { margin-top: 14px; opacity: 0; transform: translateY(8px); transition: opacity .5s ease, transform .5s ease; }
.answer.is-visible { opacity: 1; transform: none; }
.answer__text { font-size: 14px; color: var(--ink-2); }
.answer__big { font-size: 18px; color: var(--ink); }

.dist { display: flex; align-items: flex-end; gap: 7px; height: 86px; margin-top: 14px; }
.dist span {
  flex: 1; background: var(--accent); border-radius: 3px 3px 0 0;
  height: var(--h); transform-origin: bottom; transform: scaleY(0);
  transition: transform .6s cubic-bezier(.2,.8,.3,1);
}
.dist span.dist__median { background: var(--ink); }
.answer.is-visible .dist span { transform: scaleY(1); }
.dist span:nth-child(1) { transition-delay: .15s } .dist span:nth-child(2) { transition-delay: .25s }
.dist span:nth-child(3) { transition-delay: .35s } .dist span:nth-child(4) { transition-delay: .45s }
.dist span:nth-child(5) { transition-delay: .55s } .dist span:nth-child(6) { transition-delay: .65s }
.dist span:nth-child(7) { transition-delay: .75s }
.dist__axis { display: flex; justify-content: space-between; margin-top: 6px; font-size: 10px; color: var(--ink-3); font-family: var(--font-mono); }

/* ===== chat animation states (driven by main.js) ===== */
/* While JS is animating, it removes .is-done/.is-visible and re-adds them in sequence. */
.chat.is-animating .chat__q { white-space: pre-wrap; }
.chat__cursor {
  display: inline-block; width: 1px; height: 1em; background: #fafaf9;
  vertical-align: -0.15em; margin-left: 2px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .answer, .dist span, .tool-chip { transition: none !important; }
  .tool-chip.is-running .tool-chip__gear { animation: none; }
}

/* ===== marquee ===== */
.marquee {
  overflow: hidden; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--bg-alt); padding: 14px 0;
}
.marquee__track { display: flex; gap: 12px; width: max-content; animation: marquee 28s linear infinite; }
.marquee:hover .marquee__track { animation-play-state: paused; }
.marquee__chip {
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 18px; font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
@keyframes marquee { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .marquee__track { animation: none; flex-wrap: wrap; width: auto; padding: 0 24px; }
  .marquee__chip[aria-hidden] { display: none; }
}

/* ===== personas ===== */
.personas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 34px; }
.persona {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 24px;
}
.persona--offset1 { margin-top: 28px; }
.persona--offset2 { margin-top: 56px; }
.persona__icon { margin-bottom: 14px; }
.persona__who { font-size: 15px; font-weight: 700; color: var(--accent-deep); }
.persona__q { margin-top: 12px; font-size: 13.5px; color: var(--ink-2); }
.persona__a { margin-top: 14px; font-size: 12.5px; color: var(--ink-3); }

/* ===== scroll reveal ===== */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-visible { opacity: 1; transform: none; }
.persona.reveal:nth-child(2) { transition-delay: .12s; }
.persona.reveal:nth-child(3) { transition-delay: .24s; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }
/* With JS off there is no IntersectionObserver to reveal sections — show them. */
@media (scripting: none) { .reveal { opacity: 1; transform: none; transition: none; } }

/* ===== percentiles ===== */
.section--alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); max-width: none; }
.section--alt > * { max-width: var(--maxw); margin-left: auto; margin-right: auto; }
.section__example { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); margin-left: 10px; }

.pctls { display: flex; gap: 12px; margin-top: 34px; align-items: stretch; }
.pctl {
  flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 14px; text-align: center;
}
.pctl__label { display: block; font-size: 11px; color: var(--ink-3); }
.pctl__value { display: block; margin-top: 8px; font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.pctl--median { background: var(--ink); border-color: var(--ink); transform: scale(1.06); }
.pctl--median .pctl__label { color: #d6d3d1; }
.pctl--median .pctl__value { color: #fff; font-size: 24px; }

/* ===== texture ===== */
/* Generated washi grain stretched cover (no tiling -> no seams), SVG noise underneath as fallback. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: .35;
  background-image: url("assets/washi.jpg"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.55 0 0 0 0 0.52 0 0 0 0 0.47 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: cover, 240px;
  background-blend-mode: multiply;
}

/* ===== responsive ===== */
@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; gap: 36px; padding-top: 32px; }
  .hero__title { font-size: 32px; }
  .personas { grid-template-columns: 1fr; }
  .persona--offset1, .persona--offset2 { margin-top: 0; }
  .pctls { flex-wrap: wrap; }
  .pctl { flex: 1 1 30%; }
  .pctl--median { flex-basis: 100%; order: -1; transform: none; }
  .section { padding: 56px 24px; }
}
@media (max-width: 480px) {
  .hero__title { font-size: 27px; }
  .chat__body { min-height: 280px; padding: 16px 14px 20px; }
  .pctl { flex-basis: 45%; }
}
