/* DNav Modals, Stories & Contact Popups */

@media (max-width: 1024px) {

    /* Stories Slider */
    .dnav-stories-wrapper { 
        display: flex; 
        gap: 12px; 
        padding: 15px 15px; 
        overflow-x: auto; 
        background: #fff; 
        border-bottom: 1px solid #f0f0f1; 
        scrollbar-width: none; 
        -ms-overflow-style: none; 
        box-sizing: border-box; 
        width: 100%; 
        flex-shrink: 0; 
        scroll-snap-type: x mandatory; 
    }
    
    .dnav-stories-wrapper::-webkit-scrollbar { 
        display: none; 
    }
    
    .dnav-story-item { 
        display: flex; 
        flex-direction: column; 
        align-items: center; 
        cursor: pointer; 
        flex-shrink: 0; 
        width: calc(100% / var(--dnav-story-vis) - 10px); 
        scroll-snap-align: start; 
        -webkit-tap-highlight-color: transparent; 
    }
    
    .dnav-story-thumb { 
        width: 100%; 
        aspect-ratio: 1/1; 
        border-radius: 50%; 
        padding: 2.5px; 
        background: linear-gradient(45deg, var(--dnav-story-border), #ff7a00); 
        display: flex; 
        align-items: center; 
        justify-content: center; 
        box-sizing: border-box; 
        transition: transform 0.2s ease; 
    }
    
    .dnav-story-item:active .dnav-story-thumb { 
        transform: scale(0.92); 
    }
    
    .dnav-story-thumb img { 
        width: 100%; 
        height: 100%; 
        border-radius: 50%; 
        object-fit: cover; 
        border: 2.5px solid #fff; 
        box-sizing: border-box; 
    }
    
    .dnav-story-text { 
        font-size: 11px; 
        margin-top: 6px; 
        text-align: center; 
        color: var(--dnav-story-text); 
        white-space: nowrap; 
        overflow: hidden; 
        text-overflow: ellipsis; 
        max-width: 100%; 
        font-weight: 500; 
    }
}

/* Stories Modal Base */
.dnav-story-viewer-modal { 
    position: fixed !important; 
    top: 0 !important; 
    left: 0 !important; 
    width: 100vw !important; 
    height: 100dvh !important; 
    background: #0c0c0c !important; 
    z-index: 999999999 !important; 
    display: none; 
    flex-direction: column; 
}

.dnav-story-viewer-modal.active { 
    display: flex; 
    animation: dnavFadeInModal 0.3s ease; 
}

@keyframes dnavFadeInModal { 
    from { opacity: 0; } 
    to { opacity: 1; } 
}

.dnav-story-header { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    padding: 15px 10px 30px 10px; 
    z-index: 2; 
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent); 
    box-sizing: border-box; 
}

.dnav-story-progress-container { 
    display: flex; 
    gap: 5px; 
    width: 100%; 
    height: 3px; 
    margin-bottom: 15px; 
}

.dnav-story-progress-bar { 
    flex: 1; 
    background: rgba(255,255,255,0.3); 
    border-radius: 3px; 
    overflow: hidden; 
}

.dnav-story-progress-fill { 
    height: 100%; 
    background: #fff; 
    width: 0%; 
}

