/* ============================================
   Responsive — Tablet & Mobile Optimizations
   Breakpoints: 1024px (tablet), 768px (mobile), 480px (small)
   ============================================ */

:root {
  --bp-tablet: 1024px;
  --bp-mobile: 768px;
  --bp-small: 480px;
  --header-height-mobile: 64px;
  --touch-min: 44px;
}

/* ---------- TABLET (769px – 1024px) ---------- */
@media (max-width: 1024px) {
  :root {
    --header-height: 72px;
    --section-padding: clamp(64px, 8vw, 100px);
  }

  .nav-link {
    padding: 8px 12px;
    font-size: 0.75rem;
  }

  .header-cta .btn {
    padding: 10px 20px;
    font-size: 0.7rem;
  }

  .mega-menu {
    min-width: 580px;
    padding: 24px;
  }

  .hero-title {
    font-size: clamp(2rem, 5vw, 3rem);
  }

  .page-hero {
    min-height: 45vh;
  }

  .page-hero-content h1 {
    font-size: clamp(2rem, 4.5vw, 3rem);
  }

  .references-preview {
    grid-template-columns: repeat(2, 1fr);
  }

  .reference-items {
    grid-template-columns: 1fr;
  }

  .filter-tabs {
    flex-wrap: wrap;
    justify-content: center;
  }

  .two-col .col-image {
    aspect-ratio: 16/10;
    max-height: 420px;
  }

  .team-grid {
    gap: 20px;
  }

  .whatsapp-float {
    width: 52px;
    height: 52px;
    bottom: 20px;
    right: 20px;
  }
}

