/* ArchiChat site styles. Shared by every page. Page-specific rules live in each page's <style>.
   Mobile-first: base rules are the phone layout. Enhancements at two breakpoints:
     @media (min-width: 721px)  — tablet and up (two-column layouts, inline nav, sticky CTA hidden)
     @media (min-width: 1024px) — desktop (wider gutters, dense chart labels, generous section padding) */

:root {
  --bg: #0f1316;
  --bg2: #121719;
  --surface: #161b20;
  --line: #232a31;
  --line2: #3a434d;
  --text: #e8ecef;
  --muted: #b4bcc6;
  --dim: #8b95a1;
  --accent: #6fd3ea;
  --accent-ink: #0f1316;
  --decay: #7c8694;
  --sans: 'Schibsted Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --wrapW: 1240px;
  --padX: 20px;
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 721px) { :root { --padX: 24px } }

*, *::before, *::after { box-sizing: border-box }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto } }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
body.nav-open { overflow: hidden }

a { color: var(--text) }
a:hover { color: var(--accent) }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px }

img, svg, video { display: block; max-width: 100% }
img { height: auto }

.wrap {
  width: 100%;
  max-width: var(--wrapW);
  margin: 0 auto;
  padding-left: var(--padX);
  padding-right: var(--padX);
}

.wrap--narrow { max-width: 800px }

/* ── Type ── */
h1, h2, h3, h4 { font-family: var(--sans); font-weight: 600; color: var(--text); margin: 0; overflow-wrap: break-word }
h1 { font-size: clamp(40px, 11vw, 76px); line-height: 0.98; letter-spacing: -2px; text-wrap: balance }
h2 { font-size: clamp(30px, 8.4vw, 48px); line-height: 1.02; letter-spacing: -1.2px; text-wrap: balance }
h3 { font-size: 22px; letter-spacing: -0.4px }
.lead { margin: 0; font-size: 18px; line-height: 1.55; color: var(--muted); text-wrap: pretty }
.small { font-size: 14px; color: var(--dim) }
.mono { font-family: var(--mono); font-size: 12px; color: var(--dim) }
.text-grad { color: inherit }
@media (min-width: 721px) {
  h1 { font-size: clamp(42px, 5.4vw, 76px); letter-spacing: -2.4px }
  h2 { font-size: clamp(32px, 3.6vw, 48px) }
  h3 { font-size: 24px }
  .lead { font-size: 19px }
}

/* ── Buttons & links ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 11px 18px;
  border: 1px solid var(--line2);
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--text); color: var(--text) }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) }
.btn.primary:hover { background: #8adcee; border-color: #8adcee; color: var(--accent-ink) }
.btn.large { min-height: 48px; padding: 14px 22px; font-size: 16px }
.link { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--text); text-decoration: underline; text-underline-offset: 4px }
.link:hover { color: var(--accent) }

/* ── Header ── */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg) }
.site-header-inner {
  max-width: var(--wrapW);
  margin: 0 auto;
  padding: 14px var(--padX);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
}
.brand { display: flex; align-items: center; gap: 10px; min-height: var(--tap); text-decoration: none; color: var(--text) }
.brand:hover { color: var(--text) }
.brand-mark { width: 26px; height: 26px; flex-shrink: 0 }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.4px }

/* Toggle: visible on phones, hidden once the inline nav fits. Stays above the overlay so it can close it. */
.nav-toggle {
  position: relative;
  z-index: 60;
  display: flex;
  width: var(--tap); height: var(--tap);
  flex-shrink: 0;
  align-items: center; justify-content: center;
  border: 1px solid var(--line2);
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}
.nav-toggle svg { overflow: visible }
.nav-toggle rect { transform-box: fill-box; transform-origin: center; transition: transform .2s, opacity .2s }
.nav-toggle[aria-expanded="true"] rect:nth-child(1) { transform: translateY(6.25px) rotate(45deg) }
.nav-toggle[aria-expanded="true"] rect:nth-child(2) { opacity: 0 }
.nav-toggle[aria-expanded="true"] rect:nth-child(3) { transform: translateY(-6.25px) rotate(-45deg) }

