/* ============================================================================
   NorthCore sitebuilder kit — the engineering layer.

   Imported by every build. NEVER copied into a client and edited: if a build
   needs to change something in here, the kit is wrong and the kit gets fixed
   (RULES #31). The art direction layer — tokens, type, the signature
   component, section order — is written per build, on top of this.

   TOKEN CONTRACT. A build must define all seven; the kit assumes nothing about
   their values, so the same rules work on a dark ground or a light one:

     --ground      the page background
     --ink         primary text on --ground
     --dim         secondary text on --ground
     --accent      the accent colour
     --accent-ink  text colour ON an --accent fill
     --line        hairlines and borders
     --panel       a raised surface (cards, the phone sheet)

   Earlier drafts hard-coded --paper for the burger bars, which made them
   invisible the first time this was used on a light ground.
   ========================================================================= */

/* ---- reset ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { min-height: 100%; -webkit-font-smoothing: antialiased; }
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
p, h1, h2, h3, h4, li { overflow-wrap: break-word; }

/* Grid and flex children default to min-width:auto and overflow their track.
   Cost us a 320px header once; it is a one-line fix, so it lives here. */
.split > *, .grid > *, .rows > * { min-width: 0; }

/* ---- spacing scale ----------------------------------------------------- */
:root {
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 128px;
  --gut: clamp(20px, 5vw, 40px);
  --maxw: 1200px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}
/* Density is a per-build decision (W1: "it feels bare and a lot of space").
   Set data-density on <html>; sections read --sec-y. */
:root, :root[data-density="normal"] { --sec-y: clamp(56px, 8vw, 104px); }
:root[data-density="tight"]         { --sec-y: clamp(40px, 5.5vw, 72px); }
:root[data-density="airy"]          { --sec-y: clamp(72px, 11vw, 152px); }

/* ---- fluid type -------------------------------------------------------- */
/* One ladder, clamped, so a build sets families and weights and not sizes. */
:root {
  --t--1: clamp(13px, .78rem + .15vw, 14px);
  --t-0:  clamp(16px, .95rem + .2vw,  18px);
  --t-1:  clamp(18px, 1.02rem + .35vw, 21px);
  --t-2:  clamp(21px, 1.1rem + .8vw,   28px);
  --t-3:  clamp(26px, 1.2rem + 1.6vw,  40px);
  --t-4:  clamp(32px, 1.3rem + 2.9vw,  58px);
  --t-5:  clamp(40px, 1.4rem + 4.6vw,  82px);
  --t-6:  clamp(46px, 1.5rem + 6.4vw, 110px);
}
body { font-size: var(--t-0); line-height: 1.6; }
/* Large display type still needs a readable measure. */
h1, h2 { line-height: 1.04; letter-spacing: -.02em; text-wrap: balance; }
h3, h4 { line-height: 1.18; text-wrap: balance; }
p { max-width: 68ch; }

/* ---- layout primitives ------------------------------------------------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gut); }
.sec { padding-block: var(--sec-y); }
.split { display: grid; gap: var(--s-6); }
@media (min-width: 900px) { .split { grid-template-columns: 1fr 1fr; align-items: center; } }
.grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.rows { display: grid; gap: var(--s-3); }
.stack > * + * { margin-top: var(--flow, var(--s-4)); }

/* A sticky/flex viewport holding a .wrap collapses to content width; auto
   margins eat the rest. Hit twice. */
.pin > .wrap, .hero > .wrap { width: 100%; }

/* ---- focus ------------------------------------------------------------- */
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}
.skip-link {
  position: absolute; left: var(--s-4); top: -60px; z-index: 200;
  background: var(--ink); color: var(--ground);
  padding: var(--s-3) var(--s-4); border-radius: 6px;
  transition: top .18s var(--ease);
}
.skip-link:focus { top: var(--s-4); }

