/* Layout components - Header, Footer, Navigation */

:root {
  --beanthentic-green: #25671E;
  --beanthentic-green-dark: #1c5216;
  --beanthentic-green-accent: #25671E;
  --beanthentic-cream: #fdfaf6;
  --beanthentic-text: #1a1f16;
  --navbar-bg: #0B3D1B;
  --navbar-bg-shade: #082F15;
  --navbar-fg: #fdfaf6;
  --navbar-border: rgba(0, 0, 0, 0.22);
}

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  inset-inline: 0;
  width: 100%;
  max-width: 100%;
  margin: 0;
  box-sizing: border-box;
  z-index: 1200;
  background: linear-gradient(180deg, var(--navbar-bg) 0%, var(--navbar-bg-shade) 100%);
  border-bottom: 1px solid var(--navbar-border);
  padding-top: env(safe-area-inset-top);
  padding-left: 0;
  padding-right: 0;
  /* Stable compositing layer — avoids subpixel “nudge” on some WebViews while scrolling */
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* js/beanthentic_fixed_topbar.js sets --beanthentic-fixed-topbar-h and these classes */
:root {
  --beanthentic-fixed-topbar-h: calc(env(safe-area-inset-top, 0px) + 5.5rem);
}

html.beanthentic-fixed-topbar-active {
  scroll-padding-top: var(--beanthentic-fixed-topbar-h);
}

body.beanthentic-fixed-topbar-active {
  padding-top: var(--beanthentic-fixed-topbar-h);
}

/* Reserve space under fixed header on first paint (before topbar JS measures) */
body.has-app-bottom-nav,
body.pi-page,
body.help-page,
body.contact-page,
body.account-settings-page,
body.reg-summary-page,
body:has(header.msg-top),
body:has(header.hist-hero),
body:has(header.about-hero),
body:has(header.mv-hero),
body:has(header.fr-reg-hero):not(.register-farm-flow) {
  padding-top: var(--beanthentic-fixed-topbar-h);
}

body.login-page,
body.signup-page,
body.tutorial-page,
body.choose-lang-page,
body.server-url-page {
  padding-top: 0 !important;
}

/* Keep vertical document scroll working in WebView: avoid overflow-x on html (breaks some Android WebViews). */
html {
  max-width: 100%;
  overscroll-behavior: none;
}

body {
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
}

.nav {
  width: 100%;
  max-width: none;
  margin: 0;
  box-sizing: border-box;
  /* Burger + logo flush left; only safe-area / minimal inset on the left edge. */
  padding: 0.32rem 1.1rem 0.32rem max(0.2rem, env(safe-area-inset-left, 0px));
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  column-gap: 0.45rem;
  position: relative;
}

.nav-logo-wrap {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  min-width: 0;
}

.nav-right-cluster {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-shrink: 0;
  justify-self: end;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 1rem;
  text-transform: uppercase;
  color: var(--navbar-fg);
  min-width: 0;
  margin-right: 0;
}

@keyframes logoPopIn {
  0% {
    transform: translateY(10px);
    opacity: 0;
  }

  60% {
    transform: translateY(-2px);
    opacity: 1;
  }

  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.logo-mark {
  width: 132px;
  height: 112px;
  object-fit: contain;
  object-position: center center;
  display: block;
  /* Make the logo appear larger WITHOUT increasing header/nav height. */
  transform: scale(var(--beanthentic-logo-scale)) !important;
  transform-origin: left center;
  animation: logoPopIn 0.55s ease-out 0.05s both;
}

.logo-img {
  width: 48px;
  height: 48px;
  display: block;
  box-sizing: content-box;
  object-fit: contain;
  border-radius: 999px;
  padding: 10px;
  background: rgba(253, 250, 246, 0.96);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.18),
    0 2px 6px rgba(0, 0, 0, 0.12);
  filter: none;
}


/* Main nav links — row on desktop, collapsible panel on narrow screens */
.nav-menu-toggle {
  display: inline-flex;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(253, 250, 246, 0.35);
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  flex-shrink: 0;
}

.nav-menu-toggle-line {
  display: block;
  width: 22px;
  height: 2px;
  background: #fdfaf6;
  border-radius: 999px;
}

