/**
 * The Traffic Plans Company - Design Tokens
 * Rollout 0 - Foundations / R0.2 Component Library
 *
 * Three-tier token architecture (per TheWebSociety DS v1):
 * Tier 1: Primitives (raw values, never used directly in components)
 * Tier 2: Semantic (role-based, resolved per BAND - the band is this
 *         project's equivalent of a light/dark mode: asphalt, white,
 *         panel_grey, orange each carry their own text-colour resolution)
 * Tier 3: Component (component-scoped, references semantic only)
 *
 * Source: ~/.twss/brands/traffic-plans-company.tokens.json (R0.1, THEA-651)
 * Extends ~/.twss/design-system/v1/tokens.json. Do not fork a parallel
 * system - add to this file and back-propagate durable patterns.
 *
 * ONE ORANGE RULE: #F4941D is the only orange token in this file. If a
 * contrast problem ever looks like it needs a second orange, the fix is
 * changing the TEXT colour token or the BAND, never adding an orange value.
 */

/* ─── TIER 1: PRIMITIVES ──────────────────────────────────────────────── */
:root {
  --primitive-orange:       #F4941D;
  --primitive-ink:          #414142;
  --primitive-asphalt:      #222222;
  --primitive-asphalt-soft: #3A3A3A; /* THEA-675 - second stop of the render-placeholder gradient
                                        (service-card__media, team-card__portrait, hero render-placeholder).
                                        Not a brand palette colour - a decorative lighter tint of asphalt
                                        used only so the greybox placeholder reads as a gradient, not a
                                        flat fill. Tokenised so no component hardcodes the hex directly. */
  --primitive-signal-red:   #C02B0A;
  --primitive-panel-grey:   #F1F1F1;
  --primitive-white:        #FFFFFF;

  --primitive-font-family:  'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

  --primitive-size-h1:      clamp(40px, 6vw, 60px);
  --primitive-size-h2:      32px;
  --primitive-size-h3:      22px;
  --primitive-size-body:    17px;
  --primitive-size-body-sm: 15px;
  --primitive-size-eyebrow: 13px;
  --primitive-size-button:  16px;

  --primitive-space-1:  4px;
  --primitive-space-2:  8px;
  --primitive-space-3:  12px;
  --primitive-space-4:  16px;
  --primitive-space-5:  24px;
  --primitive-space-6:  32px;
  --primitive-space-7:  48px;
  --primitive-space-8:  64px;
  --primitive-space-9:  96px;
  --primitive-space-10: 128px;

  --primitive-radius-sm: 2px;
  --primitive-radius-md: 4px;
  --primitive-radius-lg: 8px;

  --primitive-duration-instant:   0ms;
  --primitive-duration-quick:     150ms;
  --primitive-duration-fast:      220ms;
  --primitive-duration-moderate:  400ms;
  --primitive-duration-mid:       600ms;
  --primitive-duration-cinematic: 900ms;

  --primitive-easing-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --primitive-easing-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --primitive-easing-snap:   cubic-bezier(0.34, 1.56, 0.64, 1);

  /* THEA-673 - motion tokens, extends the duration/easing primitives above
     rather than starting a parallel --motion-* system. Mirrored in JS as a
     plain object (homepage.html's inline MOTION constant) since GSAP tweens
     read numbers, not CSS custom properties. */
  --primitive-delay-stagger-sm: 40ms;
  --primitive-delay-stagger-md: 60ms;
  --primitive-delay-stagger-lg: 90ms;

  --primitive-scale-press: 0.97;
  --primitive-scale-lift:  1.02;

  --primitive-reveal-y:      24px; /* standard band-content reveal travel */
  --primitive-reveal-y-hero: 40px; /* hero-only, larger travel for the cinematic duration */

  /* Breakpoints - reference only, media queries below use the literal px */
  --bp-tablet:  600px;
  --bp-desktop: 1024px;
  --bp-wide:    1440px;

  --container-max: 1312px;
}

/* THEA-673 - reduced-motion override at the token layer, so no component or
   motion script needs its own @media query: durations collapse to 0, every
   GSAP tween becomes an instant cut. Easing tokens stay defined (still used
   by colour/opacity-only crossfades that remain even under reduced motion). */