/* Phone nav: full-screen overlay, opened by .nav-toggle (site.js) */
.site-nav {
  display: none;
  position: fixed; inset: 0; z-index: 50;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: rgba(15,19,22,.97);
  flex-direction: column; align-items: stretch; justify-content: flex-start;
  gap: 4px;
  padding: 96px var(--padX) calc(24px + var(--safe-b));
  font-size: 15px;
}
.site-nav.open { display: flex }
.nav-link { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); color: var(--muted); text-decoration: none }
.nav-link:hover, .nav-link[aria-current="page"] { color: var(--text) }
.site-nav .nav-link { font-size: 20px; padding: 12px 16px; border-radius: 3px }
.site-nav .nav-link:hover { background: var(--surface) }
.site-nav .nav-link[aria-current="page"] { background: var(--surface) }
.site-nav .btn { margin-top: 12px; min-height: 48px; font-size: 16px }

@media (min-width: 721px) {
  .site-header-inner { padding: 18px var(--padX); gap: 24px }
  .nav-toggle { display: none }
  .site-nav, .site-nav.open {
    display: flex;
    position: static; inset: auto; z-index: auto;
    overflow: visible;
    background: none;
    flex-direction: row; align-items: center; justify-content: flex-start;
    gap: 28px; padding: 0;
  }
  .site-nav .nav-link { font-size: 15px; padding: 0 2px; border-radius: 0 }
  .site-nav .nav-link:hover, .site-nav .nav-link[aria-current="page"] { background: none }
  .site-nav .btn { margin-top: 0; min-height: var(--tap); font-size: 15px }
  body.nav-open { overflow: visible }
}

/* ── Sections ── */
.section { border-top: 1px solid var(--line) }
.section-inner { max-width: var(--wrapW); margin: 0 auto; padding: 56px var(--padX); width: 100% }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; flex-wrap: wrap }
.section-head p { margin: 0; color: var(--muted); max-width: 460px }
.section.alt { background: var(--bg2) }
@media (min-width: 721px) { .section-inner { padding-top: 72px; padding-bottom: 72px } }
@media (min-width: 1024px) { .section-inner { padding-top: 88px; padding-bottom: 88px } }

/* Definition list as spec sheet */
.spec { margin: 0; display: flex; flex-direction: column; font-size: 16px }
.spec > div { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 16px 0; border-top: 1px solid var(--line) }
.spec > div:last-child { border-bottom: 1px solid var(--line) }
.spec dt { color: var(--dim) }
.spec dd { margin: 0 }
@media (min-width: 721px) { .spec > div { grid-template-columns: minmax(140px, 1fr) 2fr; gap: 16px } }

/* Row list (domains, blog) */
.rows { list-style: none; margin: 0; padding: 0 }
.rows > li { padding: 20px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px }
.rows > li:last-child { border-bottom: 1px solid var(--line) }
.rows h3 { font-size: 20px; letter-spacing: -0.3px }
.rows p { margin: 0; color: var(--muted); font-size: 16px }
/* Row links get a 44px tap zone without changing the visual rhythm */
.rows a { display: inline-block; font-weight: 500; text-decoration: none; padding: 9px 0; margin: -9px 0 }

/* ── FAQ (details) ── */
.faq h2 { font-size: 28px; letter-spacing: -0.6px; margin-bottom: 22px }
.faq details { border-top: 1px solid var(--line) }
.faq details:last-of-type { border-bottom: 1px solid var(--line) }
.faq summary {
  list-style: none;
  cursor: pointer;
  min-height: 56px;
  padding: 16px 0;
  font-weight: 600;
  font-size: 17px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  -webkit-user-select: none; user-select: none;
}
.faq summary::-webkit-details-marker { display: none }
.faq summary::marker { content: '' }
.faq summary::after { content: '+'; color: var(--dim); font-weight: 400; font-size: 24px; line-height: 1; flex-shrink: 0; width: 24px; text-align: center; transition: transform .2s }
.faq details[open] summary::after { transform: rotate(45deg); color: var(--accent) }
.faq-body { color: var(--muted); font-size: 16px; padding-bottom: 18px }
.faq-body a { color: var(--text) }

