/* ─── BASE: TOKENS, RESET, LAYOUT, COMPONENTS ────────────────
   Shared across every page; load it before consent.css. Fill the brand tokens from CLIENT.md and
   build pages with the role tokens below. How to choose values: docs/design.md. */

/* CLIENT: the client's self-hosted fonts (WOFF2 in /work/kith-kiln/assets/fonts/), then name them in --font-body
   and --font-display. Preload only the files the first screen uses (docs/design.md, Typography).
@font-face {
  font-family: "Client Sans";
  src: url("/work/kith-kiln/assets/fonts/client-sans-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
*/

:root {
  /* CLIENT: brand colours from CLIENT.md. Every colour role below derives from these four. */
  --brand-primary: #23518c;
  --brand-secondary: #c4572f;
  --brand-text: #1c1f23;
  --brand-background: #faf9f6;

  /* Colour roles: page CSS uses these, never the brand values or raw hex */
  --color-bg: var(--brand-background);
  --color-surface: color-mix(in oklab, var(--brand-text) 4%, var(--brand-background));
  --color-text: var(--brand-text);
  --color-text-muted: color-mix(in oklab, var(--brand-text) 72%, var(--brand-background));
  --color-border: color-mix(in oklab, var(--brand-text) 14%, var(--brand-background));
  --color-border-strong: color-mix(in oklab, var(--brand-text) 55%, var(--brand-background));
  --color-action: var(--brand-primary);
  --color-action-hover: color-mix(in oklab, var(--brand-primary) 82%, #000);
  --color-on-action: #fff;
  --color-link: var(--brand-primary);
  --color-accent: var(--brand-secondary);
  --color-focus: var(--brand-primary);
  --color-selection: color-mix(in oklab, var(--brand-primary) 20%, var(--brand-background));
  --color-success: #1e7b45;
  --color-warning: #8a5a00;
  --color-error: #b3261e;

  /* Type: CLIENT: the client's families. Until then the system font stands in. */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: var(--font-body);
  /* Fluid scale: 360px viewport → 1280px. Body is 17px on phones, 18px on desktop. */
  --step--1: clamp(0.875rem, 0.851rem + 0.109vw, 0.938rem);
  --step-0: clamp(1.063rem, 1.038rem + 0.109vw, 1.125rem);
  --step-1: clamp(1.25rem, 1.189rem + 0.272vw, 1.406rem);
  --step-2: clamp(1.438rem, 1.315rem + 0.543vw, 1.75rem);
  --step-3: clamp(1.688rem, 1.492rem + 0.87vw, 2.188rem);
  --step-4: clamp(1.938rem, 1.62rem + 1.413vw, 2.75rem);
  --step-5: clamp(2.25rem, 1.785rem + 2.065vw, 3.438rem);
  --step-6: clamp(2.5rem, 1.717rem + 3.478vw, 4.5rem);
  --leading-tight: 1.08;
  --leading-snug: 1.2;
  --leading-body: 1.6;
  --tracking-tight: -0.02em;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --measure: 68ch;

  /* Space: a 4px-based scale, plus the page-level roles */
  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-s: 1rem;
  --space-m: 1.5rem;
  --space-l: 2rem;
  --space-xl: 3rem;
  --space-2xl: 4rem;
  --space-3xl: 6rem;
  --gutter: clamp(1rem, 0.609rem + 1.739vw, 2rem);
  --section-space: clamp(4rem, 2.435rem + 6.957vw, 8rem);
  --container: 75rem;
  --container-narrow: 46rem;
  --header-h: 4.5rem;
  --tap: 44px;

  /* Breakpoints, for reference and scripts. Custom properties don't work inside @media, so media
     queries repeat these numbers, mobile-first: (min-width: …). */
  --bp-sm: 640px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;

  --radius-s: 4px;
  --radius-m: 8px;
  --radius-l: 16px;
  --radius-full: 999px;
  --shadow-s: 0 1px 2px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.06);
  --shadow-m: 0 2px 4px rgb(0 0 0 / 0.05), 0 12px 32px rgb(0 0 0 / 0.1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --z-header: 100;
}

/* Dark band: re-derives the roles so everything inside it keeps its contrast */
.section-inverse {
  --color-bg: var(--brand-text);
  --color-surface: color-mix(in oklab, var(--brand-background) 8%, var(--brand-text));
  --color-text: var(--brand-background);
  --color-text-muted: color-mix(in oklab, var(--brand-background) 75%, var(--brand-text));
  --color-border: color-mix(in oklab, var(--brand-background) 20%, var(--brand-text));
  --color-border-strong: color-mix(in oklab, var(--brand-background) 55%, var(--brand-text));
  --color-action: color-mix(in oklab, var(--brand-primary) 45%, var(--brand-background));
  --color-action-hover: var(--brand-background);
  --color-on-action: var(--brand-text);
  --color-link: color-mix(in oklab, var(--brand-primary) 45%, var(--brand-background));
  --color-focus: var(--brand-background);
  --color-selection: color-mix(in oklab, var(--brand-primary) 45%, var(--brand-text));
  background: var(--color-bg);
  color: var(--color-text);
}

/* ── Reset and browser surfaces ── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--space-s));
  scrollbar-color: var(--color-border-strong) var(--color-bg);
}
/* Keeps focused fields clear of the open cookie banner */
html.fhc-banner-open { scroll-padding-bottom: calc(var(--fhc-banner-h, 0px) + var(--space-s)); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--leading-body);
  caret-color: var(--color-action);
  accent-color: var(--color-action);
}
::selection { background: var(--color-selection); color: var(--color-text); }
img, picture, svg, video { display: block; max-width: 100%; }
img, video { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; }
table, .num { font-variant-numeric: tabular-nums; }