@media (prefers-reduced-motion: reduce) {
  :root {
    --primitive-duration-quick:     0ms;
    --primitive-duration-fast:      0ms;
    --primitive-duration-moderate:  0ms;
    --primitive-duration-mid:       0ms;
    --primitive-duration-cinematic: 0ms;
    --primitive-reveal-y:      0px;
    --primitive-reveal-y-hero: 0px;
  }
}

/* ─── TIER 2: SEMANTIC - resolved per band ───────────────────────────── */
/* Each band is a self-contained "mode". Apply a band class to a 100vw
   section wrapper; every component inside inherits its text colours from
   these semantic custom properties rather than ever hardcoding a hex.

   SAFE FALLBACK: every --band-* token gets a dark-on-light default here at
   :root. A component that consumes --band-heading-text etc. without a
   literal var() fallback, and that ends up placed outside any .band-*
   ancestor, must resolve to something legible - not silently inherit an
   undefined value. This is what a 59-failure contrast sweep found: band
   tokens leaking their light-on-dark values into contexts with no painted
   dark background. The per-band classes below override these defaults
   only where a real coloured background is actually painted. */
:root {
  --band-bg:            var(--primitive-white);
  --band-heading-text:  var(--primitive-asphalt);
  --band-body-text:     var(--primitive-ink);
  --band-h2-text:       var(--primitive-asphalt);
  --band-hairline:      rgba(34, 34, 34, 0.12);
  --band-muted:         rgba(65, 65, 66, 0.78); /* 5.35:1 on white - 0.7 measured 4.29:1, fails AA */
}

.band-asphalt {
  --band-bg:            var(--primitive-asphalt);
  --band-heading-text:  var(--primitive-white);
  --band-body-text:     var(--primitive-panel-grey);
  --band-h2-text:       var(--primitive-orange); /* only band where the orange H2 tic applies - 6.89:1 */
  --band-hairline:      rgba(255, 255, 255, 0.14);
  --band-muted:         rgba(241, 241, 241, 0.7);
}

.band-white {
  --band-bg:            var(--primitive-white);
  --band-heading-text:  var(--primitive-asphalt);
  --band-body-text:     var(--primitive-ink);
  --band-h2-text:       var(--primitive-asphalt); /* orange on white = 2.31:1, fails AA - never here */
  --band-hairline:      rgba(34, 34, 34, 0.12);
  --band-muted:         rgba(65, 65, 66, 0.78); /* 5.35:1 on white/panel-grey - 0.7 measured 4.29:1, fails AA */
}

.band-panel_grey {
  --band-bg:            var(--primitive-panel-grey);
  --band-heading-text:  var(--primitive-asphalt);
  --band-body-text:     var(--primitive-ink);
  --band-h2-text:       var(--primitive-asphalt); /* orange on panel grey = 2.04:1, fails AA */
  --band-hairline:      rgba(34, 34, 34, 0.12);
  --band-muted:         rgba(65, 65, 66, 0.78); /* 5.35:1 on white/panel-grey - 0.7 measured 4.29:1, fails AA */
}

.band-orange {
  --band-bg:            var(--primitive-orange);
  --band-heading-text:  var(--primitive-asphalt); /* never white on orange */
  --band-body-text:     var(--primitive-asphalt);
  --band-h2-text:       var(--primitive-asphalt); /* no orange-on-orange */
  --band-hairline:      rgba(34, 34, 34, 0.18);
  --band-muted:         rgba(34, 34, 34, 0.65);
}

/* ─── TIER 3: COMPONENT tokens - reference semantic only ─────────────── */
:root {
  --btn-primary-bg:      var(--primitive-orange);
  --btn-primary-text:    var(--primitive-asphalt); /* orange ground text is always asphalt, never white */
  --btn-secondary-bg:    var(--primitive-asphalt);
  --btn-secondary-text:  var(--primitive-white);
  --btn-min-height:      48px;
  --btn-radius:          var(--primitive-radius-md);

  --card-radius:         var(--primitive-radius-lg);
  --card-shadow:         0 4px 16px rgba(0, 0, 0, 0.08);
  --card-shadow-hover:   0 8px 32px rgba(0, 0, 0, 0.14);

  --focus-ring-width:    3px;
  --focus-ring-offset:   2px;

  --error-colour:        var(--primitive-signal-red);
}

