/* ==========================================================================
   Base — reset, typography, layout primitives, buttons, header
   ========================================================================== */

/* ---- Reset ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-height);
}

body {
  background: var(--color-white);
  color: var(--color-black);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

ul[role="list"] {
  list-style: none;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--color-brand-blue);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--color-black);
  color: var(--color-white);
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- Typography ---- */
.t-hero,
.t-h1,
.t-h2,
.t-h3,
.t-h4 {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.t-hero { font-size: var(--fs-hero); line-height: var(--lh-hero); letter-spacing: -0.035em; }
.t-h1   { font-size: var(--fs-h1);   line-height: var(--lh-h1);   letter-spacing: -0.03em; }
.t-h2   { font-size: var(--fs-h2);   line-height: var(--lh-h2); }
.t-h3   { font-size: var(--fs-h3);   line-height: var(--lh-h3); }
.t-h4   { font-size: var(--fs-h4);   line-height: var(--lh-h4);   letter-spacing: -0.01em; }

.t-body-xl { font-size: var(--fs-body-xl); line-height: var(--lh-body-xl); }
.t-body    { font-size: var(--fs-body);    line-height: var(--lh-body); }
.t-small   { font-size: var(--fs-small);   line-height: var(--lh-small); }

.t-label {
  font-family: var(--font-body);
  font-size: var(--fs-label);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---- Layout ---- */
.container {
  width: 100%;
  max-width: calc(var(--container-max) + var(--container-pad) * 2);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.grid-12 {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  column-gap: var(--grid-gap);
}

.section {
  padding-block: var(--section-standard);
}

.section--major {
  padding-block: var(--section-major);
}

/* Full-bleed sections manage their own padding */
.section--bleed {
  width: 100%;
  padding-block: 0;
}

/* ---- Button ----
   ONE button for the whole site. Do not add variants or style buttons elsewhere.

   Markup: <a class="btn" href="#">Label {% include "partials/icon-arrow.html" %}</a>
   Size:   add btn--sm for compact places (header)

   Rest:          outlined in brand colour, label + arrow in brand colour.
   Hover / press: the brand colour fills up from the bottom and the label +
                  arrow switch to --btn-on-color. The label colour swap is
                  timed to the moment the fill passes behind the text, so the
                  label is never the same colour as what is behind it.
   Press:         also nudges 1px down.
*/
.btn {
  --btn-color: var(--color-brand-blue);
  --btn-on-color: var(--color-white);
  --btn-fill-duration: 400ms;
  --btn-fill-ease: cubic-bezier(0.65, 0, 0.35, 1);

  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: 0 var(--space-5);
  font-family: var(--font-body);
  font-size: var(--fs-button);
  font-weight: var(--fw-semibold);
  line-height: 1;
  white-space: nowrap;
  color: var(--btn-color);
  background-color: transparent;
  border: 1.5px solid var(--btn-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  /* The fill crosses the text band (about 35 to 65% height) at ~40 to 60% of
     its duration with this symmetric easing, so the colour swap runs in
     that window. Same timing in reverse when the fill drains. */
  transition:
    color 100ms linear calc(var(--btn-fill-duration) * 0.4),
    transform var(--duration-fast) ease;
}

/* Fill layer: above the background, below the label */
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-color: var(--btn-color);
  transform: scaleY(0);
  transform-origin: 50% 100%;
  transition: transform var(--btn-fill-duration) var(--btn-fill-ease);
}

.btn:hover,
.btn:focus-visible,
.btn:active {
  color: var(--btn-on-color);
}

.btn:hover::before,
.btn:focus-visible::before,
.btn:active::before {
  transform: scaleY(1);
}

.btn:active {
  transform: translateY(1px);
}

.btn__arrow {
  flex: none;
  width: 16px;
  height: 16px;
  transition: transform var(--duration-base) var(--ease-out);
}

.btn:hover .btn__arrow,
.btn:focus-visible .btn__arrow,
.btn:active .btn__arrow {
  transform: translateX(4px);
}

.btn--sm {
  min-height: 42px;
  padding: 0 var(--space-4);
  gap: var(--space-2);
}

/* ---- Accent colours ----
   Put one on a page or component; children read:
   --accent       fills, rules, underlines, highlights
   --accent-on    text on top of an --accent fill
   --accent-text  accent-coloured TEXT on light backgrounds. Orange is too light
                  to read on white (about 1.9:1), so orange pages use black text. */
.accent--red    { --accent: var(--color-brand-red);    --accent-on: var(--color-white); --accent-text: var(--color-brand-red); }
.accent--orange { --accent: var(--color-brand-orange); --accent-on: var(--color-black); --accent-text: var(--color-black); }
.accent--blue   { --accent: var(--color-brand-blue);   --accent-on: var(--color-white); --accent-text: var(--color-brand-blue); }

/* ---- Carousel (shared) ----
   Used wherever 2+ images share one media frame (case studies, products).
   Markup: .carousel[data-carousel] > .carousel__track > .carousel__slide > img,
   plus .carousel__controls. The parent frame must be position: relative with a size.
   Set --carousel-accent on an ancestor to colour the button hover.
   .carousel--text: for text slides (e.g. testimonials). Normal flow instead of
   a fixed frame, slides size to their content, controls sit below. */
.carousel,
.carousel__track {
  position: absolute;
  inset: 0;
}

.carousel__track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.carousel__track::-webkit-scrollbar {
  display: none;
}

.carousel__slide {
  position: relative;
  flex: 0 0 100%;
  scroll-snap-align: start;
  overflow: hidden;
}

/* Image carousels only: the image fills the slide. Text slides (.carousel--text)
   keep their images (e.g. headshots) at their own size. */
.carousel:not(.carousel--text) .carousel__slide img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel__controls {
  position: absolute;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 1;
  display: flex;
  align-items: center;
  background: var(--color-pitch-black);
  color: var(--color-white);
}

.carousel__count {
  min-width: 56px;
  font-size: var(--fs-label);
  font-weight: var(--fw-semibold);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.carousel__btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--color-white);
  transition: color var(--duration-fast) ease;
}

.carousel__btn:hover {
  color: var(--carousel-accent, var(--color-brand-blue));
}

.carousel__btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.carousel__btn .btn__arrow {
  transition: transform var(--duration-base) var(--ease-out);
}

.carousel__btn--prev .btn__arrow {
  transform: rotate(180deg);
}

/* Text variant */
.carousel--text,
.carousel--text .carousel__track {
  position: relative;
  inset: auto;
}

.carousel--text .carousel__track {
  align-items: flex-start;
}

.carousel--text .carousel__slide {
  overflow: visible;
}

.carousel--text .carousel__controls {
  position: static;
  display: inline-flex;
  margin-top: var(--space-8);
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
}

.carousel--text .carousel__btn {
  color: inherit;
}

/* ---- Forms (shared) ----
   Wrap a form in .form. Fields: .field > .field__label + input/textarea,
   .field__error under it. Checkbox pills: .choices > label.choice > input + span.
   Functional UI, so inputs use the 6px radius. */
.form {
  display: grid;
  gap: var(--space-6);
}

.form__row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
}

.field {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field__label {
  padding: 0;
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  color: var(--color-black);
}

.field__label span {
  font-weight: var(--fw-regular);
  color: var(--color-gray-500);
}

.form input:not([type="checkbox"]):not([type="radio"]),
.form textarea,
.form select {
  width: 100%;
  min-height: 52px;
  padding: var(--space-3) var(--space-4);
  font: inherit;
  font-size: var(--fs-body);
  color: var(--color-black);
  background: var(--color-white);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.form textarea {
  min-height: 160px;
  resize: vertical;
}

.form input:hover:not([type="checkbox"]),
.form textarea:hover {
  border-color: var(--color-gray-500);
}

.form input:focus-visible,
.form textarea:focus-visible,
.form select:focus-visible {
  outline: none;
  border-color: var(--color-brand-blue);
  box-shadow: 0 0 0 3px rgb(37 102 183 / 0.18);
}

.form [aria-invalid="true"] {
  border-color: var(--color-brand-red);
}

.field__error,
.form__error {
  font-size: var(--fs-small);
  color: var(--color-brand-red);
}

/* Checkbox pills */
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.choice {
  position: relative;
  cursor: pointer;
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-5);
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  color: var(--color-gray-700);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-pill);
  transition: color var(--duration-fast) ease, background-color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.choice:hover span {
  border-color: var(--color-black);
  color: var(--color-black);
}

.choice input:checked + span {
  color: var(--color-white);
  background: var(--color-brand-blue);
  border-color: var(--color-brand-blue);
}

.choice input:focus-visible + span {
  outline: 2px solid var(--color-brand-blue);
  outline-offset: 3px;
}

/* Honeypot: off screen for people, still in the form for bots */
.form__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form__submit {
  justify-self: start;
}

/* Success notice after sending */
.form-notice {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  padding: var(--space-5) var(--space-6);
  background: var(--color-gray-50);
  border-left: 3px solid var(--color-brand-blue);
}

@media (max-width: 640px) {
  .form__row {
    grid-template-columns: minmax(0, 1fr);
  }

  .form__submit {
    justify-self: stretch;
  }
}

/* ---- Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-white);
  border-bottom: 1px solid transparent;
  transition: border-color var(--duration-base) ease;
}

.site-header.is-scrolled {
  border-bottom-color: var(--color-gray-200);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  height: var(--header-height);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
}

.logo__mark {
  width: auto;
  height: 36px;
}

@media (max-width: 640px) {
  .logo__mark {
    height: 30px;
  }
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-7);
}

.site-nav__list {
  display: flex;
  gap: var(--space-6);
}

.site-nav__link {
  position: relative;
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  color: var(--color-gray-700);
  transition: color var(--duration-fast) ease;
}

.site-nav__link:hover {
  color: var(--color-black);
}

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  margin-right: calc(var(--space-3) * -1);
}

.nav-toggle__bars,
.nav-toggle__bars::before {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-black);
  transition: transform var(--duration-base) var(--ease-out);
}

.nav-toggle__bars {
  position: relative;
  transform: translateY(-4px);
}

.nav-toggle__bars::before {
  content: "";
  position: absolute;
  top: 8px;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars {
  transform: translateY(0) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before {
  transform: translateY(-8px) rotate(-90deg);
}

@media (max-width: 1024px) {
  .nav-toggle {
    display: inline-flex;
  }

  .site-nav {
    position: fixed;
    inset: var(--header-height) 0 0 0;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-8);
    padding: var(--space-8) var(--container-pad);
    background: var(--color-white);
    border-top: 1px solid var(--color-gray-200);
    visibility: hidden;
    opacity: 0;
    transition: opacity var(--duration-base) ease, visibility 0s linear var(--duration-base);
  }

  .site-nav.is-open {
    visibility: visible;
    opacity: 1;
    transition: opacity var(--duration-base) ease;
  }

  .site-nav__list {
    flex-direction: column;
    gap: 0;
  }

  .site-nav__link {
    display: block;
    padding-block: var(--space-4);
    font-family: var(--font-display);
    font-size: var(--fs-h3);
    line-height: var(--lh-h3);
    color: var(--color-black);
    border-bottom: 1px solid var(--color-gray-200);
  }

  .site-nav .btn {
    align-self: flex-start;
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
}
