/* ===========================================================================
   First Steps YCCI - base layer
   Reads the tokens in docs/tokens.css. Never hard-code a colour or a size
   here that a token already names.
   Structure: reset -> type -> layout -> components -> nav -> footer
   =========================================================================== */

/* ------------------------------- 1. reset -------------------------------- */

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

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

body {
  margin: 0;
  background: var(--color-page);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  /* Alice ships regular 400 only. Let a stray <strong> fail visibly in
     development rather than shipping as faux bold. Brief section 5.1. */
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a { color: inherit; }

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

:root { --nav-height: 76px; }
@media (max-width: 800px) { :root { --nav-height: 64px; } }

/* -------------------------------- 2. type -------------------------------- */
/* Playfair at 22px and up only; below 18px is always Alice. Brief section 5.2. */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--color-ink);
  text-wrap: balance;
}

h1 { font-size: var(--text-h1); font-weight: 500; line-height: var(--leading-tight); }
h2 { font-size: var(--text-h2); font-weight: 500; line-height: 1.18; }
h3 { font-size: var(--text-h3); font-weight: 600; line-height: var(--leading-snug); }
h4 { font-size: var(--text-h4); font-weight: 600; line-height: 1.35; }

.display {
  font-family: var(--font-display);
  font-size: var(--text-display);
  font-weight: 500;
  line-height: var(--leading-tight);
  text-wrap: balance;
}

.lead    { font-size: var(--text-lead);    line-height: 1.55; }
.small   { font-size: var(--text-small);   line-height: var(--leading-small); }
.caption { font-size: var(--text-caption); line-height: 1.5; color: var(--color-ink-secondary); }

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-caption);
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--color-ink-secondary);
  margin: 0;
}

p { max-width: var(--measure); }

/* Viewports under 600px step the two largest sizes down. Brief section 5.3. */
@media (max-width: 600px) {
  .display { font-size: 2.25rem; }  /* 36px */
  h1       { font-size: 1.875rem; } /* 30px */
  h2       { font-size: 1.75rem; }  /* 28px */
}

/* ------------------------------- 3. layout ------------------------------- */

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

.container--narrow { max-width: var(--container-narrow); }

.section { padding-block: var(--space-9); }
@media (max-width: 800px) { .section { padding-block: var(--space-7); } }

.section--warm { background: var(--color-surface-warm); }

.section__head { max-width: var(--container-narrow); margin-bottom: var(--space-7); }
.section__title { margin-top: var(--space-3); }
.section__intro {
  margin-top: var(--space-4);
  color: var(--color-ink-secondary);
  font-size: var(--text-lead);
  line-height: 1.55;
}

.section__cta {
  margin-top: var(--space-7);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
}
.section__cta-note { margin: 0; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-10));
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  color: var(--color-ink);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top var(--dur-fast) var(--ease-out);
}
.skip-link:focus { top: var(--space-4); }

/* ----------------------------- 4. components ----------------------------- */
/* Buttons. Label is verb-first and names the outcome. Brief section 7. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--button-min-target);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  transition: background-color var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}

.btn--sm { min-height: 40px; padding: var(--space-2) var(--space-4); font-size: var(--text-small); }

.btn--primary {
  background: var(--button-primary-bg);
  color: var(--button-primary-fg);
}
.btn--primary:hover { background: var(--color-action-hover); }

.btn--secondary {
  background: transparent;
  color: var(--button-secondary-fg);
  border: var(--border-control) solid var(--button-secondary-border);
}
.btn--secondary:hover { border-color: var(--color-ink); background: var(--color-surface); }

.btn--urgent {
  background: var(--button-urgent-bg);
  color: var(--button-urgent-fg);
}
.btn--urgent:hover { background: var(--color-urgent-hover); }

.btn--tertiary {
  padding-inline: 0;
  color: var(--color-ink);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* Inverse pair - for use ON the hero scrim only, where an ink-filled button
   would disappear. White field carries ink at 12.3:1. */
.btn--inverse {
  background: var(--color-surface);
  color: var(--color-ink);
}
.btn--inverse:hover { background: var(--color-surface-warm); }

.btn--inverse-outline {
  background: transparent;
  color: var(--color-ink-inverse);
  border: var(--border-control) solid var(--color-ink-inverse);
}
.btn--inverse-outline:hover { background: rgba(255, 255, 255, 0.12); }

/* Chips. Pastel fill, ink text, never white text. Brief section 3.3. */
.chip {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--chip-radius);
  background: var(--color-fill-blush);
  color: var(--chip-fg);
  font-size: var(--text-caption);
  line-height: 1.5;
}

/* Framed image - the structural motif. White mat, hairline, square corners. */
.frame {
  background: var(--image-mat-bg);
  padding: var(--image-mat-pad);
  border: var(--image-mat-border);
  border-radius: var(--radius-image);
}
.frame img { border-radius: var(--radius-image); width: 100%; }
.frame__caption {
  margin-top: var(--space-2);
  font-size: var(--text-caption);
  color: var(--color-ink-secondary);
}

