/**
 * responsive.css
 * ──────────────
 * Breakpoint overrides. Loaded last so these rules win over sections.css.
 *
 * Breakpoints:
 *   ≤1100px  — 2-column grids
 *   ≤900px   — mobile nav, hero stack
 *   ≤640px   — single column, device mockups stack vertically
 *   601–900px — reduced phone/desktop overlap on case study pages
 */

.nav-menu {
  display: none;
}

@media (max-width: 1100px) {
  /* Grids: 3 columns → 2 columns */
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

@media (max-width: 1023px) {
  /* Mobile navigation: one fixed drawer outside the header. */
  .nav-links--desktop,
  .nav-actions {
    display: none;
  }

  .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1002;
  }

  .nav-toggle {
    display: flex;
    position: relative;
    z-index: 1004;
    min-width: 48px;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .nav-menu {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    top: var(--nav-height);
    right: 0;
    bottom: auto;
    height: calc(100vh - var(--nav-height));
    height: calc(100dvh - var(--nav-height));
    width: min(320px, 88vw);
    z-index: 1003;
    padding: 28px 24px 32px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    transition: transform 0.3s var(--ease);
    box-shadow: none;
    pointer-events: none;
    will-change: transform;
    transform: translateX(100%);
  }

  html[dir="ltr"] .nav-menu {
    right: auto;
    left: 0;
    transform: translateX(-100%);
  }

  html[dir="ltr"] .nav-menu:not(.is-open) {
    transform: translateX(-100%);
  }

  html[dir="rtl"] .nav-menu:not(.is-open) {
    transform: translateX(100%);
  }

  html[dir="rtl"] .nav-menu.is-open,
  html[dir="ltr"] .nav-menu.is-open {
    transform: translateX(0);
  }

  .nav-menu.is-open {
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.12);
    pointer-events: auto;
  }

  html[dir="ltr"] .nav-menu.is-open {
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.12);
  }

  .nav-menu .nav-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 24px;
  }

  .nav-menu .nav-links a {
    font-size: 18px;
    font-weight: 600;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    width: 100%;
    padding-block: 4px;
  }

  .nav-menu .lang-switch--mobile {
    margin-bottom: 20px;
  }

  .nav-menu .btn-primary {
    display: inline-flex;
    width: 100%;
    justify-content: center;
    min-height: 48px;
    margin-top: 8px;
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1001;
    background: rgba(17, 17, 17, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease);
    -webkit-tap-highlight-color: transparent;
    pointer-events: none;
  }

  .nav-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  body.nav-open {
    overflow: hidden;
    touch-action: none;
  }

  .hero {
    min-height: auto;
    padding: 28px 0 56px;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 40px;
    min-height: auto;
  }

  .hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .hero-text {
    margin-inline: auto;
  }

  .hero-tech {
    justify-content: center;
  }

  .hero-content .btn-group {
    justify-content: center;
    width: 100%;
  }

  .hero-visual {
    order: -1;
  }

  .hero-macbook {
    max-width: min(520px, 100%);
    margin-inline: auto;
    transform: none;
  }

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

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

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

  .services-grid,
  .why-grid {
    grid-template-columns: 1fr;
  }

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

  .case-block {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 640px) {
  .container,
  .container-wide {
    width: calc(100% - 32px);
  }

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

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

  .hero-tech {
    gap: 8px;
  }

  .hero-tech__item {
    min-width: 60px;
  }

  .hero-tech__icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .hero-content .btn-group {
    flex-direction: column;
  }

  .hero-content .btn-group .btn {
    width: 100%;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }

  .project-card__body {
    padding: 24px;
  }

  .case-hero__image {
    aspect-ratio: 16 / 10;
    border-radius: var(--radius-lg);
  }

  /* Device showcase: stack desktop first, phone below */
  .device-showcase__stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 48px;
    min-height: auto;
    padding: 24px 0 16px;
  }

  .device-mockup--desktop {
    order: 1;
    margin-inline-start: 0;
    max-width: 100%;
  }

  .device-mockup--phone {
    position: relative;
    inset-inline-start: auto;
    bottom: auto;
    order: 2;
    width: min(200px, 52vw);
    transform: rotate(-4deg);
    animation: none;
  }

  .device-mockup--phone:hover {
    transform: rotate(-2deg) scale(1.03);
  }
}

@media (min-width: 601px) and (max-width: 900px) {
  /* Tablet: smaller phone, less overlap with desktop mockup */
  .device-mockup--phone {
    inset-inline-start: clamp(-8px, 1vw, 24px);
    bottom: clamp(32px, 8vw, 64px);
    width: clamp(130px, 20vw, 180px);
  }

  .device-mockup--desktop {
    margin-inline-start: clamp(48px, 10vw, 100px);
  }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

@media (min-width: 1101px) {
  .services-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .why-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
