/*
 * ELBADIL Modern Design System v2.0
 * Responsive, accessible, RTL-first Arabic news theme styles
 * ─────────────────────────────────────────────────────────
 */

/* ═══════════════════════════════════════════
   1. GLOBAL RESET & BASE
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

::selection {
    background-color: rgba(var(--site-color-rgb), .18);
    color: var(--body-color);
}

img { max-width: 100%; height: auto; display: block; }

a {
    text-decoration: none;
    transition: var(--glob-transition);
}

/* ═══════════════════════════════════════════
   2. SCROLLBAR (Webkit)
═══════════════════════════════════════════ */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--body-bg-color); }
::-webkit-scrollbar-thumb {
    background: rgba(var(--site-color-rgb), .4);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--site-color-rgb), .7);
}

/* ═══════════════════════════════════════════
   3. SITE HEADER — Modern sticky glass
═══════════════════════════════════════════ */
#site-header {
    border-top: 3px solid var(--site-color);
    background: rgba(255,255,255,.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: var(--wp-admin--admin-bar--height, 0);
    z-index: var(--z-sticky);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

[data-theme^="dark"] #site-header {
    background: rgba(15, 23, 42, .97);
}

body.scroll-down #site-header {
    transform: translateY(-100%);
}

/* site logo */
.site-logo img {
    min-width: 110px;
    max-width: 170px !important;
    transition: opacity var(--transition-fast);
}
.site-logo img:hover { opacity: .85; }
.site-logo .title {
    font-family: var(--site-font-heading);
    font-weight: var(--font-weight-black);
    font-size: var(--font-size-xl);
}

