/* ============================================================
   LATIN EMPIRE X — PWA / Mobile App Styles
   app.css — Loaded alongside styles.css for mobile experience
   ============================================================ */

:root {
  --gold-main: #d4af37;
  --gold-light: #f9d976;
  --gold-dark: #aa7700;
  --bg-dark: #050402;
  --bg-nav: rgba(10, 8, 5, 0.97);
  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================================
   APP PAGE TRANSITIONS
   ============================================================ */
@keyframes appPageIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

body.pwa-standalone main,
body.pwa-standalone .dashboard-container,
body.pwa-standalone .login-container {
  animation: appPageIn 0.32s ease forwards;
}

/* ============================================================
   GLOBAL TOUCH / SCROLL IMPROVEMENTS
   ============================================================ */
html {
  scroll-behavior: smooth;
}

/* Eliminate 300ms tap delay on all interactive elements */
a, button, input, select, textarea, label,
[role="button"], [onclick] {
  touch-action: manipulation;
}

/* Remove flash highlight on tap for a native-app feel */
a, button, .btn, .nav-item, .mobile-nav-item,
.app-nav-item, .portal-box, .story-item,
.tier-card, .coin-package, .feed-post,
.inbox-item, .notif-item, .creator-spotlight-card {
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   TOUCH TARGET ENHANCEMENTS — min 48px tap targets
   ============================================================ */
@media (max-width: 768px) {
  .btn,
  .nav-item,
  .action-btn,
  .portal-box,
  .story-item,
  .mobile-nav-item,
  .app-nav-item,
  input[type="submit"],
  input[type="button"],
  button {
    min-height: 48px;
  }

  /* Input fields - comfortable touch size */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    min-height: 48px;
    font-size: 16px; /* prevent iOS zoom on focus */
  }
}

/* ============================================================
   BOTTOM NAVIGATION BAR — .app-bottom-nav
   Hidden on desktop, shown on mobile
   ============================================================ */
.app-bottom-nav {
  display: none; /* hidden by default (desktop) */
}

@media (max-width: 768px) {
  /* Hide the OLD mobile-nav when app-bottom-nav is present */
  .mobile-nav {
    display: none !important;
  }

  .app-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-nav);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(212, 175, 55, 0.25);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.7);
    justify-content: space-around;
    align-items: center;
    z-index: 4000;
    /* hardware-accelerate the fixed bar */
    will-change: transform;
    transform: translateZ(0);
  }

  /* Ensure content doesn't hide behind bottom nav */
  body {
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom)) !important;
  }

  /* ---- Individual nav items ---- */
  .app-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #666;
    text-decoration: none;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    min-width: 48px;
    min-height: 48px;
    padding: 6px 8px;
    border-radius: 10px;
    transition: color 0.25s ease, background 0.25s ease;
    position: relative;
  }

  .app-nav-item i {
    font-size: 1.35rem;
    line-height: 1;
    transition: transform 0.2s ease;
  }

  .app-nav-item:active i {
    transform: scale(0.88);
  }

  .app-nav-item.active {
    color: var(--gold-main);
  }

  .app-nav-item.active i {
    filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.55));
  }

  .app-nav-item:hover {
    color: var(--gold-light);
    background: rgba(212, 175, 55, 0.07);
  }

  /* ---- LIVE button — special gold ring + pulsing red dot ---- */
  .app-nav-live {
    position: relative;
  }

  .app-nav-live i {
    color: #ff3b3b;
    filter: drop-shadow(0 0 5px rgba(255, 59, 59, 0.5));
  }

  .app-nav-live.active i,
  .app-nav-live:hover i {
    color: #ff3b3b;
  }

  /* Pulsing red dot above the Live icon */
  .app-nav-live::before {
    content: '';
    position: absolute;
    top: 4px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: #ff3b3b;
    border-radius: 50%;
    border: 1.5px solid var(--bg-dark);
    animation: livePulse 1.4s ease-in-out infinite;
    z-index: 1;
  }

  @keyframes livePulse {
    0%   { transform: scale(1);   box-shadow: 0 0 0 0 rgba(255, 59, 59, 0.7); }
    50%  { transform: scale(1.2); box-shadow: 0 0 0 5px rgba(255, 59, 59, 0); }
    100% { transform: scale(1);   box-shadow: 0 0 0 0 rgba(255, 59, 59, 0); }
  }

  /* ---- Active gold underline indicator ---- */
  .app-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: var(--gold-main);
    border-radius: 2px 2px 0 0;
    box-shadow: 0 0 6px rgba(212, 175, 55, 0.6);
  }

  /* ---- Desktop nav hidden on mobile ---- */
  .navbar .nav-links {
    /* handled by existing styles.css, kept here for clarity */
  }

  /* ---- AI widget — shift up above bottom nav ---- */
  .ai-widget-btn {
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px) !important;
  }

  .ai-chat-window {
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px) !important;
  }

  /* ---- Age gate fill entire screen properly ---- */
  .age-gate-overlay {
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
  }

  /* ---- Dashboard mobile bottom padding ---- */
  .dashboard-container {
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px) !important;
  }

  /* ---- Footer hidden (already handled in existing CSS) ---- */
  .site-footer {
    display: none !important;
  }

  /* ---- Navbar compact on mobile ---- */
  .navbar {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    height: 50px !important;
    padding: 0 15px !important;
    background: #000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    z-index: 3500;
  }
}

