/* ==========================================================================
   Mobile-first hardening — tap targets, fluid header, no sideways scroll.
   Applied unconditionally (these rules are safe on desktop too).
   ========================================================================== */
:root {
  --tap-min: 44px;
  --bottom-nav-h: 60px;
}

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

body {
  -webkit-text-size-adjust: 100%;
  /* Ensure content clears both bottom-nav + potential unlock bar */
  padding-bottom: calc(var(--bottom-nav-h) + 56px + env(safe-area-inset-bottom, 0px));
}

/* All buttons: prevent double-tap zoom and give tactile feedback */
button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  opacity: 0.85;
}

/* Stop iOS auto-zoom on input focus (font-size must be >= 16px) */
input, select, textarea {
  font-size: 16px !important;
  touch-action: manipulation;
}

/* ==========================================================================
   Topbar — fluid, no overflow at any width
   ========================================================================== */
.topbar {
  padding: 10px 12px 0;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: nowrap;
  margin-bottom: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-shrink: 1;
}

.brand-text h1 {
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  margin-left: auto;
}

/* Compact action buttons */
.topbar-admin-btn,
.api-tag,
.how-btn {
  min-height: 34px;
  padding: 5px 9px;
  font-size: 11px;
  white-space: nowrap;
}

/* Scrollable tabs / filter / market bars */
.tabs,
.market-bar,
.filter-bar {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.tabs {
  gap: 4px;
  padding: 3px 3px 6px;
}

.tab {
  min-height: var(--tap-min);
  padding: 10px 12px;
  font-size: 12px;
  flex: 0 0 auto;
}

.market-chip,
.filter-chip {
  min-height: 38px;
  padding: 8px 12px;
}

/* ==========================================================================
   Main content area
   ========================================================================== */
#content {
  padding: 10px 12px;
}

/* Search input — font-size 16px already set above via input rule */
.search-bar input {
  font-size: 16px;
}

.search-clear {
  width: 30px;
  height: 30px;
  font-size: 14px;
}

/* ==========================================================================
   Fixture cards
   ========================================================================== */
.fixture-row {
  padding: 12px;
  border-radius: 14px;
}

.fixture-row-header {
  gap: 8px;
}

.fixture-call {
  row-gap: 6px;
}

/* Market grid inside expanded fixture drawer */
.market-grid {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

/* Settlement stats card — 2-col on very narrow screens */
@media (max-width: 380px) {
  .settlement-card {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Copy button tap target */
.copy-btn,
.rec-copy,
.hero-copy,
.modal-close,
.vip-upsell-btn,
.bet-tier-chip,
.slip-config-chip,
.road-build-btn {
  min-height: var(--tap-min);
}

.copy-btn {
  padding: 10px 14px;
  font-size: 12px;
}

/* ==========================================================================
   Bottom Navigation Bar  (shown on mobile only via @media below)
   ========================================================================== */
.bottom-nav {
  display: none;
}

@media (max-width: 767px) {
  /* Hide desktop tab row — bottom-nav takes over */
  .tabs {
    display: none;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    /* Height = nav area + iOS home-bar safe area */
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 100;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: 0;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--hint);
    padding: 10px 6px 6px;
    cursor: pointer;
    border-radius: 10px;
    transition: color 0.18s, background 0.18s;
    flex: 1;
    text-decoration: none;
    min-height: 56px;
    position: relative;
  }

  /* Active state: soft pill background */
  .bottom-nav-item.active {
    color: var(--link);
  }

  .bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--link);
    border-radius: 2px;
  }

  .bottom-nav-icon {
    font-size: 19px;
    line-height: 1;
    margin-bottom: 3px;
    margin-top: 4px;
  }

  .bottom-nav-label {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
  }

  /* Unlock bar sits above bottom-nav */
  .unlock-bar {
    bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  }
}

/* ==========================================================================
   Toast — above bottom-nav + unlock-bar
   ========================================================================== */
.toast {
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  white-space: normal;
  text-align: center;
  /* On mobile sit above bottom-nav */
  bottom: calc(var(--bottom-nav-h) + 64px + env(safe-area-inset-bottom, 0px));
}

/* ==========================================================================
   Modals — slide up from bottom on mobile
   ========================================================================== */
.modal-backdrop {
  padding: 16px;
  align-items: flex-end;
}

.modal {
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  border-radius: 18px 18px 14px 14px;
}

/* ==========================================================================
   Betslip / Road components
   ========================================================================== */
.bet-tiers-bar,
.slip-config-chips {
  padding-bottom: 4px;
}

.bet-tier-chip {
  flex: 0 0 auto;
}

.slip-card,
.rec-card,
.hero-card,
.vip-upsell-card {
  overflow-wrap: anywhere;
}

.slip-leg {
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.slip-leg-pick {
  overflow-wrap: anywhere;
}

.road-table-wrap {
  margin: 0 -4px 14px;
}

.road-form {
  grid-template-columns: repeat(2, 1fr);
}

.road-field input,
.slip-config-toggle {
  min-height: var(--tap-min);
}

/* ==========================================================================
   Admin dashboard grid — prevent overflow on narrow screens
   ========================================================================== */
.admin-stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}

.admin-form-row {
  flex-direction: column;
  align-items: stretch;
}

.admin-input,
.admin-select {
  min-width: 0;
  width: 100%;
}

.admin-input-small {
  width: 100%;
  text-align: left;
}

.admin-btn-row {
  flex-direction: column;
}

.admin-outline-btn,
.admin-action-btn {
  min-height: var(--tap-min);
  width: 100%;
  text-align: center;
}

/* ==========================================================================
   Extra-small screens (≤ 380px)
   ========================================================================== */
@media (max-width: 380px) {
  .brand-mark {
    display: none; /* hide BW mark to save space */
  }

  .brand-text h1 {
    font-size: 15px;
  }

  .sub-brand {
    display: none;
  }

  .how-btn span,
  .how-btn-text {
    display: none; /* hide label, keep icon */
  }

  .hero-match {
    font-size: 15px;
  }

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

  .hero-copy {
    width: 100%;
  }

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

  .steps {
    flex-direction: column;
  }

  /* Market grid: 2 columns on tiny screens */
  .market-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Tablet / wide layout (≥ 700px) — centre-constrain all sections
   ========================================================================== */
@media (min-width: 700px) {
  body {
    padding-bottom: 80px; /* no bottom-nav on desktop */
  }

  #content,
  .hero,
  .legend,
  .trust-block,
  .vip-upsell {
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
  }

  .topbar-row,
  .tabs,
  .market-bar,
  .filter-bar {
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
  }

  .unlock-bar {
    bottom: 0; /* sits at very bottom on desktop — no bottom-nav */
  }

  .toast {
    bottom: 80px;
  }
}

/* ==========================================================================
   Accessibility: honour reduced-motion preference
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Ensure images and tables never cause horizontal scroll */
img,
table {
  max-width: 100%;
}
