/*
 * Kahu Logic Blocks — atom foundation + design system (KAN-465, v2).
 *
 * Foundation strategy:
 *   - Bootstrap 5 / CoreUI provides the structural layer (grid, spacing
 *     utilities, accordion/card behaviour) — loaded by the theme, NOT redefined
 *     here. We deliberately do not re-skin Bootstrap's components.
 *   - This file styles the `kl-` atoms (buttons, headings, eyebrows, checklists)
 *     PLUS the shared design-system layer the molecule blocks build on: design
 *     tokens, the type scale, the full-width band breakout, surface variants
 *     (light / tint / dark), the seeded header nav, and the seeded footer.
 *   - `kl-` prefix keeps these scoped so they never clobber the site skin or
 *     Bootstrap utility classes. Molecule blocks (KAN-251) compose these atoms.
 *
 * BRAND OVERRIDE CONTRACT: every colour/font below reads a `--kl-*` token with a
 * neutral default. The per-tenant brand stylesheet (chat-bff buildBrandCss →
 * bridge CustomCssInjector) re-declares those tokens at `:root:root` strength
 * (the injector emits BEFORE this file, so plain `:root` there would lose), and
 * the SAME components then render each tenant's palette + type. Never hard-code
 * a colour in a molecule's view.css — add a token here instead.
 */

