/*
Theme Name:  cima2day
Theme URI:   https://cima2day.com
Description: Arabic Cinema & Streaming WordPress Theme — Mobile-First, RTL, Dark Mode, SEO-Ready
Author:      cima2day
Author URI:  https://cima2day.com
Version:     3.0.0
Text Domain: cima2day
Tags:        rtl-language, dark, entertainment, movie, series, arabic, streaming
*/

/* ═══════════════════════════════════════════════════
   CSS CUSTOM PROPERTIES — Design Tokens
═══════════════════════════════════════════════════ */
:root {
    --accent-red:        #e63946;
    --accent-gold:       #ffd60a;
    --bg-primary:        #0d0d1a;
    --bg-secondary:      #12121f;
    --bg-card:           #1a1a2e;
    --bg-nav:            rgba(10,10,24,0.95);
    --border-color:      rgba(255,255,255,0.08);
    --text-primary:      #ffffff;
    --text-secondary:    #c9d1d9;
    --text-muted:        #8b949e;
    --font-arabic:       'Cairo', 'Tajawal', 'Arial', sans-serif;
    --radius-card:       12px;
    --shadow-card:       0 8px 32px rgba(0,0,0,0.55);
    --transition:        all 0.25s ease;
    --primary:           #e63946;
    --container-width:   1320px;
    --header-h:          65px;
}

/* ═══════════════════════════════════════════════════
   RESET + BASE
═══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-arabic);
    direction: rtl;
    min-height: 100vh;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-arabic); cursor: pointer; }

/* ═══════════════════════════════════════════════════
   ACCESSIBILITY
═══════════════════════════════════════════════════ */
.skip-to-main {
    position: absolute;
    top: -100%;
    right: 0;
    background: var(--accent-red);
    color: #fff;
    padding: 10px 20px;
    font-weight: 700;
    z-index: 9999;
    border-radius: 0 0 8px 0;
    transition: top 0.2s;
}
.skip-to-main:focus { top: 0; }
:focus-visible { outline: 2px solid var(--accent-red); outline-offset: 3px; }

/* ═══════════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════════ */
.container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}
#main-content { min-height: 60vh; }

/* ═══════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════ */
#site-header {
    position: fixed;
    top: 0; right: 0; left: 0;
    height: var(--header-h);
    background: var(--bg-nav);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    transition: background 0.3s;
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}
.site-logo {
    font-size: 1.5rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: -0.5px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.site-logo span { color: var(--accent-red); }
.site-logo img { height: 40px; width: auto; }

/* NAV */
.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 24px;
    flex: 1;
}
.main-nav > a, .nav-dropdown-wrap > a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    transition: var(--transition);
    white-space: nowrap;
}
.main-nav > a:hover,
.nav-dropdown-wrap > a:hover,
.main-nav > a.active,
.nav-dropdown-wrap > a.active {
    color: #fff;
    background: rgba(255,255,255,0.07);
}

/* DROPDOWN */
.nav-dropdown-wrap { position: relative; }
.nav-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.6);
    z-index: 200;
}
.nav-dropdown a {
    display: block;
    color: var(--text-secondary);
    font-size: 0.88rem;
    padding: 9px 14px;
    border-radius: 7px;
    transition: var(--transition);
}
.nav-dropdown a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-dropdown-wrap:hover .nav-dropdown { display: block; }

/* HEADER ACTIONS */
.header-actions { display: flex; align-items: center; gap: 8px; margin-right: auto; }
.search-btn, .mobile-menu-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: var(--transition);
}
.search-btn:hover, .mobile-menu-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.mobile-menu-btn { display: none; }

/* MOBILE NAV */
.mobile-nav {
    display: none;
    flex-direction: column;
    position: fixed;
    top: var(--header-h);
    right: 0; left: 0;
    bottom: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    overflow-y: auto;
    z-index: 999;
    padding: 8px 0 40px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}
.mobile-nav.open { display: flex; transform: translateX(0); }
.mobile-nav a {
    display: block;
    color: var(--text-secondary);
    padding: 13px 20px;
    font-size: 0.92rem;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}
