/*
 * Application shell: header, navigation, page frame, footer.
 * Mobile-first. Every wider rule is additive inside a min-width query.
 */

.shell {
  width: min(100% - (2 * var(--space-4)), var(--shell-width));
  margin-inline: auto;
}

@media (min-width: 48rem) {
  .shell {
    width: min(100% - (2 * var(--space-8)), var(--shell-width));
  }
}

/* ---------------------------------------------------------------- header */

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: color-mix(in oklab, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: var(--border-width) solid var(--line);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text-primary);
  font-family: var(--font-reading);
  font-weight: var(--weight-bold);
  font-size: var(--text-md);
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand__mark {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: var(--text-on-accent);
  font-family: var(--font-interface);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
  align-self: center;
}

.brand__word {
  color: var(--text-primary);
}

.site-header__spacer {
  flex: 1;
}

.primary-nav {
  display: none;
  align-items: center;
  gap: var(--space-1);
}

.primary-nav__link {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transition: background var(--duration-fast) var(--easing),
    color var(--duration-fast) var(--easing);
}

.primary-nav__link:hover {
  background: var(--surface-sunken);
  color: var(--text-primary);
}

/* The current page is a filled chip, not an underlined one.
 *
 * This used to be a sunken background with `box-shadow: inset 0 -2px 0` under
 * it — a rule drawn along the bottom edge. Two marks were doing one job, and
 * the underline is the older of the two idioms: it comes from tabbed documents,
 * where the selected tab had to look joined to the sheet below it. Nothing here
 * is joined to anything, so the rule was decoration that read as an artefact.
 *
 * The chip is the same treatment the mobile navigation already used, so the
 * two now look like one control at two widths rather than two controls. The
 * border carries the shape where accent-soft sits close to the surface colour,
 * which is what happens in dark mode.
 */
.primary-nav__link[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

@media (min-width: 60rem) {
  .primary-nav {
    display: flex;
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ------------------------------------------------------------- mobile nav */

.mobile-nav {
  display: block;
  border-bottom: var(--border-width) solid var(--line);
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}

.mobile-nav::-webkit-scrollbar {
  display: none;
}

.mobile-nav__list {
  display: flex;
  gap: var(--space-1);
  padding-block: var(--space-2);
}

.mobile-nav__link {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  text-decoration: none;
}

.mobile-nav__link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  border: var(--border-width) solid var(--accent-border);
}

@media (min-width: 60rem) {
  .mobile-nav {
    display: none;
  }
}

/* ----------------------------------------------------------------- main */

.page {
  flex: 1;
  padding-block: var(--space-6) var(--space-16);
}

/*
 * The page region is focused after every navigation so keyboard and screen
 * reader users land on the new content. It is a programmatic target, not a tab
 * stop, so it must not paint the focus ring that real interactive controls use.
 */
.page:focus,
.page:focus-visible {
  outline: none;
  box-shadow: none;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-bottom: var(--space-5);
  margin-bottom: var(--space-6);
  border-bottom: var(--border-width) solid var(--line);
}

.page-header__eyebrow {
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.page-header__lead {
  max-width: var(--measure);
  color: var(--text-secondary);
  font-size: var(--text-md);
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* Two-column reading frame: content plus a contextual rail. The rail moves
   below the content on narrow viewports rather than being hidden, so nothing
   is only reachable on a desktop. */
.frame {
  display: grid;
  gap: var(--space-8);
  align-items: start;
}

@media (min-width: 64rem) {
  .frame {
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: var(--space-10);
  }

  .frame__rail {
    position: sticky;
    top: calc(56px + var(--space-6));
  }
}

.frame--narrow {
  max-width: var(--shell-narrow);
  margin-inline: auto;
}

.rail-block + .rail-block {
  margin-top: var(--space-6);
}

.rail-block__title {
  font-family: var(--font-interface);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  border-top: var(--border-width) solid var(--line);
  background: var(--surface-sunken);
  padding-block: var(--space-8);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
}

.site-footer__links a {
  color: var(--text-secondary);
  text-decoration: none;
}

.site-footer__links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.site-footer__note {
  max-width: var(--measure);
}

@media (min-width: 48rem) {
  .site-footer__inner {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
  }
}
