/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE LINSEN-DRAWER
   Eine geteilte Komponente fuer alle Wesen-Sub-Sites.
   Aktiv nur bis 700 px Breite — Desktop bleibt unberuehrt.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Standard: alles versteckt. Wird via @media unten eingeblendet. */
#ml-toggle,
#ml-drawer,
#ml-overlay {
  display: none;
}

/* Sichtbarkeits-Schalter: nur Mobile */
@media (max-width: 700px) {
  #ml-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0.6rem;
    left: 0.65rem;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #1a1a1a;
    border: 1px solid rgba(0, 0, 0, 0.12);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
    z-index: 9500;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
    padding: 0;
  }
  #ml-toggle:active {
    transform: scale(0.94);
  }

  /* Auf dunklen Themes Knopf invertieren */
  body.theme-myzel #ml-toggle,
  body.theme-barrikade #ml-toggle,
  body.theme-terminal #ml-toggle,
  body.theme-kosmos #ml-toggle,
  body.theme-ruine #ml-toggle {
    background: rgba(20, 20, 30, 0.92);
    color: #f0f0f0;
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
  }

  /* Overlay-Hintergrund */
  #ml-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 9400;
    pointer-events: none;
    transition: background 0.22s ease;
  }
  #ml-overlay.open {
    background: rgba(0, 0, 0, 0.45);
    pointer-events: auto;
  }

  /* Drawer */
  #ml-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 280px);
    background: var(--bg-secondary, #1a1a2e);
    color: var(--text-primary, #f0f0f0);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    z-index: 9450;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    font-family: 'Space Grotesk', system-ui, sans-serif;
  }
  #ml-drawer.open {
    transform: translateX(0);
  }

  /* Drawer-Kopf */
  .ml-kopf {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 0.9rem 0.7rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .ml-kopf-titel {
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
  }
  .ml-kopf-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: transparent;
    color: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }
  .ml-kopf-close:active {
    background: rgba(255, 255, 255, 0.08);
  }

  /* Linsen-Liste */
  .ml-liste {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0.45rem 1rem;
  }

  /* Einzelne Linse */
  .ml-linse {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.65rem 0.7rem;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }
  .ml-linse:active {
    background: rgba(255, 255, 255, 0.08);
  }
  .ml-linse .ml-icon {
    font-size: 1.15rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
  }
  .ml-linse .ml-label {
    flex: 1;
    letter-spacing: 0.02em;
  }
  .ml-linse .ml-beta {
    font-size: 0.55rem;
    color: var(--accent, #C62828);
    background: rgba(198, 40, 40, 0.15);
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }
  .ml-linse .ml-extern {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
  }

  /* Sub-Linsen (in aufgeklappter Gruppe) */
  .ml-linse.ml-sub {
    padding-left: 2rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
  }

  /* Trenner */
  .ml-trenner {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0.5rem 0.7rem;
  }

  /* Gruppen-Header (ARCHIV / ANSICHT) */
  .ml-gruppe-header {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.65rem 0.7rem;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
  }
  .ml-gruppe-header:active {
    background: rgba(255, 255, 255, 0.08);
  }
  .ml-gruppe-header .ml-pfeil {
    margin-left: auto;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    transition: transform 0.18s ease;
  }
  .ml-gruppe.offen .ml-gruppe-header .ml-pfeil {
    transform: rotate(90deg);
  }

  .ml-gruppe-inhalt {
    display: none;
  }
  .ml-gruppe.offen .ml-gruppe-inhalt {
    display: block;
  }

  /* Helles Theme (monumental, grundlagen-page) — Drawer in heller Variante */
  body.theme-monumental #ml-drawer,
  body:not([class*="theme-"]) #ml-drawer {
    background: #ffffff;
    color: #1a1715;
    border-right-color: #e0dccb;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  }
  body.theme-monumental .ml-kopf,
  body:not([class*="theme-"]) .ml-kopf {
    border-bottom-color: #ebe6dc;
  }
  body.theme-monumental .ml-kopf-titel,
  body:not([class*="theme-"]) .ml-kopf-titel {
    color: rgba(0, 0, 0, 0.45);
  }
  body.theme-monumental .ml-kopf-close,
  body:not([class*="theme-"]) .ml-kopf-close {
    border-color: rgba(0, 0, 0, 0.15);
  }
  body.theme-monumental .ml-linse:active,
  body.theme-monumental .ml-gruppe-header:active,
  body:not([class*="theme-"]) .ml-linse:active,
  body:not([class*="theme-"]) .ml-gruppe-header:active {
    background: rgba(0, 0, 0, 0.05);
  }
  body.theme-monumental .ml-trenner,
  body:not([class*="theme-"]) .ml-trenner {
    background: rgba(0, 0, 0, 0.08);
  }
  body.theme-monumental .ml-linse.ml-sub,
  body:not([class*="theme-"]) .ml-linse.ml-sub {
    color: rgba(0, 0, 0, 0.7);
  }
  body.theme-monumental .ml-extern,
  body:not([class*="theme-"]) .ml-extern,
  body.theme-monumental .ml-gruppe-header .ml-pfeil,
  body:not([class*="theme-"]) .ml-gruppe-header .ml-pfeil {
    color: rgba(0, 0, 0, 0.4);
  }
}

/* Sehr kleine Screens: schmal halten */
@media (max-width: 360px) {
  #ml-drawer {
    width: 88vw;
  }
}
