/* ==========================================================================
   base.css  reset, element defaults, typography, focus
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Anchor targets clear the sticky header instead of hiding under it. */
  scroll-padding-top: calc(var(--header-height) + var(--space-4));
  /* Browser surfaces. The world is light-only, so native controls and
     scrollbars stay light even on a device set to dark mode. The default tap
     flash is an off-palette blue; touch feedback is carried by :active and the
     focus ring instead. */
  color-scheme: light;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background-color: var(--color-background);
  color: var(--color-text);
  /* Theme the text caret. It is one of the few browser-drawn marks that
     belongs to no design system, and it sits on every form field. */
  caret-color: var(--color-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Guard against a single wide child producing horizontal scroll at 320px. */
  overflow-x: hidden;
  /* Placeholder tokens like [COMPANY_ESTABLISHED_YEAR] are long unbreakable
     strings. Without this they blow out a grid track at 320px and create
     horizontal scroll that no element bounding-box check will attribute. */
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  color: var(--color-text);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-display);
  font-weight: var(--weight-bold);
}
h2 { font-size: var(--text-section); }
h3 { font-size: var(--text-xl); line-height: var(--leading-snug); }
h4 { font-size: var(--text-md); line-height: var(--leading-snug); }

p {
  margin: 0;
  text-wrap: pretty;
}

p + p {
  margin-top: var(--space-4);
}

a {
  color: var(--color-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--color-accent);
}

img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

figure,
blockquote,
dl,
dt,
dd {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

table {
  border-collapse: collapse;
  width: 100%;
}

hr {
  border: 0;
  border-top: var(--border-hairline);
  margin: 0;
}

/* --------------------------------------------------------------------------
   Focus  dual ring.
   A light inner ring plus a dark outer ring. One of the two always contrasts
   against the ground it lands on (white body, navy band, or maroon button),
   which no single-colour ring achieves across this palette.
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--color-focus-inner);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px var(--color-focus-outer);
  border-radius: var(--radius-sm);
}

/* Mouse users keep the quiet look; keyboard users keep the loud ring. */
:focus:not(:focus-visible) {
  outline: none;
}

/* --------------------------------------------------------------------------
   Skip link  first tab stop on every page.
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: var(--z-skip);
  padding: var(--space-3) var(--space-5);
  background-color: var(--color-background);
  color: var(--color-primary-dark);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  /* The header ground is white, so the chip needs its own edge to be a
     visible object at all rather than relying on the shadow alone. */
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  transform: translateY(calc(-100% - var(--space-4)));
}

.skip-link:focus {
  transform: translateY(0);
  /* The shadow is applied on focus only. Parked off-screen it sat 4px below
     the viewport top with a 34px blur, painting a grey smear along the top of
     the white header on every page load. */
  box-shadow: var(--shadow-lg);
}

/* --------------------------------------------------------------------------
   Selection
   -------------------------------------------------------------------------- */
::selection {
  background-color: var(--color-accent);
  color: var(--color-background);
}

/* --------------------------------------------------------------------------
   Hidden. `hidden` is used to remove filtered-out catalogue cards and to
   reveal the empty state, so it must beat any component rule that sets a
   display value on the same element.
   -------------------------------------------------------------------------- */
[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Screen-reader-only. Used for text that exists for assistive tech only
   (icon button labels, table captions)  never for text a sighted user needs.
   -------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Motion. The brief allows subtle animation only, and this respects the OS
   setting rather than overriding it.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