.dnav-story-close {
    /* دکمه بستن استوری: فقط آیکون سفید، بدون پس‌زمینه/کادر */
    appearance: none !important;
    -webkit-appearance: none !important;
    border: 0 !important;
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    color: #fff !important;
    cursor: pointer;
    float: left;
    margin-left: 5px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 8px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 !important;
    text-decoration: none !important;
    text-shadow: none;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.dnav-story-close svg {
    width: 28px;
    height: 28px;
    display: block;
    fill: currentColor;
    pointer-events: none;
}
.dnav-story-close:hover,
.dnav-story-close:active {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    color: #fff !important;
    opacity: 1;
}

.dnav-story-body { 
    flex: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    position: relative; 
    width: 100%; 
    height: 100%; 
    touch-action: pan-y;
    overscroll-behavior: contain;
    user-select: none;
    -webkit-user-select: none;
}

.dnav-story-link { 
    display: block; 
    width: 100%; 
    height: 100%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

.dnav-story-link.dnav-story-link-disabled {
    cursor: default;
    pointer-events: none;
}

.dnav-story-body img { 
    max-width: 100%; 
    max-height: 100dvh; 
    object-fit: contain; 
}

.dnav-story-like-wrapper { 
    position: absolute; 
    bottom: 40px; 
    right: 20px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 5px; 
    z-index: 5; 
}

.dnav-story-like-btn { 
    background: rgba(0,0,0,0.4); 
    border: none; 
    color: #fff; 
    border-radius: 50%; 
    width: 50px; 
    height: 50px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    backdrop-filter: blur(5px); 
    -webkit-backdrop-filter: blur(5px); 
    transition: all 0.2s; 
    outline: none; 
    -webkit-tap-highlight-color: transparent; 
}

.dnav-story-like-btn.liked { color: #ff3040; animation: heartPulse 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes heartPulse { 
    0% { transform: scale(1); } 
    50% { transform: scale(1.3); } 
    100% { transform: scale(1); } 
}

.dnav-story-like-count { 
    color: #fff; 
    font-size: 13px; 
    font-weight: bold; 
    text-shadow: 0 1px 3px rgba(0,0,0,0.8); 
}

/* Contact Popup */
.dnav-contact-popup-modal { 
    position: fixed !important; 
    inset: 0 !important; 
    width: 100vw !important; 
    height: 100dvh !important; 
    z-index: 1000000 !important; 
    display: none; 
    align-items: flex-end; 
    justify-content: center; 
    box-sizing: border-box; 
    padding: 0; 
}

.dnav-contact-popup-modal.active { 
    display: flex !important; 
}

.dnav-contact-popup-overlay { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(0, 0, 0, 0.5); 
    backdrop-filter: blur(4px); 
    -webkit-backdrop-filter: blur(4px); 
    transition: all 0.3s ease; 
}

.dnav-contact-popup-content { 
    position: relative; 
    background: var(--dnav-contact-bg); 
    color: var(--dnav-contact-text); 
    width: 100%; 
    max-width: var(--dnav-contact-width); 
    height: var(--dnav-contact-height, auto);
    max-height: calc(100dvh - var(--dnav-margin-bottom) - 40px);
    border-radius: 20px 20px 0 0; 
    box-shadow: 0 -5px 25px rgba(0,0,0,0.15); 
    overflow: auto; 
    z-index: 10; 
    margin-bottom: calc(var(--dnav-margin-bottom) + 60px); 
    animation: dnavPopupSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); 
    direction: rtl; 
    text-align: right; 
    box-sizing: border-box; 
    display: flex; 
    flex-direction: column; 
}

@media (max-width: 1024px) {
    .dnav-contact-popup-modal { 
        align-items: flex-end !important; 
        padding: 0 var(--dnav-margin-side) !important; 
        justify-content: center; 
    }
    
    .dnav-contact-popup-content { 
        max-width: 100% !important; 
        border-radius: 24px !important; 
        margin-bottom: calc(var(--dnav-margin-bottom) + 80px) !important; 
        padding-bottom: 20px !important; 
        animation: dnavPopupSlideUpMob 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important; 
    }
}

@keyframes dnavPopupSlideUp { 
    from { transform: translateY(100%); } 
    to { transform: translateY(0); } 
}

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

.dnav-contact-popup-header { 
    padding: 20px 20px 15px 20px; 
    border-bottom: 1px solid rgba(0,0,0,0.06); 
    position: relative; 
}

.dnav-contact-popup-header h3 { 
    margin: 0 0 5px 0; 
    font-size: 16px; 
    font-weight: bold; 
    color: var(--dnav-contact-text); 
}

.dnav-contact-popup-desc { 
    margin: 0; 
    font-size: 12px; 
    opacity: 0.8; 
}

.dnav-contact-popup-close-btn { 
    position: absolute; 
    top: 18px; 
    left: 18px; 
    background: transparent; 
    border: none; 
    color: var(--dnav-contact-text); 
    cursor: pointer; 
    padding: 0; 
    outline: none; 
    opacity: 0.7; 
    transition: opacity 0.2s; 
}

.dnav-contact-popup-close-btn:hover { 
    opacity: 1; 
}

.dnav-contact-popup-body { 
    padding: 20px; 
    overflow-y: auto; 
    max-height: calc(80vh - 100px); 
}

.dnav-contact-grid-presets { 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
}

.dnav-contact-preset-item { 
    display: flex; 
    align-items: center; 
    padding: 12px 15px; 
    border-radius: 10px; 
    text-decoration: none !important; 
    background: rgba(0,0,0,0.02); 
    transition: background 0.2s, transform 0.2s; 
    box-sizing: border-box; 
    border: 1px solid rgba(0,0,0,0.03); 
}

.dnav-contact-preset-item:active { 
    transform: scale(0.98); 
}

.preset-icon-wrap { 
    width: 36px; 
    height: 36px; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    margin-left: 12px; 
    flex-shrink: 0; 
    color: #ffffff; 
    overflow: hidden; 
}

.preset-icon-wrap img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
}

