/*
 * Mobile navbar drawer — peer-checked fallback + polish.
 *
 * The compiled Tailwind bundle (tailwind-main.css) currently ships without
 * peer-checked variants, so the markup class `peer-checked:flex` on
 * #mobile-nav-drawer has no effect and the hamburger toggle never opens
 * the drawer. This file implements the :checked sibling selector directly
 * so the pure-CSS hamburger works regardless of the Tailwind build state.
 *
 * It also paints a polished mobile drawer: card-style surface, gradient
 * accent, slide-down animation, full-viewport backdrop, and a clearly
 * themed close button.
 *
 * Selector contract (do not change these ids without updating base.html):
 *   - #mobile-nav-toggle     : the <input type="checkbox"> driver
 *   - #mobile-nav-toggle-btn : the <label> that flips the checkbox
 *   - #mobile-nav-drawer     : the drawer panel that should slide in
 *   - #mobile-nav-backdrop   : the dim/blur backdrop behind the drawer
 */

/* ── Open the drawer when the hamburger checkbox is checked ───────────── */
#mobile-nav-toggle:checked ~ #mobile-nav-drawer {
  display: flex !important;
  animation: mobileNavDrawerIn 220ms ease-out both;
}

#mobile-nav-toggle:checked ~ #mobile-nav-backdrop {
  display: block !important;
  animation: mobileNavBackdropIn 220ms ease-out both;
}

/* Swap the hamburger glyph for an ✕ close glyph while the drawer is open.
 * The <label> text node is `&#9776;` (☰); we hide it via font-size:0 and
 * paint the ✕ via ::before at the normal size. */
#mobile-nav-toggle:checked ~ #mobile-nav-toggle-btn {
  font-size: 0;
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

#mobile-nav-toggle:checked ~ #mobile-nav-toggle-btn::before {
  content: "\2715"; /* ✕ */
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
}

/* ── Polished drawer surface ─────────────────────────────────────────── */
.mobile-nav-drawer {
  position: relative;
  z-index: 50;
  background: linear-gradient(180deg, #111827 0%, #0b1220 100%);
  border: 1px solid rgba(55, 65, 81, 0.7);
  border-radius: 16px;
  padding: 14px 12px 18px;
  margin-top: 14px;
  box-shadow:
    0 20px 40px -10px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  gap: 4px;
}

/* Green→blue accent stripe across the top */
.mobile-nav-drawer::before {
  content: "";
  display: block;
  height: 3px;
  border-radius: 3px;
  margin: -2px 6px 10px;
  background: linear-gradient(90deg,
              rgba(34, 197, 94, 0.8) 0%,
              rgba(52, 211, 153, 0.7) 50%,
              rgba(59, 130, 246, 0.7) 100%);
}

/* Anchor / button rows inside the drawer */
.mobile-nav-drawer > a,
.mobile-nav-drawer > form > button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  color: #f3f4f6;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background-color 150ms ease,
              border-color 150ms ease,
              transform 120ms ease;
  text-decoration: none;
  width: 100%;
  text-align: left;
  background: transparent;
}

.mobile-nav-drawer > a:hover,
.mobile-nav-drawer > a:focus-visible,
.mobile-nav-drawer > form > button:hover,
.mobile-nav-drawer > form > button:focus-visible {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(34, 197, 94, 0.35);
  transform: translateX(2px);
  outline: none;
}

.mobile-nav-drawer > a:active,
.mobile-nav-drawer > form > button:active {
  transform: translateX(0) scale(0.99);
}

/* Subtle separator before the logout form */
.mobile-nav-drawer > form {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid rgba(55, 65, 81, 0.6);
}

/* Coin pill: keep compact and self-contained */
.mobile-nav-drawer .coin-display {
  align-self: flex-start;
  margin: 4px 6px;
}

/* ── Backdrop ────────────────────────────────────────────────────────── */
#mobile-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.55);
  backdrop-filter: blur(2px);
  z-index: 30;
}

/* ── Animations ──────────────────────────────────────────────────────── */
@keyframes mobileNavDrawerIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mobileNavBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
  #mobile-nav-toggle:checked ~ #mobile-nav-drawer,
  #mobile-nav-toggle:checked ~ #mobile-nav-backdrop {
    animation: none;
  }
  .mobile-nav-drawer > a,
  .mobile-nav-drawer > form > button {
    transition: none;
  }
}

/* ── Desktop (md and up): force hamburger + drawer hidden ────────────── *
 * Tailwind's `.inline-flex` utility is emitted AFTER `.md\:hidden` in the
 * compiled bundle, so at ≥768px the later rule wins and the hamburger
 * stays visible on desktop. Force it hidden here. */
@media (min-width: 768px) {
  #mobile-nav-toggle-btn,
  #mobile-nav-drawer,
  #mobile-nav-backdrop {
    display: none !important;
  }
  /* Defensive: even if the checkbox is somehow :checked (e.g. device
   * rotation from mobile to desktop width) the drawer must not expand
   * the navbar row. */
  #mobile-nav-toggle:checked ~ #mobile-nav-drawer,
  #mobile-nav-toggle:checked ~ #mobile-nav-backdrop {
    display: none !important;
  }
  #mobile-nav-toggle {
    display: none !important;
  }
}
