/* ═══════════════════════════════════════════════════════════════
   DAS LINKE WESEN - MOBILE OPTIMIERUNG CSS
   5 beschriftete Buttons, 3 Dropdown-Menüs
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   ESSAY-POPUP OVERLAY (versteckt bis geöffnet)
   ═══════════════════════════════════════════════════════════════ */

/* Standard: Overlay versteckt */
.essay-popup-overlay:not(.open) {
  display: none !important;
}

.essay-popup-overlay.open {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .essay-popup-overlay.open {
    align-items: stretch;
    padding: 0;
  }
  .essay-popup {
    max-height: 100vh;
    height: 100vh;
    width: 100%;
    border-radius: 0;
    overflow-y: auto;
    padding: 1rem 1rem 80px;
  }
  .essay-popup-header {
    position: sticky;
    top: 0;
    background: var(--bg-primary, #121225);
    z-index: 3;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
  }
}

/* ═══════════════════════════════════════════════════════════════
   BOTTOM NAV BAR
   ═══════════════════════════════════════════════════════════════ */

#mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  #mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-secondary, #1a1a2e);
    border-top: 1px solid var(--border, #333);
    z-index: 9000;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-secondary, #888);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
  flex: 1;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-btn .nav-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.mobile-nav-btn .nav-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0.7;
}

.mobile-nav-btn.active {
  color: var(--accent, #C62828);
}

.mobile-nav-btn.active .nav-label {
  opacity: 1;
}

.mobile-nav-btn.menu-open {
  color: var(--accent, #C62828);
  background: var(--bg-tertiary, #252540);
}

.mobile-nav-btn:active {
  transform: scale(0.92);
}

/* ═══════════════════════════════════════════════════════════════
   MENÜ-OVERLAY & POPUP
   ═══════════════════════════════════════════════════════════════ */

#mobile-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 8999;
  transition: background 0.2s ease;
}

#mobile-menu-overlay.open {
  background: rgba(0, 0, 0, 0.5);
}

#mobile-menu-popup {
  position: fixed;
  bottom: 56px;
  left: 8px;
  right: 8px;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border, #444);
  border-radius: 16px;
  overflow: hidden;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.2s ease;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

#mobile-menu-popup.open {
  transform: translateY(0);
  opacity: 1;
}

/* Menü-Header */
.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border, #333);
}

.mobile-menu-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary, #eee);
  letter-spacing: 0.02em;
}