.preset-title { 
    font-size: 12px; 
    font-weight: 700; 
    flex: 1; 
    color: var(--dnav-contact-text); 
}

.preset-val { 
    font-size: 11px; 
    opacity: 0.9; 
    font-weight: 500; 
    color: var(--dnav-contact-text); 
    margin-right: 10px; 
}

.dnav-contact-channels-divider { 
    height: 1px; 
    border-top: 1px solid rgba(0,0,0,0.06); 
    background: rgba(0,0,0,0.06); 
    margin: 20px auto 10px auto; 
    width: 90%; 
}

.dnav-contact-channels-title { 
    text-align: center; 
    font-size: 15px; 
    font-weight: bold; 
    color: #333; 
    margin: 20px 0 10px 0; 
}

/* Social channel layout is owned by dnav-frontend-extra.css. */

/* Accessibility: Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .dnav-story-viewer-modal.active,
    .dnav-contact-popup-content,
    .dnav-contact-popup-overlay,
    .dnav-contact-popup-close-btn,
    .dnav-contact-preset-item,
    .dnav-social-channel-item,
    .dnav-story-like-btn,
    .dnav-story-like-btn.liked {
        animation-duration: 0.01ms !important;
        animation-name: none !important;
        transition-duration: 0.01ms !important;
    }
    .dnav-story-like-btn.liked {
        animation-name: none !important;
    }
}

/* Accessibility focus policy:
   - Touch/programmatic focus must not leave a distracting browser/theme ring.
   - Keyboard focus keeps a visible indicator for screen-reader/keyboard users. */
.dnav-contact-popup-close-btn:focus:not(:focus-visible),
.dnav-contact-popup-content a:focus:not(:focus-visible),
.dnav-contact-popup-content button:focus:not(:focus-visible),
.dnav-contact-popup-content input:focus:not(:focus-visible),
.dnav-contact-popup-content select:focus:not(:focus-visible),
.dnav-contact-popup-content textarea:focus:not(:focus-visible) {
    outline: 0 !important;
    box-shadow: none !important;
}
.dnav-contact-popup-close-btn:focus-visible,
.dnav-contact-popup-content a:focus-visible,
.dnav-contact-popup-content button:focus-visible,
.dnav-contact-popup-content input:focus-visible,
.dnav-contact-popup-content select:focus-visible,
.dnav-contact-popup-content textarea:focus-visible {
    outline: 3px solid currentColor !important;
    outline-offset: 3px !important;
}


/* Story viewer close control: real button for keyboard/screen-reader access. */
.dnav-story-close:focus:not(:focus-visible) {
    outline: 0 !important;
    box-shadow: none !important;
}
.dnav-story-close:focus-visible {
    outline: 3px solid currentColor !important;
    outline-offset: 3px !important;
}


