/* Page shell: containers, header, footer. */

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

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

.container--narrow {
  max-width: calc(var(--measure) + var(--gutter) * 2);
}

.site-main {
  flex: 1;
  padding-block: var(--space-xl) var(--space-3xl);
}

/* Header ---------------------------------------------------------------- */

.site-header {
  border-bottom: var(--border-width) solid var(--border);
  background-color: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(180%) blur(12px);
  background-color: color-mix(in srgb, var(--bg) 85%, transparent);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2xs) var(--space-md);
  min-height: 4rem;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  text-decoration: none;
  white-space: nowrap;
  min-width: 0;
}

.site-logo__mark {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: var(--border-width) solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  transition: border-color var(--transition), color var(--transition);
}

.site-logo:hover .site-logo__mark {
  border-color: var(--accent);
  color: var(--accent);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: clamp(var(--space-xs), 2.5vw, var(--space-md));
}

/* On narrow phones the wordmark is dropped so the nav and the monogram still
   fit on one line — without this the header forces the whole page wider than
   the viewport. */
@media (max-width: 30rem) {
  /* Hidden visually but kept in the accessibility tree, so the logo link still
     has "Sean Behan" as its accessible name. */
  .site-logo__name {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .site-nav {
    gap: var(--space-xs);
  }
}

.site-nav__link {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
  padding-block: var(--space-3xs);
  border-bottom: 1px solid transparent;
}

.site-nav__link:hover {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.site-nav__link[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* Theme toggle ---------------------------------------------------------- */

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: color var(--transition), border-color var(--transition);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.theme-toggle svg {
  width: 1rem;
  height: 1rem;
}

/* Only one of the two icons is shown, depending on the resolved theme. */
.theme-toggle__moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle__moon { display: block; }
}

:root[data-theme="dark"] .theme-toggle__sun { display: none; }
:root[data-theme="dark"] .theme-toggle__moon { display: block; }
:root[data-theme="light"] .theme-toggle__sun { display: block; }
:root[data-theme="light"] .theme-toggle__moon { display: none; }

/* Footer ---------------------------------------------------------------- */

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

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm) var(--space-md);
}

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

.site-footer a {
  text-decoration: none;
  color: var(--text-muted);
}

.site-footer a:hover {
  color: var(--accent);
}

/* Flash messages -------------------------------------------------------- */

.flash {
  margin-bottom: var(--space-lg);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius);
  border: var(--border-width) solid var(--border);
  font-size: var(--text-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2xs);
}

.flash--notice {
  background-color: var(--success-subtle);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
  color: var(--text);
}

.flash--alert {
  background-color: var(--danger-subtle);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--text);
}

/* Section rhythm -------------------------------------------------------- */

.section {
  margin-block-start: var(--space-2xl);
}

.section__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-2xs);
  border-bottom: var(--border-width) solid var(--border);
}

.section__title {
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}

.section__link {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}

.section__link:hover {
  color: var(--accent);
}
