/* ==========================================================================
   CALIGO - Mobile Experience Stylesheet (Smartphones & Tablets <= 768px)
   STRICT RULE: Only active in @media (max-width: 768px)
   Guarantees 100% Desktop preservation while delivering flawless mobile layout.
   ========================================================================== */

/* Hidden on Desktop */
.btn-mobile-burger,
.btn-mobile-lang,
.mobile-drawer,
.mobile-drawer-backdrop,
.mobile-bottom-nav {
  display: none !important;
}

@media (max-width: 768px) {
  /* 1. ZERO-HORIZONTAL-OVERFLOW LOCK */
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
    position: relative;
    box-sizing: border-box;
  }

  *, *::before, *::after {
    box-sizing: border-box !important;
  }

  .wrap, .section, main {
    max-width: 100% !important;
    overflow-x: hidden !important;
    padding-left: clamp(12px, 3.5vw, 18px) !important;
    padding-right: clamp(12px, 3.5vw, 18px) !important;
  }

  /* Padding at bottom for Mobile Bottom Navigation */
  body {
    padding-bottom: 74px !important;
  }

  /* 2. HEADER & TOPBAR ON MOBILE */
  .topbar {
    padding: 0 12px !important;
    height: 56px !important;
    width: 100% !important;
    max-width: 100vw !important;
    justify-content: space-between !important;
    white-space: normal !important;
  }

  /* Hide Desktop buttons on mobile */
  .topbar-right .btn-settings,
  .topbar-right a.btn,
  .topbar-right #topbarThurumBtn,
  .topnav {
    display: none !important;
  }

  .topbar-right {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: auto !important;
    flex-shrink: 0 !important;
  }

  /* Mobile Language Toggle Button in Header */
  .btn-mobile-lang {
    background: rgba(212, 175, 55, 0.15) !important;
    border: 1px solid var(--gold) !important;
    color: var(--gold2, #ffd700) !important;
    font-size: 0.8rem !important;
    font-weight: 800 !important;
    padding: 5px 9px !important;
    border-radius: 6px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    cursor: pointer !important;
    min-height: 38px !important;
  }

  /* Mobile Hamburger Toggle Button */
  .btn-mobile-burger {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(212, 175, 55, 0.4) !important;
    color: #fff !important;
    width: 42px !important;
    height: 42px !important;
    border-radius: 8px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 5px !important;
    cursor: pointer !important;
    padding: 0 !important;
    transition: all 0.2s ease !important;
  }

  .btn-mobile-burger span {
    display: block;
    width: 20px;
    height: 2px;
    background: #ffd700;
    border-radius: 2px;
    transition: all 0.25s ease;
  }

  .btn-mobile-burger.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .btn-mobile-burger.active span:nth-child(2) {
    opacity: 0;
  }
  .btn-mobile-burger.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* 3. MOBILE SLIDE-IN DRAWER */
  .mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: block !important;
  }

  .mobile-drawer-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(84vw, 340px);
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(180deg, #101626 0%, #080c16 100%);
    border-left: 2px solid var(--gold);
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.9);
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex !important;
    flex-direction: column;
    padding: 1.2rem 1rem;
    overflow-y: auto;
  }

  .mobile-drawer.active {
    transform: translateX(0);
  }

  .mobile-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.25);
    margin-bottom: 1rem;
  }

  .mobile-drawer-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--gold2, #ffd700);
    letter-spacing: 2px;
    text-transform: uppercase;
  }

  .mobile-drawer-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    cursor: pointer;
  }

  .mobile-drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }

  .mobile-drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s;
    min-height: 48px;
  }

  .mobile-drawer-link:active, .mobile-drawer-link:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--gold);
    color: #fff;
  }

  .mobile-drawer-link.btn-gold-drawer {
    background: linear-gradient(135deg, #d4af37, #b8860b);
    color: #0b0f19;
    font-weight: 800;
    border-color: #ffd700;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.35);
  }

  /* 4. MOBILE BOTTOM NAVIGATION BAR */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(10, 14, 24, 0.96);
    backdrop-filter: blur(16px);
    border-top: 1.5px solid rgba(212, 175, 55, 0.4);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.7);
    z-index: 950;
    display: flex !important;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mb-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 5px 6px;
    border-radius: 8px;
    flex: 1;
    min-height: 48px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
  }

  .mb-item.active, .mb-item:active {
    color: var(--gold2, #ffd700);
  }

  .mb-item-icon {
    font-size: 1.25rem;
    line-height: 1;
  }

  /* 5. HERO FIXES (No Overflow, Centered Impact) */
  .hero {
    overflow: hidden !important;
    max-width: 100vw !important;
    padding-top: calc(var(--top) + 0.8rem) !important;
  }

  .hero .hc.hc5 {
    display: none !important;
  }

  .hero-cards-left {
    display: none !important;
  }

  .hero .cta-row {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.75rem !important;
  }

  .hero .cta-row .btn {
    width: 100% !important;
    justify-content: center !important;
    min-height: 48px !important;
    font-size: 1rem !important;
  }

  /* 6. CARD FILTERS HORIZONTAL SWIPE CAROUSEL */
  .filters {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
    width: 100% !important;
    gap: 8px !important;
    padding: 6px 12px 14px 12px !important;
    justify-content: flex-start !important;
    scrollbar-width: none !important;
  }

  .filters::-webkit-scrollbar {
    display: none !important;
  }

  .filters button {
    flex: 0 0 auto !important;
    min-height: 44px !important;
    padding: 0.5rem 0.9rem !important;
    font-size: 0.85rem !important;
  }

  /* 7. FACTION RANK CHAIN (Wrap cleanly in 2x2 grid) */
  .rank-chain {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .rank-chain em {
    display: none !important;
  }

  .fac {
    padding: 0.75rem 0.6rem !important;
    min-height: 64px !important;
    border-radius: 10px !important;
  }

  /* 8. CARD STUDIO RESPONSIVENESS */
  .studio-wrap,
  .studio-top-bar,
  .studio-deck-action-row,
  .deck-actions-right,
  .stage-toolbar,
  .stage-format-row {
    max-width: 100% !important;
    flex-wrap: wrap !important;
    overflow-x: hidden !important;
  }

  .deck-actions-right {
    width: 100% !important;
    justify-content: stretch !important;
    gap: 6px !important;
  }

  .deck-actions-right .btn {
    flex: 1 1 45% !important;
    min-height: 44px !important;
  }

  .studio-card-viewport {
    max-width: 100% !important;
    padding: 8px !important;
    overflow-x: hidden !important;
  }

  /* 9. CAMPFIRE FIX */
  .campfire-section {
    max-width: 100vw !important;
    overflow: hidden !important;
  }

  /* 10. ACCORDION ENHANCEMENTS FOR MOBILE */
  .mobile-accordion-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 48px;
    margin-bottom: 8px;
  }

  .mobile-accordion-toggle span.arrow {
    transition: transform 0.25s ease;
    color: var(--gold);
  }

  .mobile-accordion-toggle.open span.arrow {
    transform: rotate(180deg);
  }
}

/* Sehr schmale Handys (320 px): Kopfleiste kompakter, damit der runde Knopf rechts nicht abgeschnitten wird */
@media (max-width: 350px) {
  .topbar { padding-inline: 8px !important; }
  .brand { letter-spacing: .12em !important; font-size: .82rem !important; gap: .3rem !important; }
  .brand svg, .brand-symbol { width: 26px !important; height: 26px !important; }
  .topbar-right { gap: .2rem !important; }
}