/* FAQ (static dl) */
.qa { margin: 0; display: flex; flex-direction: column; gap: 22px }
.qa > div { display: flex; flex-direction: column; gap: 6px }
.qa dt { font-weight: 600 }
.qa dd { margin: 0; color: var(--muted); font-size: 16px }

/* ── Footer ── */
.site-footer { border-top: 1px solid var(--line) }
.site-footer-inner {
  max-width: var(--wrapW);
  margin: 0 auto;
  padding: 20px var(--padX) calc(24px + var(--safe-b));
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  font-size: 14px; color: var(--dim);
}
.site-footer-inner > span { display: inline-block; padding: 11px 0 }
.site-footer a { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--dim); text-decoration: none }
.site-footer a:hover { color: var(--text) }
.footer-nav { display: flex; gap: 4px 20px; flex-wrap: wrap }
@media (min-width: 721px) {
  .site-footer-inner { flex-direction: row; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; padding: 16px var(--padX) }
  .footer-nav { gap: 22px }
}

/* ── Sticky phone CTA (shown by site.js after scrolling; hidden near page CTAs/footer) ── */
.sticky-cta {
  position: fixed; left: 12px; right: 12px; z-index: 40;
  bottom: calc(12px + var(--safe-b));
  display: flex; gap: 8px; justify-content: center;
  padding: 8px;
  background: rgba(15,19,22,.94);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid var(--line2);
  border-radius: 6px;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .3s, transform .3s;
}
.sticky-cta.shown { opacity: 1; transform: translateY(0); pointer-events: auto }
.sticky-cta .btn { flex: 1 1 0; min-width: 0; padding: 12px 8px; font-size: 14px }
.sticky-cta .btn.primary { flex: 1.3 1 0 }
@media (min-width: 721px) { .sticky-cta { display: none } }

/* ── Article pages (blog posts, agent drift) ── */
.page-main { padding-top: 40px; padding-bottom: 72px }
.breadcrumb { font-size: 14px; color: var(--dim); margin: 0 0 28px; overflow-wrap: anywhere }
.breadcrumb a { display: inline-block; color: var(--dim); text-decoration: none; padding: 8px 0; margin: -8px 0 }
.breadcrumb a:hover { color: var(--text) }
.article-meta { font-family: var(--mono); font-size: 12px; color: var(--dim); margin: 0 0 20px; letter-spacing: .2px; line-height: 1.8 }
.article-meta a { color: inherit; text-decoration: none }
article h1 { font-size: clamp(34px, 9.4vw, 56px); letter-spacing: -1.6px; margin: 0 0 20px }
article .lead { margin: 0 0 36px; max-width: 640px }
article h2 { font-size: clamp(26px, 7vw, 32px); letter-spacing: -0.8px; margin: 44px 0 14px }
article h3 { font-size: 20px; letter-spacing: -0.3px; margin: 32px 0 10px }
article p, article li { color: var(--muted); font-size: 17px; line-height: 1.7 }
article p { margin: 0 0 20px }
article p strong, article li strong { color: var(--text) }
article ul, article ol { margin: 0 0 20px; padding-left: 22px }
article li { margin: 6px 0 }
article blockquote { margin: 28px 0; padding: 4px 0 4px 18px; border-left: 2px solid var(--accent) }
article blockquote p { margin: 0; color: var(--text); font-size: 18px }
a.inline { color: var(--text); text-decoration: underline; text-underline-offset: 4px }
a.inline:hover { color: var(--accent) }
code { font-family: var(--mono); font-size: 14px; background: var(--surface); padding: 2px 6px; border-radius: 3px; color: var(--text); overflow-wrap: anywhere }
pre { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 16px; background: var(--surface); border-radius: 3px; font-family: var(--mono); font-size: 14px; line-height: 1.6 }
pre code { padding: 0; background: none; overflow-wrap: normal; white-space: pre }

