/* StackTrellis - Phase 1 styles. Tokens first, then base, components, pages. */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --color-bg: #ffffff;
  --color-surface: #f5f6fd;
  --color-text: #0f172a;
  --color-text-muted: #4a5568;
  --color-primary: #4338ca;
  --color-on-primary: #ffffff;
  --color-accent: #22d3ee;
  --color-border: #e2e5f5;
  --color-focus: #4338ca;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 80px;
  --radius-sm: 6px; --radius-md: 12px; --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .10);
  --container: 1120px;
  --ease: cubic-bezier(.2, .6, .2, 1);
  --header-h: 68px;
  --hero-a: #dfe3ff;
  --hero-b: #d6f6fd;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --color-bg: #0b1020;
  --color-surface: #10172e;
  --color-text: #e8ecf8;
  --color-text-muted: #a3b0c7;
  --color-primary: #a5b4fc;
  --color-on-primary: #0b1020;
  --color-border: #242e52;
  --color-focus: #a5b4fc;
  --hero-a: #262f6b;
  --hero-b: #0c3a4a;
  --shadow-sm: 0 0 0 1px #242e52;
  --shadow-md: 0 0 0 1px #242e52;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-sans); font-size: 1.0625rem; line-height: 1.6;
  color: var(--color-text); background: var(--color-bg);
}
img, svg { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 var(--space-4); font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 1.2rem + 3.6vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 1.1rem + 1.8vw, 2.3rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 var(--space-4); }
a { color: var(--color-primary); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; border-radius: 3px; }
ul, ol { padding-left: 1.25rem; margin: 0 0 var(--space-4); }
hr { border: 0; border-top: 1px solid var(--color-border); margin: var(--space-6) 0; }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--space-4); }
.section { padding-block: var(--space-7); }
.section--alt { background: var(--color-surface); }
.section__head { max-width: 640px; margin-bottom: var(--space-6); }
.section__head p { color: var(--color-text-muted); }
.eyebrow { font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--color-primary); margin-bottom: var(--space-2); }
.muted { color: var(--color-text-muted); }
.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--color-primary); color: var(--color-on-primary); padding: 8px 14px; border-radius: var(--radius-sm); z-index: 200; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (min-width: 640px) { .container { padding-inline: var(--space-5); } .section { padding-block: var(--space-8); } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 10px 20px; border-radius: var(--radius-md); border: 2px solid transparent;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform 150ms var(--ease), background-color 150ms var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost { border-color: var(--color-border); color: var(--color-text); background: transparent; }
.btn--ghost:hover { border-color: var(--color-primary); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* ---------- Header / nav ---------- */
.site-header { position: sticky; top: 0; z-index: 100; background: var(--color-bg); border-bottom: 1px solid var(--color-border); }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; min-height: var(--header-h); gap: var(--space-4); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--color-text); text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand svg { width: 34px; height: 34px; }
.brand .brand__accent { color: var(--color-primary); }

.nav-toggle { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; background: none; border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text); cursor: pointer; }
.nav { display: none; position: absolute; top: var(--header-h); left: 0; right: 0; background: var(--color-bg); border-bottom: 1px solid var(--color-border); padding: var(--space-3) var(--space-4) var(--space-5); max-height: calc(100vh - var(--header-h)); overflow-y: auto; }
.nav.is-open { display: block; }
.nav ul { list-style: none; margin: 0; padding: 0; }
.nav a, .nav button.nav__link { display: block; width: 100%; text-align: left; padding: 12px 4px; color: var(--color-text); text-decoration: none; font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav button.nav__link:hover, .nav a[aria-current="page"] { color: var(--color-primary); }
.nav__sub { display: none; padding-left: var(--space-4); }
.nav__sub.is-open { display: block; }
.nav__sub a { font-weight: 400; color: var(--color-text-muted); padding: 8px 4px; }
.nav__sub small { display: block; padding: 8px 4px 0; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--color-text-muted); }
.header-tools { display: flex; align-items: center; gap: var(--space-2); }
.theme-toggle { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text); cursor: pointer; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.header-cta { display: none; }