/* Simple prose block used by the pages that are still stubs. */
.page-head { padding-block: var(--space-9) var(--space-7); }
.page-head__title { margin-top: var(--space-3); }
.page-head__intro {
  margin-top: var(--space-4);
  color: var(--color-ink-secondary);
  font-size: var(--text-lead);
  line-height: 1.55;
}

.placeholder-note {
  margin-top: var(--space-6);
  padding: var(--space-5);
  background: var(--color-surface);
  border: var(--border-hairline) solid var(--color-border);
  border-radius: var(--radius-lg);
  max-width: var(--container-narrow);
}
.placeholder-note p + p { margin-top: var(--space-3); }
.placeholder-note .chip { margin-bottom: var(--space-3); }

/* -------------------------------- 5. nav --------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-page);
  border-bottom: var(--border-hairline) solid var(--color-border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  /* The header's 1px bottom border sits outside this box - subtract it so the
     header measures exactly --nav-height and the hero still fits one screen. */
  min-height: calc(var(--nav-height) - var(--border-hairline));
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--color-ink);
}
.nav__mark { width: 44px; height: 44px; }
.nav__name {
  font-family: var(--font-display);
  font-size: var(--text-h4);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.nav__list { display: flex; align-items: center; gap: var(--space-5); }

.nav__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--button-min-target);
  text-decoration: none;
  font-size: var(--text-small);
}

/* Colour belongs to the plain items only. This block sits after .btn--primary
   in the cascade and carries the same specificity, so setting `color` on the
   bare .nav__link would win and paint the Donate label ink-on-ink. The button
   keeps its component pair from brief section 7: white on --color-action. */
.nav__link:not(.btn) {
  color: var(--color-ink);
  border-bottom: 2px solid transparent;
}
.nav__link:not(.btn):hover { border-bottom-color: var(--color-ink); }
.nav__link:not(.btn).is-current { border-bottom-color: var(--color-ink); }

.nav__link.btn--primary { color: var(--button-primary-fg); }

.nav__toggle {
  display: none;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--button-min-target);
  padding-inline: var(--space-2);
  font-size: var(--text-small);
}
.nav__toggle-bars {
  position: relative;
  display: block;
  width: 20px; height: 2px;
  background: var(--color-ink);
}
.nav__toggle-bars::before,
.nav__toggle-bars::after {
  content: ""; position: absolute; left: 0;
  width: 20px; height: 2px; background: var(--color-ink);
}
.nav__toggle-bars::before { top: -6px; }
.nav__toggle-bars::after  { top: 6px; }

@media (max-width: 800px) {
  .nav__toggle { display: inline-flex; }
  .nav__name { font-size: var(--text-body); }
  .nav__mark { width: 36px; height: 36px; }

  .nav__menu {
    display: none;
    position: absolute;
    left: 0; right: 0;
    top: var(--nav-height);
    background: var(--color-page);
    border-bottom: var(--border-hairline) solid var(--color-border);
    box-shadow: var(--shadow-overlay);
    padding: var(--space-4) var(--space-5) var(--space-6);
  }
  .nav__menu.is-open { display: block; }

  .nav__list { flex-direction: column; align-items: stretch; gap: var(--space-2); }
  .nav__link { justify-content: flex-start; }
  .nav__link.btn { justify-content: center; margin-top: var(--space-3); }
}

/* ------------------------------- 6. footer ------------------------------- */

.site-footer {
  margin-top: var(--space-9);
  background: var(--color-page);
  border-top: var(--border-hairline) solid var(--color-border);
  padding-block: var(--space-8) var(--space-6);
}

.footer__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}

.footer__logo { width: 96px; height: 96px; }
.footer__desc {
  margin-top: var(--space-4);
  color: var(--color-ink-secondary);
  max-width: 46ch;
}
.footer__contact { margin-top: var(--space-3); display: grid; }
.footer__contact a {
  display: inline-flex;
  align-items: center;
  min-height: var(--button-min-target);
  width: fit-content;
  text-underline-offset: 0.2em;
}

.footer__cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-6);
}
.footer__links { margin-top: var(--space-2); display: grid; }
.footer__links a {
  display: inline-flex;
  align-items: center;
  /* Brief section 10 commits to 44px targets, footer links included. */
  min-height: var(--button-min-target);
  width: fit-content;
  text-decoration: none;
}
.footer__links a:hover { text-decoration: underline; text-underline-offset: 0.2em; }

.footer__bottom {
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: var(--border-hairline) solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
  justify-content: space-between;
}

@media (max-width: 800px) {
  .footer__inner { grid-template-columns: 1fr; gap: var(--space-7); }
}

/* --------------------------- 7. scroll progress -------------------------- */
/* The bar is created by js/scroll.js and only exists when motion is allowed,
   so there is nothing to hide for prefers-reduced-motion. It rides above the
   sticky header, which is what sits behind it once the page has moved. */

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: 3px;
  background: var(--color-action);
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}
