/* Custom Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}

body {
    overflow-x: hidden;
}

/* Navigation Links */
.nav-link {
    transition: color 0.3s;
    color: rgba(0, 0, 0, 0.5);
}

.nav-link:hover {
    color: rgba(0, 0, 0, 1);
}

.nav-link.active {
    color: rgba(0, 0, 0, 1);
}

.mobile-nav-link {
    color: rgba(0, 0, 0, 0.5);
    transition: color 0.3s;
}

.mobile-nav-link:hover {
    color: rgba(0, 0, 0, 1);
}

/* Form Inputs */
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #000;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Toast Animation */
@keyframes slideDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 0);
        opacity: 1;
    }
    to {
        transform: translate(-50%, -100%);
        opacity: 0;
    }
}

#toast.show {
    display: block;
    animation: slideDown 0.3s ease-out;
}

#toast.hide {
    animation: slideUp 0.3s ease-out;
}

/* Mobile Menu Slide Animation */
#mobile-menu {
    position: fixed;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100vh;
    background: white;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    transition: left 0.3s ease-in-out;
    z-index: 1000;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

#mobile-menu.show {
    left: 0;
}

#mobile-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

#mobile-menu-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Bottom Navigation (Mobile) */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px env(safe-area-inset-right) calc(8px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 60;
}

/* Hide bottom nav when side menu is open */
body.menu-open #bottom-nav {
    transform: translateY(100%);
    pointer-events: none;
}

/* Body padding to avoid bottom nav overlap on mobile */
@media (max-width: 767px) {
    body {
        padding-bottom: calc(64px + env(safe-area-inset-bottom));
    }
    
    /* Hide desktop navigation on mobile */
    header nav.hidden.md\\:flex {
        display: none !important;
    }
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 56px;
    color: rgba(0, 0, 0, 0.6);
    background: transparent;
    border-radius: 10px;
    transition: background 0.2s, color 0.2s;
}

.bottom-nav-item .icon {
    width: 22px;
    height: 22px;
    stroke-width: 1.8;
}

.bottom-nav-item.active,
.bottom-nav-item:hover {
    color: rgba(0, 0, 0, 1);
    background: rgba(0, 0, 0, 0.05);
}

/* Desktop Navigation - Always visible on desktop */
#desktop-nav {
    display: none;
}

@media (min-width: 768px) {
    #bottom-nav { display: none; }
    
    /* Ensure desktop navigation is visible */
    #desktop-nav {
        display: flex !important;
        align-items: center;
        gap: 2rem;
    }
    
    /* Show CTA button on desktop */
    #desktop-cta {
        display: block !important;
    }
}

/* Loading Screen Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes logoGlow {
    0%, 100% {
        text-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    }
    50% {
        text-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    }
}

@keyframes spinnerPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

#loading-screen {
    animation: fadeIn 0.5s ease-out;
}

#loading-screen.fade-out {
    animation: fadeOut 0.5s ease-in forwards;
}

#loading-screen .animate-spin {
    animation: spin 1s linear infinite;
}

/* Backdrop Blur Support */
@supports ((-webkit-backdrop-filter: blur(12px)) or (backdrop-filter: blur(12px))) {
    header {
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
    }
}

/* basic layout */
.stories-section { padding: 24px; background: #000000; font-family: Vazirmatn, sans-serif; }
.container { max-width: 1200px; margin: 0 auto; }
.header h3 { margin: 0 0 12px 0; color: #0f172a; font-weight: 800; }

/* wrapper and arrows */
.story-wrapper { position: relative; display: flex; align-items: center; gap: 8px; }
.stories-prev,
.stories-next {
  background: #ffffff; color: #000000; border: 0; width: 36px; height: 36px; border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12); cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease;
}
.stories-prev:hover,
.stories-next:hover {
  background: #ffffff; transform: scale(1.05);
}

/* story list */
.story-list { 
  display: flex; 
  gap: 16px; 
  overflow-x: auto; 
  padding: 6px 4px; 
  scroll-snap-type: x mandatory; 
  -webkit-overflow-scrolling: touch;
  flex: 1;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}
.story-list::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}
.story-card { flex: 0 0 auto; width: 180px; height: 260px; border-radius: 12px; overflow: hidden; position: relative;
  background: #0f172a; color: #fff; text-decoration: none; scroll-snap-align: start; display: block; }
.story-card img, .story-card video { width: 100%; height: 100%; object-fit: cover; display: block; }
.story-title { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 12px; font-weight: 800; font-size: 14px; text-shadow: 0 2px 6px rgba(0,0,0,.45); background: linear-gradient(180deg, transparent, rgba(0,0,0,.55)); }
.story-badge { position: absolute; top: 10px; right: 10px; background: #f59e0b; color: #111827; font-weight: 800; font-size: 11px; padding: 4px 8px; border-radius: 999px; }

/* play overlay */
.story-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 42px; height: 42px; border-radius: 999px; background: rgba(255,255,255,.9); color: #0f172a; display:flex; align-items:center; justify-content:center; font-weight:900; z-index:5; }

/* modal */
.story-modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.8); z-index: 999; padding: 20px; }
.hidden { display: none !important; }
.viewer { 
  position: relative; 
  width: min(420px, 92vw); 
  max-width: 420px;
  max-height: 90vh;
  aspect-ratio: 9/16; 
  border-radius: 18px; 
  overflow: hidden; 
  background: #000; 
  box-shadow: 0 20px 60px rgba(0,0,0,.6); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
}

/* Desktop: بزرگتر و با نسبت 16:9 برای ویدیو */
@media (min-width: 768px) {
  .viewer {
    width: min(800px, 85vw);
    max-width: 800px;
    max-height: 85vh;
    aspect-ratio: 16/9;
  }
}

/* media inside viewer */
.story-media { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }

/* spinner */
.spinner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 35; background: rgba(0,0,0,.15); }
.spinner-ring { width: 32px; height: 32px; border: 3px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* progress bars */
.story-progress { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 6px; z-index: 40; }
.story-progress .seg { flex:1; height:4px; border-radius:999px; background: rgba(255,255,255,.35); overflow:hidden; }
.story-progress .seg > div { height:100%; width:0; background:#fff; transition: width linear; }

/* tap regions for prev/next */
.tap { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 25; }
.tap-left { left: 0; }
.tap-right { right: 0; }

/* close */
.close-btn { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 999px; background:#fff; color:#1f2937; border:0; z-index:40; font-size:16px; line-height:36px; }
/* responsive */
@media (max-width:640px) {
  .story-card { width: 140px; height: 200px; }
  .stories-prev, .stories-next { display: none; }
}

/* PWA Install Banner Styles - Full Screen */
#pwa-install-banner {
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.3s ease-out;
}

#pwa-install-banner:not(.hidden) {
    opacity: 1;
    transform: scale(1);
}

#pwa-install-banner > div {
    position: relative;
    height: 100%;
    width: 100%;
}

/* Smooth scroll for banner content */
#pwa-install-banner > div::-webkit-scrollbar {
    width: 4px;
}

#pwa-install-banner > div::-webkit-scrollbar-track {
    background: transparent;
}

#pwa-install-banner > div::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}