/* ==========================================================================
   Base — reset, typography, layout primitives, utilities, motion defaults.
   ========================================================================== */

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { min-height: 100vh; }
  img, picture, svg { display: block; max-width: 100%; }
  img { height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { background: none; border: 0; padding: 0; cursor: pointer; }
  ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
  a { color: inherit; }
  p, h1, h2, h3, h4 { overflow-wrap: break-word; }
}

@layer base {
  html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + var(--header-top) + 1rem);
  }

  body {
    font-family: var(--font-base);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    color: var(--color-text);
    background: var(--color-page);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  body.is-locked { overflow: hidden; }

  h1, h2, h3 {
    color: var(--color-primary);
    font-weight: 700;
    line-height: var(--lh-heading);
    text-wrap: pretty; /* "balance" re-flows lines differently from Figma's fixed text boxes */
  }

  h2 { font-size: var(--fs-h2); }
  h3 { font-size: var(--fs-h3); line-height: 1.33; }
  p { text-wrap: pretty; }

  /* Highlighted phrase inside a heading ("… Public Sector …") */
  .hl { color: var(--color-accent-text); }

  :focus-visible {
    outline: 3px solid var(--color-cta);
    outline-offset: 3px;
    border-radius: 4px;
  }
  .on-dark :focus-visible { outline-color: var(--color-text-on-dark); }

  ::selection { background: var(--color-cta); color: var(--color-primary); }

  /* ---- Layout primitives ----
     .container is the page grid: 1 flexible outer column each side + content columns.
     Desktop (≥1024): 14 content columns of ≤70px with 30px gutters → 16-column grid centred.
     Tablet: 8 columns / 24px gutters. Mobile: 4 columns / 16px gutters.
     Direct children span the content area; use .col-* helpers to sit on the grid. */
  .container {
    --cols: 4;
    --gap: 16px;
    display: grid;
    /* Small screens: fixed side margins (gutter), content columns share the rest */
    grid-template-columns:
      [full-start] max(0px, calc(var(--gutter) - var(--gap)))
      [grid-start content-start] repeat(var(--cols), minmax(0, 1fr)) [content-end grid-end]
      max(0px, calc(var(--gutter) - var(--gap))) [full-end];
    column-gap: var(--gap);
    width: 100%;
  }
  @media (min-width: 640px) { .container { --cols: 8; --gap: 24px; } }
  /* Desktop: the Figma grid. 16 columns (≤70px) + 30px gutters, centred;
     content occupies columns 2–15. At 1920px content sits at x 275–1645. */
  @media (min-width: 1024px) {
    .container {
      --gap: var(--grid-gap);
      grid-template-columns:
        [full-start] minmax(0, 1fr)
        [grid-start] minmax(0, var(--grid-col))
        [content-start] repeat(14, minmax(0, var(--grid-col))) [content-end]
        minmax(0, var(--grid-col)) [grid-end]
        minmax(0, 1fr) [full-end];
    }
  }
  .container > * { grid-column: content; min-width: 0; }

  /* Optional placement on the 14-column grid (desktop only) */
  @media (min-width: 1024px) {
    .container > .col-1-5  { grid-column: content-start / span 5; }
    .container > .col-6-14 { grid-column: span 9 / content-end; }
  }

  /* Dev aid: grid overlay toggled with Shift+G or ?grid in the URL (js/grid-overlay.js) */
  .grid-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
  }
  /* The overlay reuses .container, so it always matches the live grid */
  .grid-overlay .container { height: 100%; }
  .grid-overlay__col { grid-column: auto; height: 100%; background: var(--grid-overlay); }
  .grid-overlay__col:first-child { grid-column: grid-start; }
  .grid-overlay__col:nth-child(n + 5) { display: none; }                 /* mobile: 4 */
  @media (min-width: 640px) { .grid-overlay__col:nth-child(-n + 8) { display: block; } }  /* tablet: 8 */
  @media (min-width: 1024px) { .grid-overlay__col:nth-child(n) { display: block; } }      /* desktop: 16 */

  .section { padding-block: var(--section-gap); }
  .section--flush-top { padding-top: 0; }

  .section__head { max-width: 62rem; margin-bottom: clamp(2rem, 4vw, 3rem); } /* Figma heading box: 982px */
  .section__head > * + * { margin-top: 1rem; }
  @media (min-width: 1024px) {
    .section__head--end { margin-left: auto; text-align: right; }
  }

  .lead { max-width: 44rem; }

  /* ---- Utilities ---- */
  .visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
  }

  .skip-link {
    position: absolute;
    left: 1rem; top: -100px;
    z-index: 100;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: var(--color-text-on-dark);
    font-weight: 700;
    text-decoration: none;
    transition: top var(--dur-base) var(--ease-out);
  }
  .skip-link:focus-visible { top: 1rem; }

}

/* ---- Scroll reveal (§9A). Content is visible by default; the hidden state only applies
   once JS has added .js-motion to <html>.
   - Uses the individual `translate` property, not `transform`, so an element's own hover
     transform (lift, scale) composes with the reveal instead of fighting it.
   - Deliberately UNLAYERED: unlayered rules beat every @layer, so a component's `transition`
     (e.g. .lift) can't cancel the reveal. The list therefore also carries `transform` for hover. ---- */
.js-motion [data-reveal] {
  opacity: 0;
  translate: 0 var(--reveal-distance);
  transition:
    opacity var(--dur-slow) var(--ease-out),
    translate var(--dur-slow) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
  transition-delay: calc(var(--i, 0) * var(--stagger)), calc(var(--i, 0) * var(--stagger)), 0s;
}
.js-motion [data-reveal="right"] { translate: calc(var(--reveal-distance) * 1.5) 0; }
.js-motion [data-reveal="fade"] { translate: none; }
.js-motion [data-reveal].is-visible { opacity: 1; translate: none; }

/* Cross-document page transitions (progressive — ignored where unsupported) */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 200ms; }

/* ---- Reduced motion: the one sanctioned use of !important (§9A) ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1 !important; translate: none !important; }
}

/* Designer's manual heading line breaks — desktop only */
@layer base {
  .br-lg { display: none; }
  @media (min-width: 1024px) { .br-lg { display: inline; } }
  /* Figma's exact line breaks (Technology Services, Figma 215:23). js/fit-lines.js adds
     .fig-breaks wherever every Figma line fits the column (any desktop width); without JS
     they show from 1600px, where the layout has Figma's full 1370px content width. */
  .br-fig { display: none; }
  .fig-breaks .br-fig { display: inline; }
  @media (min-width: 1600px) { html:not(.js) .br-fig { display: inline; } }
}

/* Public-sector site: homepage cards/buttons whose page isn't built have no href (UCI 2026-11-18); no link cursor */
@layer base {
  a:not([href]) { cursor: default; }
}