:root {
  /* colour tokens (brand CSS overrides these) */
  --kl-ink: #0f0f12;
  --kl-accent: #6d5efc;
  --kl-muted: #5c5c66;
  --kl-tick: #1aa260;
  --kl-bg: #ffffff;
  --kl-surface: #f6f6f8;
  --kl-surface-dark: #12121a;
  --kl-line: #e6e6ec;
  --kl-accent-tint: color-mix(in srgb, var(--kl-accent) 7%, #ffffff);
  --kl-on-dark: rgba(255, 255, 255, 0.92);
  --kl-on-dark-muted: rgba(255, 255, 255, 0.68);
  --kl-on-accent: #ffffff;

  /* shape + rhythm */
  --kl-radius: 12px;
  --kl-radius-sm: 8px;
  --kl-maxw: 72rem;
  --kl-band-pad: clamp(3.25rem, 8vw, 5.5rem);
  --kl-section-pad: clamp(2.5rem, 6vw, 4rem);

  /* type scale (display sizes clamp with the viewport) */
  --kl-font-display: inherit;
  --kl-font-body: inherit;
  --kl-text-hero: clamp(2.4rem, 5.5vw, 4rem);
  --kl-text-h2: clamp(1.75rem, 3.2vw, 2.5rem);
  --kl-text-h3: 1.2rem;
  --kl-text-lede: clamp(1.05rem, 1.6vw, 1.25rem);

  /* motion: specific properties, strong ease-out, no bounce */
  --kl-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

::selection {
  background: var(--kl-accent);
  color: var(--kl-on-accent, #fff);
}

/* The full-width band breakout below uses 100vw, which on browsers with classic
   (non-overlay) scrollbars measures ~15px wider than the visible viewport and
   would otherwise create a permanent horizontal scroll. Clipping the horizontal
   overflow at the root is the standard guard; `clip` (not `hidden`) so no new
   scroll container is created. */
html { overflow-x: clip; }

/* ── full-width band breakout ─────────────────────────────────────────────
   The Atomik theme wraps every block in a fixed `.container`, which boxes any
   block that paints a background. Bands escape it (100vw + negative margin)
   and re-center their own content column — so surfaces, heroes and CTA bands
   run edge-to-edge like a designed site, not a boxed template. */
.kl-band {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  padding-left: max(1.5rem, calc(50vw - var(--kl-maxw) / 2));
  padding-right: max(1.5rem, calc(50vw - var(--kl-maxw) / 2));
}

/* ── heading + <em> accent (house style: italic emphasis tail) ───────────── */
.kl-heading {
  font-family: var(--kl-font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: var(--kl-ink);
  text-wrap: balance;
}
.kl-heading em {
  font-style: italic;
  color: var(--kl-accent);
}

/* eyebrow / kicker */
.kl-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--kl-font-body);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--kl-accent);
}

/* badge / pill */
.kl-badge {
  display: inline-block;
  padding: 0.2em 0.7em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}
.kl-badge--default { background: var(--kl-surface); color: var(--kl-ink); }
.kl-badge--popular { background: var(--kl-accent); color: var(--kl-on-accent, #fff); }
.kl-badge--value   { background: #fff3d6; color: #8a6d1f; }

/* ── button / CTA ─────────────────────────────────────────────────────────
   Transition specific properties only (never `all`); press feedback on
   :active; a visible focus ring for keyboard users. */
.kl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.75em 1.35em;
  border-radius: var(--kl-radius);
  font-family: var(--kl-font-body);
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  transition: transform 0.15s var(--kl-ease-out), opacity 0.15s var(--kl-ease-out), background-color 0.15s var(--kl-ease-out);
}
.kl-btn:hover { transform: translateY(-1px); }
.kl-btn:active { transform: translateY(0) scale(0.98); }
.kl-btn:focus-visible {
  outline: 2px solid var(--kl-accent);
  outline-offset: 2px;
}
.kl-btn--primary   { background: var(--kl-ink); color: #fff; }
.kl-btn--secondary { background: transparent; color: var(--kl-ink); box-shadow: inset 0 0 0 1.5px var(--kl-ink); }
.kl-btn--link      { padding: 0; background: none; color: var(--kl-accent); }
.kl-btn--link:hover { transform: none; text-decoration: underline; text-underline-offset: 0.25em; }

/* icon */
.kl-icon { display: inline-block; line-height: 1; }

/* checklist */
.kl-checklist { list-style: none; margin: 0; padding: 0; }
.kl-check { display: flex; align-items: flex-start; gap: 0.6em; margin: 0.4em 0; }
.kl-check__tick {
  flex: 0 0 auto;
  width: 1.1em;
  height: 1.1em;
  border-radius: 50%;
  background: var(--kl-tick);
  position: relative;
}
.kl-check__tick::after {
  content: "";
  position: absolute;
  left: 0.34em;
  top: 0.18em;
  width: 0.28em;
  height: 0.52em;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.kl-check__text { color: var(--kl-ink); }

/* price */
.kl-price { display: inline-flex; align-items: baseline; gap: 0.15em; }
.kl-price__from {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--kl-muted);
  margin-right: 0.4em;
}
.kl-price__symbol { font-size: 1.2rem; font-weight: 600; }
.kl-price__amount { font-size: 2.4rem; font-weight: 600; line-height: 1; }
.kl-price__period { font-size: 0.9rem; color: var(--kl-muted); }

/* image */
.kl-img { display: block; max-width: 100%; height: auto; border-radius: var(--kl-radius); }

/* ── typography defaults for seeded pages ────────────────────────────────
   Semantic tags inside kl- contexts read the brand font tokens, so a page an
   agent creates later (bare <h1>/<p>, no .kl-* wrapper) still renders on-brand. */
.kl-prose, .kl-section, .kl-split, .kl-cta, .kl-faq, .kl-hero, .kl-metric, .kl-testimonial, .kl-feature {
  font-family: var(--kl-font-body);
}
.kl-prose h2, .kl-prose h3, .kl-prose h4 {
  font-family: var(--kl-font-display);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.kl-prose { line-height: 1.65; }
.kl-prose p { max-width: 70ch; }

/* ── dark-context: shared overrides for every dark band ──────────────────
   Any block surface painted with --kl-surface-dark flips its type + buttons to
   the on-dark set in ONE place, so contrast never depends on a per-block rule. */
:is(.kl-section--dark, .kl-split--dark, .kl-metric--dark, .kl-testimonial--dark, .kl-faq--dark, .kl-cta--dark) {
  background: var(--kl-surface-dark);
  color: var(--kl-on-dark);
}
:is(.kl-section--dark, .kl-split--dark, .kl-metric--dark, .kl-testimonial--dark, .kl-faq--dark, .kl-cta--dark) :is(.kl-heading, .kl-check__text) {
  color: #fff;
}
:is(.kl-section--dark, .kl-split--dark, .kl-metric--dark, .kl-testimonial--dark, .kl-faq--dark, .kl-cta--dark) :is(.kl-feature__body, .kl-split__body, .kl-cta__body, .kl-faq__a, .kl-metric__copy, .kl-testimonial__role, .kl-cta__reassure, p) {
  color: var(--kl-on-dark-muted);
}
:is(.kl-section--dark, .kl-split--dark, .kl-metric--dark, .kl-testimonial--dark, .kl-faq--dark, .kl-cta--dark) .kl-btn--primary {
  background: #fff;
  color: var(--kl-ink);
}
:is(.kl-section--dark, .kl-split--dark, .kl-metric--dark, .kl-testimonial--dark, .kl-faq--dark, .kl-cta--dark) .kl-btn--secondary {
  color: #fff;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}
:is(.kl-section--dark, .kl-split--dark, .kl-metric--dark, .kl-testimonial--dark, .kl-faq--dark, .kl-cta--dark) .kl-heading em {
  color: color-mix(in srgb, var(--kl-accent) 55%, #ffffff);
}

/* tint-context: the soft brand wash bands */
:is(.kl-section--tint, .kl-split--tint, .kl-metric--tint, .kl-testimonial--tint, .kl-faq--tint) {
  background: var(--kl-accent-tint);
}

/* ── seeded header nav (kahu_prose in the Navigation global area) ─────────
   Wordmark + link row + a button-styled CTA. flex-wrap keeps it robust at any
   width with zero JS — links flow to a second row on small screens. */
.kl-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  padding: 1rem max(1.5rem, calc(50vw - var(--kl-maxw) / 2));
  border-bottom: 1px solid var(--kl-line);
  background: var(--kl-bg);
}
.kl-nav__brand {
  font-family: var(--kl-font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--kl-ink);
  text-decoration: none;
  margin-right: auto;
}
.kl-nav__list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 1.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.kl-nav__item { margin: 0; }
.kl-nav__link {
  font-family: var(--kl-font-body);
  font-size: 0.975rem;
  font-weight: 500;
  color: var(--kl-ink);
  text-decoration: none;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
  transition: border-color 0.15s var(--kl-ease-out), color 0.15s var(--kl-ease-out);
}
.kl-nav__link:hover { border-bottom-color: var(--kl-accent); }
.kl-nav__cta {
  display: inline-flex;
  align-items: center;
  font-family: var(--kl-font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--kl-ink);
  text-decoration: none;
  padding: 0.6em 1.2em;
  border-radius: var(--kl-radius);
  transition: transform 0.15s var(--kl-ease-out), opacity 0.15s var(--kl-ease-out);
}
.kl-nav__cta:hover { transform: translateY(-1px); color: #fff; }
.kl-nav__cta:active { transform: scale(0.98); }
@media (max-width: 40rem) {
  .kl-nav { gap: 0.5rem 1.1rem; padding-top: 0.85rem; padding-bottom: 0.85rem; }
  .kl-nav__list { gap: 0.25rem 1.1rem; }
  .kl-nav__link { font-size: 0.9rem; }
}

/* ── seeded footer (kahu_prose in the Footer global area) ─────────────────
   A dark closing band: brand column + link columns + a legal line. */
.kl-prose:has(> .kl-footer__grid) {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-top: var(--kl-section-pad);
  padding: var(--kl-band-pad) max(1.5rem, calc(50vw - var(--kl-maxw) / 2)) 2rem;
  background: var(--kl-surface-dark);
  color: var(--kl-on-dark-muted);
}
.kl-footer__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 2.5rem;
  max-width: var(--kl-maxw);
}
.kl-footer__col h3 {
  font-family: var(--kl-font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #fff;
  margin: 0 0 0.85rem;
}
.kl-footer__col p { margin: 0 0 0.5rem; line-height: 1.6; color: var(--kl-on-dark-muted); }
.kl-footer__col ul { list-style: none; margin: 0; padding: 0; }
.kl-footer__col li { margin: 0 0 0.55rem; }
.kl-footer__col a { color: var(--kl-on-dark-muted); text-decoration: none; }
.kl-footer__col a:hover { color: #fff; }
.kl-footer__legal {
  margin: 2.5rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.45);
}

/* legacy plain footer prose (pre-v2 seeds without the grid) — quiet and tidy */
.kl-footer-contact, .kl-footer-copy { color: var(--kl-muted); font-size: 0.9rem; }

/* ── reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .kl-btn, .kl-nav__link, .kl-nav__cta {
    transition: none;
  }
  .kl-btn:hover, .kl-btn:active, .kl-nav__cta:hover, .kl-nav__cta:active { transform: none; }
}