/* ── Type ── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  text-wrap: balance;
  overflow-wrap: break-word;
}
h1 { font-size: var(--step-5); line-height: var(--leading-tight); letter-spacing: var(--tracking-tight); }
h2 { font-size: var(--step-4); letter-spacing: var(--tracking-tight); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }
p, li, dd, figcaption { text-wrap: pretty; overflow-wrap: break-word; }
a { color: var(--color-link); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
.display { font-size: var(--step-6); letter-spacing: -0.03em; }
.lede { font-size: var(--step-1); line-height: 1.5; color: var(--color-text-muted); max-width: 52ch; }
.small { font-size: var(--step--1); }
.muted { color: var(--color-text-muted); }

/* Long-form text: headings get more space above than below */
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1em; }
.prose > :is(h2, h3) { margin-top: 1.8em; }
.prose > :is(h2, h3) + * { margin-top: 0.6em; }
.prose h2 { font-size: var(--step-3); }
.prose :is(ul, ol) { padding-left: 1.25em; }
.prose li + li { margin-top: 0.4em; }

/* ── Layout ── */
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}
.container-narrow { max-width: calc(var(--container-narrow) + 2 * var(--gutter)); }
.section { padding-block: var(--section-space); }
.section-surface { background: var(--color-surface); }
.section-head { max-width: 46rem; margin-bottom: var(--space-xl); }
.section-head > * + * { margin-top: var(--space-s); }
.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-m)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--space-s)); }
.grid {
  display: grid;
  gap: var(--grid-gap, var(--space-l));
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--grid-min, 16rem)), 1fr));
}
.split { display: grid; gap: var(--space-xl); align-items: center; }
.with-aside { display: grid; gap: var(--space-xl); }
@media (min-width: 768px) {
  .split { grid-template-columns: 1fr 1fr; gap: var(--space-2xl); }
  .split-reverse > :first-child { order: 2; }
}
@media (min-width: 1024px) {
  .with-aside { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--space-2xl); }
  .with-aside > .section-head { margin-bottom: 0; }
}

/* ── Header and nav ── */
.skip-link {
  position: absolute;
  top: var(--space-s);
  left: var(--space-s);
  z-index: calc(var(--z-header) + 1);
  padding: var(--space-xs) var(--space-s);
  border-radius: var(--radius-s);
  background: var(--color-text);
  color: var(--color-bg);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  padding-top: env(safe-area-inset-top);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-m);
  min-height: var(--header-h);
}
.brand {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  text-decoration: none;
}
.brand img { width: auto; height: 2rem; }
.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: var(--tap);
  padding-inline: var(--space-s);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-s);
  background: transparent;
  font-weight: var(--weight-medium);
}
.site-nav ul { display: flex; flex-direction: column; gap: var(--space-3xs); padding: 0; list-style: none; }
.site-nav a:not(.btn) {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding-inline: var(--space-xs);
  border-radius: var(--radius-s);
  color: var(--color-text);
  font-weight: var(--weight-medium);
  text-decoration: none;
}
.site-nav a:not(.btn):hover { background: var(--color-surface); }
.site-nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.35em; }
.site-nav .btn { margin-top: var(--space-s); }
/* Below 1024px the nav is a popover the Menu button opens; no script needed */
.site-nav:popover-open {
  position: fixed;
  inset: calc(var(--header-h) + env(safe-area-inset-top)) 0 auto;
  width: auto;
  height: auto;
  margin: 0;
  padding: var(--space-s) var(--gutter) var(--space-l);
  border: 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-m);
}
@media (min-width: 1024px) {
  .nav-toggle { display: none; }
  .site-nav,
  .site-nav:popover-open {
    display: block;
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    overflow: visible;
    color: inherit;
  }
  .site-nav ul { flex-direction: row; align-items: center; gap: var(--space-2xs); }
  .site-nav .btn { margin: 0 0 0 var(--space-xs); }
}

