/* nav-dropdown.css — UnterhaltsPlan
 * Shared header navigation with Produkte and Ratgeber dropdowns.
 * Pure CSS, no JS. Checkbox-hack for native click-toggle on mobile,
 * :hover / :focus-within for desktop accessibility.
 *
 * Color tokens come from each page's existing :root vars
 * (--ink, --muted, --accent, --accent-mid, --accent-light, --border, --card).
 */

.main-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.main-nav > a,
.main-nav .nav-summary {
  color: var(--muted, #555);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}

.main-nav > a:hover,
.main-nav .nav-summary:hover {
  color: var(--ink, #1a1a1a);
}

.main-nav > a.active,
.main-nav .nav-dropdown.active .nav-summary {
  color: var(--accent-mid, #2a4015);
  font-weight: 600;
}

/* --- Dropdown container --- */
.nav-dropdown {
  position: relative;
}

/* Hidden checkbox drives click-toggle state without JS */
.nav-dropdown .nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
  margin: -1px;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.nav-dropdown .nav-summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  user-select: none;
}

.nav-dropdown .nav-summary::after {
  content: "▾";
  font-size: 10px;
  opacity: 0.6;
  margin-left: 2px;
  transition: transform 0.15s;
}

.nav-dropdown .nav-toggle:checked ~ .nav-summary::after {
  transform: rotate(180deg);
}

/* --- Panel --- */
.dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: -8px;
  min-width: 280px;
  max-width: 340px;
  background: var(--card, #fff);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(20, 30, 20, 0.12);
  padding: 8px;
  display: none;
  z-index: 200;
}

.nav-dropdown .nav-toggle:checked ~ .dropdown-panel {
  display: block;
}

/* Desktop: hover and focus-within open the panel without click */
@media (min-width: 901px) {
  .nav-dropdown:hover .dropdown-panel,
  .nav-dropdown:focus-within .dropdown-panel {
    display: block;
  }

  /* Bridge the 8px gap between trigger bottom and panel top so the
     cursor stays within a hovered descendant while crossing the gap. */
  .dropdown-panel::before {
    content: '';
    display: block;
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 8px;
  }
}

/* --- Items --- */
.dropdown-item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink, #1a1a1a);
  transition: background 0.12s;
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
  background: var(--accent-light, #e8f0df);
  outline: none;
}

.dropdown-title {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink, #1a1a1a);
  line-height: 1.3;
}

.dropdown-desc {
  display: block;
  font-size: 12.5px;
  color: var(--muted, #555);
  margin-top: 3px;
  line-height: 1.4;
}

.dropdown-badge {
  display: inline-block;
  background: oklch(0.94 0.04 80);
  color: oklch(0.42 0.08 60);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 6px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  vertical-align: middle;
  line-height: 1.5;
}

/* --- Compact desktop (1024-1100px): tighten gap, shorten CTA --- */
@media (max-width: 1100px) and (min-width: 901px) {
  .main-nav {
    gap: 18px;
  }
  .btn-header.btn-header--nav {
    padding: 9px 16px;
    font-size: 13.5px;
  }
  .btn-header.btn-header--nav .btn-header-full {
    display: none;
  }
}

@media (min-width: 1101px) {
  .btn-header.btn-header--nav .btn-header-short {
    display: none;
  }
}

/* Mobile (<=900px): show full CTA label */
@media (max-width: 900px) {
  .btn-header.btn-header--nav .btn-header-short {
    display: none;
  }
}

/* --- Mobile (<=900px): stack nav, dropdowns as accordions --- */
@media (max-width: 900px) {
  .header-inner {
    flex-wrap: wrap;
    row-gap: 12px;
    padding-top: 12px;
    padding-bottom: 12px;
    height: auto !important;
  }

  .main-nav {
    order: 3;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    border-top: 1px solid var(--border, rgba(0, 0, 0, 0.08));
    padding-top: 8px;
    margin-top: 4px;
  }

  .main-nav > a,
  .main-nav .nav-summary {
    padding: 12px 4px;
    font-size: 15px;
    border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.06));
  }

  .main-nav > a:last-child {
    border-bottom: none;
  }

  .nav-dropdown {
    border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.06));
  }

  .nav-dropdown:last-child {
    border-bottom: none;
  }

  .nav-dropdown .nav-summary {
    border-bottom: none !important;
    justify-content: space-between;
    display: flex;
  }

  .dropdown-panel {
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    min-width: 0;
    max-width: none;
    padding: 4px 0 10px 12px;
    background: transparent;
  }

  .dropdown-item {
    padding: 8px 10px;
  }

  .dropdown-title {
    font-size: 14.5px;
  }
}

