/* ================= PROJECT MODAL ================= */

.project-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.5s var(--ease), visibility 0s linear 0.5s;

  &.is-open {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.5s var(--ease);

    .sheet {
      transform: translateY(0);
    }
  }

  .backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 6, 7, 0.86);
    backdrop-filter: blur(6px);
  }

  .sheet {
    position: absolute;
    inset: 0;
    background: var(--bg);
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateY(3%);
    transition: transform 0.55s var(--ease);
    overscroll-behavior: contain;
  }

  /* ---------- Modal Topbar ---------- */

  .modal-topbar {
    position: sticky;
    top: 0;
    z-index: 20;

    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 22px 4%;

    background: linear-gradient(180deg,
        rgba(9, 9, 10, 0.9),
        rgba(9, 9, 10, 0));

    .close-btn,
    .nav-btn {
      width: 46px;
      height: 46px;
      border-radius: 50%;
      border: 1px solid var(--border-strong);
      background: rgba(9, 9, 10, 0.6);
      backdrop-filter: blur(10px);

      display: flex;
      align-items: center;
      justify-content: center;

      color: var(--white);

      transition: all 0.35s var(--ease);
    }

    .close-btn {
      &:hover {
        background: var(--primary);
        color: #0a0a0a;
        border-color: var(--primary);
        transform: rotate(90deg);
      }
    }

    .prevnext {
      display: flex;
      gap: 10px;
    }

    .nav-btn {
      &:hover {
        border-color: var(--primary);
        color: var(--primary);
      }
    }

    .counter {
      font-size: 0.8rem;
      color: var(--dim);
      align-self: center;
      margin-right: 14px;
    }
  }

  /* ---------- Modal Hero ---------- */

  .modal-hero {
    position: relative;

    width: 92%;
    max-width: 1400px;

    margin: 0 auto;

    border-radius: var(--radius-lg);
    overflow: hidden;

    aspect-ratio: 16 / 8;

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    .fade {
      position: absolute;
      inset: 0;
      display: none;

      background: linear-gradient(180deg,
          transparent 55%,
          var(--bg) 100%);
    }
  }

  /* ---------- Modal Head ---------- */

  .modal-head {
    width: 92%;
    max-width: 1400px;

    margin: -60px auto 0;

    position: relative;
    z-index: 2;

    padding-bottom: 60px;

    border-bottom: 1px solid var(--border);

    .cat {
      display: block;

      color: var(--primary);

      font-size: 0.8rem;
      letter-spacing: 0.16em;
      text-transform: uppercase;

      margin-bottom: 14px;
    }

    h2 {
      font-size: clamp(1.7rem, 3.4vw, 2.7rem);
      margin-bottom: 26px;
    }
  }

  /* ---------- Modal Top (image + info, 2-column on desktop) ---------- */

  .modal-top {
    display: contents;
  }

  /* ---------- Modal Overview (lives inside modal-head, right column) ---------- */

  .modal-head {
    .modal-overview {
      margin-top: 30px;
      padding-top: 30px;

      border-top: 1px solid var(--border);

      h4.label {
        font-family: var(--font-display);

        font-size: 0.85rem;
        letter-spacing: 0.1em;
        text-transform: uppercase;

        color: var(--dim);

        margin-bottom: 18px;
      }

      p {
        font-size: 1.05rem;
      }
    }
  }

  /* ---------- Modal Meta ---------- */

  .modal-meta {
    display: flex;
    align-items: start;
    gap: 24px;
    flex-flow: row wrap;

    @media (min-width:768px) {
      justify-content: space-between;
    }

    margin-top: 30px;

    div {
      span {
        display: block;

        font-size: 0.78rem;
        color: var(--dim);

        text-transform: uppercase;
        letter-spacing: 0.05em;

        margin-bottom: 8px;
      }

      b {
        font-family: var(--font-display);
        font-size: 1rem;
        font-weight: 600;
      }

      a {
        color: var(--white);

        &:hover {
          color: var(--primary);
        }
      }
    }
  }

  /* ---------- Modal Body ---------- */

  .modal-body {
    width: 92%;
    max-width: 1400px;

    margin: 60px auto 0;

    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;

    .block {
      grid-column: span 2;
      margin-bottom: 10px;

      &.half {
        grid-column: span 1;
      }
    }

    h4.label {
      font-family: var(--font-display);

      font-size: 0.85rem;
      letter-spacing: 0.1em;
      text-transform: uppercase;

      color: var(--dim);

      margin-bottom: 18px;
    }

    p {
      font-size: 1.05rem;
    }

    /* ---------- Tech Stack ---------- */

    .tech-stack {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;

      span {
        padding: 9px 16px;

        border-radius: var(--radius-pill);
        border: 1px solid var(--border);

        font-size: 0.85rem;
        color: var(--muted);
      }
    }

    /* ---------- Feature List ---------- */

    .feature-list {
      li {
        display: flex;
        gap: 12px;

        margin-bottom: 14px;

        font-size: 0.98rem;
        color: var(--muted);

        align-items: flex-start;
      }

      i {
        color: var(--primary);
        margin-top: 5px;
        flex-shrink: 0;
      }
    }
  }

  /* ---------- Modal Gallery ---------- */

  .modal-gallery {
    width: 92%;
    max-width: 1400px;

    margin: 70px auto 0;
  }

  .gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;

    .g-item {
      border-radius: var(--radius-md);
      overflow: hidden;

      cursor: zoom-in;

      aspect-ratio: 16 / 11;

      position: relative;

      img {
        width: 100%;
        height: 100%;
        object-position: top;
        object-fit: cover;
        transition: transform 0.6s var(--ease);
      }

      &:hover {
        img {
          transform: scale(1.05);
        }
      }
    }
  }

  /* ---------- Modal CTA ---------- */

  .modal-cta {
    width: 92%;
    max-width: 1400px;

    margin: 80px auto 0;

    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 44px;

    border-radius: var(--radius-lg);

    flex-wrap: wrap;
    gap: 20px;
  }

  /* ---------- Project Navigation ---------- */

  .modal-projectnav {
    width: 92%;
    max-width: 1400px;

    margin: 70px auto 0;

    padding: 40px 0 90px;

    border-top: 1px solid var(--border);

    display: flex;
    justify-content: space-between;

    gap: 20px;

    .pn-link {
      display: flex;
      flex-direction: column;
      gap: 8px;

      max-width: 45%;

      span {
        font-size: 0.78rem;
        color: var(--dim);

        text-transform: uppercase;
        letter-spacing: 0.08em;
      }

      b {
        font-family: var(--font-display);
        font-size: 1.3rem;

        transition: color 0.3s;
      }

      &:hover {
        b {
          color: var(--primary);
        }
      }

      &:last-child {
        align-items: flex-end;
        text-align: right;
      }
    }
  }
}