/* ---------- MOBILE (max 768px) ---------- */
@media (max-width: 768px) {
  :root {
    --header-height: var(--header-height-mobile);
    --section-padding: clamp(56px, 12vw, 80px);
  }

  html { font-size: 15px; }

  .container {
    padding: 0 16px;
  }

  /* Header */
  .logo {
    font-size: 1.25rem;
  }

  .nav-desktop,
  .header-cta {
    display: none;
  }

  .menu-toggle {
    display: flex;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    align-items: center;
    justify-content: center;
  }

  /* Mobile Nav */
  .mobile-nav {
    justify-content: flex-start;
    padding: calc(var(--header-height-mobile) + 24px) 24px 32px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    align-items: stretch;
  }

  .mobile-nav a {
    font-size: 1.125rem;
    padding: 14px 0;
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
  }

  .mobile-nav-cta {
    margin-top: 16px !important;
    justify-content: center;
    background: var(--color-gold);
    color: var(--color-white) !important;
    border: none !important;
    border-radius: 0;
    font-weight: 600;
    letter-spacing: 0.04em;
  }

  .mobile-nav-cta:hover {
    background: var(--color-wood-dark);
    color: var(--color-white) !important;
  }

  /* Hero */
  .hero {
    min-height: 100svh;
    min-height: 100dvh;
  }

  .hero-content {
    padding-top: calc(var(--header-height-mobile) + 24px);
    padding-bottom: 48px;
  }

  .hero-title {
    font-size: clamp(1.75rem, 8vw, 2.5rem);
    line-height: 1.2;
  }

  .hero-desc {
    font-size: 0.95rem;
    line-height: 1.75;
  }

  .hero-label {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
  }

  .hero-scroll {
    display: none;
  }

  .btn {
    padding: 14px 28px;
    min-height: var(--touch-min);
    width: 100%;
    justify-content: center;
  }

  .btn-group {
    flex-direction: column;
    width: 100%;
  }

  .btn-group .btn {
    width: 100%;
  }

  /* Page Hero */
  .page-hero {
    min-height: 38vh;
    min-height: 38svh;
    padding-bottom: 32px;
  }

  .page-hero-content {
    padding-top: calc(var(--header-height-mobile) + 20px);
  }

  .page-hero-content h1 {
    font-size: clamp(1.75rem, 7vw, 2.5rem);
  }

  .page-hero-desc {
    font-size: 0.7rem;
    letter-spacing: 0.06em;
  }

  .breadcrumb {
    flex-wrap: wrap;
    font-size: 0.75rem;
    gap: 8px;
  }

  /* Grids */
  .services-grid,
  .projects-grid,
  .testimonials-grid,
  .category-grid,
  .why-grid,
  .gallery-grid,
  .values-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .stats-grid.three-col {
    grid-template-columns: 1fr;
  }

  .stat-number {
    font-size: clamp(2rem, 8vw, 2.75rem);
  }

  .timeline {
    grid-template-columns: 1fr;
  }

  .timeline::before {
    display: none;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .cert-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .team-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .project-info-grid,
  .contact-grid,
  .two-col {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .two-col.reverse {
    direction: ltr;
  }

  .two-col .col-image {
    aspect-ratio: 4/3;
    max-height: none;
  }

  .mega-menu {
    display: none;
  }

  /* Filters — horizontal scroll on mobile */
  .filter-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
    gap: 8px;
    padding-bottom: 8px;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .filter-tabs::-webkit-scrollbar {
    display: none;
  }

  .filter-tab {
    flex-shrink: 0;
    white-space: nowrap;
    min-height: var(--touch-min);
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
  }

  .references-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
    padding-bottom: 8px;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .references-filters::-webkit-scrollbar {
    display: none;
  }

  .ref-filter-btn {
    flex-shrink: 0;
    white-space: nowrap;
    min-height: var(--touch-min);
    display: inline-flex;
    align-items: center;
  }

  .references-search {
    max-width: 100%;
    font-size: 16px;
    min-height: var(--touch-min);
  }

  /* Forms — prevent iOS zoom */
  input,
  textarea,
  select {
    font-size: 16px !important;
    min-height: var(--touch-min);
  }

  textarea {
    min-height: 120px;
  }

  /* Project cards */
  .project-card {
    aspect-ratio: 4/3;
  }

  .project-overlay h3 {
    font-size: 1.125rem;
  }

  /* References */
  .references-preview {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .references-preview-item {
    padding: 20px 12px;
  }

  .references-preview-item span {
    font-size: 2rem;
  }

  .reference-item {
    padding: 16px 18px;
  }

  .reference-category-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .reference-items {
    grid-template-columns: 1fr;
  }

  /* Founder letter */
  .founder-letter {
    padding: 24px 20px;
  }

  .founder-letter p {
    font-size: 0.95rem;
  }

  /* Parallax — disable fixed on mobile */
  .parallax-bg {
    background-attachment: scroll;
  }

  /* WhatsApp float */
  .whatsapp-float {
    width: 50px;
    height: 50px;
    bottom: max(16px, env(safe-area-inset-bottom));
    right: max(16px, env(safe-area-inset-right));
  }

  .whatsapp-float svg {
    width: 26px;
    height: 26px;
  }

  /* Map */
  .map-container {
    height: 280px;
  }

  .map-container iframe {
    height: 100%;
  }

  /* Contact */
  .contact-info-item {
    gap: 16px;
  }

  .contact-form-wrapper {
    padding: 24px 20px;
  }

  /* Section typography */
  .section-title {
    font-size: clamp(1.625rem, 6vw, 2.25rem);
  }

  .section-desc {
    font-size: 0.95rem;
  }

  /* Gallery detail */
  .gallery-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .gallery-item.large {
    grid-column: span 2;
  }
}

/* ---------- SMALL MOBILE (max 480px) ---------- */
@media (max-width: 480px) {
  html { font-size: 14px; }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .team-grid {
    grid-template-columns: 1fr;
  }

  .cert-grid {
    grid-template-columns: 1fr;
  }

  .references-preview {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .gallery-item.large {
    grid-column: span 1;
  }

  .logo {
    font-size: 1.125rem;
    letter-spacing: 0.05em;
  }

  .footer-social a {
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* ---------- LANDSCAPE MOBILE ---------- */
@media (max-width: 768px) and (orientation: landscape) {
  .hero {
    min-height: auto;
    padding: 80px 0 48px;
  }

  .page-hero {
    min-height: 50vh;
  }

  .mobile-nav {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    gap: 0 24px;
    padding-top: var(--header-height-mobile);
  }

  .mobile-nav a {
    width: auto;
    border: none;
    font-size: 0.95rem;
    padding: 8px 12px;
    min-height: auto;
  }

  .mobile-nav-cta {
    width: 100%;
    flex-basis: 100%;
    max-width: 280px;
  }
}

/* ---------- TOUCH & ACCESSIBILITY ---------- */
@media (hover: none) and (pointer: coarse) {
  .nav-link::after,
  .project-card:hover .project-overlay,
  .service-card:hover {
    /* Reduce hover-dependent effects on touch devices */
  }

  .btn:active {
    transform: scale(0.98);
  }

  .project-card:active {
    transform: scale(0.99);
  }
}

/* Safe area support (notched phones) */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .header {
    padding-top: env(safe-area-inset-top);
  }

  .scroll-progress {
    top: env(safe-area-inset-top);
  }
}