/* ── Buttons, links and icons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  min-height: var(--tap);
  padding: var(--space-xs) var(--space-m);
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background-color var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast);
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--color-action); color: var(--color-on-action); }
.btn-primary:hover { background: var(--color-action-hover); }
.btn-secondary { border-color: var(--color-border-strong); background: transparent; color: var(--color-text); }
.btn-secondary:hover { border-color: var(--color-text); }
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: var(--tap);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  white-space: nowrap;
}
.link-arrow:hover { text-decoration: underline; }
.link-arrow .icon { transition: transform var(--duration-fast) var(--ease-out); }
.link-arrow:hover .icon { transform: translateX(3px); }
/* Inline SVG icons on a 24px grid; they take the text colour */
.icon {
  flex: none;
  width: var(--icon-size, 1.25rem);
  height: var(--icon-size, 1.25rem);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Content blocks ── */
.hero { padding-block: var(--space-2xl) var(--section-space); }
.hero-grid { display: grid; gap: var(--space-xl); align-items: center; }
.hero-text > * + * { margin-top: var(--space-m); }
.hero-text .cluster { margin-top: var(--space-l); }
.hero-note { font-size: var(--step--1); color: var(--color-text-muted); }
@media (min-width: 1024px) {
  .hero-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--space-2xl); }
}
.media { overflow: hidden; aspect-ratio: var(--ratio, 4 / 3); border-radius: var(--radius-m); background: var(--color-surface); }
.media img { width: 100%; height: 100%; object-fit: cover; }

.service-list { padding: 0; list-style: none; border-top: 1px solid var(--color-border); }
.service-list li { display: grid; gap: var(--space-2xs) var(--space-l); padding-block: var(--space-l); border-bottom: 1px solid var(--color-border); }
.service-list p { max-width: 52ch; color: var(--color-text-muted); }
@media (min-width: 768px) {
  .service-list li { grid-template-columns: minmax(10rem, 1fr) minmax(0, 2fr) auto; align-items: baseline; }
}

.check-list { display: grid; gap: var(--space-s); padding: 0; list-style: none; }
.check-list li { display: grid; grid-template-columns: 1.5rem 1fr; gap: var(--space-xs); }
.check-list .icon { --icon-size: 1.5rem; color: var(--color-action); }

.quote { max-width: 50rem; }
.quote blockquote p {
  font-family: var(--font-display);
  font-size: var(--step-3);
  line-height: 1.3;
  letter-spacing: var(--tracking-tight);
}
.quote figcaption { margin-top: var(--space-m); color: var(--color-text-muted); }
.quote cite { font-style: normal; font-weight: var(--weight-semibold); color: var(--color-text); }

.faq { max-width: var(--container-narrow); border-top: 1px solid var(--color-border); }
.faq details { border-bottom: 1px solid var(--color-border); }
.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-m);
  min-height: var(--tap);
  padding-block: var(--space-m);
  font-size: var(--step-1);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  list-style: none;
  cursor: pointer;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary .icon { transition: transform var(--duration-base) var(--ease-out); }
.faq details[open] summary .icon { transform: rotate(45deg); }
.faq details > div { max-width: var(--measure); padding-bottom: var(--space-m); }

.cta { display: grid; gap: var(--space-l); }
.cta p { max-width: 52ch; margin-top: var(--space-s); color: var(--color-text-muted); }
@media (min-width: 1024px) {
  .cta { grid-template-columns: 1fr auto; align-items: end; }
}

.page-header { padding-block: var(--space-2xl) var(--space-xl); border-bottom: 1px solid var(--color-border); }
.page-header .container > * + * { margin-top: var(--space-s); }

.error-page { min-height: 60vh; display: grid; align-content: center; padding-block: var(--section-space); }
.error-page .display { margin-bottom: var(--space-m); }
.error-page .lede { margin-bottom: var(--space-l); }

