/* ==========================================================================
   Responsive layer — mobile-first enhancements
   sm  ≥ 40rem  (640px)   large phones / small tablets
   md  ≥ 48rem  (768px)   tablets
   nav ≥ 60rem  (960px)   desktop navigation
   lg  ≥ 64rem  (1024px)  laptops
   xl  ≥ 90rem  (1440px)  large desktops
   ========================================================================== */

/* Small phones: keep the hero CTAs full-width and easy to tap */
@media (max-width: 29.99rem) {
  .hero__actions .btn {
    flex: 1 1 100%;
  }

  .portrait__caption {
    flex-direction: column;
    gap: var(--space-2xs);
  }
}

/* Phones: the project number moves to the top-right corner instead of taking its own row */
@media (max-width: 47.99rem) {
  .project__index {
    position: absolute;
    top: var(--space-xl);
    right: 0;
    line-height: 1.4;
  }

  .project__type {
    padding-right: 1.75rem;
    letter-spacing: 0.1em;
  }
}

/* --------------------------------------------------------------------------
   sm ≥ 640px
   -------------------------------------------------------------------------- */
@media (min-width: 40rem) {
  .hero__meta {
    display: block;
  }

  .toolkit {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .contact-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--space-xl);
  }

  .field--full {
    grid-column: 1 / -1;
  }

  .site-footer__top {
    grid-template-columns: 1fr auto;
    align-items: end;
  }
}

/* --------------------------------------------------------------------------
   md ≥ 768px
   -------------------------------------------------------------------------- */
@media (min-width: 48rem) {
  :root {
    --header-height: 5rem;
  }

  .hero__body {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: var(--space-xl);
    align-items: start;
  }

  .hero__support {
    padding-top: 0.35em;
  }

  .expertise {
    grid-template-columns: 4rem minmax(0, 1fr);
    column-gap: var(--space-lg);
  }

  .expertise__index {
    padding-top: 0.55em;
  }

  .stack-list {
    grid-column: 2;
  }

  .project__inner {
    grid-template-columns: 4rem minmax(0, 1fr);
    column-gap: var(--space-lg);
  }

  .project__index {
    padding-top: 2.1em;
  }

  .project__aside,
  .project__media {
    grid-column: 2;
  }

  .about {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: var(--space-xl);
  }

  .portrait {
    position: sticky;
    top: calc(var(--header-height) + var(--space-lg));
  }
}

/* --------------------------------------------------------------------------
   nav ≥ 960px — swap the hamburger for the inline navigation
   -------------------------------------------------------------------------- */
@media (min-width: 60rem) {
  .nav {
    display: block;
  }

  .menu-toggle,
  .mobile-menu {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   lg ≥ 1024px
   -------------------------------------------------------------------------- */
@media (min-width: 64rem) {
  /* Section heading: title left, intro text right, aligned to the baseline */
  .section-head:not(.section-head--stacked) {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--space-xl);
    align-items: end;
  }

  .section-head:not(.section-head--stacked) .label {
    grid-column: 1 / -1;
  }

  .section-head:not(.section-head--stacked) .section-title {
    grid-column: 1 / span 7;
  }

  .section-head:not(.section-head--stacked) .section-intro {
    grid-column: 9 / -1;
    font-size: var(--fs-base);
    line-height: var(--lh-body);
  }

  .hero__body {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    margin-top: var(--space-lg);
  }

  .hero__intro {
    grid-column: 1 / span 6;
  }

  .hero__support {
    grid-column: 8 / span 4;
  }

  .expertise {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--space-xl);
    padding-block: var(--space-2xl);
  }

  .expertise__index {
    grid-column: 1 / span 1;
  }

  .expertise__main {
    grid-column: 2 / span 6;
  }

  .stack-list {
    grid-column: 9 / -1;
    flex-direction: column;
    gap: var(--space-xs);
    padding-top: 0.6em;
  }

  .expertise__title {
    transition: transform var(--duration-base) var(--ease-out);
  }

  .expertise:hover .expertise__title {
    transform: translateX(0.5rem);
  }

  .toolkit {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: var(--space-xl);
  }

  .project__inner {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--space-xl);
    padding-block: var(--space-2xl);
  }

  .project__index {
    grid-column: 1 / span 1;
  }

  .project__main {
    grid-column: 2 / span 6;
  }

  .project__aside {
    grid-column: 9 / -1;
    padding-top: 1.9em;
  }

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

  .project:hover .project__title {
    transform: translateX(0.5rem);
  }

  .project:hover .project__inner {
    background-color: var(--hover-fill);
  }

  .about {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--space-xl);
  }

  .portrait {
    grid-column: 1 / span 5;
  }

  .about__content {
    grid-column: 7 / -1;
  }

  .contact {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--space-xl);
  }

  .contact-links {
    grid-column: 1 / span 5;
  }

  .contact-form {
    grid-column: 7 / -1;
  }

  .section--contact .section-head {
    margin-bottom: var(--space-2xl);
  }
}

/* Floating hover preview for projects that include a .project__media image.
   Only on devices with a precise pointer; elsewhere the image sits inline. */
@media (min-width: 64rem) and (hover: hover) and (pointer: fine) {
  .project__media {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
    width: clamp(18rem, 24vw, 24rem);
    pointer-events: none;
    opacity: 0;
    transform: translate(var(--preview-x, 0), var(--preview-y, 0)) scale(0.92);
    transition:
      opacity var(--duration-base) ease,
      transform var(--duration-base) var(--ease-out);
  }

  .project.is-previewing .project__media {
    opacity: 1;
    transform: translate(var(--preview-x, 0), var(--preview-y, 0)) scale(1);
  }
}

/* --------------------------------------------------------------------------
   xl ≥ 1440px
   -------------------------------------------------------------------------- */
@media (min-width: 90rem) {
  .section-head:not(.section-head--stacked) .section-intro {
    font-size: var(--fs-lead);
    line-height: 1.55;
  }
}

/* Short landscape phones: let the hero size to its content */
@media (max-height: 34rem) and (orientation: landscape) {
  .hero {
    min-height: auto;
  }
}
