/* Layout layer: page-width shell, header, footer, nav, page/post headers. */
@layer layout {
  :where(.site-header, .site-footer, .home-intro, .home-section, .page-shell, .post) {
    width: min(100% - 2 * var(--gutter), var(--page));
    margin-inline: auto;
  }

  .post {
    width: min(100% - 2 * var(--gutter), var(--measure-wide));
  }

  .skip-link {
    position: absolute;
    left: calc(var(--gutter) + env(safe-area-inset-left));
    top: calc(var(--space-3) + env(safe-area-inset-top));
    z-index: 10;
    transform: translateY(-150%);
    background: var(--color-fg);
    color: var(--color-bg);
    padding: var(--space-3) var(--space-4);
    min-block-size: 44px;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    transition: transform 150ms ease;
  }

  .skip-link:focus {
    transform: translateY(0);
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
  }

  .site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding-block: var(--space-8) var(--space-6);
    border-bottom: 1px solid var(--color-rule);
  }

  main {
    flex: 1 0 auto;
  }

  .site-title {
    color: var(--color-fg);
    font-size: var(--fs-lg);
    font-weight: var(--weight-bold);
    letter-spacing: -0.005em;
    text-decoration: none;
  }

  .header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-6);
    min-width: 0;
  }

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

  .site-nav a,
  .site-footer a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    color: var(--color-muted);
    text-decoration: none;
  }

  .site-nav a:hover,
  .site-footer a:hover {
    color: var(--color-fg);
    text-decoration: underline;
    text-underline-offset: 0.25em;
  }

  .site-nav a[aria-current='page'],
  .site-nav a[aria-current='true'] {
    color: var(--color-fg);
  }

  .site-footer {
    border-top: 1px solid var(--color-rule);
    margin-top: var(--space-16);
    padding-block: var(--space-8) var(--space-10);
  }

  .footer-meta {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: var(--space-2) var(--space-5);
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--color-muted);
    font-size: var(--fs-caption);
    white-space: nowrap;
  }

  .footer-meta a,
  .footer-meta > span {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .footer-meta a {
    padding-inline: var(--space-1);
    margin-inline: calc(-1 * var(--space-1));
  }

  .footer-copyright {
    gap: 0.25em;
  }

  .footer-contact {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: var(--space-2) var(--space-5);
    min-width: 0;
  }

  /* Page header (shared by .home-intro, .page-header, .post-header) */
  .home-intro {
    padding-block: clamp(2rem, 5vw, 4rem) var(--space-6);
  }

  .home-intro h1,
  .page-header h1,
  .post-header h1 {
    max-width: var(--measure-wide);
    color: var(--color-fg);
    font-size: var(--fs-3xl);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
    text-wrap: balance;
  }

  .home-intro-name {
    color: var(--color-accent);
  }

  .home-intro p:not(.eyebrow),
  .page-header p,
  .dek {
    max-width: var(--measure);
    color: var(--color-muted);
    font-size: var(--fs-dek);
  }

  .post-header {
    max-width: var(--measure-wide);
    padding-block: var(--space-10) var(--space-6);
  }

  .page-header {
    max-width: var(--measure-wide);
    padding-block: var(--space-2) var(--space-6);
  }

  .page-shell--full-width .page-header,
  .page-shell--full-width .page-header p,
  .page-shell--full-width .about-copy,
  .page-shell--full-width > .about-copy > p {
    width: 100%;
    max-width: none;
    max-inline-size: none;
  }

  .post-header .dek {
    margin-block: var(--space-4) 0;
  }

  .post-meta {
    margin-block: var(--space-3) 0;
    color: var(--color-muted);
    font-size: var(--fs-caption);
    line-height: 1.4;
  }

  .home-section,
  .page-shell {
    margin-top: var(--space-8);
  }
}
