/*
 * Mobile-Burger + Off-Canvas-Drawer.
 * 1:1 aus brainfood-startseite.html portiert; Variablen aus main.css.
 */

/* Hamburger / X — kein Hintergrund, 3 spans morphen zum X.
 * Animation greift via aria-expanded="true" am Button. */
.mobile-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: transparent;
  color: var(--bf-gray-dark);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 0;
  padding: 0;
  position: relative;
  z-index: 210; /* über dem Drawer, damit der Toggle als Close-Button auch im offenen Menü greift */
  transition: color 0.18s var(--ease);
}
.mobile-toggle:hover { color: var(--bf-green-dark-1); }
.mobile-toggle:focus-visible {
  outline: 2px solid var(--bf-turquoise);
  outline-offset: 2px;
}

.mobile-toggle__bars {
  position: relative;
  width: 22px;
  height: 16px;
  display: inline-block;
}
.mobile-toggle__bars > span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.28s var(--ease), top 0.18s var(--ease) 0.10s, opacity 0.18s var(--ease);
}
.mobile-toggle__bars > span:nth-child(1) { top: 0; }
.mobile-toggle__bars > span:nth-child(2) { top: 7px; }
.mobile-toggle__bars > span:nth-child(3) { top: 14px; }

/* Aktiver State: morph zu X. Top-Bar wandert in die Mitte und rotiert,
 * Mittel-Bar verschwindet, Bottom-Bar wandert in die Mitte und rotiert. */
.mobile-toggle[aria-expanded="true"] .mobile-toggle__bars > span {
  transition: top 0.18s var(--ease), transform 0.28s var(--ease) 0.10s, opacity 0.18s var(--ease);
}
.mobile-toggle[aria-expanded="true"] .mobile-toggle__bars > span:nth-child(1) {
  top: 7px;
  transform: rotate(45deg);
}
.mobile-toggle[aria-expanded="true"] .mobile-toggle__bars > span:nth-child(2) {
  opacity: 0;
}
.mobile-toggle[aria-expanded="true"] .mobile-toggle__bars > span:nth-child(3) {
  top: 7px;
  transform: rotate(-45deg);
}

/* Mobile-Menü öffnet sich UNTER dem Sticky-Header (überdeckt ihn nicht).
 * Header bleibt sichtbar, Hamburger morpht zu X.
 * Header-Höhe: 80px Default, 64px ab 768px (siehe critical-css). */
.mobile-menu {
  position: fixed;
  top: 80px;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 90; /* unter site-header (100), über content */
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0.3s;
}
.mobile-menu.open {
  visibility: visible;
  pointer-events: auto;
}
@media (max-width: 768px) {
  .mobile-menu { top: 64px; }
}

.mobile-menu__overlay {
  /* Halbtransparentes Overlay UNTER dem Drawer (closes on click). */
  position: absolute;
  inset: 0;
  background: rgba(38, 50, 55, 0);
  cursor: pointer;
  transition: background 0.3s var(--ease);
}
.mobile-menu.open .mobile-menu__overlay {
  background: rgba(38, 50, 55, 0.35);
}

.mobile-menu__drawer {
  /* Drawer wächst von oben (vom Header weg) per max-height + scaleY-Origin. */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  max-height: 0;
  background: var(--bf-white);
  display: flex;
  flex-direction: column;
  padding: 0 28px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(38, 50, 55, 0.12);
  transition: max-height 0.42s var(--ease), padding 0.32s var(--ease);
}
.mobile-menu.open .mobile-menu__drawer {
  max-height: calc(100vh - 80px);
  padding: 16px 28px 28px;
  overflow-y: auto;
}
@media (max-width: 768px) {
  .mobile-menu.open .mobile-menu__drawer { max-height: calc(100vh - 64px); }
}

/* Drawer-Head (Logo + separater Close-Button) — nicht mehr nötig, Site-Header
 * bleibt sichtbar mit dem morphenden Hamburger als Close-Toggle. */
.mobile-menu__head { display: none; }

.mobile-menu__close {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: transparent;
  color: var(--bf-gray-60);
  display: grid;
  place-items: center;
  transition: color 0.18s;
  cursor: pointer;
  border: 0;
  padding: 0;
}
.mobile-menu__close:hover {
  background: transparent;
  color: var(--bf-gray-dark);
}
.mobile-menu__close:focus-visible {
  outline: 2px solid var(--bf-turquoise);
  outline-offset: 2px;
}

.mobile-menu__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-grow: 1;
}
.mobile-menu__nav a {
  padding: 15px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 17px;
  color: var(--bf-gray-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
  text-decoration: none;
  /* Slide-in von oben + fade-in beim Öffnen — Stagger via nth-child. */
  opacity: 0;
  transform: translateY(-12px);
}
.mobile-menu.open .mobile-menu__nav a {
  animation: bfMenuItemIn 0.42s var(--ease) forwards;
}
.mobile-menu.open .mobile-menu__nav a:nth-child(1) { animation-delay: 0.08s; }
.mobile-menu.open .mobile-menu__nav a:nth-child(2) { animation-delay: 0.14s; }
.mobile-menu.open .mobile-menu__nav a:nth-child(3) { animation-delay: 0.20s; }
.mobile-menu.open .mobile-menu__nav a:nth-child(4) { animation-delay: 0.26s; }
.mobile-menu.open .mobile-menu__nav a:nth-child(5) { animation-delay: 0.32s; }
.mobile-menu.open .mobile-menu__nav a:nth-child(6) { animation-delay: 0.38s; }
.mobile-menu.open .mobile-menu__nav a:nth-child(n+7) { animation-delay: 0.44s; }

@keyframes bfMenuItemIn {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mobile-menu__nav a:hover {
  background: var(--bf-turquoise-20);
  color: var(--bf-green-dark-1);
}
.mobile-menu__nav a:focus-visible {
  outline: 2px solid var(--bf-turquoise);
  outline-offset: 2px;
}

.mobile-menu__nav-arrow {
  color: var(--bf-gray-40);
  transition: transform 0.18s var(--ease);
  flex-shrink: 0;
}
.mobile-menu__nav a:hover .mobile-menu__nav-arrow {
  transform: translateX(4px);
  color: var(--bf-turquoise-dark);
}

.mobile-menu__sub {
  padding-top: 16px;
  margin-top: 12px;
  border-top: 1px solid var(--bf-gray-20);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mobile-menu__sub a {
  padding: 11px 18px;
  font-size: 14.5px;
  color: var(--bf-gray-60);
  border-radius: var(--radius-md);
  transition: background 0.18s, color 0.18s;
  text-decoration: none;
}
.mobile-menu__sub a:hover {
  background: var(--bf-beige-light);
  color: var(--bf-gray-dark);
}

.mobile-menu__bottom {
  padding-top: 22px;
  margin-top: 22px;
  border-top: 1px solid var(--bf-gray-20);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mobile-menu__login {
  text-align: center;
  padding: 12px;
  font-size: 14.5px;
  color: var(--bf-gray-60);
  border-radius: var(--radius-md);
  transition: background 0.18s;
  text-decoration: none;
}
.mobile-menu__login:hover {
  background: var(--bf-beige-light);
  color: var(--bf-gray-dark);
}

body.menu-open {
  overflow: hidden;
}

/* Burger sichtbar bis 1140 px — synchron zu nav.css. */
@media (max-width: 1140px) {
  .mobile-toggle { display: grid; }
}
