/* ===================================================
   kempfart Tarot — PWA App Enhancements
   Macht die Seite auf dem Handy zu einer echten App
   =================================================== */

/* ── App-Header (nur im standalone-Mode) ── */
.app-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 99;
  padding: max(env(safe-area-inset-top, 8px), 12px) 20px 10px;
  background: rgba(14,14,20,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  align-items: center;
  justify-content: space-between;
}
.app-header-title {
  font-family: 'Basteru', Georgia, serif;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #f0e040, #e0448a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.app-header-close {
  width: 36px; height: 36px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: rgba(240,236,228,0.7);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.app-header-close:hover,
.app-header-close:active {
  background: rgba(255,255,255,0.14);
}

/* ── Standalone: Standard-Nav ausblenden, App-Header anzeigen ── */
@media (display-mode: standalone) {
  nav { display: none !important; }
  .app-header { display: flex; }
  main {
    padding-top: calc(env(safe-area-inset-top, 0px) + 70px) !important;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 100px) !important;
  }
  .page-bg { opacity: 0.08; }
  
  /* Kein Pull-to-Refresh / Overscroll */
  html, body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
  }
  #spreadArea {
    overscroll-behavior: contain;
  }

  /* Text-Selektion deaktivieren (App-Gefühl) */
  body {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
  input, textarea { user-select: text; -webkit-user-select: text; }

  /* Splash-Screen ausblenden sobald die App läuft */
  .app-splash { display: none; }
}

/* ── Splash Screen (beim ersten Start, nur standalone) ── */
.app-splash {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0e0e14;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  opacity: 1;
  transition: opacity 0.5s ease;
}
.app-splash.fade-out {
  opacity: 0;
  pointer-events: none;
}
.app-splash-icon {
  width: 100px; height: 100px;
  border-radius: 22px;
  box-shadow: 0 8px 40px rgba(224,68,138,0.3);
}
.app-splash-title {
  font-family: 'Basteru', Georgia, serif;
  font-size: 1.6rem;
  color: #f0ece4;
  letter-spacing: 0.04em;
}
.app-splash-sub {
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(240,236,228,0.4);
}
.app-splash-dots {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.app-splash-dots span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(240,236,228,0.15);
  animation: splashDot 1.2s ease-in-out infinite;
}
.app-splash-dots span:nth-child(2) { animation-delay: 0.2s; }
.app-splash-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes splashDot {
  0%, 60%, 100% { background: rgba(240,236,228,0.15); transform: scale(1); }
  30% { background: #e0448a; transform: scale(1.3); }
}

@media (display-mode: standalone) {
  .app-splash { display: flex; }
}

/* ── Mobile: Karten vergrößern (App-Gefühl) ── */
@media (max-width: 640px) {
  :root {
    --card-w: 140px;
    --card-h: 238px;
  }
  #spreadArea {
    gap: 0.6rem;
    padding: 0 0.5rem;
  }
  #spreadArea.cross-layout {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.4rem;
  }
  #spreadArea.cross-layout .card { --card-w: 100%; --card-h: auto; }
  .card-slot-label { font-size: 0.58rem; }
}
@media (max-width: 420px) {
  :root {
    --card-w: 120px;
    --card-h: 204px;
  }
  #spreadArea.cross-layout {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.3rem;
  }
}

/* ── App-ähnliche Aktionen: Bottom Bar auf Mobile ── */
@media (max-width: 640px) {
  .spread-picker { gap: 0.4rem; }
  .spread-btn {
    padding: 0.45rem 0.9rem;
    font-size: 0.7rem;
  }
  .btn-mischen, .btn-alle {
    padding: 0.65rem 1.4rem;
    font-size: 0.75rem;
  }
  .info-box {
    font-size: 0.78rem;
    padding: 0.6rem 1rem;
  }
}

/* ── Touch-Targets: Immer mindestens 44px ── */
.spread-btn, .btn-mischen, .btn-alle,
#btnAiDeutung, #btnShare {
  min-height: 44px;
}

/* ── Native Share Sheet Styling ── */
#sharePanel {
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 1.2rem;
  margin-top: 1.2rem;
}
#sharePreviewImg {
  border-radius: 12px;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  background: #1b1630;
}
.share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}
.share-btn {
  flex: 1;
  min-width: 100px;
  min-height: 44px;
  border: 1.5px solid rgba(255,255,255,0.13);
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(240,236,228,0.8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.share-btn:active {
  background: rgba(255,255,255,0.1);
  transform: scale(0.96);
}

/* ── KI Loading Animation ── */
.ai-loading-dots span {
  width: 6px; height: 6px;
}

/* ── Smooth Scrolling ── */
html {
  scroll-behavior: smooth;
}

/* ── Modal verbessert für Mobile App ── */
.modal {
  overscroll-behavior: contain;
}
.modal-content {
  border-radius: 16px;
}
@media (max-width: 640px) {
  .modal-content {
    width: 92vw;
    max-width: 400px;
  }
}