/* ═══════════════════════════════════════════
   4. NAVIGATION MENU
═══════════════════════════════════════════ */
.nav-menu a {
    font-family: var(--site-font-heading);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    letter-spacing: 0.01em;
    border-radius: var(--glob-border-radius-sm);
    padding: .5em .9em;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-menu li:hover > a,
.nav-menu li.current-menu-item > a,
.nav-menu li.current-menu-ancestor > a {
    background: rgba(var(--site-color-rgb), .08);
    color: var(--site-color) !important;
}

/* ═══════════════════════════════════════════
   5. POST / ARTICLE CARDS
═══════════════════════════════════════════ */
.post-loop-item {
    background: var(--light-bg);
    border-radius: var(--glob-border-radius);
    overflow: hidden;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    box-shadow: var(--shadow-xs);
}

.post-loop-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

/* Post thumbnail */
.post-loop-item .post-thumbnail {
    overflow: hidden;
    border-radius: var(--glob-border-radius) var(--glob-border-radius) 0 0;
}

.post-loop-item .post-thumbnail img {
    transition: transform var(--transition-slow);
    width: 100%;
    object-fit: cover;
}
.post-loop-item:hover .post-thumbnail img {
    transform: scale(1.05);
}

/* Post title */
.post-loop-item .post-title,
.post-loop-item h2,
.post-loop-item h3 {
    font-family: var(--site-font-heading);
    font-weight: var(--font-weight-bold);
    line-height: 1.4;
    margin-bottom: .5em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-loop-item .post-title a:hover {
    color: var(--site-color);
}

/* Category badge on cards */
.post-loop-item .term-badge,
.post-loop-item .category-badge {
    display: inline-block;
    background: var(--site-color);
    color: #fff !important;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    padding: 2px 10px;
    border-radius: var(--glob-border-radius-pill);
    letter-spacing: .03em;
    transition: background var(--transition-fast);
}
.post-loop-item .term-badge:hover { background: var(--site-color-darker-1); }

/* Meta row */
.post-meta,
.post-meta-items {
    font-size: var(--font-size-xs);
    color: var(--meta-color);
    display: flex;
    flex-wrap: wrap;
    gap: .4em .8em;
    align-items: center;
}

.post-meta a:hover { color: var(--site-color); }

/* ═══════════════════════════════════════════
   6. SINGLE POST / ARTICLE
═══════════════════════════════════════════ */
.entry-content {
    font-size: var(--font-size-md);
    line-height: var(--line-height-loose);
    color: var(--body-color);
    max-width: var(--content-width);
    margin-inline: auto;
}

.entry-content p { margin-bottom: 1.35em; }

.entry-content h2,
.entry-content h3 {
    font-family: var(--site-font-heading);
    font-weight: var(--font-weight-bold);
    margin-top: 2em;
    margin-bottom: .6em;
    line-height: 1.3;
}

/* Blockquote */
.entry-content blockquote {
    border-right: 4px solid var(--site-color);
    background: rgba(var(--site-color-rgb), .05);
    padding: 1.2em 1.5em;
    border-radius: 0 var(--glob-border-radius) var(--glob-border-radius) 0;
    margin: 1.5em 0;
    font-style: normal;
    font-weight: var(--font-weight-medium);
    color: var(--body-color);
    font-size: var(--font-size-lg);
}

.ltr .entry-content blockquote {
    border-left: 4px solid var(--site-color);
    border-right: none;
    border-radius: var(--glob-border-radius) 0 0 var(--glob-border-radius);
}

/* Tables */
.entry-content table {
    width: 100%;
    border-collapse: collapse;
    border-radius: var(--glob-border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.entry-content th {
    background: var(--site-color);
    color: #fff;
    padding: .8em 1em;
    text-align: right;
    font-weight: var(--font-weight-bold);
}
.entry-content td {
    padding: .7em 1em;
    border-bottom: 1px solid var(--border-color, rgba(0,0,0,.06));
}
.entry-content tr:nth-child(even) td { background: rgba(0,0,0,.025); }

/* Code */
.entry-content code {
    background: rgba(var(--site-color-rgb), .08);
    color: var(--site-color);
    padding: .15em .4em;
    border-radius: 4px;
    font-size: .9em;
}

/* ═══════════════════════════════════════════
   7. SIDEBAR WIDGETS
═══════════════════════════════════════════ */
.widget {
    background: var(--light-bg);
    border-radius: var(--glob-border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    margin-bottom: var(--post-gap);
    transition: box-shadow var(--transition-base);
}
.widget:hover { box-shadow: var(--shadow-md); }

.widget-title,
.widget > h3 {
    font-family: var(--site-font-heading);
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-base);
    padding: .85em 1.2em;
    border-bottom: 1px solid var(--border-color, rgba(0,0,0,.06));
    margin: 0;
    display: flex;
    align-items: center;
    gap: .5em;
}

.widget-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1.1em;
    background: var(--site-color);
    border-radius: 99px;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   8. BUTTONS
═══════════════════════════════════════════ */
.btn {
    font-family: var(--site-font-heading);
    font-weight: var(--font-weight-bold);
    border-radius: var(--glob-border-radius-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
    letter-spacing: .02em;
}

.btn-primary {
    background: var(--site-color);
    border-color: var(--site-color);
    box-shadow: 0 2px 8px rgba(var(--site-color-rgb), .3);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--site-color-darker-1);
    border-color: var(--site-color-darker-1);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(var(--site-color-rgb), .4);
}

.btn:active { transform: translateY(0); }

/* ═══════════════════════════════════════════
   9. SITE FOOTER
═══════════════════════════════════════════ */
#site-footer {
    border-top: 3px solid var(--site-color);
    border-bottom: none !important;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-base);
}

#site-footer a { transition: color var(--transition-fast); }
#site-footer a:hover { color: var(--site-color); }

/* ═══════════════════════════════════════════
   10. SEARCH BOX
═══════════════════════════════════════════ */
.search-field {
    border-radius: var(--glob-border-radius-pill);
    padding-inline-end: 2.5em;
    border: 2px solid rgba(var(--site-color-rgb), .2);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.search-field:focus {
    border-color: var(--site-color);
    box-shadow: 0 0 0 3px rgba(var(--site-color-rgb), .15);
    outline: none;
}
.search-submit {
    border-radius: var(--glob-border-radius-pill);
}

/* ═══════════════════════════════════════════
   11. BADGES & LABELS
═══════════════════════════════════════════ */
.badge-breaking {
    background: #ef4444;
    color: #fff;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    padding: 2px 10px;
    border-radius: var(--glob-border-radius-pill);
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50%       { opacity: .7; }
}

/* ═══════════════════════════════════════════
   12. READING PROGRESS BAR
═══════════════════════════════════════════ */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--site-color), var(--site-color-lighter-1));
    z-index: calc(var(--z-sticky) + 5);
    transition: width .1s linear;
}