@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .nav { display: block; position: static; border: 0; padding: 0; max-height: none; overflow: visible; background: none; }
  .nav > ul { display: flex; align-items: center; gap: var(--space-1); }
  .nav a, .nav button.nav__link { padding: 10px 12px; width: auto; }
  .has-sub { position: relative; }
  .nav__sub { position: absolute; top: 100%; left: 0; min-width: 260px; padding: var(--space-3); background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
  .header-cta { display: inline-flex; }
}

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding-block: var(--space-7) var(--space-8); background: radial-gradient(700px 380px at 90% 0, var(--hero-a) 0, transparent 65%), radial-gradient(500px 300px at 0 100%, var(--hero-b) 0, transparent 60%), var(--color-bg); }
.hero__lattice { position: absolute; inset: 0; color: var(--color-primary); opacity: .09; pointer-events: none; }
.hero__lattice svg { width: 100%; height: 100%; }
.hero .container { position: relative; }
.hero__tag { font-size: 1.05rem; color: var(--color-text-muted); max-width: 620px; }
.hero h1 .accent { color: var(--color-primary); }
.page-hero { padding-block: var(--space-7); background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.page-hero p { max-width: 680px; color: var(--color-text-muted); font-size: 1.15rem; margin-bottom: 0; }
.breadcrumb { font-size: .9rem; margin-bottom: var(--space-3); color: var(--color-text-muted); }
.breadcrumb a { color: var(--color-text-muted); }

/* ---------- Cards / grids ---------- */
.grid { display: grid; gap: var(--space-5); }
@media (min-width: 640px) { .grid--2, .grid--3, .grid--4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid--3 { grid-template-columns: repeat(3, 1fr); } .grid--4 { grid-template-columns: repeat(4, 1fr); } }
.card { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.section--alt .card { background: var(--color-bg); }
.card h3 { margin-bottom: var(--space-2); }
.card p { color: var(--color-text-muted); }
.card ul { color: var(--color-text-muted); }
.card .card__link { margin-top: auto; font-weight: 600; }
.card__icon { width: 44px; height: 44px; border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-primary); display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-4); border: 1px solid var(--color-border); }
.card--link { text-decoration: none; color: inherit; transition: transform 150ms var(--ease), border-color 150ms var(--ease); }
.card--link:hover { transform: translateY(-2px); border-color: var(--color-primary); }
.card__thumb { aspect-ratio: 16 / 10; border-radius: var(--radius-md); margin-bottom: var(--space-4); background: var(--color-surface); border: 1px dashed var(--color-border); display: flex; align-items: center; justify-content: center; color: var(--color-text-muted); font-size: .9rem; }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text-muted); margin: 0 6px 6px 0; }

/* Process steps */
.steps { list-style: none; padding: 0; counter-reset: step; display: grid; gap: var(--space-5); }
@media (min-width: 900px) { .steps { grid-template-columns: repeat(4, 1fr); } }
.steps li { counter-increment: step; position: relative; padding-top: var(--space-6); }
.steps li::before { content: "0" counter(step); position: absolute; top: 0; left: 0; font-weight: 800; font-size: 1.6rem; color: var(--color-primary); }
.steps h3 { margin-bottom: var(--space-1); }
.steps p { color: var(--color-text-muted); margin: 0; }

/* Testimonials */
.quote { margin: 0; }
.quote blockquote { margin: 0 0 var(--space-4); font-size: 1.05rem; }
.quote figcaption { font-size: .9rem; color: var(--color-text-muted); }

/* FAQ */
.faq { max-width: 800px; }
.faq details { border-bottom: 1px solid var(--color-border); padding: var(--space-4) 0; }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: var(--space-4); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--color-primary); }
.faq details[open] summary::after { content: "\2212"; }
.faq details p { margin: var(--space-3) 0 0; color: var(--color-text-muted); }

