/**
 * Nour Theme - Additional CSS
 * Preloader, mobile menu, sticky nav, animations
 * @package Nour
 */

/* =============================================================================
   PRELOADER
   ============================================================================= */
.nour-preloader {
    position: fixed;
    inset: 0;
    background: var(--nour-bg-card);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .5s ease;
}

.nour-preloader__inner {
    text-align: center;
}

.nour-preloader__logo {
    display: block;
    font-size: 36px;
    font-weight: 900;
    color: var(--nour-primary);
    margin-bottom: 20px;
    letter-spacing: -1px;
}

.nour-preloader__bar {
    width: 200px;
    height: 3px;
    background: var(--nour-border);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
    position: relative;
}

.nour-preloader__bar::after {
    content: '';
    position: absolute;
    top: 0; left: -50%;
    width: 50%;
    height: 100%;
    background: var(--nour-primary);
    animation: nour-preloader-bar 1.2s ease infinite;
    border-radius: 2px;
}

@keyframes nour-preloader-bar {
    0%   { left: -50%; }
    100% { left: 100%; }
}

/* =============================================================================
   STICKY NAV
   ============================================================================= */
.nour-nav.is-sticky {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    animation: nour-slide-down .3s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
}

.nour-nav.is-hidden {
    transform: translateY(-100%);
    transition: transform .3s ease;
}

@keyframes nour-slide-down {
    from { transform: translateY(-100%); }
    to   { transform: translateY(0); }
}

/* Offset content when nav sticks */
body.admin-bar .nour-nav.is-sticky { top: 32px; }
@media (max-width: 782px) {
    body.admin-bar .nour-nav.is-sticky { top: 46px; }
}

/* =============================================================================
   MOBILE MENU
   ============================================================================= */
.nour-nav__hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: #fff;
}

.nour-nav__hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: all .3s ease;
    transform-origin: center;
}

.nour-nav__hamburger[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nour-nav__hamburger[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.nour-nav__hamburger[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nour-mobile-menu {
    display: none;
    background: #1a1a1a;
    border-top: 1px solid rgba(255,255,255,.08);
    max-height: 0;
    overflow: hidden;
    transition: max-height .4s ease;
}

.nour-mobile-menu.is-open {
    display: block;
    max-height: 600px;
    overflow-y: auto;
}

.nour-mobile-menu__list,
.nour-mobile-menu .menu {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}

.nour-mobile-menu__list li a,
.nour-mobile-menu .menu li a {
    display: flex;
    align-items: center;
    padding: 13px 20px;
    color: #d1d5db;
    font-size: 14px;
    border-bottom: 1px solid rgba(255,255,255,.05);
    transition: all .2s;
}

.nour-mobile-menu__list li a:hover,
.nour-mobile-menu .menu li a:hover {
    color: #fff;
    background: rgba(255,255,255,.06);
    padding-right: 28px;
}

.nour-mobile-menu__list .sub-menu,
.nour-mobile-menu .menu .sub-menu {
    padding-right: 16px;
    background: rgba(0,0,0,.2);
    list-style: none;
}

/* Body overlay when menu is open */
body.menu-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 490;
}

/* =============================================================================
   SINGLE POST LAYOUT VARIANTS
   ============================================================================= */

/* Layout: Magazine */
.layout-magazine .nour-post-content {
    column-count: 2;
    column-gap: 32px;
}

.layout-magazine .nour-post-content img {
    column-span: all;
}

/* Layout: Wide */
.layout-wide .nour-wrapper {
    max-width: 100%;
    grid-template-columns: 1fr;
}

/* Layout: Centered */
.layout-centered #primary {
    max-width: 760px;
    margin: 0 auto;
}

/* Layout: No Sidebar */
.nour-wrapper.no-sidebar {
    grid-template-columns: 1fr;
    max-width: 860px;
    margin: 0 auto;
}

/* =============================================================================
   ENHANCED CARD HOVER
   ============================================================================= */
.nour-card {
    will-change: transform;
}

.nour-card:hover .nour-card__thumb img {
    transform: scale(1.05);
}

/* Image overlay effect */
.nour-card__thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background .3s;
}

.nour-card:hover .nour-card__thumb::after {
    background: rgba(0,0,0,.08);
}

/* =============================================================================
   FEATURED POST BADGE
   ============================================================================= */
.nour-card--featured::before {
    content: '★';
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--nour-accent);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 1;
}

/* =============================================================================
   ARCHIVE HEADER ANIMATION
   ============================================================================= */
.nour-archive-header {
    animation: nour-fade-in .5s ease;
}

