/* ---------------------------------------------------------------------------
   Page structure: header, nav, main, footer.
   --------------------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--s-3) var(--s-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 700;
  font-size: var(--fs-lg);
  color: var(--c-text);
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
  color: var(--c-text);
}

.brand__mark {
  font-size: 1.4em;
  line-height: 1;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--c-text-muted);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
}

.site-nav a:hover {
  background: var(--c-surface);
  color: var(--c-text);
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  color: var(--c-text);
  background: var(--c-surface-2);
  font-weight: 600;
}

.site-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--s-6) var(--s-4) var(--s-8);
}

.site-footer {
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
  margin-top: var(--s-8);
}

.site-footer__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--s-6) var(--s-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-5);
  justify-content: space-between;
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}

.site-footer h3 {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-text);
  margin: 0 0 var(--s-2);
}

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

.site-footer li {
  margin-bottom: var(--s-1);
}

/* --- Reusable layout pieces --- */

.stack > * + * {
  margin-top: var(--s-4);
}

.grid {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.prose {
  max-width: 70ch;
}

/* --- Small screens --- */

@media (max-width: 640px) {
  :root {
    --fs-3xl: 1.875rem;
    --fs-2xl: 1.5rem;
  }

  .site-header__inner {
    padding: var(--s-3);
  }

  .site-main {
    padding: var(--s-5) var(--s-4) var(--s-7);
  }

  .site-nav a {
    padding: var(--s-2);
  }

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

/* --- Printing: strip the furniture, keep the content --- */

@media print {
  .site-header,
  .site-footer,
  .theme-toggle,
  .skip-link,
  .copy-btn,
  .wall-controls {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  .site-main {
    max-width: none;
    padding: 0;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555;
  }

  pre,
  blockquote,
  .card {
    break-inside: avoid;
    border: 1px solid #999;
  }
}
