/* ═══════════════════════════════════════════
   RESPONSIVE (ITCSS: Utilities/Overrides Layer)
   All media query breakpoints centralized
   ═══════════════════════════════════════════ */

/* ── Drawer slide-in animation ── */
@keyframes drawerSlideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes drawerSlideOut {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

@keyframes backdropFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Tablet (1024px) ── */
@media (max-width: 1024px) {
  .nav__logo img {
    height: 56px;
  }

  /* ── Nav links: hidden by default on mobile ──
     Using display:none guarantees removal from flex flow
     in ALL browsers (including Comet, UC Browser, etc.) */
  .nav__links {
    display: none;
  }

  /* ── Drawer appears only when .active ── */
  .nav__links.active {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    width: 300px;
    max-width: 85vw;
    height: 100%;
    height: 100dvh;
    background: #0b1120;
    border-left: 1px solid rgba(14, 165, 233, 0.15);
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0;
    z-index: 9998;
    padding: 4.5rem 0 2rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.5);
    animation: drawerSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  /* ── Closing animation ── */
  .nav__links.closing {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    width: 300px;
    max-width: 85vw;
    height: 100%;
    height: 100dvh;
    background: #0b1120;
    border-left: 1px solid rgba(14, 165, 233, 0.15);
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0;
    z-index: 9998;
    padding: 4.5rem 0 2rem;
    overflow-y: auto;
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.5);
    animation: drawerSlideOut 0.25s cubic-bezier(0.4, 0, 1, 1) forwards;
  }

  .nav__links li {
    list-style: none;
    width: 100%;
  }

  .nav__links.active a,
  .nav__links.closing a {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.9rem 2rem;
    min-height: var(--touch-min);
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-300);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
  }

  .nav__links.active a:hover,
  .nav__links.active a:active {
    color: var(--white);
    background: rgba(14, 165, 233, 0.08);
    padding-left: 2.5rem;
  }

  .nav__links.active a::after,
  .nav__links.closing a::after {
    display: none;
  }

  .nav__links.active .nav__cta,
  .nav__links.closing .nav__cta {
    margin: 1.5rem 2rem 0;
    text-align: center;
    border-bottom: none !important;
    border-radius: 8px;
    width: auto !important;
    padding: 0.7rem 1.5rem !important;
  }

  /* ── Backdrop overlay ── */
  .nav__backdrop {
    display: none;
  }

  .nav__backdrop.active {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9997;
    animation: backdropFadeIn 0.3s ease forwards;
  }

  /* ── Hamburger toggle — forced visible ── */
  .nav__mobile-toggle {
    display: flex !important;
    flex-shrink: 0;
    margin-left: auto;
    z-index: 9999;
  }

  .nav__mobile-toggle.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }

  .nav__mobile-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }

  .nav__mobile-toggle.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }

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

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

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

  .hero__hex-container {
    width: 320px;
    height: 320px;
  }

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

  .ai-section__capabilities {
    grid-template-columns: 1fr;
  }

  .portfolio__card {
    min-width: 280px;
    max-width: 300px;
  }
}