.mobile-nav a:hover { color: #fff; background: rgba(255,255,255,0.04); }

/* ═══════════════════════════════════════════════════
   SEARCH OVERLAY
═══════════════════════════════════════════════════ */
.search-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
    padding-left: 20px;
    padding-right: 20px;
}
.search-overlay.open { display: flex; }
.search-overlay-inner {
    width: 100%;
    max-width: 600px;
    position: relative;
}
.search-overlay input {
    width: 100%;
    background: var(--bg-card);
    border: 2px solid var(--accent-red);
    border-radius: 12px;
    color: #fff;
    font-family: var(--font-arabic);
    font-size: 1.1rem;
    padding: 16px 20px;
    outline: none;
}
.search-close {
    position: absolute;
    top: -50px;
    left: 0;
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 1.4rem;
    transition: color 0.2s;
}
.search-close:hover { color: #fff; }
#searchResults .search-item {
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
    transition: var(--transition);
}
#searchResults .search-item:hover { border-color: var(--accent-red); }
#searchResults .search-item img {
    width: 44px;
    height: 64px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}
#searchResults .search-item-info { flex: 1; min-width: 0; }
#searchResults .search-item-title { font-weight: 700; font-size: 0.95rem; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#searchResults .search-item-meta { color: var(--text-muted); font-size: 0.78rem; margin-top: 3px; }

/* ═══════════════════════════════════════════════════
   MEDIA CARDS
═══════════════════════════════════════════════════ */
.media-card {
    position: relative;
    flex: 0 0 auto;
    width: 160px;
    border-radius: var(--radius-card);
    overflow: hidden;
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.media-card:hover { transform: translateY(-6px) scale(1.02); box-shadow: 0 20px 50px rgba(0,0,0,0.7); }
.media-card a { display: block; position: relative; }
.media-card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; }
.card-no-img { width: 100%; aspect-ratio: 2/3; background: var(--bg-secondary); }