@keyframes nour-fade-in {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =============================================================================
   SEARCH RESULTS LIVE
   ============================================================================= */
.nour-search-results {
    background: rgba(0,0,0,.8);
    border-radius: 0 0 var(--nour-radius) var(--nour-radius);
    max-height: 400px;
    overflow-y: auto;
    margin-top: 4px;
}

.nour-search-result:hover {
    background: rgba(255,255,255,.08) !important;
}

/* =============================================================================
   WooCommerce INTEGRATION
   ============================================================================= */
.woocommerce-page .nour-wrapper {
    display: grid;
    grid-template-columns: 1fr var(--nour-sidebar-w);
    gap: var(--nour-gap);
}

.woocommerce ul.products li.product .nour-cat {
    margin-bottom: 8px;
}

.woocommerce .woocommerce-ordering select,
.woocommerce .woocommerce-result-count {
    font-family: var(--nour-font-arabic);
}

/* WC Product Card */
.woocommerce ul.products li.product {
    border: 1px solid var(--nour-border);
    border-radius: var(--nour-radius);
    overflow: hidden;
    transition: var(--nour-transition);
}

.woocommerce ul.products li.product:hover {
    transform: translateY(-3px);
    box-shadow: var(--nour-shadow);
}

/* =============================================================================
   BUDDYPRESS INTEGRATION
   ============================================================================= */
#buddypress .nour-widget {
    margin-bottom: 20px;
}

#buddypress .activity-list .activity-item {
    border-bottom: 1px solid var(--nour-border);
    padding: 16px 0;
}

#buddypress .bp-avatar img {
    border-radius: 50%;
}

/* =============================================================================
   AMP COMPATIBILITY
   ============================================================================= */
amp-img {
    background-color: var(--nour-gray-100);
}

/* =============================================================================
   PRINT ENHANCEMENTS
   ============================================================================= */
@media print {
    .nour-preloader,
    .nour-breaking-popup,
    .nour-mobile-menu { display: none !important; }
}

/* =============================================================================
   ACCESSIBILITY: FOCUS STYLES
   ============================================================================= */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--nour-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Skip to content */
.skip-link {
    position: absolute;
    top: -40px;
    right: 0;
    background: var(--nour-primary);
    color: #fff;
    padding: 8px 16px;
    z-index: 9999;
    font-size: 14px;
    transition: top .2s;
}
.skip-link:focus { top: 0; }

/* =============================================================================
   DARK MODE ENHANCED
   ============================================================================= */
[data-theme="dark"] .nour-card {
    border-color: var(--nour-border);
}

[data-theme="dark"] .nour-header {
    border-bottom-color: var(--nour-primary);
}

[data-theme="dark"] img {
    opacity: .9;
}

[data-theme="dark"] .nour-slider__image {
    opacity: .6;
}

[data-theme="dark"] .nour-newsletter {
    opacity: .95;
}

[data-theme="dark"] code {
    background: rgba(255,255,255,.1);
    color: #f8f8f2;
}

[data-theme="dark"] pre {
    background: #0d1117;
    border: 1px solid var(--nour-border);
}

[data-theme="dark"] .nour-topbar {
    background: #0d1117;
}

[data-theme="dark"] .nour-footer-widgets {
    background: #0d1117;
}

[data-theme="dark"] .nour-footer-bottom {
    background: #070b0f;
}

[data-theme="dark"] table tr:nth-child(even) {
    background: rgba(255,255,255,.03);
}

[data-theme="dark"] .nour-pros {
    background: rgba(21,128,61,.1);
    border-color: rgba(134,239,172,.2);
}

[data-theme="dark"] .nour-cons {
    background: rgba(185,28,28,.1);
    border-color: rgba(252,165,165,.2);
}

/* =============================================================================
   ANIMATION: FADE IN CARDS ON SCROLL
   ============================================================================= */
.nour-card,
.nour-list-card {
    animation: nour-card-in .4s ease both;
}

@keyframes nour-card-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for grid children */
.nour-grid-3 > *:nth-child(1),
.nour-grid-4 > *:nth-child(1) { animation-delay: .05s; }
.nour-grid-3 > *:nth-child(2),
.nour-grid-4 > *:nth-child(2) { animation-delay: .10s; }
.nour-grid-3 > *:nth-child(3),
.nour-grid-4 > *:nth-child(3) { animation-delay: .15s; }
.nour-grid-3 > *:nth-child(4),
.nour-grid-4 > *:nth-child(4) { animation-delay: .20s; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