/* Large text “Menu” / “Close” — no confusing X icon (farmer-friendly) */
.nav-toggle {
  display: none;
  margin-left: auto;
  min-height: 48px;
  padding: 0.65rem 1.35rem;
  border: 2px solid rgba(253, 250, 246, 0.55);
  border-radius: 999px;
  background: rgba(253, 250, 246, 0.2);
  color: #fdfaf6;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.nav-toggle:hover {
  background: rgba(253, 250, 246, 0.32);
}

.nav-open .nav-toggle {
  background: rgba(253, 250, 246, 0.95);
  color: var(--beanthentic-green-accent);
  border-color: rgba(253, 250, 246, 0.95);
}

.nav-toggle-label {
  pointer-events: none;
}

.nav-links {
  grid-column: 1 / -1;
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  font-size: 0.95rem;
  padding: 0.5rem 0 0.25rem;
  margin: 0;
  list-style: none;
}

.nav-links.is-open {
  display: flex;
}

.nav-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(12, 7, 3, 0.4);
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  pointer-events: none;
}

.nav-mobile-overlay.is-visible {
  display: block;
  pointer-events: auto;
}

body.nav-menu-open {
  overflow: hidden;
}

@media (min-width: 901px) {
  .nav {
    padding: 0.4rem 1.35rem;
  }

  .nav-menu-toggle {
    display: none !important;
  }

  .nav-links {
    grid-column: auto;
    display: flex !important;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 1.5rem;
    padding: 0;
  }

  .nav-links.is-open {
    display: flex !important;
  }
}

@media (max-width: 900px) {
  .nav-links {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 31;
    background: var(--beanthentic-green-dark);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0 0 12px 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
    padding: 0.65rem 0.85rem 0.75rem;
    margin-top: 0;
  }

  .logo-mark {
    width: 114px;
    height: 96px;
    transform-origin: left center;
  }

  .logo {
    font-size: 0.82rem;
    letter-spacing: 0.06em;
  }

  .nav-links .about-nav {
    width: 100%;
  }

  .nav-links>a {
    padding: 0.55rem 0.4rem;
    border-radius: 10px;
  }

  .about-nav-dropdown {
    position: static;
    left: auto;
    right: auto;
    top: auto;
    width: 100%;
    margin-top: 0.35rem;
    max-height: min(55vh, 360px);
  }
}

/* Top bar burger (mobile) */
.sidebar-burger {
  display: inline-flex;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(253, 250, 246, 0.35);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 0;
}

.sidebar-burger-line {
  display: block;
  width: 22px;
  height: 2px;
  background: #fdfaf6;
  border-radius: 999px;
  margin: 0;
}

.home-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 7, 3, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 55;
}

.home-sidebar-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

body.no-scroll {
  overflow: hidden;
}

/* About dropdown (top nav) */
.about-nav {
  position: relative;
}

.about-nav-toggle {
  position: relative;
}

.about-nav-toggle[aria-expanded="true"]::after {
  /* Use the same underline as other nav links */
  width: 100%;
}

.about-nav-dropdown {
  position: absolute;
  left: 0;
  right: auto;
  top: calc(100% + 10px);
  width: 260px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(20, 117, 57, 0.18);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(61, 33, 16, 0.18);
  padding: 0.35rem 0;
  z-index: 70;
  max-height: min(70vh, 420px);
  overflow: auto;
}

.about-nav-dropdown .about-nav-item {
  /* Use about-menu-item base look, but without the right arrow. */
  display: block;
}

.about-nav-dropdown .about-menu-item::after {
  /* Remove the right-side arrow indicator entirely in top-nav dropdown. */
  content: none !important;
}

