/* ==== Mobile: max-width 900px (single structural breakpoint) ==== */
@media (max-width: 900px) {
  header nav { display: none; }
  header .kb-cta { display: none; }
  #kb-hamburger { display: flex; }

  /* Contact form: EMPRESA/WHATSAPP stack instead of squeezing into two columns */
  .kb-field-row { grid-template-columns: 1fr; }

  /* ---- Drawer (built by js/main.js, only exists in the DOM while open) ----
     A dimmed backdrop (click closes) plus a right-aligned floating panel —
     neither covers the full screen. */
  #kb-menu-backdrop {
    position: fixed; inset: 0; z-index: 80;
    background: rgba(6,7,9,.55);
  }
  #kb-mobile-drawer {
    position: fixed; top: 16px; right: 16px; z-index: 81;
    width: min(82vw, 320px);
    max-height: calc(100vh - 32px);
    border-radius: 20px;
    background: rgba(10,11,14,.97);
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    overflow-y: auto; overscroll-behavior: contain;
    display: flex; flex-direction: column;
    padding: 20px clamp(18px, 5vw, 28px) 28px;
  }
  #kb-mobile-drawer .kb-drawer-top { display: flex; justify-content: flex-end; margin-bottom: 8px; }
  #kb-mobile-drawer .kb-drawer-close {
    width: 48px; height: 48px; background: none; border: none; color: var(--fg);
    font-size: 26px; line-height: 1; cursor: pointer;
    transition: transform .2s ease, opacity .2s ease;
    opacity: 0; animation: kb-drawer-item-in .35s cubic-bezier(.16,.84,.3,1) both;
  }
  #kb-mobile-drawer .kb-drawer-close:hover,
  #kb-mobile-drawer .kb-drawer-close:active { transform: rotate(90deg); }
  #kb-mobile-drawer nav { display: flex; flex-direction: column; margin-top: 12px; }
  #kb-mobile-drawer .kb-drawer-item {
    display: flex; align-items: center; gap: 16px;
    min-height: clamp(46px, 7.2vh, 58px);
    font-size: clamp(18.5px, 5.2vw, 22px); font-weight: 600; color: var(--fg);
    border-bottom: 1px solid rgba(255,255,255,.08);
    opacity: 0; animation: kb-drawer-item-in .4s cubic-bezier(.16,.84,.3,1) both;
  }
  #kb-mobile-drawer .kb-drawer-num { font-family: var(--mono); font-size: 13px; color: var(--accent-light); }
  #kb-mobile-drawer .kb-drawer-item.kb-drawer-cta {
    margin-top: 20px; border-bottom: none; justify-content: center; text-align: center;
    background: var(--accent); border-radius: 999px; padding: 0 20px;
  }
  #kb-mobile-drawer .kb-drawer-item.kb-drawer-cta .kb-drawer-num { display: none; }

  /* ---- Projects: arrow + counter header, bleeding snap rail, indicators ---- */
  .kb-project-nav {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px;
  }
  .kb-project-arrow {
    width: 50px; height: 50px; flex: none; border-radius: 50%;
    border: 1px solid rgba(255,255,255,.16); background: transparent; color: var(--fg);
    font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  }
  .kb-project-status { text-align: center; flex: 1; min-width: 0; }
  .kb-project-name { display: block; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .kb-project-count { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--muted-3); margin-top: 2px; }

  .kb-tabs {
    flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x mandatory;
    margin: 0 calc(-1 * var(--space-section-x)) 24px; padding: 0 var(--space-section-x) 4px;
    scrollbar-width: none;
  }
  .kb-tabs::-webkit-scrollbar { display: none; }
  .kb-tabs .kb-tab { scroll-snap-align: center; flex: none; }

  .kb-case { grid-template-columns: minmax(0, 1fr); touch-action: pan-y; }

  .kb-project-indicators { display: flex; justify-content: center; gap: 6px; margin-top: 18px; }
  .kb-project-indicators button {
    width: 30px; height: 30px; padding: 0; border: none; background: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }
  .kb-project-indicators button::after {
    content: ''; display: block; height: 4px; width: 14px; border-radius: 2px;
    background: rgba(255,255,255,.18); transition: width .25s, background .25s;
  }
  .kb-project-indicators button.kb-active::after { width: 30px; background: var(--accent); }
  .kb-project-hint { display: block; text-align: center; font-family: var(--mono); font-size: 11.5px; color: var(--muted-3); margin-top: 10px; }

  /* ---- Testimonials: horizontal snap carousel ---- */
  .kb-testimonials {
    display: flex; grid-template-columns: none; overflow-x: auto; scroll-snap-type: x mandatory;
    margin: 0 calc(-1 * var(--space-section-x)); padding: 0 var(--space-section-x);
    scrollbar-width: none;
  }
  .kb-testimonials::-webkit-scrollbar { display: none; }
  .kb-testimonial { flex: 0 0 84%; scroll-snap-align: center; }
  .kb-testimonial-dots { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }
  .kb-testimonial-dots button {
    width: 48px; height: 48px; padding: 0; border: none; background: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }
  .kb-testimonial-dots button::after {
    content: ''; display: block; width: 8px; height: 8px; border-radius: 50%;
    background: rgba(255,255,255,.22); transition: background .25s, transform .25s;
  }
  .kb-testimonial-dots button.kb-active::after { background: var(--accent); transform: scale(1.3); }
  .kb-testimonial-hint { display: block; text-align: center; font-family: var(--mono); font-size: 11.5px; color: var(--muted-3); margin-top: 6px; }

  /* ---- Cubes: only 4 survive, scaled down ---- */
  [data-cube-index="2"], [data-cube-index="3"], [data-cube-index="5"], [data-cube-index="6"] { display: none; }
  .kb-cube { scale: .62; }
  .kb-section-cube-problemas { right: 84px; }
  .kb-section-cube-projetos { right: 76px; }
  .kb-tag { width: 100%; justify-content: center; text-align: center; }
  .kb-tag-mobile-break { display: block; }

  .kb-footer-inner { grid-template-columns: 1fr; gap: 32px; padding-top: 42px; padding-bottom: 36px; }
  .kb-footer-next { padding-top: 4px; }
  .kb-footer-bottom { flex-direction: column; align-items: flex-start; gap: 14px; padding-top: 16px; }
}

/* KPI tiles: always 2x2 below 850px. */
@media (max-width: 850px) {
  .kb-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ==== Small phones: extra compaction so the hero never outgrows a short
   viewport (iPhone SE, small Android, landscape) ==== */
@media (max-width: 480px) {
  #topo { padding-top: 48px; padding-bottom: 32px; }
  .kb-tag { margin-bottom: 18px; }
  #topo h1 { margin-bottom: 14px; }
  .kb-lede { font-size: 15px; line-height: 1.45; margin-bottom: 18px; }
  .kb-hero-actions { margin-bottom: 24px; }
  .kb-hero-note { display: block; margin: 6px 0 0; }
  .kb-stats { gap: 1px; }
  .kb-stat { padding: 14px 12px; }
  .kb-stat-label { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}

@media (max-height: 700px) and (max-width: 900px) {
  #topo { padding-top: 40px; padding-bottom: 28px; }
  .kb-tag { margin-bottom: 16px; }
  .kb-hero-actions { margin-bottom: 22px; }
}