/* ─── BASE ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--primitive-font-family);
  font-size: var(--primitive-size-body);
  line-height: 1.65;
  color: var(--primitive-ink);
  background: var(--primitive-white);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--primitive-font-family); margin: 0; }

.h1, h1 {
  font-weight: 800;
  font-size: var(--primitive-size-h1);
  line-height: 1.06;
  text-transform: uppercase;
  color: var(--band-heading-text, var(--primitive-asphalt));
}

.h2, h2 {
  font-weight: 700;
  font-size: var(--primitive-size-h2);
  line-height: 1.2;
  color: var(--band-h2-text, var(--primitive-asphalt));
}

.h3, h3 {
  font-weight: 700;
  font-size: var(--primitive-size-h3);
  line-height: 1.3;
  color: var(--band-heading-text, var(--primitive-asphalt));
}

p { color: var(--band-body-text, var(--primitive-ink)); }

a { color: inherit; }

/* Visible focus everywhere - WCAG 2.2 2.4.7. Never suppressed with outline:none.
   Ring colour is band-aware (WCAG 1.4.11 non-text contrast, 3:1 minimum), not a
   fixed orange: orange-on-orange is 1:1 (invisible on the orange band itself),
   orange-on-white is 2.31:1 and orange-on-panel-grey is 2.04:1 - both fail 3:1.
   --band-heading-text already resolves to something that clears 3:1 against
   its own band background in all four colourways, so reusing it here is safe
   by construction rather than needing a fifth measured pairing. */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--band-heading-text, var(--primitive-asphalt));
  outline-offset: var(--focus-ring-offset);
}

.band {
  width: 100%;
  background: var(--band-bg);
  padding-block: var(--primitive-space-9);

  /* v12.2 - THE HAIRLINE BETWEEN SECTIONS. Founder 2026-11-09: "why is there a
     weird line between each section". Measured on the homepage: EVERY band
     boundary lands on a fractional pixel - at 768 the tops are .563, .531,
     .203, .281 and .078; at 1280 they are .672, 0, .75, .375 and .344. Two
     stacked bands therefore share one device row, and each one's background
     box is rounded to the device grid independently. Where the two roundings
     disagree, the row belongs to neither band and the page ground behind them
     (.tpc-light-ground, white) paints through it as a 1px line. Chrome blends
     that row instead of dropping it, which is why it is invisible here at 1x
     and 2x and still obvious on the iPad.
     The fix is an overlap, not a colour: every band is pulled up 1px and given
     1px back as top padding, so the box is exactly the height it was and the
     content does not move, while the band's own background now covers the
     contested row.
     PADDING, not a transparent top border. The border was the first cut and it
     made things WORSE - measured, the join went from flat to a hard 1px step,
     (147,40,16) over (160,41,14) on the why band and (232,97,28) over
     (244,147,29) on the close band. background-clip defaults to border-box so
     the background did paint under the border, but background-ORIGIN defaults
     to padding-box, so the gradient's 0% still began 1px lower and the extra
     row fell through to the repeat, which wraps to the gradient's END colour.
     Declaring `background-origin: border-box` here does not rescue it either:
     every band colourway sets `background:` as a SHORTHAND, and the shorthand
     resets origin to its initial padding-box, so the later rule always wins.
     Growing the padding box instead moves the gradient's origin with it, which
     is why this version measures flat.
     The one known cost: a page that re-declares `padding-block` on a specific
     band after this (.tpc-testimonial at mobile) cancels the compensation and
     that band's content sits 1px higher. The overlap itself still holds, which
     is the part that matters. */
  margin-top: -1px;
  padding-top: calc(var(--primitive-space-9) + 1px);
}

.band__inner {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--primitive-space-5);
}

@media (max-width: 1024px) {
  .band { padding-block: var(--primitive-space-7); padding-top: calc(var(--primitive-space-7) + 1px); }
}
