/* ==========================================================================
   Base - reset, typography, layout primitives, accessibility floor
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* .site-header__inner is min-height 72px plus its 1px border. Anything
     scrolled to by an in-page link or by scrollIntoView() has to reserve it
     or it arrives underneath the header: /donate's jumpToForm() was landing
     the "How often" legend at y = -3, so the donor met a headless form. */
  --header-h: 73px;
}

/* Every in-page target clears the sticky header. :where() keeps the
   specificity at zero so any component can still set its own. */
:where([id]) {
  scroll-margin-top: calc(var(--header-h) + var(--s-5));
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out);
}

/* The `hidden` attribute has to actually hide.
   The user agent sets [hidden] { display: none } at the very bottom of the
   cascade, so ANY class rule that sets `display` beats it - and this codebase
   sets display on almost every component class. `.btn { display: inline-flex }`
   alone was enough to paint the apply wizard's Send and Back buttons on step 1
   while every script on the page believed they were hidden; clicking the
   phantom Send threw "not focusable" and teleported the applicant to step 4.
   One global rule, once, rather than a per-component patch each time it bites. */
[hidden] {
  display: none !important;
}

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

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: var(--tracking-display);
  line-height: var(--lh-snug);
  margin: 0 0 var(--s-4);
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-display-l);
  line-height: var(--lh-tight);
}
h2 {
  font-size: var(--fs-h2);
}
h3 {
  font-size: var(--fs-h3);
  letter-spacing: -0.02em;
}

p {
  margin: 0 0 var(--s-4);
  text-wrap: pretty;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover {
  text-decoration-thickness: 2px;
}

ul,
ol {
  margin: 0 0 var(--s-4);
  padding-left: 1.25em;
}
li {
  margin-bottom: var(--s-2);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--s-7) 0;
}

/* ---- Focus: visible, always. Never remove without a replacement. -------
   The dark-skin ring is a white outline with a coloured halo behind it. The
   halo used to be a literal rgba(90,169,255,.35) - Connect-IT 360 blue, hard
   coded - which meant every SharkMakers page still had one parent-brand
   colour on it, on the one element a keyboard user looks at most. It is a
   token now, derived from whichever --accent the brand resolved to, so the
   halo is blue on Connect-IT 360 and teal on SharkMakers. The white outline
   is what carries the 3:1 indicator contrast in both cases; the halo only
   has to separate the ring from the content behind it. */
:root {
  --focus-glow: color-mix(in srgb, var(--accent) 38%, transparent);
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}
:root[data-skin="dark"] :focus-visible {
  outline-color: #ffffff;
  box-shadow: 0 0 0 6px var(--focus-glow);
}

/* ---- Native form controls follow the skin ------------------------------
   Without this the UA paints radios and checkboxes in its light-mode
   rendering: an unchecked radio is a pale disc, which on a near-black form
   reads as a filled, already-answered option. Declaring the scheme makes the
   unchecked state an outline again and fixes scrollbars and select menus at
   the same time. */
:root,
:root[data-skin="dark"] {
  color-scheme: dark;
}
:root[data-skin="light"] {
  color-scheme: light;
}

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: var(--s-4);
  z-index: 200;
  transform: translateY(-200%);
  background: var(--accent);
  color: var(--accent-ink);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-md);
  font-weight: 600;
  text-decoration: none;
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus {
  transform: translateY(0);
}

.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;
}

/* ---- Layout ----------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--s-5);
}
@media (min-width: 768px) {
  .container {
    padding-inline: var(--s-6);
  }
}

.section {
  position: relative;
  padding-block: var(--section-y);
  background: var(--bg);
  color: var(--text);
}

.prose {
  max-width: var(--prose);
}
.prose h2 {
  margin-top: var(--s-7);
}
.prose h3 {
  margin-top: var(--s-6);
}
.prose > :first-child {
  margin-top: 0;
}

/* The card grids. Column counts are declared on a finer track so a short
   last row can be centred instead of hanging off the left edge.

   The item counts on /programs, /students, /mentors, /sponsors and the
   /donate amount tiles are what they are - they are set by how many
   programmes and partners there actually are, and nobody should be adding a
   filler card to make a row come out even. So the grid takes responsibility
   for it: every tile keeps the same width, and a last row that cannot fill
   is centred under the rows above. With a full last row none of these rules
   match and the layout is exactly as it was.

   Written on a 2x track (6 columns for a 3-up, 8 for a 4-up) because a
   centred offset has to be a whole number of columns: for a 3-up, one
   orphan starts at track 3 of 6, two orphans start at track 2. */
.grid {
  display: grid;
  gap: var(--s-5);
}
@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: repeat(4, 1fr);
  }
  .grid-2 > * {
    grid-column: span 2;
  }
  .grid-2 > :last-child:nth-child(odd) {
    grid-column: 2 / span 2;
  }
}
@media (min-width: 900px) {
  .grid-3 {
    grid-template-columns: repeat(6, 1fr);
  }
  .grid-3 > * {
    grid-column: span 2;
  }
  /* Last row of one. */
  .grid-3 > :last-child:nth-child(3n + 1) {
    grid-column: 3 / span 2;
  }
  /* Last row of two: place the first, and the second auto-flows after it. */
  .grid-3 > :nth-last-child(2):nth-child(3n + 1) {
    grid-column: 2 / span 2;
  }

  .grid-4 {
    grid-template-columns: repeat(8, 1fr);
  }
  .grid-4 > * {
    grid-column: span 2;
  }
  .grid-4 > :last-child:nth-child(4n + 1) {
    grid-column: 4 / span 2;
  }
  .grid-4 > :nth-last-child(2):nth-child(4n + 1) {
    grid-column: 3 / span 2;
  }
  .grid-4 > :nth-last-child(3):nth-child(4n + 1) {
    grid-column: 2 / span 2;
  }
}
@media (min-width: 640px) and (max-width: 899px) {
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
  .grid-3 > *,
  .grid-4 > * {
    grid-column: span 2;
  }
  .grid-3 > :last-child:nth-child(odd),
  .grid-4 > :last-child:nth-child(odd) {
    grid-column: 2 / span 2;
  }
}

.stack > * + * {
  margin-top: var(--s-4);
}
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
}

/* Wide content must scroll inside itself, never the page body. */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---- Motion: honour the user's setting. This is not optional here --
   accessibility is the curriculum this organisation teaches. ------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .parallax-layer {
    transform: none !important;
  }
  .reveal,
  .reveal--armed {
    opacity: 1 !important;
    transform: none !important;
  }
}