/* CTA band */
.cta-band { background: var(--color-text); color: var(--color-bg); text-align: center; border-radius: var(--radius-lg); padding: var(--space-7) var(--space-5); }
.cta-band p { max-width: 560px; margin-inline: auto; opacity: .85; }
.cta-band .btn-row { justify-content: center; }
.cta-band .btn--primary { background: var(--color-accent); color: #0f172a; }
.cta-band .btn--ghost { color: var(--color-bg); border-color: rgba(128, 128, 128, .6); }

/* Prose (legal, blog, details) */
.prose { max-width: 760px; }
.prose h2 { margin-top: var(--space-6); font-size: 1.5rem; }
.prose h3 { margin-top: var(--space-5); }
.notice { border-left: 4px solid var(--color-accent); background: var(--color-surface); padding: var(--space-4); border-radius: var(--radius-sm); margin-bottom: var(--space-5); }
.meta { color: var(--color-text-muted); font-size: .9rem; }
.two-col { display: grid; gap: var(--space-6); }
@media (min-width: 900px) { .two-col { grid-template-columns: 1.6fr 1fr; align-items: start; } }
.aside-box { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-5); }
.checklist { list-style: none; padding: 0; }
.checklist li { padding-left: 28px; position: relative; margin-bottom: var(--space-2); }
.checklist li::before { content: ""; position: absolute; left: 0; top: .5em; width: 14px; height: 8px; border-left: 3px solid var(--color-primary); border-bottom: 3px solid var(--color-primary); transform: rotate(-45deg); }

/* ---------- Forms ---------- */
.form { display: grid; gap: var(--space-4); }
.field label { display: block; font-weight: 600; margin-bottom: var(--space-1); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--color-text);
  background: var(--color-bg); border: 1px solid var(--color-text-muted); border-radius: var(--radius-sm);
}
.field textarea { min-height: 140px; resize: vertical; }
.field .hint { font-size: .85rem; color: var(--color-text-muted); }
.hp { position: absolute; left: -9999px; }
.form-status { margin: 0; font-weight: 600; }
.form-status:empty { display: none; }

/* ---------- Footer ---------- */
.site-footer { background: var(--color-surface); border-top: 1px solid var(--color-border); padding-block: var(--space-7) var(--space-5); font-size: .95rem; }
.footer-grid { display: grid; gap: var(--space-6); }
@media (min-width: 640px) { .footer-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .footer-grid { grid-template-columns: 1.5fr 1fr 1fr 1.4fr; } }
.site-footer h2 { font-size: .85rem; letter-spacing: .1em; text-transform: uppercase; color: var(--color-text-muted); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: var(--space-2); }
.site-footer a { color: var(--color-text); text-decoration: none; }
.site-footer a:hover { color: var(--color-primary); text-decoration: underline; }
.newsletter { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.newsletter input { flex: 1 1 180px; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--color-text); background: var(--color-bg); border: 1px solid var(--color-text-muted); border-radius: var(--radius-sm); }
.footer-bottom { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--color-border); display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-3); color: var(--color-text-muted); }

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

/* ---------- Cookie consent, chat button, landing pages ---------- */
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--color-text); cursor: pointer; text-decoration: none; }
.linklike:hover { color: var(--color-primary); text-decoration: underline; }
.consent { position: fixed; z-index: 150; left: var(--space-3); right: var(--space-3); bottom: var(--space-3); max-width: 760px; margin-inline: auto; background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: var(--space-5); }
.consent[hidden] { display: none; }
.consent h2 { font-size: 1.1rem; margin-bottom: var(--space-2); }
.consent p { color: var(--color-text-muted); font-size: .95rem; margin-bottom: var(--space-3); }
.consent__prefs { border: 0; padding: 0; margin: 0 0 var(--space-3); display: grid; gap: var(--space-2); }
.consent__prefs[hidden] { display: none; }
.consent__prefs .field-check { display: flex; gap: 10px; align-items: center; }
.consent__prefs input { width: 20px; height: 20px; min-height: 0; }
.consent__actions { margin-top: var(--space-2); }
.chat-fab { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 90; width: 54px; height: 54px; border-radius: 50%; background: #128c7e; color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-md); }
.chat-fab:hover { filter: brightness(1.1); }
.landing__image { width: 100%; height: auto; border-radius: var(--radius-lg); margin-bottom: var(--space-5); }
.newsletter .form-status { flex-basis: 100%; }

.card__thumb--img { object-fit: cover; width: 100%; height: auto; border-style: solid; }

[hidden], .btn[hidden], .consent [hidden] { display: none !important; }

/* Links inside running text must not rely on colour alone (WCAG 1.4.1). */
.site-footer p a, .consent p a, .meta a, .notice a { text-decoration: underline; }
