/* Header layout */
.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  border-bottom: 1px solid transparent;
  transition: background 180ms ease, border-color 180ms ease, backdrop-filter 180ms ease;
}

.site-header.is-scrolled {
  border-color: var(--color-border);
  background: rgb(13 13 15 / 0.78);
  backdrop-filter: blur(18px);
}

/* Navigation layout */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
}

.nav__menu {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

/* Hero layout */
.hero {
  min-height: calc(100svh - 76px);
  display: grid;
  align-items: center;
  padding-top: clamp(32px, 7vh, 56px);
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(300px, 0.78fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: center;
}

.hero__grid > *,
.section__grid > *,
.contact__grid > *,
.bento-grid > *,
.skill-matrix > * {
  min-width: 0;
}

.hero__content {
  display: grid;
  gap: 1.3rem;
  min-width: 0;
  max-width: 100%;
}

.hero__role {
  min-height: 2.4rem;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
}

.hero__copy {
  max-width: 58ch;
  font-size: var(--text-lg);
  overflow-wrap: anywhere;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.6rem;
  max-width: 100%;
}

/* Section grids */
.section__grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: start;
}

.section__grid--about {
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.2fr);
}

.section__content {
  display: grid;
  gap: 1.1rem;
}

/* Content grids */
.skill-matrix {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.bento-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  grid-auto-rows: minmax(220px, auto);
  gap: 1rem;
}

.project-card--featured {
  grid-row: span 2;
}

.contact__grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: clamp(2rem, 6vw, 5rem);
}

/* Footer and error page layout */
.footer__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 1rem;
  align-items: center;
}

.error-page {
  min-height: 100svh;
}

.error-shell {
  width: min(720px, calc(100% - 40px));
  min-height: 100svh;
  margin-inline: auto;
  display: grid;
  align-content: center;
  gap: 2rem;
}

/* Tablet and mobile layout */
@media (max-width: 900px) {
  .nav__menu {
    position: fixed;
    inset: 76px 16px auto 16px;
    display: grid;
    gap: 0.35rem;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: rgb(19 19 26 / 0.96);
    box-shadow: var(--shadow-soft);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-12px);
    transition: opacity 180ms ease, transform 180ms ease;
  }

  .nav__menu.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .hero__grid,
  .section__grid,
  .section__grid--about,
  .contact__grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .terminal-card {
    max-width: 560px;
    justify-self: start;
  }
}

/* Narrow desktop adjustments */
@media (max-width: 1180px) and (min-width: 901px) {
  .nav__link {
    padding-inline: 0.55rem;
  }

  .brand {
    max-width: 270px;
  }

  .brand__text small {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Mobile layout */
@media (max-width: 720px) {
  .nav {
    min-height: 68px;
  }

  .nav__menu {
    inset: 68px 16px auto 16px;
  }

  .brand__text small {
    display: none;
  }

  .hero__grid {
    gap: 2.5rem;
  }

  .skill-matrix,
  .bento-grid,
  .footer__grid {
    grid-template-columns: 1fr;
  }

  .project-card--featured {
    grid-row: auto;
  }

  .footer__grid {
    justify-items: start;
  }
}

/* Small mobile layout */
@media (max-width: 520px) {
  .hero {
    padding-top: 36px;
  }

  .hero__content,
  .terminal-card {
    width: calc(100vw - 40px);
    max-width: calc(100vw - 40px);
  }

  .hero__copy {
    max-width: 22ch;
  }

  .hero__actions {
    width: calc(100vw - 40px);
    max-width: calc(100vw - 40px);
    display: grid;
    grid-template-columns: 1fr;
  }

  .hero__actions .btn {
    width: 100%;
  }
}