.mobile-menu-close {
  background: var(--bg-tertiary, #252540);
  border: 1px solid var(--border, #444);
  color: var(--text-secondary, #aaa);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  cursor: pointer;
}

.mobile-menu-body {
  padding: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   GRID-MENÜ (Ansichten)
   ═══════════════════════════════════════════════════════════════ */

.mobile-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.mobile-menu-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--bg-tertiary, #252540);
  border: 1px solid var(--border, #333);
  border-radius: 12px;
  color: var(--text-primary, #eee);
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-grid-item .grid-icon {
  font-size: 1.5rem;
}

.mobile-menu-grid-item .grid-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.mobile-menu-grid-item:active {
  background: var(--accent, #C62828);
  transform: scale(0.95);
}

/* ═══════════════════════════════════════════════════════════════
   LIST-MENÜ (Archiv, Social)
   ═══════════════════════════════════════════════════════════════ */

.mobile-menu-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  background: none;
  border: none;
  border-radius: 10px;
  color: var(--text-primary, #eee);
  cursor: pointer;
  transition: background 0.15s ease;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-list-item:active {
  background: var(--bg-tertiary, #252540);
}

.mobile-menu-list-item .list-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.mobile-menu-list-item .list-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.mobile-menu-list-item .list-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.mobile-menu-list-item .list-desc {
  font-size: 0.7rem;
  color: var(--text-secondary, #888);
}

.mobile-menu-list-item .list-extern {
  color: var(--text-secondary, #888);
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   ESSAY-POPUP STYLES
   ═══════════════════════════════════════════════════════════════ */

.essay-popup {
  background: var(--bg-primary, #121225);
  border: 1px solid var(--border, #333);
  border-radius: 16px;
  max-width: 700px;
  width: 95%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
  position: relative;
  top: 0;
  z-index: 2;
}

.essay-popup-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border, #333);
  position: sticky;
  top: 0;
  z-index: 2;
}

.essay-popup-icon {
  font-size: 1.8rem;
}

.essay-popup-title {
  font-size: 1.3rem;
  font-weight: 700;
  flex: 1;
  font-family: 'Space Grotesk', sans-serif;
}

.essay-popup-close {
  background: var(--bg-tertiary, #252540) !important;
  border: 1px solid var(--border, #444) !important;
  color: var(--text-primary, #fff) !important;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
}

.essay-popup-close:hover,
.essay-popup-close:active {
  background: var(--accent, #C62828) !important;
}

.essay-popup-summary {
  color: var(--text-secondary, #aaa);
}

@media (max-width: 768px) {
  .essay-popup-summary {
    display: none !important;
  }
}

.essay-popup-body {
  color: var(--text-primary, #eee);
  line-height: 1.7;
  font-size: 0.95rem;
}

.essay-popup-body p {
  margin-bottom: 0.8rem;
}

.essay-popup-nav {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #333);
}

.essay-popup-nav button {
  flex: 1;
  padding: 0.6rem;
  background: var(--bg-tertiary, #252540);
  border: 1px solid var(--border, #444);
  color: var(--text-primary, #eee);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
}

.essay-popup-nav button:last-child {
  text-align: right;
  align-items: flex-end;
}

.essay-popup-nav button:active {
  background: var(--accent, #C62828);
}

.essay-popup-nav button .nav-dir {
  font-size: 0.65rem;
  color: var(--text-secondary, #888);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════════════
   ESSAY TEXT FORMATTING
   ═══════════════════════════════════════════════════════════════ */

.essay-lead {
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.8;
  color: var(--text-primary, #eee);
  border-left: 3px solid var(--accent, #C62828);
  padding-left: 1rem;
  margin-bottom: 1.2rem;
}

.essay-trenner {
  width: 30px;
  height: 1px;
  background: var(--border, #444);
  margin: 1rem 0;
}

.essay-satz-lead {
  color: var(--accent, #C62828);
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE: Content-Bereich Spacing (Platz für Bottom-Nav)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Gesamten Viewport verkleinern damit Nav-Leiste nicht überdeckt */
  body {
    height: calc(100vh - 70px);
    height: calc(100dvh - 70px); /* dvh = dynamic viewport height */
  }
  
  /* Spacer-Element am Ende des scrollbaren Bereichs */
  main::after {
    content: '';
    display: block;
    height: 70px;
    flex-shrink: 0;
  }
  
  /* Detail-Panel über der Nav */
  .detail-panel {
    bottom: 60px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   MONUMENTAL THEME - Menü-Overrides
   ═══════════════════════════════════════════════════════════════ */

body.theme-monumental #mobile-bottom-nav {
  background: #f5f5f0;
  border-top-color: #ccc;
}

body.theme-monumental .mobile-nav-btn {
  color: #666;
}

body.theme-monumental .mobile-nav-btn.active {
  color: #C62828;
}

body.theme-monumental #mobile-menu-popup {
  background: #fff;
  border-color: #ddd;
}

body.theme-monumental .mobile-menu-header {
  border-bottom-color: #ddd;
}

body.theme-monumental .mobile-menu-title {
  color: #111;
}

body.theme-monumental .mobile-menu-grid-item {
  background: #f5f5f0;
  border-color: #ddd;
  color: #111;
}

body.theme-monumental .mobile-menu-list-item {
  color: #111;
}

body.theme-monumental .mobile-menu-list-item .list-desc {
  color: #666;
}

/* ═══════════════════════════════════════════════════════════════
   MONUMENTAL THEME - Haus-Ausnahme
   Haus-Ansicht hat dunkle Hintergründe, Text muss hell bleiben
   ═══════════════════════════════════════════════════════════════ */

body.theme-monumental #ansicht-wg,
body.theme-monumental #ansicht-wg *,
body.theme-monumental .haus-container,
body.theme-monumental .haus-container *,
body.theme-monumental .haus-gebaeude,
body.theme-monumental .haus-gebaeude *,
body.theme-monumental .haus-etage,
body.theme-monumental .haus-etage *,
body.theme-monumental .zimmer-card,
body.theme-monumental .zimmer-card *,
body.theme-monumental .zimmer-header,
body.theme-monumental .zimmer-header *,
body.theme-monumental .zimmer-inhalt,
body.theme-monumental .zimmer-inhalt *,
body.theme-monumental .etage,
body.theme-monumental .etage *,
body.theme-monumental .etage-header,
body.theme-monumental .etage-header *,
body.theme-monumental .fluegel-bewohner,
body.theme-monumental .fluegel-bewohner *,
body.theme-monumental .fluegel-beiname,
body.theme-monumental .bewohner-card,
body.theme-monumental .bewohner-card * {
  color: #eee !important;
}

/* Bewohner-Modal: dunkler Text (Modal lebt im body, nicht im Haus) */
body.theme-monumental .bewohner-modal .modal-box { background: #fff !important; border-color: #d0d0d0 !important; }
body.theme-monumental .bewohner-modal .modal-title { color: #111 !important; }
body.theme-monumental .bewohner-modal .modal-header { border-bottom-color: #ddd !important; }
body.theme-monumental .bewohner-fluegel-block,
body.theme-monumental .bfl-name,
body.theme-monumental .bfl-count { color: #444 !important; }
body.theme-monumental .bewohner-fluegel-card { background: rgba(0,0,0,0.04) !important; border-color: rgba(0,0,0,0.12) !important; }
body.theme-monumental .bfc-name { color: #111 !important; }
body.theme-monumental .bfc-pos { color: #666 !important; }

/* Haus-Hintergründe im Monumental-Theme dunkel belassen */
body.theme-monumental #ansicht-wg {
  background: #1a1a2e !important;
}
body.theme-monumental .zimmer-card {
  background: rgba(30, 30, 50, 0.9) !important;
  border-color: #444 !important;
}