/* ---------- Body State ---------- */

body {
  &.modal-open {
    overflow: hidden;
  }
}


/* =========================================================
   LIGHTBOX
   ========================================================= */

.lightbox {
  position: fixed;
  inset: 0;

  z-index: 3000;

  background: rgba(4, 4, 5, 0.96);

  display: flex;
  align-items: center;
  justify-content: center;

  visibility: hidden;
  opacity: 0;

  transition:
    opacity 0.4s var(--ease),
    visibility 0s linear 0.4s;

  &.is-open {
    visibility: visible;
    opacity: 1;

    transition: opacity 0.4s var(--ease);
  }

  .lb-stage {
    display: flex;
    align-items: center;
    justify-content: center;

    max-width: 88vw;
    max-height: 82vh;
  }

  img {
    max-width: 88vw;
    max-height: 82vh;

    object-fit: contain;

    border-radius: 14px;
  }

  /* Tall full-page website screenshots: keep a large, readable width,
     preserve full height, and allow vertical scrolling instead of
     shrinking the image to fit the viewport. */
  &.is-tall {
    .lb-stage {
      width: 88vw;
      max-width: 1400px;
      max-height: 86vh;

      align-items: flex-start;

      overflow-y: auto;
      overflow-x: hidden;
      -webkit-overflow-scrolling: touch;

      border-radius: 14px;
    }

    img {
      display: block;

      width: 100%;
      max-width: none;
      max-height: none;
      height: auto;

      object-fit: unset;
    }
  }

  .lb-close,
  .lb-prev,
  .lb-next {
    position: absolute;

    width: 48px;
    height: 48px;

    border-radius: 50%;
    border: 1px solid var(--border-strong);

    display: flex;
    align-items: center;
    justify-content: center;

    color: var(--white);

    background: rgba(255, 255, 255, 0.05);

    transition: all 0.3s var(--ease);

    &:hover {
      border-color: var(--primary);
      color: var(--primary);
    }
  }

  .lb-close {
    top: 26px;
    right: 26px;
  }

  .lb-prev {
    left: 26px;
    top: 50%;

    transform: translateY(-50%);
  }

  .lb-next {
    right: 26px;
    top: 50%;

    transform: translateY(-50%);
  }

  .lb-count {
    position: absolute;

    bottom: 26px;
    left: 50%;

    transform: translateX(-50%);

    font-size: 0.8rem;
    color: var(--dim);
  }
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (min-width: 901px) {
  .project-modal {
    .modal-top {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 60px;
      align-items: center;

      width: 92%;
      max-width: 1400px;

      margin: 0 auto;

      .modal-hero {
        width: 100%;
        max-width: none;
        margin: 0;
        aspect-ratio: 1/1;

        img {
          width: 100%;
          height: 100%;
          object-fit: contain;
        }
      }

      .modal-head {
        width: 100%;
        max-width: none;

        margin: 0;

        padding-bottom: 0;
        border-bottom: none;
      }
    }
  }
}

@media (max-width: 900px) {

  .project-modal {

    .modal-body {
      grid-template-columns: 1fr;
      gap: 34px;

      .block,
      .block.half {
        grid-column: span 1;
      }
    }

    .modal-meta {
      grid-template-columns: repeat(2, 1fr);
    }

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

      .g-item {
        &:first-child {
          grid-column: span 1;
        }
      }
    }

    .modal-projectnav {
      flex-direction: column;

      .pn-link,
      .pn-link:last-child {
        max-width: 100%;

        align-items: flex-start;
        text-align: left;
      }
    }
  }

  .lightbox {

    .lb-prev,
    .lb-next {
      width: 40px;
      height: 40px;
    }
  }
}