.about-nav-dropdown .about-menu-item {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 0;
  border: 0;
  background: transparent;
  color: var(--beanthentic-green-accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.about-nav-dropdown .about-menu-item:hover {
  background: rgba(20, 117, 57, 0.08);
}

.about-nav-dropdown .about-menu-item.is-active {
  background: rgba(20, 117, 57, 0.1);
  color: #0b3d2e;
}

.about-history-submenu {
  padding: 0.15rem 0.75rem 0.5rem;
  display: grid;
  gap: 0.3rem;
}

.about-history-submenu[hidden] {
  display: none;
}

.about-history-submenu .about-history-subitem {
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  gap: 1.5rem;
  font-size: 0.95rem;
  align-items: center;
}

/* Dashboard uses a fixed left sidebar: keep header aligned */
.dashboard-page header .nav {
  max-width: none;
  margin: 0;
  padding-left: calc(260px + 1.5rem);
  padding-right: 1.5rem;
  transition: padding-left 0.3s ease;
}

/* When the dashboard sidebar is collapsed, align navbar to the left */
.dashboard-page.sidebar-collapsed header .nav {
  padding-left: 1.5rem;
}

@media (max-width: 768px) {
  .dashboard-page header .nav {
    padding-left: 1.1rem;
    padding-right: 1.1rem;
  }
}

.nav-links a {
  position: relative;
  padding-bottom: 0.2rem;
  color: #fdfaf6;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #8b4a2b, var(--beanthentic-green));
  transition: width 0.2s ease-out;
}

.nav-links a:hover::after {
  width: 100%;
}

.nav-links a.active {
  font-weight: 600;
}

/* Homepage sidebar layout */
.home-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.2rem;
  align-items: start;
}

.home-main-content {
  min-width: 0;
}

/* History + varieties (Liberica/Robusta/Excelsa) — itinatago ang homepage hero; parang hiwalay na page */
body.beanthentic-about-only #home {
  display: none !important;
}

body.beanthentic-about-only #about-mission-vision {
  scroll-margin-top: 0.5rem;
}

body.beanthentic-about-only .about-topic[id] {
  scroll-margin-top: 0.75rem;
}

.home-sidebar {
  position: sticky;
  top: var(--beanthentic-fixed-topbar-h, 52px);
  width: auto;
  transform: none;
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(198, 157, 125, 0.45);
  border-radius: 14px;
  padding: 0.9rem;
  box-shadow: 0 10px 24px rgba(78, 45, 21, 0.12);
}

.home-sidebar.is-drawer-open {
  /* no-op on desktop: sidebar is always visible */
  transform: none;
}

.home-sidebar h2 {
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #5c3925;
  margin-bottom: 0.6rem;
}

.sidebar-links {
  display: grid;
  gap: 0.45rem;
}

.sidebar-links a {
  font-size: 0.9rem;
  color: #4d372b;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar-links a:hover {
  background: rgba(20, 117, 57, 0.1);
  color: #1f6d38;
}

.sidebar-links a.active {
  background: linear-gradient(135deg, rgba(11, 61, 46, 0.95), rgba(62, 166, 66, 0.95));
  color: #fdfaf6;
  font-weight: 600;
}

/* About expandable toggle arrow (homepage sidebar) */
.home-sidebar .sidebar-about-toggle {
  position: relative;
  padding-right: 2.2rem;
}

.home-sidebar .sidebar-about-toggle::after {
  content: "›";
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%) rotate(0deg);
  transition: transform 0.2s ease;
  font-size: 1.15rem;
  color: currentColor;
  pointer-events: none;
}

.home-sidebar .sidebar-about-toggle[aria-expanded="true"]::after {
  transform: translateY(-50%) rotate(90deg);
}

/* Slide down submenu (Home sidebar -> About) */
.home-sidebar .sidebar-submenu {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-6px);
  transition: max-height 0.25s ease, opacity 0.18s ease, transform 0.25s ease;
  pointer-events: none;
}

.home-sidebar .sidebar-submenu.is-open {
  max-height: 220px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Footer — same green family as navbar */
footer {
  margin-top: 3rem;
  padding: 1.5rem max(1.5rem, env(safe-area-inset-left)) max(2.5rem, calc(1.5rem + env(safe-area-inset-bottom))) max(1.5rem, env(safe-area-inset-right));
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.83rem;
  color: var(--navbar-fg);
  background: var(--navbar-bg);
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.footer-inner span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.footer-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #c08552;
}

/* -------------------------------------------------------------------------- */
/* App-style bottom navigation (use body.has-app-bottom-nav) */
/* -------------------------------------------------------------------------- */

/* Header burger — opens menu (Social, Privacy, account) */
.header-burger-btn {
  display: none !important;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: transparent;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  flex-shrink: 0;
  color: #ffffff;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none;
  transition: background 0.18s ease, transform 0.12s ease;
}

/* Sidebar drawer is temporarily disabled with burger hidden. */
.header-nav-drawer {
  display: none !important;
}

.header-burger-btn:hover {
  background: rgba(255, 255, 255, 0.10);
  box-shadow: none;
}

.header-burger-btn:active {
  background: rgba(255, 255, 255, 0.16);
  transform: scale(0.97);
}

.header-burger-btn:focus {
  outline: none;
}

.header-burger-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.92);
  outline-offset: 2px;
}

