/* ===== Mobile navigation & responsive refinements ===== */

/* Mobile menu overlay */
.mobile-nav {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 80px 24px 32px;
  flex-direction: column;
  gap: 6px;
}
.mobile-nav.open {
  display: flex;
}
.mobile-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 550;
  color: var(--fg);
  border: 1px solid transparent;
}
.mobile-nav a:hover,
.mobile-nav a.active {
  background: var(--card);
  border-color: var(--border);
}
.mobile-nav .mobile-cta {
  margin-top: 16px;
  justify-content: center;
  background: var(--fg);
  color: var(--bg);
  border: 0;
}
.mobile-nav-close {
  position: absolute;
  top: 14px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 18px;
  cursor: pointer;
  color: var(--fg);
}

/* Improve menu button */
.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: var(--fg);
}

/* Header on mobile: keep theme + menu, compact brand */
@media (max-width: 720px) {
  .header-inner {
    gap: 12px;
    height: 58px;
  }
  .brand {
    font-size: 15px;
    gap: 8px;
  }
  .brand-logo {
    width: 28px;
    height: 28px;
    font-size: 11px;
    border-radius: 8px;
  }
  .header-actions {
    margin-left: auto;
    gap: 8px;
  }
  .menu-btn {
    display: inline-flex;
  }
  /* keep one compact action button */
  .header-actions .btn {
    display: none;
  }
  .header-actions .btn-primary {
    display: inline-flex;
    padding: 8px 12px;
    font-size: 12.5px;
  }
  .theme-toggle {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .container {
    width: min(100% - 28px, var(--max));
  }

  /* Hero */
  .hero {
    padding: 48px 0 36px;
  }
  .hero h1 {
    font-size: clamp(1.85rem, 8.5vw, 2.35rem);
    margin: 16px 0 14px;
  }
  .hero-lead {
    font-size: 15px;
    line-height: 1.65;
  }
  .hero-actions {
    margin-top: 22px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .hero-actions .btn {
    width: 100%;
    min-height: 46px;
  }
  .hero-trust {
    gap: 12px 16px;
    margin-top: 22px;
    font-size: 12px;
  }
  .orbit-wrap {
    width: min(100%, 240px);
    margin-top: 8px;
  }
  .marquee-section {
    margin-top: 36px;
  }

  /* Sections */
  .section {
    padding: 56px 0;
  }
  .section-head {
    margin-bottom: 24px;
  }
  .section-head h2 {
    font-size: clamp(1.55rem, 7vw, 1.95rem);
  }
  .section-head p {
    font-size: 14.5px;
  }

  /* Stats: 2x2 */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .stat-num {
    font-size: 1.65rem;
  }
  .stat-label {
    font-size: 10px;
  }

  /* Cards */
  .card {
    padding: 18px;
  }
  .api-grid,
  .feature-grid,
  .price-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .api-card p {
    min-height: 0;
  }
  .api-card-top {
    gap: 10px;
    margin-bottom: 10px;
  }
  .icon-box {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 13px;
  }
  .price-card {
    padding: 22px 18px;
  }
  .price-card.featured {
    transform: none;
  }
  .price-amount {
    font-size: 2rem;
  }

  /* CTA */
  .cta-box {
    padding: 32px 20px;
    border-radius: 18px;
  }
  .cta-box h2 {
    font-size: 1.55rem;
  }
  .cta-box .btn {
    width: 100%;
    min-height: 46px;
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .footer-bottom {
    flex-direction: column;
    gap: 8px;
  }

  /* Forms */
  .auth-wrap {
    padding: 28px 0 48px;
    min-height: calc(100vh - 58px);
  }
  .auth-card {
    padding: 24px 18px;
    border-radius: 16px;
    width: min(100%, 400px);
  }
  .input,
  .btn {
    min-height: 44px;
    font-size: 15px;
  }
  .tabs button {
    padding: 11px;
    font-size: 14px;
  }

  /* Console */
  .console-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .side-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .side-nav button {
    white-space: nowrap;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
  }
  .side-nav button.active {
    background: var(--fg);
    color: var(--bg);
    border-color: var(--fg);
  }
  .panel {
    padding: 18px 16px;
    border-radius: 14px;
  }
  .kpi-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .kpi .value {
    font-size: 1.35rem;
  }
  .key-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .key-row > div:last-child {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
  }
  .key-row .btn {
    width: 100%;
    min-height: 42px;
  }

  /* Tables: horizontal scroll wrapper */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
  }
  table {
    min-width: 480px;
    font-size: 12.5px;
  }
  th,
  td {
    padding: 9px 6px;
    white-space: nowrap;
  }
  th:nth-child(2),
  td:nth-child(2) {
    white-space: normal;
    min-width: 120px;
  }

  /* Docs */
  .docs-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .code-block {
    font-size: 11.5px;
    padding: 12px;
    max-height: 280px;
  }
  .param-table td:first-child {
    white-space: normal;
    word-break: break-all;
  }
  .param-table td:last-child {
    white-space: normal;
    min-width: 140px;
  }

  /* Chips / marquee */
  .api-chip {
    padding: 8px 12px;
    font-size: 11px;
  }
  .marquee-head {
    font-size: 10px;
    letter-spacing: 0.08em;
  }

  /* Pricing list */
  .price-list li {
    font-size: 13px;
  }
  .price-list {
    gap: 8px;
    margin-top: 12px;
  }

  /* Search on apis page */
  #search {
    max-width: none !important;
    width: 100%;
  }

  /* Safe area for notched phones */
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* Small phones */
@media (max-width: 380px) {
  .hero h1 {
    font-size: 1.75rem;
  }
  .stats-grid {
    gap: 10px;
  }
  .stat-num {
    font-size: 1.45rem;
  }
  .price-amount {
    font-size: 1.75rem;
  }
}

/* Touch: larger hit areas & disable 300ms feel */
@media (hover: none) and (pointer: coarse) {
  .btn,
  .cat-tab,
  .theme-toggle,
  .menu-btn,
  .side-nav button {
    min-height: 42px;
  }
  .nav a {
    padding: 10px 12px;
  }
}

/* Prevent horizontal page scroll */
html,
body {
  overflow-x: hidden;
  max-width: 100vw;
}
pre,
code,
.mono,
.code-block {
  max-width: 100%;
}
