/* GAIO Tech — shared mobile / responsive layer */

:root {
  --bottom-nav-h: 4.25rem;
  --mobile-top-h: 3.25rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

@media (max-width: 900px) {
  :root {
    --topbar-h: var(--mobile-top-h);
  }
}

/* ---- Global: prevent horizontal overflow ---- */
html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  max-width: 100%;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

table {
  max-width: 100%;
}

/* ---- Marketing chrome ---- */
@media (max-width: 767px) {
  body.marketing .site-nav {
    padding: 0.625rem var(--pad-x);
    gap: 0.5rem;
  }

  body.marketing .logo svg {
    height: 1.5rem;
  }

  body.marketing .nav-actions {
    gap: 0.5rem;
    margin-left: auto;
  }

  body.marketing .nav-actions .btn:not(.btn-primary) {
    display: none;
  }

  body.marketing .nav-actions .btn-primary {
    min-height: 40px;
    padding: 0 0.875rem;
    font-size: 0.6875rem;
  }

  body.marketing .mobile-drawer {
    inset: calc(var(--mobile-top-h) + var(--safe-top)) 0 0 0;
    padding-bottom: calc(1.5rem + var(--safe-bottom));
    overflow-y: auto;
  }

  body.marketing .footer-grid {
    gap: 2rem;
  }

  body.marketing .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---- Homepage (index) ---- */
@media (max-width: 767px) {
  .hero {
    padding: clamp(2rem, 8vw, 3rem) var(--pad-x);
  }

  .hero-num {
    font-size: clamp(3.5rem, 22vw, 7rem);
    right: 0.5rem;
  }

  .hero h1 {
    font-size: clamp(2rem, 9vw, 2.75rem);
    max-width: 100%;
  }

  .hero-lead {
    font-size: 1rem;
    max-width: 100%;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .hero-meta {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .llm-strip {
    gap: 1rem;
  }

  .section {
    padding: clamp(2.5rem, 8vw, 4rem) var(--pad-x);
  }

  .section-num {
    font-size: clamp(3rem, 16vw, 5.5rem);
    right: var(--pad-x);
  }

  .section-head h2 {
    font-size: clamp(1.5rem, 6vw, 2rem);
    max-width: 100%;
  }

  .section-head p {
    max-width: 100%;
  }

  .shift-chart-canvas {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .shift-chart-canvas svg {
    min-width: 320px;
  }

  .shift-kpis {
    gap: 0.75rem 1rem;
  }

  .shift-kpi {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 0;
  }

  .metric-row {
    grid-template-columns: 1fr 1fr;
  }

  .roi-layout {
    grid-template-columns: 1fr;
  }

  .pricing-card.featured {
    margin: 0;
    padding-top: 2rem;
  }

  .plan-compare-scroll {
    margin-left: calc(var(--pad-x) * -1);
    margin-right: calc(var(--pad-x) * -1);
    border-left: none;
    border-right: none;
  }

  .tab-panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---- Blog index ---- */
@media (max-width: 767px) {
  .blog-hero h1 {
    max-width: 100%;
  }

  .blog-toolbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    max-width: 100%;
  }

  .filter-btn {
    flex-shrink: 0;
  }

  .post-count {
    text-align: left;
  }

  .blog-cta-form {
    flex-direction: column;
  }

  .blog-cta-form input,
  .blog-cta-form button {
    width: 100%;
  }
}

/* ---- Blog article ---- */
@media (max-width: 767px) {
  .article-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .article-toc {
    position: relative;
    top: auto;
    margin-bottom: 1.5rem;
    padding: 1rem;
  }

  .article-header {
    padding: 1.5rem var(--pad-x) 1.25rem;
  }

  .article-body {
    padding: 0 var(--pad-x) 2rem;
  }

  .article-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .share-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .share-buttons .share-btn {
    justify-content: center;
  }

  .article-newsletter-form {
    flex-direction: column;
  }

  .article-newsletter-form input,
  .article-newsletter-form button {
    width: 100%;
  }
}

/* ---- Login ---- */
@media (max-width: 767px) {
  .login-main {
    align-items: flex-start;
    padding-top: 2rem;
  }

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

/* ---- App: bottom navigation on mobile ---- */
@media (max-width: 900px) {
  .sidebar-toggle {
    display: none !important;
  }

  .app-shell {
    display: block;
    min-height: 100vh;
  }

  .workspace-select,
  .sidebar-user,
  .nav-group-label,
  .nav-desc,
  .sidebar-footer .logout-row {
    display: none !important;
  }

  /* Top bar: logo + theme */
  .sidebar-logo {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 90;
    height: calc(var(--mobile-top-h) + var(--safe-top));
    padding: calc(0.5rem + var(--safe-top)) 1rem 0.5rem;
    border-bottom: 1px solid color-mix(in oklch, var(--panel-fg) 12%, transparent);
    border-right: none;
    background: var(--panel);
  }

  /* Bottom bar: primary nav */
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    flex-direction: row;
    align-items: stretch;
    border-right: none;
    border-top: 1px solid color-mix(in oklch, var(--panel-fg) 12%, transparent);
    transform: none !important;
    overflow: hidden;
    z-index: 100;
    padding-bottom: var(--safe-bottom);
    background: var(--panel);
  }

  .sidebar-nav,
  .sidebar-footer {
    display: flex;
    flex: 1;
    flex-direction: row;
    align-items: stretch;
    padding: 0;
    min-width: 0;
  }

  .sidebar-footer {
    flex: 0 0 auto;
    border-top: none;
  }

  .sidebar-nav .nav-item,
  .sidebar-footer .nav-item {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    margin: 0;
    padding: 0.35rem 0.25rem;
    border-radius: 0;
    min-width: 0;
    min-height: var(--bottom-nav-h);
    text-align: center;
  }

  .sidebar-nav .nav-item .nav-title,
  .sidebar-footer .nav-item .nav-title {
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .sidebar-nav .nav-item .nav-icon,
  .sidebar-footer .nav-item .nav-icon {
    width: 20px;
    height: 20px;
    opacity: 1;
  }

  /* Floating scan action */
  .sidebar-actions {
    display: block !important;
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 0.75rem);
    right: 1rem;
    z-index: 101;
    padding: 0;
    width: auto;
  }

  .sidebar-actions .btn-publisher {
    display: none;
  }

  .sidebar-actions .btn-scan {
    width: 3.25rem;
    height: 3.25rem;
    min-height: 3.25rem;
    padding: 0;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
  }

  .sidebar-actions .btn-scan svg {
    margin: 0;
  }

  .sidebar-actions .btn-scan {
    font-size: 0;
    gap: 0;
  }

  .main {
    margin-left: 0;
    min-height: 100vh;
  }

  .main:not(:has(.app-topbar)) {
    padding-top: calc(var(--mobile-top-h) + var(--safe-top));
  }

  .main:has(.app-topbar) {
    padding-top: calc(var(--mobile-top-h) + var(--safe-top) + var(--topbar-h));
  }

  .main-inner {
    padding: 1rem 1rem calc(var(--bottom-nav-h) + var(--safe-bottom) + 4.5rem);
  }

  .page-header {
    margin-bottom: 1.5rem;
  }

  .filter-toolbar {
    gap: 0.5rem;
  }

  .search-wrap {
    flex: 1 1 100%;
    max-width: none;
  }

  .filter-group {
    flex: 1 1 100%;
    width: 100%;
  }

  .filter-field,
  .filter-select:not(.filter-field .filter-select) {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }

  .filter-select {
    max-width: none;
    font-size: 0.8125rem;
  }

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

  .scan-row-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .scan-date {
    white-space: normal;
  }

  .summary-strip {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .summary-sep {
    display: none;
  }

  .scan-toast,
  .toast {
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 1rem);
    left: 1rem;
    right: 1rem;
  }
}

/* ---- Report detail ---- */
@media (max-width: 900px) {
  .report-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .report-title-block {
    min-width: 0;
    width: 100%;
  }

  .question-card {
    grid-template-columns: 1fr;
  }

  .question-actions {
    flex-wrap: wrap;
  }

  .question-actions .btn-action {
    flex: 1 1 calc(50% - 0.25rem);
    justify-content: center;
  }

  .report-footer-actions {
    flex-direction: column;
  }

  .report-footer-actions button,
  .report-footer-actions a {
    width: 100%;
    justify-content: center;
  }

  .report-hero-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .report-date-range {
    padding-top: 0;
  }

  .brand-book-card,
  .tracking-card {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-brand-book,
  .tracking-actions {
    width: 100%;
  }

  .btn-brand-book {
    justify-content: center;
  }

  .tracking-actions .btn-track-config,
  .tracking-actions .btn-track-all {
    flex: 1;
    justify-content: center;
  }

  .timeline-card-head {
    flex-direction: column;
  }

  .period-tabs {
    width: 100%;
    justify-content: stretch;
  }

  .period-tab {
    flex: 1;
    text-align: center;
  }

  .report-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* ---- AI Share of Voice ---- */
@media (max-width: 900px) {
  .query-title {
    max-width: 100%;
    font-size: 1.25rem;
  }

  .kpi-row {
    grid-template-columns: 1fr 1fr;
  }

  .model-row {
    grid-template-columns: 1fr;
  }

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

  .chart-wrap svg {
    min-width: 0;
  }

  .response-body {
    max-height: none;
  }
}

@media (max-width: 480px) {
  .kpi-row {
    grid-template-columns: 1fr;
  }

  .hero-meta {
    grid-template-columns: 1fr;
  }

  .shift-kpi {
    flex: 1 1 100%;
  }

  .query-actions .btn-action {
    flex: 1 1 100%;
  }
}