/* Menu open — keeps burger visually “selected” in brand brown */
body.header-drawer-open .header-burger-btn,
.header-burger-btn[aria-expanded="true"] {
  background: linear-gradient(155deg, #a8643c 0%, #7a4428 45%, #5c341f 100%);
  border-color: transparent;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 4px 12px rgba(60, 30, 14, 0.35);
  color: var(--navbar-fg);
}

body.header-drawer-open .header-burger-btn:hover,
.header-burger-btn[aria-expanded="true"]:hover {
  background: linear-gradient(155deg, #b26e45 0%, #844d2e 45%, #683a22 100%);
}

body.header-drawer-open .header-burger-btn:active,
.header-burger-btn[aria-expanded="true"]:active {
  background: linear-gradient(155deg, #8f5634 0%, #6b3d24 100%);
  transform: scale(0.97);
}

body.header-drawer-open .header-burger-btn:focus-visible,
.header-burger-btn[aria-expanded="true"]:focus-visible {
  outline-color: rgba(253, 250, 246, 0.95);
}

.header-burger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
}

body.header-drawer-open .header-burger-btn,
.header-burger-btn[aria-expanded="true"] {
  color: var(--navbar-fg);
}

.header-account-snippet {
  display: none !important;
  align-items: center;
  gap: 0.28rem;
  max-width: min(42vw, 9.5rem);
  padding: 0.12rem 0.42rem 0.12rem 0.3rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(253, 250, 246, 0.28);
  color: var(--navbar-fg);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.header-account-snippet:not([hidden]) {
  display: none !important;
}

.header-account-avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(253, 250, 246, 0.95);
  color: var(--beanthentic-green);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-account-avatar svg {
  width: 13px;
  height: 13px;
}

.header-account-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Slide-in drawer from the left */
.header-nav-drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.header-nav-drawer:not(.is-open) {
  visibility: hidden;
}

.header-nav-drawer.is-open {
  pointer-events: auto;
  visibility: visible;
}

.header-nav-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 18, 14, 0.45);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.header-nav-drawer.is-open .header-nav-drawer-backdrop {
  opacity: 1;
}

.header-nav-drawer-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(100vw - 3rem, 300px);
  max-width: 100%;
  background: #f0f2f0;
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.18);
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding: calc(0.75rem + env(safe-area-inset-top, 0px)) 0 1rem;
  border-right: 1px solid rgba(46, 111, 28, 0.12);
  /* Avoid body tap-highlight reading as brown / muddy on gray panel */
  -webkit-tap-highlight-color: transparent;
}

.header-nav-drawer.is-open .header-nav-drawer-panel {
  transform: translateX(0);
}