/* ── Forms ── */
.form { display: grid; gap: var(--space-m); }
.form-row { display: grid; gap: var(--space-m); }
.field { display: grid; gap: var(--space-2xs); }
.field label, .form legend { font-weight: var(--weight-semibold); }
.field .hint { font-size: var(--step--1); color: var(--color-text-muted); }
.form :is(input:not([type="checkbox"], [type="radio"]), select, textarea) {
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-xs) var(--space-s);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-s);
  background: var(--color-bg);
  color: var(--color-text);
}
.form :is(input, select, textarea):hover { border-color: var(--color-text); }
.form :is(input, select, textarea):user-invalid { border-color: var(--color-error); }
.form select { appearance: none; padding-right: var(--space-xl); }
.select { position: relative; display: block; }
.select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: var(--space-s);
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.form fieldset { display: grid; gap: var(--space-3xs); padding: 0; border: 0; }
.form legend { margin-bottom: var(--space-2xs); }
.choice { display: flex; align-items: flex-start; gap: var(--space-xs); min-height: var(--tap); padding-block: var(--space-2xs); }
.choice input { flex: none; width: 1.25rem; height: 1.25rem; margin-top: 0.2em; }
.form-legal { font-size: var(--step--1); color: var(--color-text-muted); }
.form-status:empty { display: none; }
.form-status { font-weight: var(--weight-semibold); }
.form-status[data-state="success"] { color: var(--color-success); }
.form-status[data-state="error"] { color: var(--color-error); }
.form .hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
@media (min-width: 640px) {
  .form-row { grid-template-columns: 1fr 1fr; }
}

.contact-grid { display: grid; gap: var(--space-2xl); }
.contact-aside h2 { margin-bottom: var(--space-m); font-size: var(--step-2); }
.contact-list { border-top: 1px solid var(--color-border); }
.contact-list div { padding-block: var(--space-m); border-bottom: 1px solid var(--color-border); }
.contact-list dt { font-size: var(--step--1); color: var(--color-text-muted); }
.contact-list dd { margin: 0; font-size: var(--step-1); font-weight: var(--weight-semibold); }
.contact-list a { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--color-text); text-decoration: none; }
.contact-list a:hover { text-decoration: underline; }
@media (min-width: 1024px) {
  .contact-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-3xl); }
}

/* ── Footer ── */
.site-footer {
  --footer-ink: var(--color-text);
  padding-block: var(--space-2xl) calc(var(--space-l) + env(safe-area-inset-bottom));
  background: var(--color-surface);
}
.footer-top { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xl) var(--space-l); }
.footer-brand { grid-column: 1 / -1; }
.footer-brand p { max-width: 32ch; margin-top: var(--space-xs); color: var(--color-text-muted); }
.footer-col h2 { margin-bottom: var(--space-2xs); font-size: var(--step-0); }
.footer-col ul { padding: 0; list-style: none; }
.footer-col a,
.site-footer .footer-cookie-btn {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-size: var(--step--1);
  color: var(--color-text);
  text-decoration: none;
}
.footer-col a:hover { color: var(--color-link); text-decoration: underline; }
.footer-meta {
  display: grid;
  gap: var(--space-2xs);
  margin-top: var(--space-xl);
  padding-top: var(--space-l);
  border-top: 1px solid var(--color-border);
  font-size: var(--step--1);
  color: var(--color-text-muted);
}
@media (min-width: 768px) {
  .footer-top { grid-template-columns: repeat(4, 1fr); }
  .footer-meta { grid-template-columns: 1fr auto; }
}
@media (min-width: 1024px) {
  .footer-top { grid-template-columns: 1.4fr repeat(4, 1fr); }
  .footer-brand { grid-column: auto; }
}

/* ── Scroll effects (wired in assets/js/effects.js) ── */
html.lenis { height: auto; }
html.lenis.lenis-smooth { scroll-behavior: auto; }
html.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
html.lenis.lenis-stopped body { overflow: hidden; }

.ital { font-style: italic; font-weight: var(--weight-medium); }

.word-wrap {
  display: inline-block;
  overflow-y: clip;
  overflow-x: visible;
  vertical-align: top;
  padding: 0.04em 0.12em 0.04em 0;
}
.word-wrap > span {
  display: inline-block;
  transform: translateY(110%);
  animation: word-rise 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
@keyframes word-rise { to { transform: translateY(0); } }

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.9s cubic-bezier(0.2, 0.7, 0.2, 1), transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal-d1 { transition-delay: 0.08s; }
.reveal-d2 { transition-delay: 0.16s; }
.reveal-d3 { transition-delay: 0.24s; }
.reveal-d4 { transition-delay: 0.32s; }

.hl[data-highlight] {
  --hl-color: var(--color-action);
  --hl-base: var(--color-text-muted);
  color: var(--hl-base);
}
.hl-on-dark[data-highlight] {
  --hl-color: var(--color-text);
  --hl-base: var(--color-text-muted);
}
.hl[data-highlight] .ltr-hl {
  color: var(--hl-base);
  transition: color 0.18s cubic-bezier(0.5, 0, 0.5, 1);
}
.hl[data-highlight] .ltr-hl.lit { color: var(--hl-color); }

/* ── Utilities ── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .word-wrap > span { transform: none !important; animation: none !important; }
  .reveal { opacity: 1 !important; transform: none !important; }
}