/* ---- tap targets ------------------------------------------------------- */
.btn, .burger, .sheet a, .tabs button {
  min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-2);
}
.btn {
  padding: 0 var(--s-5); border-radius: 8px; border: 0;
  text-decoration: none; font-weight: 600; cursor: pointer;
  transition: transform .18s var(--ease), background-color .18s var(--ease);
}
.btn:active { transform: translateY(1px); }

/* ============================================================================
   MEDIA SHAPES (RULES #28, W10 — "the different shapes for the videos to sit
   in like the one on capillos"). A build picks ONE and uses it consistently.
   Each is a container: the media inside is object-fit: cover.
   ========================================================================= */
.shape { display: block; position: relative; overflow: hidden;
         background: var(--line); }
/* a <picture> is inline by default, which makes it ignore aspect-ratio */
picture.shape > img { position: absolute; inset: 0; }
.shape > img, .shape > video { width: 100%; height: 100%; object-fit: cover; }

.shape--arch     { border-radius: 50vw 50vw 14px 14px / 34vw 34vw 14px 14px; aspect-ratio: 4 / 5; }
.shape--soft     { border-radius: 20px; aspect-ratio: 4 / 3; }
.shape--circle   { border-radius: 50%; aspect-ratio: 1; }
.shape--portrait { border-radius: 14px; aspect-ratio: 3 / 4; }
.shape--wide     { border-radius: 14px; aspect-ratio: 16 / 9; }
.shape--angled   { border-radius: 4px; aspect-ratio: 5 / 4;
                   clip-path: polygon(0 0, 100% 0, 100% 88%, 0 100%); }
/* 999px on a ~550px box is not a lozenge, it is a leaf, and it ate the subject of
   every photograph it was applied to. A fixed radius keeps the shape recognisable at
   any width instead of scaling into a point. */
.shape--lozenge  { border-radius: 96px 20px 96px 20px; aspect-ratio: 5 / 4; }
@media (max-width: 560px) { .shape--lozenge { border-radius: 56px 16px 56px 16px; } }
/* A shape that keeps a real rectangle on a phone, where fancy crops eat the
   subject's head. */
@media (max-width: 560px) {
  .shape--arch   { border-radius: 40vw 40vw 12px 12px / 22vw 22vw 12px 12px; aspect-ratio: 4 / 4.4; }
  .shape--angled { clip-path: none; }
}

/* ---- header + phone menu (RULES #30, W2) ------------------------------- */
.hdr {
  position: sticky; top: 0; z-index: 60;
  background: var(--ground);
  border-bottom: 1px solid var(--line);
}
.hdr__in { display: flex; align-items: center; gap: var(--s-4); min-height: 64px; }
.mark { margin-right: auto; text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: var(--s-2); }
.nav { display: none; gap: var(--s-5); }
.nav a { text-decoration: none; }
@media (min-width: 860px) { .nav { display: flex; } }

.burger {
  width: 46px; height: 46px; padding: 0;
  background: transparent; border: 1px solid var(--line); border-radius: 10px;
  flex-direction: column; gap: 5px; cursor: pointer;
}
.burger span {
  display: block; width: 18px; height: 2px; border-radius: 2px;
  background: var(--ink);
  transition: transform .2s var(--ease), opacity .2s var(--ease);
}
@media (min-width: 860px) { .burger { display: none; } }
[aria-expanded="true"].burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
[aria-expanded="true"].burger span:nth-child(2) { opacity: 0; }
[aria-expanded="true"].burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sheet {
  position: fixed; inset: 64px 0 auto 0; z-index: 59;
  background-color: var(--panel);             /* a real colour, never only a blur */
  border-bottom: 1px solid var(--line);
  padding: var(--s-4) var(--gut) var(--s-6);
  display: grid; gap: var(--s-2);
  transform: translateY(-8px); opacity: 0; visibility: hidden;
  transition: transform .22s var(--ease), opacity .22s var(--ease), visibility .22s;
}
.sheet[data-open="1"] { transform: none; opacity: 1; visibility: visible; }
.sheet a {
  justify-content: space-between;
  text-decoration: none; padding: var(--s-3) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-1);
}
/* No arrow glyph after the sheet links (RULES #37, Will 2026-09-22): the row is a full-
   width tap target and the hairline under it is the affordance. */