/* ── Mobile (768px) ── */
@media (max-width: 768px) {

  /* ── Container & Section spacing ── */
  .container {
    padding: 0 var(--space-container-mobile);
  }

  .section {
    padding: var(--space-section-mobile) 0;
  }

  /* ── Overflow protection ── */
  .hero,
  .section {
    overflow: hidden;
  }

  .bg-glow {
    display: none;
  }

  /* ── Nav mobile refinements ── */
  .nav {
    background: rgba(11, 17, 32, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0.5rem 0;
  }

  .nav.scrolled {
    padding: 0.25rem 0;
  }

  .nav__logo img {
    height: 42px;
  }

  .nav__logo-text {
    font-size: 0.85rem;
  }

  .nav__logo-tagline {
    font-size: 0.55rem;
  }

  /* ── Hero mobile ── */
  .hero {
    padding-top: 6rem;
    min-height: auto;
  }

  .hero__content {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 2rem;
  }

  .hero__description {
    margin-left: auto;
    margin-right: auto;
  }

  .hero__actions {
    justify-content: center;
    flex-wrap: wrap;
  }

  .hero__visual {
    order: -1;
  }

  .hero__hex-container {
    width: 260px;
    height: 260px;
    max-width: 80vw;
    max-height: 80vw;
  }

  .hero__logo-center {
    width: 180px;
    max-width: 60vw;
  }

  .hero__stats {
    justify-content: center;
    gap: 2rem;
  }

  .hero__stat-value {
    font-size: 1.5rem;
  }

  .hero__stat-label {
    font-size: 0.75rem;
  }

  /* ── Sections mobile ── */
  .services__grid,
  .clients__grid {
    grid-template-columns: 1fr;
  }

  .portfolio__card {
    min-width: min(280px, 85vw);
    max-width: min(280px, 85vw);
  }

  .portfolio__card-image {
    height: 130px;
  }

  .portfolio__tabs {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .portfolio__tab {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
  }

  .diferencial__content,
  .metodologia__content,
  .ai-section__content {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .diferencial__code-block {
    font-size: clamp(0.72rem, 1.5vw, 0.82rem);
  }

  .diferencial__code-body {
    padding: 1rem;
  }

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

  .founder__content {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 2rem;
  }

  .founder__avatar {
    margin: 0 auto;
    width: 160px;
    height: 160px;
  }

  .founder__avatar-initials {
    font-size: 2.75rem;
  }

  .founder__info .section-label {
    justify-content: center;
  }

  .founder__info .section-label::before {
    display: none;
  }

  .founder__certs-grid {
    justify-content: center;
    gap: 0.5rem;
    max-width: 100%;
  }

  .founder__certs-label {
    text-align: center;
  }

  .founder__cert-badge {
    padding: 0.5rem 0.75rem;
    min-width: 0;
  }

  .founder__cert-badge img {
    width: 30px;
    height: 30px;
  }

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

  .footer__inner {
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
  }

  .footer__links {
    gap: 0.75rem 1.5rem;
  }

  .footer__links a {
    padding: 0.5rem 0;
  }

  /* ── Modal mobile ── */
  .modal {
    padding: 1.75rem;
    border-radius: 16px;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
  }
}

/* ── Small Mobile (480px) ── */
@media (max-width: 480px) {

  /* ── Spacing ── */
  .container {
    padding: 0 var(--space-container-small);
  }

  .section {
    padding: var(--space-section-small) 0;
  }

  .nav__logo img {
    height: 36px;
  }

  .nav__logo-text {
    font-size: 0.75rem;
  }

  .nav__logo-tagline {
    font-size: 0.5rem;
  }

  .nav__links.active,
  .nav__links.closing {
    width: 100%;
    max-width: 100vw;
    border-left: none;
  }

  .nav__links.active a,
  .nav__links.closing a {
    font-size: 0.95rem;
    padding: 0.8rem 1.5rem;
  }

  .hero {
    padding-top: 5.5rem;
  }

  .hero__hex-container {
    width: 220px;
    height: 220px;
  }

  .hero__logo-center {
    width: 140px;
  }

  .hero__title {
    font-size: 1.75rem;
  }

  .hero__description {
    font-size: 0.95rem;
  }

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

  .hero__stats {
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
  }

  .cta__buttons {
    flex-direction: column;
    align-items: center;
  }

  .cta__buttons .btn-primary,
  .cta__buttons .btn-secondary {
    width: 100%;
    justify-content: center;
  }

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

  .founder__name {
    font-size: 1.35rem;
    flex-direction: column;
    gap: 0.3rem;
  }

  .founder__cert-badge {
    padding: 0.5rem 0.75rem;
  }

  .founder__cert-badge img {
    width: 28px;
    height: 28px;
  }

  .founder__cert-badge-name {
    font-size: 0.7rem;
  }

  .founder__quote {
    padding: 1rem 1.25rem;
    font-size: 0.88rem;
  }

  .services__header {
    margin-bottom: 2.5rem;
  }

  .portfolio__card {
    min-width: min(280px, calc(100vw - 2rem));
    max-width: min(280px, calc(100vw - 2rem));
  }

  /* ── Modal small ── */
  .modal {
    padding: 1.25rem;
    border-radius: 14px;
  }

  .modal__title {
    font-size: 1.35rem;
  }

  .modal__subtitle {
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
  }

  .modal__option {
    padding: 1rem;
    gap: 1rem;
  }

  .modal__option-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }
}

/* ── Ultra-small Mobile (360px) ── */
@media (max-width: 360px) {
  .nav__logo-info {
    display: none;
  }

  .hero__title {
    font-size: 1.5rem;
  }

  .hero__description {
    font-size: 0.88rem;
  }

  .numbers__value {
    font-size: 2rem;
  }

  .service-card {
    padding: 1.75rem 1.25rem;
  }

  .pilar-card {
    padding: 1.75rem 1rem;
  }

  .delivery__card {
    padding: 2rem 1.25rem;
  }

  .client-card {
    padding: 1.5rem;
  }
}

/* ── Safe Area Support (notched devices) ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .footer {
    padding-bottom: calc(3rem + env(safe-area-inset-bottom));
  }

  .modal-overlay {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .nav__links.active,
  .nav__links.closing {
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }
}