/* =====================================================================
   CANONICAL MOBILE NAVIGATION (progressive enhancement) — js/nav-mobile.js
   builds one complete, identical drawer from a config and appends it to
   <body>; it never moves the page's own header markup. On mobile the existing
   desktop nav + CTA are only hidden; desktop (>=901px) is left completely
   untouched. Without JS the stacked-nav fallback above still applies.
   ===================================================================== */

/* default (all widths): enhancement chrome hidden until mobile + nav-js */
.navm-burger,
.navm-drawer,
.navm-backdrop { display: none; }

@media (max-width: 900px) {
  /* hide the existing desktop nav + CTA inside the header (any header shape);
     the logo stays and the hamburger is added next to it. !important beats
     per-page inline rules such as `body .main-nav { display:none }`. */
  html.nav-js header .header-inner nav,
  html.nav-js header .header-inner .btn-header { display: none !important; }

  /* hamburger */
  html.nav-js .navm-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    height: 44px;
    margin-left: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink, #1a1a1a);
    border-radius: 8px;
    cursor: pointer;
  }
  .navm-burger-bars { display: block; position: relative; width: 22px; height: 16px; }
  .navm-burger-bars span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
  }
  .navm-burger-bars span:nth-child(1) { top: 0; }
  .navm-burger-bars span:nth-child(2) { top: 7px; }
  .navm-burger-bars span:nth-child(3) { top: 14px; }
  .navm-burger:focus-visible { outline: 2px solid var(--accent-mid, #2a4015); outline-offset: 2px; }

  /* backdrop */
  html.nav-js .navm-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 20, 0.46);
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
    z-index: 999;
  }
  html.nav-open .navm-backdrop { opacity: 1; pointer-events: auto; }

  /* drawer */
  html.nav-js .navm-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(86vw, 360px);
    max-width: 100%;
    background: var(--card, #fff);
    border-left: 1px solid var(--border, rgba(0, 0, 0, 0.08));
    box-shadow: -18px 0 48px rgba(20, 30, 20, 0.20);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .28s ease, visibility 0s linear .28s;
    z-index: 1000;
  }
  html.nav-open .navm-drawer {
    transform: translateX(0);
    visibility: visible;
    transition: transform .28s ease;
  }

  /* drawer head: brand + close */
  .navm-head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  }
  .navm-brand { font-size: 19px; font-weight: 700; color: var(--ink, #1a1a1a); text-decoration: none; letter-spacing: -0.2px; }
  .navm-brand span { color: var(--accent-mid, #2a4015); }
  .navm-close {
    flex: none;
    width: 44px;
    height: 44px;
    margin-right: -8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--ink, #1a1a1a);
    border-radius: 8px;
    cursor: pointer;
  }
  .navm-close svg { width: 22px; height: 22px; }

  /* calm, single focus-visible ring (no dominant ring on touch-open) */
  .navm-close:focus-visible,
  .navm-acc-btn:focus-visible,
  .navm-link:focus-visible,
  .navm-sub:focus-visible,
  .navm-cta:focus-visible {
    outline: 2px solid var(--accent-mid, #2a4015);
    outline-offset: -2px;
    border-radius: 8px;
  }

  /* scrollable nav region — force block layout so per-page `nav { display:flex }`
     inline rules can't turn the drawer items into a centered row */
  .navm-nav {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px 0;
    gap: 0;
  }
  html.nav-js .navm-drawer .navm-acc { display: block; }

  .navm-link,
  .navm-acc-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 15.5px;
    font-weight: 500;
    color: var(--ink, #1a1a1a);
    text-decoration: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
  }
  .navm-acc-btn svg { flex: none; width: 18px; height: 18px; color: var(--muted, #555); transition: transform .18s ease; }
  .navm-acc-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
  .navm-link[aria-current="page"],
  .navm-sub[aria-current="page"] { color: var(--accent-mid, #2a4015); font-weight: 700; }

  .navm-acc-panel { padding: 0 0 6px; }
  .navm-sub {
    display: block;
    min-height: 44px;
    padding: 11px 16px 11px 30px;
    font-size: 14.5px;
    color: var(--muted, #555);
    text-decoration: none;
  }
  .navm-link:hover,
  .navm-sub:hover,
  .navm-acc-btn:hover { background: var(--accent-light, #e8f0df); }

  /* CTA pinned at the foot of the drawer */
  .navm-cta {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 12px 16px calc(16px + env(safe-area-inset-bottom));
    min-height: 50px;
    padding: 14px 18px;
    background: var(--accent, #2d4a16);
    color: #fff;
    text-decoration: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
  }
  .navm-cta:hover { background: #152A09; }

  html.nav-open { overflow: hidden; }
}
