@import url('/assets/tokens.css');

/* Usagi Hub — CMS mobile & touch-friendly overrides */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.site-main {
  padding: 0;
  overflow-x: clip;
}

.site-main:not(.cms-main) {
  padding: 20px 16px 56px;
}

@media (min-width: 768px) {
  .site-main:not(.cms-main) {
    padding: 28px 20px 48px;
  }
}

/* CMS pages with embedded full-width sections */
.site-main .container {
  padding-left: 16px;
  padding-right: 16px;
}

@media (min-width: 768px) {
  .site-main .container {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* Horizontal tab bars (san-pham, backtest) */
.page-tabs .container {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.page-tabs .container::-webkit-scrollbar {
  display: none;
}

.page-tabs .ptab {
  flex-shrink: 0;
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* Tables — swipe hint on narrow screens */
.tbl-wrap,
.bt-compare-scroll {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

@media (max-width: 639px) {
  .tbl-wrap::after,
  .bt-compare-scroll::after {
    content: '← Vuốt ngang để xem →';
    display: block;
    font-size: 10px;
    color: var(--txt3);
    text-align: center;
    padding: 6px 0 2px;
    letter-spacing: 0.02em;
  }

  table.tbl {
    min-width: 520px;
  }

  table.bt-compare {
    min-width: 580px;
    font-size: 11px;
  }

  table.bt-compare th,
  table.bt-compare td {
    padding: 10px 8px;
  }
}

/* Backtest KPI row */
@media (max-width: 479px) {
  .stat-row {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .stat-row .scard {
    padding: 10px 8px !important;
  }

  .stat-row .sv {
    font-size: 15px !important;
  }
}

/* Backtest report iframe */
.bt-report-frame {
  max-width: 100%;
}

.bt-report-iframe {
  min-height: min(720px, 70vh) !important;
}

@media (max-width: 639px) {
  .bt-report-iframe {
    min-height: 55vh !important;
  }

  .mod-sel .ms-btn {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 11px;
  }

  .bt-cmp-row td {
    padding-top: 12px !important;
    padding-bottom: 12px !important;
  }
}

/* Product module cards */
@media (max-width: 559px) {
  .modules-grid {
    gap: 10px;
  }

  .mod-card {
    padding: 16px;
  }

  .mod-price {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .mod-price a {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }

  .bundle-price-wrap .bp-final {
    font-size: 28px;
  }

  .ex-card {
    padding: 20px 16px;
  }
}

/* Sticky bottom bars inside CMS body */
.sticky-bar {
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0));
}

@media (max-width: 560px) {
  .sticky-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .sticky-bar .sb-left {
    flex: 1 1 100%;
    text-align: center;
  }

  .sticky-bar .sb-right {
    flex: 1 1 100%;
    justify-content: center;
  }

  .sticky-bar .btn {
    flex: 1;
    text-align: center;
    justify-content: center;
    min-height: 44px;
  }
}

/* Page hero typography */
@media (max-width: 639px) {
  .page-hero {
    padding: 32px 0 24px !important;
  }

  .page-hero h1,
  .ph {
    font-size: clamp(22px, 6vw, 32px) !important;
    line-height: 1.15 !important;
  }

  .section {
    padding: 40px 0 !important;
  }
}

/* Touch targets */
@media (max-width: 959px) {
  .site-mmenu a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

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

/* CMS hub/blog/legal — mobile readability */
@media (max-width: 639px) {
  .blog-page {
    padding: 24px 16px 48px;
  }

  .blog-hero h1 {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }

  .blog-lead {
    font-size: 15px;
  }

  .blog-card__title {
    font-size: 1rem;
  }

  .blog-card__excerpt {
    font-size: 14px;
    line-height: 1.65;
  }

  .policy-panel {
    padding: 20px 16px 18px;
  }

  .policy-panel h2 {
    font-size: 1.15rem;
  }

  .policy-panel__lead,
  .policy-panel__list {
    font-size: 14px;
  }

  .about-spirits-grid {
    grid-template-columns: 1fr;
  }

  .about-spirit__name {
    font-size: 16px;
  }

  .hub-links a {
    flex: 1 1 calc(50% - 10px);
    text-align: center;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* CMS body bottom space when sticky bar present */
body:has(.sticky-bar) .site-main {
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0));
}
