/* Hexora — responsive layout (phones, tablets, all viewports) */

body {
  overflow-x: clip;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

body.nav-open {
  overflow: hidden;
}

/* Fluid container — tighter on small screens */
@media (max-width: 480px) {
  :root {
    --nav-h: 60px;
  }

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

/* ——— Header & navigation ——— */
.site-header {
  z-index: 200;
}

.site-header .container {
  position: relative;
  z-index: 202;
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--nav-h);
  z-index: 199;
  background: rgba(15, 17, 23, 0.55);
  backdrop-filter: blur(2px);
  -webkit-tap-highlight-color: transparent;
}

[data-theme="light"] .nav-backdrop {
  background: rgba(26, 29, 38, 0.4);
}

.nav-backdrop.is-visible {
  display: block;
}

@media (max-width: 900px) {
  .site-header nav.site-nav {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    right: 0;
    z-index: 201;
    pointer-events: none;
    display: flex;
    justify-content: center;
    padding: 0.5rem 1rem 0;
    box-sizing: border-box;
  }

  .site-header nav.site-nav .nav-links {
    pointer-events: auto;
  }

  .nav-toggle {
    display: grid;
    place-items: center;
    z-index: 203;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    width: 100%;
    max-width: 22rem;
    max-height: min(70dvh, calc(100dvh - var(--nav-h) - 1.5rem));
    overflow-y: auto;
    margin: 0 auto;
    padding: 1rem 1.25rem 1.25rem;
    list-style: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links li {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .nav-links a {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0.9rem 1.25rem;
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
    border-radius: 12px;
    box-sizing: border-box;
  }

  .btn-discord--compact span {
    display: none;
  }

  .btn-discord--compact {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
  }

  .logo {
    font-size: 1.1rem;
    min-width: 0;
  }

  .logo-mark {
    width: 36px;
    height: 36px;
  }

  .logo-mark .logo-img {
    width: 36px;
    height: 36px;
  }

  .nav-actions {
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .theme-toggle,
  .nav-toggle {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 380px) {
  .site-header .container {
    gap: 0.5rem;
  }

  .logo {
    font-size: 1rem;
    gap: 0.45rem;
  }
}

/* ——— Hero & home ——— */
@media (max-width: 640px) {
  .hero {
    padding: 2.5rem 0 2rem;
  }

  .hero-lead {
    font-size: 1rem;
  }

  .hero-cta {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-cta .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }

  .hero-stats {
    gap: 1rem;
    justify-content: space-between;
  }

  .stat {
    flex: 1 1 30%;
    min-width: 0;
    text-align: center;
  }

  .stat strong {
    font-size: 1.25rem;
  }

  .section {
    padding: 2.5rem 0;
  }

  .section-header {
    margin-bottom: 1.75rem;
  }

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

  .price-card {
    padding: 1.5rem 1.25rem;
  }

  .price {
    font-size: 2rem;
  }

  .pricing-note .btn-discord {
    width: 100%;
    justify-content: center;
  }

  .section-cta .btn-row {
    flex-direction: column;
    align-items: stretch;
  }

  .section-cta .btn-row .btn {
    width: 100%;
    min-height: 48px;
  }
}

/* ——— Commands page ——— */
@media (max-width: 959px) {
  .commands-layout {
    padding: 1.25rem 0 2.5rem;
    gap: 1.25rem;
    grid-template-columns: 1fr;
  }

  .commands-sidebar {
    position: static;
    max-height: none;
    width: 100%;
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .commands-sidebar h2 {
    margin-bottom: 0.65rem;
  }

  .cat-nav {
    flex-direction: column;
    overflow: visible;
    gap: 0.4rem;
    max-height: min(42vh, 360px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 0.15rem;
  }

  .cat-nav li {
    flex: none;
    max-width: none;
    width: 100%;
  }

  .cat-nav a {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.86rem;
  }

  .cat-nav .cat-label {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  .page-hero {
    padding: 1.75rem 0 0.75rem;
  }

  .page-hero-actions .btn-discord {
    width: 100%;
    max-width: 320px;
    justify-content: center;
  }

  .search-box {
    margin-bottom: 1rem;
  }

  .search-box input {
    font-size: 16px;
    padding: 0.9rem 1rem 0.9rem 2.75rem;
  }

  .commands-panel-head h2 {
    font-size: 1.1rem;
  }

  .commands-panel-hint {
    font-size: 0.8rem;
    line-height: 1.45;
  }

  .cmd-list-viewport {
    min-height: 16rem;
  }
}

@media (max-width: 599px) {
  .cmd-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .cmd-perm {
    white-space: normal;
    max-width: 100%;
    line-height: 1.35;
  }

  .cmd-item {
    padding: 0.85rem 1rem;
  }

  .cmd-usage li {
    padding: 0.5rem 0.65rem;
    font-size: 0.75rem;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .cmd-usage li::before {
    position: static;
    display: block;
    transform: none;
    margin-top: 0.4rem;
    opacity: 0.5;
    text-align: right;
  }

  .cmd-usage li:hover::before,
  .cmd-usage li.copied::before {
    opacity: 1;
  }

  .commands-pagination {
    gap: 0.5rem;
  }

  .commands-pagination .page-btn {
    flex: 1 1 auto;
    min-height: 44px;
  }

  .commands-pagination .page-info {
    width: 100%;
    text-align: center;
    order: -1;
  }
}

/* ——— Terms & footer ——— */
@media (max-width: 640px) {
  .terms-content {
    margin-bottom: 2.5rem;
    padding: 1.25rem 1rem;
    border-radius: var(--radius);
  }

  .terms-content h2 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
  }

  .legal-contact-actions .btn-discord {
    width: 100%;
    justify-content: center;
  }

  .footer-grid {
    gap: 1.5rem;
  }

  .footer-discord {
    width: 100%;
    max-width: 100%;
    justify-content: center;
  }

  .site-footer {
    padding: 2rem 0 calc(1.5rem + env(safe-area-inset-bottom, 0));
  }

  .footer-bottom {
    font-size: 0.8rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

/* ——— App shell ——— */
@media (max-width: 640px) {
  .app-page-loader {
    min-height: 30vh;
  }

  .app-view.is-exiting,
  .app-view.is-entering {
    transform: none;
  }
}

