/* Structure only: where things sit and how the page reflows. Color and type
   live in style.css, values in tokens.css. Phone first; the wider layouts
   switch on at 48rem. */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* A word longer than the screen breaks instead of widening the page. */
  overflow-wrap: break-word;
}

main {
  flex: 1;
}

/* A linked section stops below the top edge, not flush against it. */
section[id] {
  scroll-margin-top: var(--space-4);
}

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

/* Every band of the page holds one of these: the content column. */
.wrap {
  width: 100%;
  max-width: var(--page-width);
  margin-inline: auto;
  padding-inline: var(--space-3);
}

section {
  padding-block: var(--space-6);
}

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

.skip-link {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  z-index: 20;
  padding: var(--space-2) var(--space-3);
  transform: translateY(-200%);
}

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

/* ---- header: the repo's tested simple bar (skills/rebuild-navigation) ---- */

.site-header {
  position: relative;
  z-index: 10;
}

.site-header .bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: var(--page-width);
  margin-inline: auto;
  padding: var(--space-3);
}

/* A long name wraps inside its own space instead of pushing the buttons off. */
.site-header .brand {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* On a narrow phone the name gets the room. The same button opens the page
   just below, so nothing is lost. */
@media (max-width: 29.99rem) {
  .site-header .button {
    display: none;
  }
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* On a phone the links live in a drawer from the right. */
.site-nav[popover] {
  box-sizing: border-box;
  position: fixed;
  inset: 0 0 0 auto;
  width: min(20rem, 85vw);
  height: 100dvh;
  margin: 0;
  padding: var(--space-4);
  border: 0;
  overflow-y: auto;
}

.site-nav .menu-close {
  display: grid;
  margin-inline-start: auto;
  margin-block-end: var(--space-4);
}

.menu > li + li {
  margin-block-start: var(--space-2);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
}

.icon-button svg {
  width: 1.5rem;
  height: 1.5rem;
}

@media (min-width: 48rem) {
  .site-header .menu-toggle,
  .site-header .menu-close {
    display: none;
  }

  .site-header .bar {
    gap: var(--space-4);
    padding-inline: var(--space-5);
  }

  .site-nav[popover] {
    display: block;
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    padding: 0;
    overflow: visible;
  }

  .menu {
    display: flex;
    gap: var(--space-4);
  }

  .menu > li + li {
    margin: 0;
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  margin: var(--space-4) 0 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: var(--space-2) var(--space-4);
}

.button--small {
  min-height: 2.5rem;
  padding-inline: var(--space-3);
  flex: none;
}

.section-head {
  margin-block-end: var(--space-4);
}

.split {
  display: grid;
  gap: var(--space-5);
}

address {
  margin-block: var(--space-4) 0;
}

.site-footer {
  padding-block: var(--space-6) var(--space-4);
}

.footer-grid {
  display: grid;
  gap: var(--space-5);
}

/* A grid column is as wide as its longest word unless told it may shrink. */
.footer-grid > *,
.split > * {
  min-width: 0;
}

.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-footer li + li {
  margin-block-start: var(--space-2);
}

.colophon {
  margin-block-start: var(--space-5);
  padding-block-start: var(--space-4);
  max-width: none;
}

@media (min-width: 48rem) {
  .wrap {
    padding-inline: var(--space-5);
  }

  section {
    padding-block: var(--space-7);
  }

  .split {
    grid-template-columns: 3fr 2fr;
    gap: var(--space-7);
    align-items: start;
  }

  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

/* ---- the header on a wide screen: the name keeps its words ----
   However long the name and however many links, the bar wraps instead of
   squeezing: the name holds at least 16em of its own type (two lines for a
   long one), the links wrap among themselves, and when they still do not fit
   beside the name they move to a row of their own below it. Nothing here
   depends on the name's length or the number of links (ADR 0077, 2026-10-28:
   a 26-letter name beside seven links read one letter per line). */
@media (min-width: 48rem) {
  .site-header .bar {
    flex-wrap: wrap;
    row-gap: var(--space-2);
  }

  .site-header .brand {
    flex: 0 1 auto;
    min-width: min(100%, 16em);
  }

  .site-header .site-nav[popover] {
    flex: 1 1 24rem;
    min-width: 0;
  }

  .site-header .menu {
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: var(--space-2);
  }

  .site-header .menu a {
    white-space: nowrap;
  }

  .site-header .bar > .button {
    flex: none;
    margin-inline-start: auto;
  }
}