.header-nav-drawer-inner {
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.header-drawer-account {
  padding: 0.75rem 0.65rem 1rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid rgba(26, 31, 22, 0.1);
}

.header-drawer-account-label {
  margin: 0 0 0.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7268;
  font-weight: 700;
}

.header-drawer-account-name {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  font-weight: 700;
  color: #2a3228;
}

.header-drawer-account-email {
  margin: 0;
  font-size: 0.82rem;
  color: #5c6359;
  word-break: break-word;
}

.header-drawer-guest {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #4a5248;
}

.header-drawer-guest a {
  color: var(--beanthentic-green);
  font-weight: 700;
}

.header-drawer-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  margin-left: 0.15rem;
  margin-right: 0.15rem;
  border-radius: 14px;
  text-decoration: none;
  color: #5a6160;
  font-size: 0.95rem;
  font-weight: 600;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.header-drawer-link:hover {
  background: rgba(155, 99, 67, 0.12);
  color: #4a3224;
}

.header-drawer-link:hover .header-drawer-icon {
  color: #6d4a36;
}

/* Pinindot — solid terracotta + puting label/icon tulad ng reference */
.header-drawer-link:active {
  background: linear-gradient(180deg, #a86d4a 0%, #9b6343 38%, #865336 100%);
  color: #fff;
  font-weight: 700;
  border: none;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.12) inset,
    0 6px 16px rgba(60, 34, 18, 0.32);
  transform: scale(0.985);
}

.header-drawer-link:active .header-drawer-icon {
  color: #fff;
}

.header-drawer-link:focus {
  outline: none;
}

.header-drawer-link:focus-visible {
  outline: 2px solid rgba(155, 99, 67, 0.65);
  outline-offset: 2px;
}

/* Current route — same solid brown card look (selected) */
.header-drawer-link[aria-current="page"] {
  background: linear-gradient(180deg, #a86d4a 0%, #9b6343 35%, #80482f 100%);
  color: #fff;
  font-weight: 700;
  border: none;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.1) inset,
    0 5px 14px rgba(60, 34, 18, 0.28);
}

.header-drawer-link[aria-current="page"] .header-drawer-icon {
  color: #fff;
}

.header-drawer-link[aria-current="page"]:hover {
  background: linear-gradient(180deg, #b27854 0%, #a06a45 40%, #8d5438 100%);
  color: #fff;
}

.header-drawer-link[aria-current="page"]:hover .header-drawer-icon {
  color: #fff;
}

.header-drawer-link[aria-current="page"]:active {
  background: linear-gradient(180deg, #945e3f 0%, #7a4a33 100%);
  color: #fff;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.08) inset,
    0 4px 12px rgba(50, 28, 14, 0.34);
  transform: scale(0.985);
}

.header-drawer-link[aria-current="page"]:active .header-drawer-icon {
  color: #fff;
}

.header-drawer-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: #4d5452;
}

/* Settings dropdown caret (drawer) */
.header-drawer-link--settings {
  position: relative;
  padding-right: 2.6rem;
}

.header-drawer-link--settings::after {
  content: "›";
  position: absolute;
  right: 1.05rem;
  top: 50%;
  transform: translateY(-50%) rotate(0deg);
  transition: transform 0.18s ease, opacity 0.18s ease;
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0.7;
}

.header-drawer-link--settings[aria-expanded="true"]::after {
  transform: translateY(-50%) rotate(90deg);
  opacity: 0.9;
}

/* Drawer submenu (Settings dropdown) */
.header-drawer-submenu[hidden] {
  display: none !important;
}

.header-drawer-submenu {
  display: grid;
  gap: 0.6rem;
  margin: 0.35rem 0.15rem 0.45rem 0.15rem;
  padding: 0.15rem 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.header-drawer-submenu-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  text-decoration: none;
  color: #4a3224;
  font-size: 0.88rem;
  font-weight: 700;
  background: #ffffff;
  border: 1px solid rgba(155, 99, 67, 0.16);
  box-shadow: 0 6px 16px rgba(60, 34, 18, 0.06);
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.header-drawer-submenu-icon {
  width: 30px;
  height: 30px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(155, 99, 67, 0.18);
  color: #6d4a36;
  flex-shrink: 0;
}

.header-drawer-submenu-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.header-drawer-submenu-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-drawer-submenu-link:hover {
  background: rgba(255, 255, 255, 1);
  color: #3c281d;
  box-shadow: 0 10px 22px rgba(60, 34, 18, 0.09);
}

.header-drawer-submenu-link:active {
  transform: scale(0.99);
}

/* Selected submenu item (matches Image 2 brown highlight) */
.header-drawer-submenu-link[aria-current="page"] {
  background: linear-gradient(180deg, #a86d4a 0%, #9b6343 38%, #865336 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(60, 34, 18, 0.20);
}

.header-drawer-submenu-link[aria-current="page"] .header-drawer-submenu-icon {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.header-drawer-submenu-link[aria-current="page"] .header-drawer-submenu-icon svg {
  stroke: currentColor;
}

.header-drawer-signout {
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(160, 60, 50, 0.35);
  background: #fff;
  color: #a33c32;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.header-drawer-signout:hover {
  background: rgba(160, 60, 50, 0.06);
}

.header-drawer-signout:active {
  background: rgba(160, 60, 50, 0.1);
}

body.header-drawer-open {
  overflow: hidden;
}

.header-notifications-btn {
  display: inline-flex;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(253, 250, 246, 0.35);
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  color: var(--navbar-fg);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.18s ease, transform 0.12s ease;
}

.header-notifications-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.header-notifications-btn:active {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(0.96);
}

.header-notifications-btn:focus {
  outline: none;
}

.header-notifications-btn:focus-visible {
  outline: 2px solid rgba(253, 250, 246, 0.95);
  outline-offset: 2px;
}

.header-notifications-btn .header-notifications-icon {
  width: 20px;
  height: 20px;
}

/* Global navbar size bump for all pages except homepage */
body:not(.home-page) {
  --beanthentic-fixed-topbar-h: calc(env(safe-area-inset-top, 0px) + 5.5rem);
}

body:not(.home-page) .nav {
  padding: 0.65rem 1rem 0.65rem max(0.35rem, env(safe-area-inset-left, 0px));
}

body:not(.home-page) .logo-mark {
  width: 148px;
  height: 126px;
}

body:not(.home-page) .header-notifications-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

body:not(.home-page) .header-notifications-btn .header-notifications-icon {
  width: 22px;
  height: 22px;
}

/* Toast from header notifications (ui.js) */
.notification {
  position: fixed;
  left: 50%;
  bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(20px);
  max-width: min(22rem, calc(100vw - 2rem));
  padding: 0.75rem 1.1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--beanthentic-green);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 1200;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.notification-info {
  background: linear-gradient(135deg, var(--beanthentic-green), var(--beanthentic-green-dark));
}

body.has-app-bottom-nav {
  padding-bottom: calc(4.85rem + env(safe-area-inset-bottom, 0px));
}

.app-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  /* Above Leaflet map controls (~1000); below full-screen loaders */
  z-index: 1100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-top: 0.35rem;
  background: #ffffff;
  border-top: none;
  border-radius: 22px 22px 0 0;
  box-shadow:
    0 -10px 28px rgba(88, 60, 140, 0.12),
    0 -4px 14px rgba(22, 38, 28, 0.08);
}

.app-bottom-nav-inner {
  max-width: var(--bt-app-content-max, 1100px);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.125rem;
  padding: 0.2rem max(0.35rem, env(safe-area-inset-left)) 0.5rem max(0.35rem, env(safe-area-inset-right));
  position: relative;
}

/* About tab: opens in-page section menu (History / Mission & Vision / How to get there) */
.app-bottom-nav-about {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.app-bottom-nav-about-btn {
  width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}

.app-bottom-nav-about-menu {
  position: fixed;
  left: max(0.5rem, env(safe-area-inset-left));
  right: max(0.5rem, env(safe-area-inset-right));
  bottom: calc(3.75rem + env(safe-area-inset-bottom, 0px));
  z-index: 1150;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0.35rem 0;
  border-radius: 14px;
  background: rgba(253, 250, 246, 0.98);
  border: 1px solid rgba(46, 111, 28, 0.14);
  box-shadow: 0 -4px 18px rgba(22, 38, 28, 0.1), 0 8px 24px rgba(22, 38, 28, 0.1);
  max-height: min(50vh, 15rem);
  overflow: auto;
}

.app-bottom-nav-about-menu[hidden] {
  display: none !important;
}

.app-bottom-nav-about-item {
  display: block;
  padding: 0.65rem 1rem;
  font-size: 0.812rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 1.25;
  color: #3d4a38 !important;
  text-decoration: none !important;
  border: none;
  border-bottom: 1px solid rgba(46, 111, 28, 0.06);
  transition: background 0.15s ease;
}

.app-bottom-nav-about-item:last-child {
  border-bottom: none;
}

.app-bottom-nav-about-item:hover,
.app-bottom-nav-about-item:focus-visible {
  background: rgba(46, 111, 28, 0.08);
  outline: none;
}

.app-bottom-nav-about-group {
  display: flex;
  flex-direction: column;
}

.app-bottom-nav-about-history-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  margin: 0;
  cursor: pointer;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

.app-bottom-nav-about-history-btn:hover,
.app-bottom-nav-about-history-btn:focus-visible {
  background: rgba(46, 111, 28, 0.08);
  outline: none;
}

.app-bottom-nav-history-chevron {
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.55;
  flex-shrink: 0;
  margin-top: -0.15em;
}

.app-bottom-nav-about-history-btn[aria-expanded="true"] .app-bottom-nav-history-chevron {
  transform: rotate(-135deg);
  margin-top: 0.1em;
}

.app-bottom-nav-history-submenu {
  background: rgba(46, 111, 28, 0.035);
  border-bottom: 1px solid rgba(46, 111, 28, 0.06);
}

.app-bottom-nav-history-submenu[hidden] {
  display: none !important;
}

.app-bottom-nav-about-item--nested {
  padding-left: 1.35rem !important;
  font-size: 0.78rem;
  font-weight: 600;
}

@media (min-width: 901px) {
  .app-bottom-nav-about-menu {
    bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
  }
}

.app-bottom-nav-link {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.18rem;
  padding: 0.35rem 0.15rem 0.25rem;
  border-radius: 14px;
  text-decoration: none !important;
  color: #2a5530 !important;
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: none;
  line-height: 1.15;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    transform 0.12s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
  border: 1px solid transparent;
}

/* Outer tabs: keep tappable on narrow screens */
.app-bottom-nav-inner>a.app-bottom-nav-link {
  min-width: 2.85rem;
}

/* Sign in tab: stay tappable above Register Farm pill (all pages with app-bottom-nav) */
.app-bottom-nav a.app-bottom-nav-link--signin {
  position: relative;
  z-index: 15;
  pointer-events: auto;
}

.app-bottom-nav-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex-shrink: 0;
}

/* Same icon row height on every side tab so labels share one baseline */
.app-bottom-nav-link:not(.app-bottom-nav-link--featured) .app-bottom-nav-icon-wrap {
  height: 36px;
  min-height: 36px;
}

.app-bottom-nav-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  opacity: 0.88;
  transition: opacity 0.18s ease;
}

/* Record (QR): slightly smaller than previous oversized glyph */
#nav-qr .app-bottom-nav-icon {
  width: 26px;
  height: 26px;
}

#nav-signin .app-bottom-nav-icon--account {
  width: 28px;
  height: 28px;
}

.app-bottom-nav-label {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  margin: 0 auto;
  padding: 0 1px;
}

@media (hover: hover) and (pointer: fine) {
  .app-bottom-nav-link:hover:not(.app-bottom-nav-link--featured) {
    background: #e8f5e9;
    color: var(--beanthentic-green) !important;
    border-color: rgba(46, 111, 28, 0.2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
    border-radius: 16px;
    transform: translateY(-0.5px);
  }

  .app-bottom-nav-link:hover:not(.app-bottom-nav-link--featured) .app-bottom-nav-icon {
    opacity: 1;
    stroke-width: 2.25px;
  }
}

/* Current page — keep the same look as hover after navigation */
.app-bottom-nav-link[aria-current="page"]:not(.app-bottom-nav-link--featured) {
  background: #e8f5e9;
  color: var(--beanthentic-green) !important;
  border-color: rgba(46, 111, 28, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  border-radius: 16px;
  transform: translateY(-0.5px);
}

.app-bottom-nav-link[aria-current="page"]:not(.app-bottom-nav-link--featured) .app-bottom-nav-icon {
  opacity: 1;
  stroke-width: 2.25px;
}

.app-bottom-nav-link--featured[aria-current="page"] .app-bottom-nav-icon-wrap {
  filter: brightness(1.08);
  box-shadow:
    0 12px 26px rgba(99, 60, 180, 0.42),
    0 8px 18px rgba(20, 61, 34, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 0 0 3px rgba(46, 111, 28, 0.35);
}

.app-bottom-nav-link:active:not(.app-bottom-nav-link--featured),
.app-bottom-nav-link.is-bottom-nav-press:not(.app-bottom-nav-link--featured),
.app-bottom-nav-link:focus-visible:not(.app-bottom-nav-link--featured) {
  outline: none;
  transform: scale(0.98);
  color: var(--beanthentic-green) !important;
  background: #e8f5e9;
  border-color: rgba(46, 111, 28, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  border-radius: 16px;
}

.app-bottom-nav-link:active:not(.app-bottom-nav-link--featured) .app-bottom-nav-icon,
.app-bottom-nav-link.is-bottom-nav-press:not(.app-bottom-nav-link--featured) .app-bottom-nav-icon,
.app-bottom-nav-link:focus-visible:not(.app-bottom-nav-link--featured) .app-bottom-nav-icon {
  opacity: 1;
  stroke-width: 2.25px;
}

.app-bottom-nav-link--featured:focus-visible {
  background: transparent !important;
}

.app-bottom-nav-link--featured:active .app-bottom-nav-icon-wrap,
.app-bottom-nav-link--featured:focus-visible .app-bottom-nav-icon-wrap,
.app-bottom-nav-link--featured.is-bottom-nav-press .app-bottom-nav-icon-wrap {
  filter: brightness(1.05);
  box-shadow:
    0 11px 24px rgba(99, 60, 180, 0.34),
    0 7px 16px rgba(20, 61, 34, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

/* Center Register — elevated circular FAB (mint bar) */
.app-bottom-nav-link--featured {
  position: relative;
  z-index: 20;
  align-self: flex-end;
  flex: 0 0 auto;
  max-width: 4.2rem;
  min-width: 3.5rem;
  margin: 0;
  padding: 0 0.1rem 0.15rem !important;
  gap: 0.12rem;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #1a4d22 !important;
}

.app-bottom-nav-link--featured .app-bottom-nav-icon-wrap {
  width: 3.2rem;
  height: 3.2rem;
  margin-top: -1.05rem;
  border-radius: 50%;
  background: linear-gradient(165deg, #2a8a3e 0%, #1b5c2e 55%, #143d22 100%);
  box-shadow:
    0 12px 26px rgba(99, 60, 180, 0.38),
    0 8px 18px rgba(20, 61, 34, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

/* Register FAB: one icon at a time (stacked center; never side-by-side in flex) */
#nav-register .app-bottom-nav-icon-wrap {
  position: relative;
}

#nav-register .app-bottom-nav-register-svg {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

#nav-register .app-bottom-nav-register-svg--complete {
  display: none !important;
}

#nav-register.is-register-complete .app-bottom-nav-register-svg--pending {
  display: none !important;
}

#nav-register.is-register-complete .app-bottom-nav-register-svg--complete {
  display: block !important;
  stroke: #ffffff !important;
}

/* Registered: green featured button + white shield/check */
#nav-register.is-register-complete .app-bottom-nav-icon-wrap {
  background: linear-gradient(165deg, #2f9f3a 0%, #1c5216 100%) !important;
  box-shadow: 0 6px 16px rgba(20, 94, 30, 0.42);
}

#nav-register.is-register-complete .app-bottom-nav-register-svg--complete path {
  stroke: #ffffff !important;
}

.app-bottom-nav-link--featured .app-bottom-nav-icon {
  opacity: 1 !important;
  stroke: #ffffff !important;
  stroke-width: 2.25px;
}

/* Register: pending = filled white shield; complete = outline shield + check */
.app-bottom-nav-link--featured .app-bottom-nav-register-svg--pending {
  stroke: none !important;
  fill: #ffffff !important;
  color: #ffffff !important;
}

.app-bottom-nav-link--featured .app-bottom-nav-register-svg--pending path {
  fill: #ffffff !important;
}

.app-bottom-nav-link--featured .app-bottom-nav-register-svg--complete {
  fill: none !important;
}

.app-bottom-nav-link--featured .app-bottom-nav-register-svg--complete path {
  fill: none;
}

.app-bottom-nav-link--featured .app-bottom-nav-label {
  color: #1a4d22 !important;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: none;
  font-size: 0.58rem;
  text-align: center;
  width: 100%;
}

.app-bottom-nav-link--featured:hover {
  filter: none;
  background: transparent !important;
}

.app-bottom-nav-link--featured:hover .app-bottom-nav-icon-wrap {
  filter: brightness(1.06);
}

.app-bottom-nav-link--featured:active {
  transform: scale(0.97);
}

@media (min-width: 480px) {
  .app-bottom-nav-inner {
    gap: 0.35rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .app-bottom-nav-link {
    font-size: 0.68rem;
    padding: 0.5rem 0.35rem 0.4rem;
    border-radius: 16px;
  }

  .app-bottom-nav-link:not(.app-bottom-nav-link--featured) .app-bottom-nav-icon-wrap {
    height: 38px;
    min-height: 38px;
  }
}

@media (min-width: 901px) {
  body.has-app-bottom-nav {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
  }

  .app-bottom-nav-inner {
    max-width: 1100px;
    padding-top: 0.45rem;
    padding-bottom: 0.55rem;
  }

  .app-bottom-nav-link {
    font-size: 0.7rem;
    letter-spacing: 0.045em;
  }
}

/* -------------------------------------------------------------------------- */
/* App Opening Splash (shown on app start) */
/* -------------------------------------------------------------------------- */
#app-opening-screen {
  position: fixed;
  inset: 0;
  z-index: 200000;
  background: #eaf7e5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.85rem;
  opacity: 1;
  transition: opacity 280ms ease;
}

#app-opening-screen.is-fading {
  opacity: 0;
}

#app-opening-screen[hidden] {
  display: none !important;
}

#app-opening-logo {
  width: 124px;
  height: 124px;
  object-fit: contain;
  display: block;
}

#app-opening-title {
  color: var(--beanthentic-green);
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.95rem;
  text-align: center;
}