/* ═══════════════════════════════════════════
   13. BACK TO TOP BUTTON
═══════════════════════════════════════════ */
#back-to-top {
    position: fixed;
    bottom: 28px;
    left: 24px;
    width: 44px;
    height: 44px;
    background: var(--site-color);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity .3s, visibility .3s, transform .3s, background .2s;
    z-index: var(--z-overlay);
    box-shadow: var(--shadow-md);
    font-size: 1.1rem;
}
#back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
#back-to-top:hover {
    background: var(--site-color-darker-1);
    transform: translateY(-3px);
}

/* ═══════════════════════════════════════════
   14. DARK MODE OVERRIDES
═══════════════════════════════════════════ */
body.dark-mode,
[data-theme^="dark"] {
    --light-bg: #1e293b;
    --light-bg-alt: #0f172a;
    --light-border-color: rgba(255,255,255,.07);
}

body.dark-mode .post-loop-item,
body.dark-mode .widget {
    background: #1e293b;
    border: 1px solid rgba(255,255,255,.06);
}

body.dark-mode .entry-content code {
    background: rgba(255,255,255,.08);
}

/* Dark mode toggle button */
#dark-mode-toggle {
    background: none;
    border: 2px solid rgba(var(--site-color-rgb), .3);
    color: var(--body-color);
    border-radius: var(--glob-border-radius-pill);
    padding: .35em .9em;
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-family: var(--site-font);
    transition: var(--glob-transition);
    display: flex;
    align-items: center;
    gap: .4em;
}
#dark-mode-toggle:hover {
    border-color: var(--site-color);
    background: rgba(var(--site-color-rgb), .08);
}

/* ═══════════════════════════════════════════
   15. RESPONSIVE UTILITIES
═══════════════════════════════════════════ */
@media (max-width: 575px) {
    body { font-size: var(--font-size-base); }
    .entry-content { font-size: var(--font-size-base); }
    .widget-title { font-size: var(--font-size-sm); }
    #site-header .content-layout-row-inner { --row-padding: .6rem; }
    .site-logo img { min-width: 90px; max-width: 130px !important; }
}

@media (min-width: 576px) and (max-width: 767px) {
    .post-loop-item:hover { transform: translateY(-3px); }
}

@media (min-width: 992px) {
    .post-loop-item:hover { transform: translateY(-6px); }
}

/* ═══════════════════════════════════════════
   16. ANIMATIONS & MICRO-INTERACTIONS
═══════════════════════════════════════════ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
    from { background-position: -200% 0; }
    to   { background-position: 200% 0; }
}

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--glob-border-radius-sm);
}

/* Entrance animation for article cards */
.post-loop-item {
    animation: fadeInUp .4s ease both;
}

/* ═══════════════════════════════════════════
   17. PRINT STYLES
═══════════════════════════════════════════ */
@media print {
    #site-header, #site-footer, #side-menu,
    #news-ticker, #back-to-top, .share-buttons,
    .widget, .ad-container { display: none !important; }
    body { font-size: 12pt; color: #000; background: #fff; }
    .entry-content { max-width: 100%; }
    a::after { content: " (" attr(href) ")"; font-size: 10pt; color: #666; }
}
