/**
 * NextLife Mobile Optimization - NEU ÜBERARBEITET
 * Kompatibel mit site.css (basierend auf Dropdown-Mobile-Menü aus site.css)
 * KEINE Überschreibungen mehr, nur Ergänzungen!
 *
 * Breakpoints:
 * - 480px: Extra-Small Phones (iPhone SE etc.)
 * - 700px: Small Phones (Haupt-Breakpoint für Mobile, s. site.css)
 * - 900px: Phones / kleine Tablets
 * - 1024px: Tablets / groß
 */

/* ═══════════════════════════════════════════════════════════
   SAFE AREAS für notched Devices (iPhone X, 11+ etc.)
   ═══════════════════════════════════════════════════════════ */

:root {
  --safe-top:    max(0px, env(safe-area-inset-top));
  --safe-right:  max(0px, env(safe-area-inset-right));
  --safe-bottom: max(0px, env(safe-area-inset-bottom));
  --safe-left:   max(0px, env(safe-area-inset-left));
}

/* ═══════════════════════════════════════════════════════════
   BODY / BASE auf Mobile
   ═══════════════════════════════════════════════════════════ */

body {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Bilder skalieren korrekt auf Mobile */
img {
  max-width: 100%;
  height: auto;
}

/* Verhindert horizontales Scrollen auf Mobile */
html, body {
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════════════════════
   THEME TOGGLE & LAYOUT SELECTOR — Mobile Optimierung
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 1200px) {
  /* Layout Selector: auf kleineren Screens komprimieren */
  .nav-layout-selector {
    gap: 0.15rem;
    padding: 0.2rem;
  }
  .nav-layout-btn {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
}

@media (max-width: 900px) {
  /* Theme Toggle & Layout Selector: Buttons kleiner auf Phones */
  .nav-theme-toggle {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .nav-layout-selector {
    gap: 0.1rem;
    padding: 0.2rem;
    border-radius: 6px;
  }
  .nav-layout-btn {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
    border-radius: 4px;
  }
  .nav-layout-btn:hover {
    background: rgba(139,43,226,.15);
  }

  /* Verhindert, dass CTAs zu eng beieinander sitzen */
  .nav-right-group {
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 700px) {
  /* Extra-small phones: noch komprimierter */
  .nav-theme-toggle {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }
  .nav-layout-selector {
    gap: 0.05rem;
    padding: 0.15rem;
  }
  .nav-layout-btn {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }

  /* Text-Label auf sehr kleinen Screens verstecken, nur Icon zeigen */
  .nav-cta {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
  }
}

@media (max-width: 480px) {
  /* Ultra-small phones (iPhone SE etc.) */
  .nav-theme-toggle {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }
  .nav-layout-btn {
    width: 26px;
    height: 26px;
    font-size: 0.65rem;
  }
  .nav-layout-selector {
    gap: 0;
    padding: 0.1rem;
  }
}

/* ═══════════════════════════════════════════════════════════
   900px — Phones / kleine Tablets
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 900px) {

  /* ===== HERO / PAGE HERO ===== */
  .hero {
    min-height: calc(100vh - 40px);
  }
  .hero .section-title {
    font-size: clamp(1.8rem, 8vw, 2.8rem) !important;
  }
  .page-hero {
    min-height: 280px;
    padding: calc(var(--nav-h) + 2.5rem) 0 3rem;
  }
  .page-hero .section-title {
    letter-spacing: 2.5px !important;
  }
  .section-sub {
    font-size: 0.95rem;
  }

  /* ===== CARDS ===== */
  .card {
    padding: 1.25rem;
  }

  /* ===== BUTTONS: volle Breite auf schmalen Screens ===== */
  .btn-gold,
  .btn-outline,
  .discord-btn {
    width: 100%;
    justify-content: center;
  }

  /* ===== FORMS ===== */
  .form-grid {
    grid-template-columns: 1fr;
  }

  /* ===== NEXTLIFE FOOTER (nlf-grid) ===== */
  .nlf-main {
    padding-top: 40px !important;
  }
  .nlf-grid {
    gap: 2rem 1.5rem !important;
    padding: 0 1.25rem !important;
  }
  .nlf-brand {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
  }
  .nlf-col {
    grid-column: span 2 !important;
  }
  .nlf-bottom {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
    padding: 1rem 1.25rem 7.5rem !important;
  }
  .nlf-legal {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .nlf-emblem-row {
    padding: 1rem 0;
  }

}

/* ═══════════════════════════════════════════════════════════
   700px — HAUPT-MOBILE BREAKPOINT (s. site.css: Nav wird ausgeblendet, Burger sichtbar)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 700px) {

  /* ===== Safe-Area auf Navigation anwenden ===== */
  nav.site-nav {
    padding-top: var(--safe-top) !important;
    padding-left: max(1rem, var(--safe-left)) !important;
    padding-right: max(1rem, var(--safe-right)) !important;
    gap: 0.6rem !important;
  }
  :root {
    --nav-h: calc(72px + var(--safe-top));
  }

  /* ===== Burger Button (von site.css bereits sichtbar, jetzt vergrößert) ===== */
  .nav-burger {
    width: 44px !important;
    height: 44px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem !important;
    padding: 0 !important;
    border: 1px solid rgba(255,255,255,.15) !important;
  }

  /* ===== Mobile Menu (Dropdown von site.css) optimieren ===== */
  .nav-mobile {
    padding: 1rem max(1rem, var(--safe-left)) calc(1.5rem + var(--safe-bottom)) !important;
    max-height: calc(100vh - var(--nav-h));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-mobile > a {
    min-height: 52px;       /* Apple-Richtlinie: 44px + Puffer */
    font-size: 0.9rem !important;
    padding: 0.9rem 1rem !important;
    display: flex !important;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,.05);
    border-radius: 8px !important;
    margin-bottom: 0.15rem;
  }
  .nav-mobile-sub {
    padding-left: 0.5rem !important;
  }
  .nav-mobile-sub a {
    min-height: 46px;
    padding: 0.7rem 1rem !important;
    display: flex;
    align-items: center;
    font-size: 0.82rem !important;
  }
  .nav-mobile-divider {
    display: block !important;
    margin: 0.75rem 0.25rem !important;
  }

  /* ===== Container enger ===== */
  .container {
    padding-left:  max(1rem, var(--safe-left)) !important;
    padding-right: max(1rem, var(--safe-right)) !important;
  }
  section {
    padding: 4rem 0 !important;
  }

  /* ===== Buttons / Inputs: Touch freundlich ===== */
  button,
  input[type="button"],
  input[type="submit"],
  input[type="reset"],
  select,
  .btn-gold,
  .btn-outline,
  .nav-login,
  .faq-q,
  .cw-btn,
  .discord-btn,
  [role="button"] {
    min-height: 48px !important;
    min-width: 48px !important;
    font-size: 1rem !important;
  }
  /* Formularfelder: Verhindert iOS Zoom bei <16px */
  .field input,
  .field textarea,
  .field select,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  textarea,
  select {
    font-size: 16px !important;
    min-height: 48px;
    padding: 0.75rem 1rem !important;
  }
  textarea {
    min-height: 140px !important;
  }

  /* ===== Social Buttons größer im Footer ===== */
  .nlf-social-btn {
    width: 46px !important;
    height: 46px !important;
    font-size: 1rem !important;
  }
  .nlf-social-row {
    gap: 0.7rem !important;
  }

  /* ===== FAQ ===== */
  .faq-q {
    padding: 1rem 1.1rem !important;
    font-size: 1rem !important;
  }
  .faq-a-inner {
    padding: 0 1.1rem 1.1rem !important;
  }

  /* ===== Badges auf Mobile ===== */
  .badge {
    padding: 0.3rem 0.8rem;
    font-size: 0.65rem;
  }

  /* ===== Tabellen: Horizontal scrollbar ===== */
  .table-wrap {
    margin-left:  calc(-1 * var(--safe-left));
    margin-right: calc(-1 * var(--safe-right));
    border-radius: 0;
  }

  /* ===== Legal Pages ===== */
  .legal-title {
    font-size: 1.4rem !important;
    gap: 0.75rem !important;
  }
  .legal-title::before,
  .legal-title::after {
    display: none;
  }
  .legal-content {
    font-size: 0.98rem !important;
  }

  /* ===== Copy Widget ===== */
  .copy-widget {
    width: 100%;
    flex-wrap: wrap;
    padding: 0.6rem 0.85rem !important;
  }
  .cw-value {
    flex: 1 1 100%;
    word-break: break-all;
    white-space: normal;
    margin-bottom: 0.35rem;
  }

}

/* ═══════════════════════════════════════════════════════════
   480px — EXTRA KLEINE PHONES (iPhone SE 3. Gen, alte Geräte)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 480px) {

  .nav-logo img {
    max-width: 110px !important;
    height: 28px !important;
  }
  .topbar-duty {
    display: none !important;
  }

  .section-label {
    font-size: 0.6rem !important;
    letter-spacing: 2.5px;
    gap: 0.5rem;
  }
  .section-label::before {
    width: 16px;
  }

  .hero .section-title {
    font-size: 2rem !important;
    letter-spacing: 2px !important;
  }
  .page-hero .section-title {
    font-size: 1.6rem !important;
    letter-spacing: 2px !important;
  }
  .section-sub {
    font-size: 0.9rem !important;
  }

  .btn-gold,
  .btn-outline {
    padding: 0.8rem 1.3rem !important;
    font-size: 0.95rem !important;
    letter-spacing: 1.5px !important;
  }

  .card {
    padding: 1rem !important;
    border-radius: 12px !important;
  }

  .nlf-logo {
    height: 60px !important;
    margin-bottom: 0.75rem !important;
  }
  .nlf-logo-text {
    font-size: 1.3rem !important;
  }
  .nlf-desc {
    font-size: 0.8rem !important;
    margin-bottom: 1rem !important;
  }
  .nlf-col-title {
    font-size: 0.58rem !important;
    letter-spacing: 2px !important;
    margin-bottom: 0.85rem !important;
  }
  .nlf-link {
    font-size: 0.82rem !important;
  }
  .nlf-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 1.75rem 1.25rem !important;
  }
  .nlf-social-btn {
    width: 44px !important;
    height: 44px !important;
  }
  .nlf-copy,
  .nlf-slogan {
    font-size: 0.68rem !important;
    text-align: left !important;
  }
  .nlf-legal a {
    font-size: 0.7rem !important;
  }

  .badge {
    font-size: 0.58rem !important;
    padding: 0.25rem 0.7rem;
  }

  .changelog-item {
    padding: 1rem 1.1rem !important;
  }
  .changelog-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem !important;
    font-size: 0.68rem !important;
  }
  .changelog-note {
    font-size: 1rem !important;
  }

  /* Cookie Banner: Maximal groß aber nicht zu viel */
  #nlCookieBanner {
    left: 0.6rem !important;
    right: 0.6rem !important;
    bottom: 0.6rem !important;
    width: calc(100% - 1.2rem) !important;
    padding: 1rem !important;
    font-size: 0.85rem !important;
  }

}

/* ═══════════════════════════════════════════════════════════
   COOKIE BANNER — RESPONSIVE (alle Mobile Breakpoints)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 700px) {
  #nlCookieBanner {
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 1.6rem) !important;
    max-width: 100% !important;
    bottom: calc(0.6rem + var(--safe-bottom)) !important;
  }
  #nlCookieBanner[style*="bottom-right"] {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
  }
  #nlCookieBanner > div:first-child {
    min-width: 160px !important;
    flex: 1 1 100%;
  }
  #nlCookieBanner button {
    flex: 1 1 auto;
    min-height: 44px;
    padding: 0.5rem 0.9rem !important;
    font-size: 0.8rem !important;
    justify-content: center;
    display: inline-flex;
    align-items: center;
  }
  #nlCkOverlay {
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }
}

/* ═══════════════════════════════════════════════════════════
   HOVER auf Touch-Geräten deaktivieren (Touch hat kein hover)
   ═══════════════════════════════════════════════════════════ */

@media (hover: none) {
  .nav-links li a:hover,
  .nav-submenu a:hover,
  .card:hover,
  .btn-gold:hover,
  .btn-outline:hover,
  .discord-btn:hover,
  .nlf-link:hover,
  .nlf-social-btn:hover,
  .changelog-item:hover {
    transform: none !important;
    box-shadow: none !important;
  }
  /* Aktiven Feedback per :active statt hover */
  .nav-mobile > a:active,
  .nav-mobile-sub a:active,
  button:active,
  .btn-gold:active,
  .btn-outline:active,
  .faq-q:active,
  .nlf-social-btn:active,
  .nlf-link:active {
    background: rgba(139, 43, 226, 0.15) !important;
    transform: scale(0.98);
  }
}

/* ═══════════════════════════════════════════════════════════
   LANDSCAPE MODE auf kleinen Phones (wenig Höhe)
   ═══════════════════════════════════════════════════════════ */

@media (max-height: 520px) and (orientation: landscape) {
  .hero {
    min-height: 560px;
    padding: calc(var(--nav-h) + 2rem) 0 3rem;
  }
  .nav-mobile > a {
    min-height: 42px !important;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }
  .page-hero {
    min-height: 220px;
    padding-top: calc(var(--nav-h) + 1.5rem) !important;
    padding-bottom: 2rem !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   ACCESSIBILITY / BARRIEREFREIHEIT
   ═══════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  .nav-burger {
    border: 2px solid currentColor !important;
  }
}