/* ============================================================
   PWA STANDALONE — when running as installed app
   ============================================================ */
@media (display-mode: standalone) {
  /* Status bar safe area at top */
  .navbar {
    padding-top: env(safe-area-inset-top, 0px) !important;
    height: calc(50px + env(safe-area-inset-top, 0px)) !important;
  }

  main,
  .login-container,
  .dashboard-container {
    padding-top: calc(50px + env(safe-area-inset-top, 0px)) !important;
  }

  /* Sharper tap highlight */
  * {
    -webkit-tap-highlight-color: rgba(212, 175, 55, 0.15);
  }

  /* Prevent overscroll bounce (iOS) */
  body {
    overscroll-behavior: none;
  }
}

/* ============================================================
   SMOOTH PAGE FADE — for app-like transitions (JS adds class)
   ============================================================ */
body.page-transitioning {
  pointer-events: none;
}

/* Bottom nav must stay clickable even during transitions */
body.page-transitioning .app-bottom-nav,
.app-bottom-nav,
body.page-transitioning .ai-widget-btn,
body.page-transitioning .ai-chat-window,
body.page-transitioning #aiWidgetBtn,
body.page-transitioning #aiChatWindow,
.ai-widget-btn,
.ai-chat-window {
  pointer-events: auto !important;
}

.app-bottom-nav .app-nav-item {
  pointer-events: auto !important;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(212, 175, 55, 0.25);
}

body.page-transitioning main,
body.page-transitioning .dashboard-container,
body.page-transitioning .login-container {
  animation: appPageFade 0.22s ease forwards;
}

@keyframes appPageFade {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ============================================================
   SPLASH SCREEN — shown on PWA launch
   ============================================================ */
.lex-splash-screen {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: #0a0805;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  animation: splashFadeOut 0.5s ease 2.2s forwards;
}

.lex-splash-logo {
  font-family: 'Cinzel', serif;
  font-size: 3.5rem;
  font-weight: 700;
  color: #d4af37;
  letter-spacing: 5px;
  animation: splashLogoIn 0.6s ease 0.2s both;
}

.lex-splash-sub {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.75rem;
  color: rgba(212, 175, 55, 0.6);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-top: 8px;
  animation: splashLogoIn 0.6s ease 0.5s both;
}

.lex-splash-loader {
  margin-top: 50px;
  width: 120px;
  height: 2px;
  background: rgba(212, 175, 55, 0.15);
  border-radius: 2px;
  overflow: hidden;
  animation: splashLogoIn 0.6s ease 0.8s both;
}

.lex-splash-loader-bar {
  height: 100%;
  background: #d4af37;
  border-radius: 2px;
  animation: splashLoad 1.8s ease 0.9s both;
}

@keyframes splashLogoIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes splashLoad {
  from { width: 0%; }
  to   { width: 100%; }
}

@keyframes splashFadeOut {
  from { opacity: 1; pointer-events: all; }
  to   { opacity: 0; pointer-events: none; visibility: hidden; }
}

/* ============================================================
   NOTIFICATION BELL BADGE
   ============================================================ */
.notif-bell-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.notif-bell-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #d4af37;
  color: #000;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  font-weight: 800;
  font-family: 'Montserrat', sans-serif;
  line-height: 1;
  border: 1.5px solid #0a0805;
}

/* ============================================================
   NOTIFICATION PROMPT TOAST
   ============================================================ */
.notification-prompt {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 8, 5, 0.97);
  border: 1px solid #d4af37;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.78rem;
  color: #fff;
  z-index: 9000;
  max-width: 90vw;
  white-space: nowrap;
  animation: slideUpToast 0.3s ease;
}

@keyframes slideUpToast {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.notification-prompt-icon { font-size: 1.3rem; }
.notification-prompt-text { display: flex; flex-direction: column; gap: 2px; }
.notification-prompt-text strong { font-size: 0.82rem; }
.notification-prompt-text span { font-size: 0.72rem; color: #999; }
.notification-prompt-actions { display: flex; gap: 8px; margin-left: auto; }
.notif-allow-btn {
  background: #d4af37; color: #000; border: none;
  border-radius: 6px; padding: 6px 14px;
  font-weight: 700; font-size: 0.72rem; cursor: pointer;
  font-family: 'Montserrat', sans-serif;
}
.notif-dismiss-btn {
  background: none; border: none; color: #666;
  font-size: 1.1rem; cursor: pointer; padding: 2px 4px;
}

/* ============================================================
   MOBILE OVERFLOW GUARD — prevent horizontal scroll
   ============================================================ */
@media (max-width: 768px) {
  body, html {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* Tables get horizontal scroll instead of breaking layout */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* Modals go full-screen on very small phones */
  .coins-modal,
  .private-show-modal {
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    margin: 0 !important;
  }

  .coins-modal-overlay,
  .private-show-modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
}

@media (max-width: 480px) {
  /* Bottom nav — ensure it stays at 60px min */
  .app-bottom-nav {
    min-height: 60px;
  }

  /* Notification tabs — allow horizontal scroll if needed */
  .notif-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    gap: 2px;
  }

  .notif-tabs::-webkit-scrollbar { display: none; }

  .ntab {
    flex-shrink: 0;
    padding: 7px 10px;
    font-size: 0.7rem;
  }
}
