/* ============================================================
   ZEN MINER — mobile.css
   Mobile-first overlay: bottom navigation, floating action
   button, bottom sheets, safe-area handling, and touch tuning.
   Loaded after style.css; only activates the new layout at
   narrow viewports via the .has-bottom-nav body class + media
   query, so desktop nav (in header.php) is untouched.
   ============================================================ */

:root {
  --nav-height: 64px;
  --bottom-nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ── Offline indicator ─────────────────────────────────────────── */
#offline-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--warning, #ECC94B);
  color: #5c4a00;
  font-size: .85rem;
  font-weight: 600;
  padding: 8px 12px;
  position: sticky;
  top: 0;
  z-index: 200;
}
body.is-offline #offline-banner { display: flex; }

/* ── PWA install button (shown in nav when available) ─────────── */
#pwa-install-btn {
  display: none;
}

/* ============================================================
   Bottom Navigation — mobile only
   ============================================================ */
.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  body.has-bottom-nav {
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 12px);
  }

  /* Hide the desktop top nav links on mobile when bottom nav is active;
     hamburger menu still available for secondary items. */
  body.has-bottom-nav .navbar .nav-links a:not(.btn) {
    display: none;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 150;
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 600;
    text-decoration: none !important;
    min-height: 44px;
    position: relative;
  }

  .bottom-nav-item .bn-icon {
    font-size: 1.35rem;
    line-height: 1;
  }

  .bottom-nav-item.active {
    color: var(--primary);
  }
  .bottom-nav-item.active .bn-icon {
    transform: translateY(-2px);
    transition: transform .2s ease;
  }

  /* Floating "Start Mining" action button, replaces the middle tab */
  .bottom-nav-fab {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    position: relative;
  }
  .bottom-nav-fab .fab-button {
    position: absolute;
    top: -22px;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 16px rgba(108,99,255,.5);
    border: 4px solid var(--surface);
    text-decoration: none !important;
  }
  .bottom-nav-fab .fab-button.mining-active {
    animation: fabPulse 2s infinite;
  }
  @keyframes fabPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(108,99,255,.5); }
    50% { box-shadow: 0 4px 28px rgba(108,99,255,.85); }
  }
  .bottom-nav-fab .fab-label {
    margin-top: 30px;
    font-size: .68rem;
    font-weight: 600;
    color: var(--muted);
  }
}

/* ============================================================
   Bottom Sheets
   ============================================================ */
.bottom-sheet-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 300;
}
.bottom-sheet-overlay.open { display: block; }

.bottom-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(20px + var(--safe-bottom));
  z-index: 301;
  transform: translateY(100%);
  transition: transform .25s ease;
  max-height: 80vh;
  overflow-y: auto;
}
.bottom-sheet-overlay.open .bottom-sheet {
  transform: translateY(0);
}
.bottom-sheet-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 999px;
  margin: 0 auto 16px;
}

/* ============================================================
   Touch & layout tuning
   ============================================================ */
@media (max-width: 768px) {
  .btn { min-height: 44px; }
  .input { min-height: 48px; font-size: 16px; } /* 16px prevents iOS auto-zoom on focus */

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .donate-grid { grid-template-columns: 1fr; }
  .features-grid { grid-template-columns: 1fr; }

  .hero { padding: 48px 16px; }
  .section { padding: 40px 0; }

  .mining-panel { padding: 24px 16px; }
  .mining-timer { font-size: 2.2rem; }
  .mining-icon { width: 64px; height: 64px; font-size: 2rem; }

  .table-wrap table { font-size: .82rem; }
  th, td { padding: 10px; }

  /* Swipeable horizontal sections (e.g. dashboard stat strips) */
  .swipe-row {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .swipe-row::-webkit-scrollbar { display: none; }
  .swipe-row > * {
    scroll-snap-align: start;
    flex: 0 0 auto;
  }
}

/* ============================================================
   Standalone/installed app tweaks
   ============================================================ */
@media (display-mode: standalone) {
  .navbar { padding-top: var(--safe-top); }
  /* Hide "install" affordances once already installed */
  #pwa-install-btn { display: none !important; }
}