/* ---- reveals ----------------------------------------------------------- */
/* One reveal per element (RULES #15). ?shot=1 kills the transition as well as
   the initial state, or a screenshot catches an element mid-flight (#18). */
.rv { opacity: 0; transform: translateY(14px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
/* builds' scripts write `is-in`; `in` is kept so either spelling works */
.rv.in, .rv.is-in, .rv-on .rv { opacity: 1; transform: none; }
.rv-d1 { transition-delay: .07s; } .rv-d2 { transition-delay: .14s; } .rv-d3 { transition-delay: .21s; }
html[data-shot="1"] .rv { opacity: 1 !important; transform: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .rv { opacity: 1 !important; transform: none !important; transition: none !important; }
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}
.no-js .rv { opacity: 1; transform: none; }

/* ============================================================================
   INTRO LOADER (RULES #26).
   Full viewport. No skip control. Once per session. Hard timeout. The page is
   already built underneath it.
   ========================================================================= */
.intro {
  position: fixed; inset: 0; z-index: 999;
  display: grid; place-items: center;
  background: var(--intro-bg, var(--ground));
  overflow: hidden;
}
.intro[hidden] { display: none; }
.intro__stage { position: absolute; inset: 0; }   /* full-bleed: the subject crosses all of it */
.intro__out { animation: introOut .62s var(--ease) forwards; }
@keyframes introOut { to { opacity: 0; visibility: hidden; } }
/* Reduced motion never sees it; the guard is also in JS so the file is not even
   fetched, but this keeps it invisible if the JS is slow. */
@media (prefers-reduced-motion: reduce) { .intro { display: none !important; } }
html[data-shot="1"] .intro { display: none !important; }
.no-js .intro { display: none; }
/* While the intro is up, the page underneath must not scroll behind it. */
html[data-intro="1"], html[data-intro="1"] body { overflow: hidden; }

/* ---- background video (RULES #27) -------------------------------------- */
/* No controls, ever. The poster carries the frame if autoplay is refused. */
.bgvid {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; pointer-events: none;
}
.bgvid::-webkit-media-controls { display: none !important; }

/* ---- utility ----------------------------------------------------------- */
.vh {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mq { overflow: hidden; }          /* marquee clip — must be in the audit CLIP list */
.tag, .kicker { font-size: var(--t--1); letter-spacing: .14em; text-transform: uppercase; }
.lede { font-size: var(--t-1); color: var(--dim); }

/* ============================================================================
   FULL-BLEED VIDEO HERO (RULES #27; Will, 2026-09-21: "I want every site to
   have a video hero from pexels (Covering the full hero background)").

   Structure the build emits:
     <section class="hero hero--vid">
       <div class="hero__bg"><video class="bgvid" data-bg …>…</video></div>
       <div class="hero__scrim"></div>
       <div class="wrap"> … .panel … </div>
     </section>

   The scrim is a GRADE, not the thing that makes the text legible. The text sits
   on `.panel`, whose alpha is solved in closed form per build (RULES #23): a
   panel of rgb(r,g,b) at alpha a over PURE WHITE can never paint lighter than
   a*c + (1-a)*255, and every token on it must clear AA against that worst case.
   A white light streak crossing the frame is not a hypothetical.
   ========================================================================= */
.hero--vid { position: relative; isolation: isolate; overflow: hidden; }
.hero--vid > .hero__bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.hero--vid > .hero__bg > video,
.hero--vid > .hero__bg > img { width: 100%; height: 100%; object-fit: cover; }
.hero--vid > .hero__scrim { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.hero--vid > .wrap { position: relative; z-index: 2; width: 100%; }

/* The panel needs a real background-color. backdrop-filter is decoration and
   must never be the thing carrying the contrast (RULES #23). */
.panel { position: relative; }
@supports (backdrop-filter: blur(2px)) {
  .panel { backdrop-filter: blur(3px); }
}