.card-gradient {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 65%;
    background: linear-gradient(to top, rgba(0,0,0,0.92) 0%, transparent 100%);
    pointer-events: none;
}
.card-badges {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}
.badge {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 4px;
    line-height: 1.4;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.badge-quality { background: rgba(13,13,26,0.75); color: #fff; border: 1px solid rgba(255,255,255,0.2); }
.badge-quality.webdl { background: rgba(33,113,177,0.8); border-color: #2271b1; }
.badge-year { background: rgba(13,13,26,0.6); color: var(--text-muted); border: 1px solid rgba(255,255,255,0.1); }
.badge-season { background: rgba(230,57,70,0.75); color: #fff; }
.badge-18 { background: #6d0202; color: #ff9999; border: 1px solid #9b0000; }
.badge-16 { background: rgba(180,80,0,0.8); color: #ffc97a; }

.card-imdb {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.68rem;
    font-weight: 800;
    background: rgba(0,0,0,0.6);
    color: var(--accent-gold);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255,214,10,0.3);
}
.card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s;
    background: rgba(0,0,0,0.35);
}
.media-card:hover .card-overlay { opacity: 1; }
.card-play-btn {
    width: 48px;
    height: 48px;
    background: var(--accent-red);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 28px rgba(230,57,70,0.6);
    transform: scale(0.9);
    transition: transform 0.2s;
}
.media-card:hover .card-play-btn { transform: scale(1); }
.card-play-btn svg { width: 20px; height: 20px; fill: #fff; }

.card-bottom {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 8px 10px;
}
.card-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 3px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.card-ep-badge {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════
   SCROLL ROW
═══════════════════════════════════════════════════ */
.scroll-row-container {
    position: relative;
}
.scroll-row {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding-bottom: 6px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.scroll-row::-webkit-scrollbar { display: none; }
.scroll-row .media-card { scroll-snap-align: start; }
.scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 38px;
    height: 68px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: var(--transition);
    font-size: 0.8rem;
}
.scroll-btn:hover { background: var(--accent-red); border-color: var(--accent-red); color: #fff; }
.scroll-btn.prev { right: -10px; }
.scroll-btn.next { left: -10px; }

/* ═══════════════════════════════════════════════════
   ARCHIVE GRID
═══════════════════════════════════════════════════ */
.archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}
.archive-grid .media-card { width: 100%; }

/* ═══════════════════════════════════════════════════
   SECTION TITLE
═══════════════════════════════════════════════════ */
.section-title {
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    font-weight: 800;
    color: #fff;
    position: relative;
    padding-right: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-title::before {
    content: '';
    position: absolute;
    right: 0;
    top: 10%;
    height: 80%;
    width: 4px;
    background: var(--accent-red);
    border-radius: 2px;
}

/* ═══════════════════════════════════════════════════
   GENRE TAGS
═══════════════════════════════════════════════════ */
.genre-tag {
    display: inline-block;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    transition: var(--transition);
}
.genre-tag:hover { border-color: var(--accent-red); color: #fff; background: rgba(230,57,70,0.1); }

/* ═══════════════════════════════════════════════════
   PAGINATION
═══════════════════════════════════════════════════ */
.pagination, .nav-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 40px 0;
    flex-wrap: wrap;
}
.pagination a, .pagination span,
.nav-links a, .nav-links span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0 12px;
    transition: var(--transition);
}
.pagination a:hover, .nav-links a:hover { border-color: var(--accent-red); color: #fff; }
.pagination .current, .nav-links .current { background: var(--accent-red); border-color: var(--accent-red); color: #fff; }

/* ═══════════════════════════════════════════════════
   FILTER BAR
═══════════════════════════════════════════════════ */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 28px;
    align-items: center;
}
.filter-select {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 9px 14px;
    font-family: var(--font-arabic);
    font-size: 0.88rem;
    appearance: none;
    -webkit-appearance: none;
    min-width: 130px;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b949e'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 32px;
    transition: var(--transition);
}
.filter-select:focus { border-color: var(--accent-red); color: #fff; outline: none; }

/* ═══════════════════════════════════════════════════
   TOAST NOTIFICATION
═══════════════════════════════════════════════════ */
#cs-toast {
    position: fixed;
    bottom: 28px;
    right: 50%;
    transform: translateX(50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 9999;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s;
}
#cs-toast.show { opacity: 1; }

/* ═══════════════════════════════════════════════════
   AD CONTAINERS — prevent CLS
═══════════════════════════════════════════════════ */
.cima2day-ad-unit {
    text-align: center;
    margin: 20px auto;
    overflow: hidden;
    max-width: 100%;
    line-height: 0;
    /* Reserve minimum height to prevent layout shift */
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ═══════════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════════ */
@keyframes fadeIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }
.fade-in { animation: fadeIn 0.4s ease both; }
@keyframes animFadeUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:none; } }
.anim-fade-up { animation: animFadeUp 0.4s ease both; }

/* ═══════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════ */
#site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: 60px;
}
.footer-nav { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 14px; padding: 0; list-style: none; }
.footer-nav a { color: var(--text-muted); font-size: 0.85rem; transition: color 0.2s; }
.footer-nav a:hover { color: var(--accent-red); }

/* ═══════════════════════════════════════════════════
   RESPONSIVE — TABLET (max 1024px)
═══════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .main-nav { display: none; }
    .mobile-menu-btn { display: flex; }
    .archive-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 12px; }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — MOBILE (max 640px)
═══════════════════════════════════════════════════ */
@media (max-width: 640px) {
    :root { --header-h: 58px; }
    .container { padding: 0 14px; }
    .archive-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
    .media-card { border-radius: 8px; }
    .section-title { font-size: 1rem; }
    .scroll-btn { display: none; }

    /* ─── 🔴 FIX 3: Header always visible on mobile single pages ─────────
       The single-movie / single-series pages wrap content in:
         <div style="padding-top:65px">
       On desktop (header-h = 70px) 65px is fine.
       On mobile (header-h = 58px) we keep 60px — still clears the header.
       The critical fix is in the JS (scrollIntoView race condition), but
       this CSS safety net ensures the wrapper never sits under the header. */
    div[style*="padding-top:65px"] {
        padding-top: 60px !important;
    }

    /* Ensure the fixed header is never accidentally hidden by child stacking */
    #site-header {
        transform: translateZ(0);   /* force GPU layer — prevents z-index collapse */
        -webkit-transform: translateZ(0);
    }

    /* On movie/series pages the hero min-height is large; shrink on mobile
       so content starts within viewport (user sees hero + title, not blank) */
    .mv-hero,
    .cs-hero-section {
        min-height: 320px !important;
    }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — TABLET (max 1024px)
   Already defined above — media block order preserved.
═══════════════════════════════════════════════════ */
