/* ================================================================
   Flourish Mobile Shell
   ----------------------------------------------------------------
   Adds three things, all hidden on desktop, all activated below
   1024px or on touch-first devices:
     1. Hamburger button in the top bar
     2. Slide-in drawer that wraps the existing .sidebar
     3. Bottom tab bar (≤640px only)
   The desktop sidebar stays exactly as-is.
   ================================================================ */

/* ─── Hamburger (in top bar) ─── */
.fl-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: var(--space-2, 8px);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  color: var(--charcoal, #2C2C2C);
  font-family: inherit;
  flex-shrink: 0;
  transition: background var(--duration-fast, 150ms) var(--ease-out, ease);
}
.fl-menu-btn:hover { background: var(--cream, #FAF7F2); }
.fl-menu-btn:active { background: var(--cream-dark, #F0EBE1); }
.fl-menu-btn svg { width: 22px; height: 22px; display: block; }

/* ─── Drawer backdrop ─── */
.fl-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(44, 44, 44, 0.45);
  z-index: var(--z-backdrop, 80);
  opacity: 0;
  transition: opacity var(--duration-base, 220ms) var(--ease-out, ease);
}
.fl-drawer-backdrop.open {
  display: block;
  opacity: 1;
}

/* ─── Bottom tab bar ─── */
.fl-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--mobile-bottomnav-h, 64px) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--white, #fff);
  border-top: 1px solid var(--border, #E8E0D6);
  z-index: var(--z-sticky, 10);
  box-shadow: 0 -2px 12px rgba(60, 45, 35, 0.06);
}
.fl-bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: var(--mobile-bottomnav-h, 64px);
}
.fl-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-muted, #7A6E68);
  font-size: 10px;
  font-weight: 600;
  padding: 6px 4px;
  min-height: 44px;
  transition: color var(--duration-fast, 150ms) var(--ease-out, ease);
  position: relative;
  text-decoration: none;
}
.fl-tab .fl-tab-icon {
  font-size: 18px;
  line-height: 1;
  display: block;
  height: 22px;
}
.fl-tab .fl-tab-label {
  font-size: 9.5px;
  letter-spacing: 0.01em;
  line-height: 1.1;
  white-space: nowrap;
}
.fl-tab:hover { color: var(--text, #3D3530); }
.fl-tab[aria-current="page"] {
  color: var(--sage-dark, #5C8060);
}
.fl-tab[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: var(--sage, #7A9E7E);
  border-radius: 0 0 3px 3px;
}

/* ─── Safe-area padding for the page-content when bottom nav is on ─── */
body.fl-has-bottom-nav .page-content {
  padding-bottom: calc(var(--mobile-bottomnav-h, 64px) + env(safe-area-inset-bottom, 0px) + 24px);
}

/* ─── Drawer behavior on tablets, phones, and touch-first browsers ─── */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  .fl-menu-btn { display: inline-flex; }

  /* Sidebar becomes a drawer; override existing inline rules */
  #app .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    min-width: 320px;
    max-width: 92vw;
    z-index: var(--z-drawer, 90);
    transform: translateX(-100%);
    transition: transform var(--duration-base, 220ms) var(--ease-out, ease);
    box-shadow: var(--shadow-xl, 0 24px 56px rgba(60, 45, 35, 0.14));
  }
  #app .sidebar.fl-drawer-open {
    transform: translateX(0);
  }
  /* Make sure the main column reclaims the full width when drawer is closed */
  :root { --sidebar-w: 0px; }

  /* Top bar gets tighter padding */
  .top-bar { padding: 0 var(--space-4, 16px); }
}

/* ─── Bottom nav appears on small phones and phone browsers in desktop-site mode ─── */
@media (max-width: 640px), (hover: none) and (pointer: coarse) {
  .fl-bottom-nav { display: block; }
  body.fl-has-bottom-nav .page-content {
    padding-bottom: calc(var(--mobile-bottomnav-h, 64px) + env(safe-area-inset-bottom, 0px) + 24px);
  }
}

/* Lock body scroll when drawer is open */
body.fl-drawer-locked {
  overflow: hidden;
}

/* Keep the desktop shell on wide, precise-pointer screens */
@media (min-width: 1025px) and (hover: hover) and (pointer: fine) {
  .fl-menu-btn { display: none !important; }
  .fl-drawer-backdrop { display: none !important; }
}