/* Tables scroll sideways on phones instead of crushing their columns */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 24px calc(-1 * var(--padX)); padding: 0 var(--padX); scrollbar-width: thin }
table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 15px }
th { text-align: left; font-weight: 600; color: var(--text); padding: 12px 16px 12px 0; border-bottom: 2px solid var(--text) }
td { padding: 14px 16px 14px 0; border-bottom: 1px solid var(--line); color: var(--muted); vertical-align: top }
td:first-child { color: var(--text); font-weight: 500 }
@media (min-width: 721px) {
  .table-wrap { margin: 24px 0; padding: 0 }
  table { min-width: 0 }
}

.faq-item { border-top: 1px solid var(--line); padding: 20px 0 }
.faq-item:last-child { border-bottom: 1px solid var(--line) }
.faq-q { font-weight: 600; font-size: 17px; color: var(--text); margin: 0 0 8px }
.faq-a { font-size: 16px; color: var(--muted); margin: 0 }
.article-cta { margin-top: 48px; padding: 24px 20px; border: 1px solid var(--line2); background: var(--bg2) }
.article-cta h3 { font-size: 22px; letter-spacing: -0.5px; margin: 0 0 10px }
.article-cta p { font-size: 16px; margin: 0 0 22px; color: var(--muted) }
.cta-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center }
@media (min-width: 721px) {
  .page-main { padding-top: 56px; padding-bottom: 96px }
  .breadcrumb { margin-bottom: 40px }
  article h1 { font-size: clamp(36px, 5vw, 56px); letter-spacing: -1.8px; margin-bottom: 24px }
  article .lead { margin-bottom: 44px }
  article h2 { font-size: clamp(26px, 3vw, 32px); margin: 52px 0 16px }
  article ul, article ol { padding-left: 24px }
  article blockquote { padding-left: 20px }
  .article-cta { margin-top: 64px; padding: 36px 32px }
  .article-cta h3 { font-size: 24px }
}

/* Blog list */
.posts { display: flex; flex-direction: column; border-top: 1px solid var(--line) }
.post { display: block; padding: 22px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text) }
.post:hover { color: var(--text) }
.post:hover .post-title { color: var(--accent) }
.post-tag { font-family: var(--mono); font-size: 12px; color: var(--dim); margin: 0 0 8px }
.post-title { font-size: 21px; font-weight: 600; letter-spacing: -0.4px; margin: 0 0 8px; transition: color .15s; line-height: 1.25 }
.post-desc { font-size: 16px; color: var(--muted); margin: 0 }
@media (min-width: 721px) {
  .post { padding: 26px 0 }
  .post-title { font-size: 22px }
}

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

/* Legacy aliases for inline styles on older pages */
:root { --c: var(--accent); --p: var(--accent); --cardBorder: var(--line); --card: var(--surface) }
.muted-link { color: var(--muted); text-decoration: none }
.muted-link:hover { color: var(--text) }

/* Extraction blocks: key points, sources, related reading (articles and concept pages) */
.key-points { max-width: 720px; margin: 0 0 40px; padding: 20px 22px; border: 1px solid var(--line); background: var(--surface); border-radius: 4px }
article .key-points h2, .key-points h2 { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--dim); letter-spacing: .2px; margin: 0 0 12px }
.key-points ul { margin: 0; padding: 0 0 0 18px; display: grid; gap: 8px }
.key-points li { color: var(--text); font-size: 16px; line-height: 1.55 }
.sources ol { margin: 0; padding: 0 0 0 20px; display: grid; gap: 8px; color: var(--muted); font-size: 15px; line-height: 1.55 }
.sources a { color: var(--text) }
.related .rows span { color: var(--muted); font-size: 16px }
.related .rows a { color: var(--text) }
@media (min-width: 721px) { .key-points { padding: 24px 26px } }
