* { box-sizing: border-box; }
html { scroll-padding-top: var(--header-height); }
body { margin: 0; background: var(--background); color: var(--text); line-height: 1.5; }
a { color: inherit; }
img, video { display: block; max-width: 100%; }
button, select, input, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.rail { width: min(var(--width), calc(100% - clamp(32px, 8vw, 96px))); margin-inline: auto; }
.block { position: relative; isolation: isolate; padding-block: var(--space-normal); }
.block h2 { margin: 0 0 .9em; color: var(--accent); font-size: clamp(1.3rem, 3vw, 2rem); line-height: 1.2; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.skip-link {
  position: fixed; z-index: 5; top: .75rem; left: .75rem;
  padding: .65rem 1rem; background: var(--surface);
  transform: translateY(calc(-100% - 1.5rem));
}
.skip-link:focus { transform: none; }

.site-header {
  position: sticky; top: 0; z-index: 4;
  margin-bottom: calc(-1 * var(--header-height));
  background-color: transparent;
  transition: background-color 300ms ease-in-out;
}
.site-header:is([data-scrolled], [data-menu-open]) { background-color: var(--header-background); }
.header-rail {
  height: var(--header-height);
  width: min(1240px, calc(100% - 32px));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand {
  min-width: 0; color: #d6d6d6; text-decoration: none;
  font: 500 20px/1.2 Karla, system-ui, sans-serif;
  letter-spacing: .12em; text-transform: uppercase;
}
.site-header nav { display: flex; gap: clamp(.65rem, 3.2vw, 2.5625rem); }
.site-header nav a {
  text-decoration: none; color: var(--muted); font-size: var(--nav-size);
  line-height: var(--nav-line); white-space: nowrap; font-weight: 400; letter-spacing: -.025em;
}
.site-header nav a:is([aria-current], :hover, :focus-visible) { color: var(--accent); }
.site-header nav a[aria-current] { text-decoration: underline; text-underline-offset: .45em; }
.menu-toggle { display: none; }

/* Keep the fade endpoint and footer edge in the same horizontal color space. */
.page-home, body:has(.resume-page) { --footer-surface: linear-gradient(90deg, #090909, var(--chrome)); }
.site-footer {
  text-align: center; padding: 1.25rem 0 1.5rem;
  font-size: 75%; --contact-icon-size: 16.5px;
  background: var(--footer-surface, linear-gradient(105deg, #090909, var(--chrome)));
  color: var(--text-soft);
}
.site-footer p { margin: 0; }
.footer-links { display: flex; justify-content: center; gap: clamp(2.8px, 2.5vw, 36px); max-width: 36rem; }
.contact-links a { display: grid; place-items: center; min-width: 44px; min-height: 44px; color: var(--accent); }
.contact-links a:is(:hover, :focus-visible) { color: var(--text); }
.contact-icon { width: var(--contact-icon-size, 22px); height: var(--contact-icon-size, 22px); object-fit: contain; }
.contact-icon-mask { background: currentColor; mask: var(--contact-icon) center / contain no-repeat; }

@media (max-width: 768px) {
  :root { --header-height: 66px; }
  .brand { font-size: 16px; letter-spacing: .1em; }
  .site-header nav { gap: .6rem; flex-wrap: wrap; justify-content: end; }
  .site-header[data-menu-ready] nav {
    position: absolute; top: 100%; inset-inline: 0; display: none;
    flex-direction: column; align-items: flex-end; gap: .25rem;
    padding: .5rem 1rem 1rem;
    background: var(--header-background);
    max-height: calc(100dvh - var(--header-height)); overflow-y: auto;
  }
  .site-header[data-menu-open] nav { display: flex; }
  .site-header[data-menu-ready] nav a { display: grid; align-items: center; min-height: 44px; }
  .menu-toggle:not([hidden]) {
    display: grid; place-items: center; flex: 0 0 44px; height: 44px;
    border: 0; background: transparent; color: var(--text-soft);
  }
  .menu-toggle span { width: 22px; height: 2px; background: currentColor; box-shadow: 0 -7px, 0 7px; }
}
@media (prefers-reduced-motion: reduce) { .site-header { transition: none; } }

/* Keep text clear of the sticky header while the first background extends behind it. */
#main-content > :is(.portfolio-projects, .resume-page) {
  padding-block-start: calc(var(--space-normal) + var(--header-height));
}
.portfolio-case > .case-section:first-of-type { padding-block-start: var(--header-height); }
