/* ==========================================================================
   VARIABLES & DESIGN TOKENS
   ========================================================================== */
:root {
    /* CSS Layout Limits */
    --article-width: 1120px; /* Card maximum outer width */
    --reading-width: 950px;  /* Max text content width (920px-980px range) */

    /* Spacing System Scale */
    --space-1: 0.25rem;  /* 4px */
    --space-2: 0.5rem;   /* 8px */
    --space-3: 0.75rem;  /* 12px */
    --space-4: 1rem;     /* 16px */
    --space-5: 1.25rem;  /* 20px */
    --space-6: 1.5rem;   /* 24px */
    --space-8: 2rem;     /* 32px */
    --space-10: 2.5rem;  /* 40px */
    --space-12: 3rem;    /* 48px */
    --space-16: 4rem;    /* 64px */
    --space-20: 5rem;    /* 80px */

    /* Fluid Typography (clamp) */
    --font-size-p: clamp(1rem, 0.95rem + 0.35vw, 1.125rem);
    --font-size-h1: clamp(2.4rem, 2rem + 1vw, 3rem);
    --font-size-h2: clamp(1.75rem, 1.55rem + 0.7vw, 2rem);
    --font-size-h3: clamp(1.4rem, 1.25rem + 0.4vw, 1.6rem);
    --font-size-h4: clamp(1.2rem, 1.15rem + 0.25vw, 1.35rem);
    --font-size-h5: clamp(1.05rem, 1.02rem + 0.15vw, 1.15rem);
    --font-size-h6: clamp(0.95rem, 0.93rem + 0.1vw, 1rem);
    
    /* Line Heights & Families */
    --line-height-body: 1.95;
    --line-height-heading: 1.3;
    
    /* Motion Transitions */
    --transition-speed: 0.2s;
    --transition-timing: ease;
    --transition-standard: background-color var(--transition-speed) var(--transition-timing),
                           border-color var(--transition-speed) var(--transition-timing),
                           color var(--transition-speed) var(--transition-timing),
                           box-shadow var(--transition-speed) var(--transition-timing),
                           transform var(--transition-speed) var(--transition-timing);

    /* Semantic Design Tokens (Dark Theme Defaults) */
    --surface: rgb(var(--color-bg));
    --surface-elevated: rgb(var(--color-card) / 0.4);
    --surface-hover: rgb(var(--color-card) / 0.6);
    --text-primary: rgb(var(--color-white));
    --text-secondary: rgb(var(--color-white) / 0.85);
    --text-muted: rgb(var(--color-white) / 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    
    /* Subtle Shadows (no heavy shadows) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.light-mode {
    /* Original Light Mode Color Overrides */
    --color-white: 0 0 0; /* Pure black for text */
    --color-black: 255 255 255;
    --color-bg: 248 250 252;
    --color-card: 255 255 255;
    --color-gray: 71 85 105;

    /* Semantic Design Tokens (Light Theme Overrides) */
    --surface: rgb(var(--color-bg));
    --surface-elevated: rgba(255, 255, 255, 0.9);
    --surface-hover: rgba(255, 255, 255, 0.95);
    --text-primary: #000000; /* Pure black */
    --text-secondary: #000000; /* Pure black */
    --text-muted: #555555;
    --border-color: rgba(0, 0, 0, 0.08);
    
    /* Soft Light Mode Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   LAYOUT & ALIGNMENT
   ========================================================================== */
body { 
    font-family: 'Outfit', sans-serif; 
    background-color: var(--surface); 
    color: var(--text-primary); 
    overflow-x: hidden; 
}

[dir="rtl"] .main-nav { 
    flex-direction: row-reverse; 
}

/* AGGRESSIVE LIGHT MODE OVERRIDES */
.light-mode .text-white { color: rgb(var(--color-white)) !important; }
.light-mode .text-white\/40 { color: rgba(var(--color-white), 0.4) !important; }
.light-mode .text-white\/60 { color: rgba(var(--color-white), 0.6) !important; }
.light-mode .text-white\/70 { color: rgba(var(--color-white), 0.7) !important; }
.light-mode .text-white\/80 { color: rgba(var(--color-white), 0.8) !important; }
.light-mode .text-white\/90 { color: rgba(var(--color-white), 0.9) !important; }

.light-mode .bg-white\/5 { background-color: rgba(0,0,0,0.03) !important; border-color: rgba(0,0,0,0.05) !important; }
.light-mode .bg-white\/10 { background-color: rgba(0,0,0,0.05) !important; border-color: rgba(0,0,0,0.08) !important; }
.light-mode .border-white\/10 { border-color: rgba(0,0,0,0.08) !important; }

.light-mode .bg-card-dark\/40, .light-mode .bg-card-dark\/80 {
    background-color: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(20px) !important;
}

/* Hero Section text must remain white in all modes (Hero has dark image bg) */
.article-hero .text-white,
.light-mode .article-hero .text-white {
    color: #ffffff !important;
}
.article-hero .text-white\/40,
.light-mode .article-hero .text-white\/40 {
    color: rgba(255, 255, 255, 0.4) !important;
}
.article-hero .text-white\/60,
.light-mode .article-hero .text-white\/60 {
    color: rgba(255, 255, 255, 0.6) !important;
}
.article-hero .text-white\/70,
.light-mode .article-hero .text-white\/70 {
    color: rgba(255, 255, 255, 0.7) !important;
}
.article-hero .text-white\/80,
.light-mode .article-hero .text-white\/80 {
    color: rgba(255, 255, 255, 0.8) !important;
}
.article-hero .text-white\/90,
.light-mode .article-hero .text-white\/90 {
    color: rgba(255, 255, 255, 0.9) !important;
}

/* Visual Alignment for Hero Headers & Content Cards */
.content-wrap, .hero-content-wrap {
    max-width: var(--article-width);
    width: 100%;
    padding-left: var(--space-6);
    padding-right: var(--space-6);
}
@media (min-width: 641px) and (max-width: 1024px) {
    .content-wrap, .hero-content-wrap {
        padding-left: var(--space-12);
        padding-right: var(--space-12);
    }
}
@media (min-width: 1025px) {
    .content-wrap, .hero-content-wrap {
        padding-left: var(--space-20);
        padding-right: var(--space-20);
    }
}

.hero-text-wrap {
    max-width: var(--reading-width);
    width: 100%;
}

/* Centered Editorial Card */
.content-wrap {
    background: var(--surface-elevated);
    backdrop-filter: blur(30px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding-top: var(--space-8);
    padding-bottom: var(--space-16);
    margin-top: calc(-1 * var(--space-16));
    position: relative;
    z-index: 20;
    box-shadow: var(--shadow-lg);
}
@media (min-width: 641px) {
    .content-wrap {
        border-radius: 24px;
        padding-top: var(--space-12);
        padding-bottom: var(--space-18, 4.5rem);
        margin-top: calc(-1 * var(--space-24, 6rem));
    }
}
@media (min-width: 1025px) {
    .content-wrap {
        border-radius: 32px;
        padding-top: var(--space-16);
        padding-bottom: var(--space-20);
        margin-top: calc(-1 * var(--space-12));
    }
}

/* Light Mode Overrides for Layout */
.light-mode .content-wrap {
    background: var(--surface-elevated) !important;
    box-shadow: var(--shadow-lg) !important;
    border-color: var(--border-color) !important;
}

/* ==========================================================================
   TYPOGRAPHY & READING EXPERIENCE
   ========================================================================== */
.article-content {
    font-size: var(--font-size-p);
    line-height: var(--line-height-body);
    color: var(--text-secondary);
    max-width: var(--reading-width);
    margin-inline: auto;
}

.post-body-content h1, 
.post-body-content h2, 
.post-body-content h3, 
.post-body-content h4, 
.post-body-content h5, 
.post-body-content h6 {
    color: var(--text-primary);
    font-weight: 800;
    letter-spacing: -0.015em;
    line-height: var(--line-height-heading);
}

.post-body-content h1 { font-size: var(--font-size-h1); margin-top: var(--space-16); margin-bottom: var(--space-6); background: linear-gradient(to right, var(--color-primary), #60a5fa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.post-body-content h2 { font-size: var(--font-size-h2); margin-top: var(--space-12); margin-bottom: var(--space-5); border-bottom: 1px solid var(--border-color); padding-bottom: var(--space-2); }
.post-body-content h3 { font-size: var(--font-size-h3); margin-top: var(--space-10); margin-bottom: var(--space-4); }
.post-body-content h4 { font-size: var(--font-size-h4); margin-top: var(--space-8); margin-bottom: var(--space-3); }
.post-body-content h5 { font-size: var(--font-size-h5); margin-top: var(--space-6); margin-bottom: var(--space-3); color: var(--color-primary); }
.post-body-content h6 { font-size: var(--font-size-h6); margin-top: var(--space-6); margin-bottom: var(--space-2); color: var(--text-muted); }

/* Stacked headings top margin override */
.post-body-content h2 + h3, 
.post-body-content h3 + h4,
.post-body-content h4 + h5 {
    margin-top: var(--space-5);
}

.post-body-content p { 
    margin-top: 0;
    margin-bottom: var(--space-6); 
    letter-spacing: 0.01em;
}

/* Modern Dropcap */
.post-body-content p:first-of-type::first-letter {
    float: left;
    font-size: 5rem;
    line-height: 0.85;
    font-weight: 900;
    color: var(--color-primary);
    margin-right: var(--space-3);
    margin-top: var(--space-2);
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, var(--color-primary), #60a5fa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
[dir="rtl"] .post-body-content p:first-of-type::first-letter {
    float: right;
    margin-right: 0;
    margin-left: var(--space-3);
}

/* ==========================================================================
   COMPONENTS
   ========================================================================== */

/* Reading Progress Bar */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: linear-gradient(to right, var(--color-primary), #60a5fa);
    z-index: 100;
    transition: width 0.1s var(--transition-timing);
}

/* Premium Article Header Hero */
.article-hero {
    position: relative;
    height: 75vh;
    min-height: 550px;
    display: flex;
    align-items: flex-end;
    padding-bottom: var(--space-20, 7rem);
    overflow: hidden;
    border-radius: 0 0 60px 60px;
}
.article-hero-bg {
    position: absolute;
    inset: 0;
    z-index: -1;
}
.article-hero-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.1);
    filter: brightness(0.4) saturate(1.2);
}
.article-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 40%, var(--surface));
    z-index: 0;
}

/* Modern Author Badge */
.author-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    padding: var(--space-2) var(--space-5) var(--space-2) var(--space-2);
    border-radius: 100px;
    margin-bottom: var(--space-6);
}

/* Modern Tags */
.post-tag {
    background: rgba(var(--color-white) / 0.05);
    border: 1px solid rgba(var(--color-white) / 0.1);
    color: var(--text-muted);
    padding: var(--space-2) var(--space-5);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.post-tag:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(var(--color-primary-rgb), 0.3);
}
.light-mode .post-tag {
    background: rgba(15, 23, 42, 0.04) !important;
    color: #475569 !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
}

/* Improved Share Buttons */
.share-btn-round {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white !important;
    box-shadow: var(--shadow-sm);
}
.share-btn-round:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: var(--shadow-md);
    filter: brightness(1.1);
}
.share-btn-round i { width: 20px; height: 20px; }

.light-mode .share-btn-round.bg-white\/10 { background-color: #f1f5f9 !important; color: #0f172a !important; border-color: #e2e8f0 !important; }
.light-mode .share-btn-round.bg-black { background-color: #0f172a !important; border-color: transparent !important; }
.light-mode .share-btn-round i, .light-mode .share-btn-round svg { color: white !important; }
.light-mode .share-btn-round.bg-white\/10 i, .light-mode .share-btn-round.bg-white\/10 svg { color: #0f172a !important; }

/* Prevent light-mode black text override on hovered social links/share buttons */
.light-mode .content-wrap a[title]:hover i,
.light-mode .content-wrap a[title]:hover svg,
.light-mode .share-btn-round:hover i,
.light-mode .share-btn-round:hover svg {
    color: #ffffff !important;
}

/* Images & Media Optimization */
.post-body-content img, 
.post-body-content iframe, 
.post-body-content video {
    max-width: 100%;
    height: auto;
    border-radius: 16px;
    margin: var(--space-8) auto var(--space-10);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: block;
}
@media (min-width: 768px) {
    .post-body-content img, 
    .post-body-content iframe, 
    .post-body-content video {
        border-radius: 24px;
        margin: var(--space-12) auto var(--space-12);
    }
}
.light-mode .post-body-content img {
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-md) !important;
}

/* Elegant Blockquotes */
.post-body-content blockquote { 
    position: relative;
    font-size: var(--font-size-p);
    font-style: italic; 
    color: var(--text-secondary); 
    padding: var(--space-6) var(--space-8); 
    margin: var(--space-8) 0 var(--space-10); 
    background: rgba(var(--color-white) / 0.02);
    border-left: 4px solid var(--color-primary);
    border-radius: 4px;
    line-height: 1.8;
}
[dir="rtl"] .post-body-content blockquote {
    border-left: none;
    border-right: 4px solid var(--color-primary);
}
.light-mode .post-body-content blockquote {
    background: rgba(15, 23, 42, 0.02) !important;
    color: var(--text-secondary) !important;
}

/* Restored Custom Lists */
.post-body-content ul { list-style-type: disc !important; }
.post-body-content ol { list-style-type: decimal !important; }
.post-body-content ul, .post-body-content ol { 
    margin-top: 0;
    margin-bottom: var(--space-6); 
    padding-left: var(--space-8);
}
[dir="rtl"] .post-body-content ul, [dir="rtl"] .post-body-content ol {
    padding-left: 0;
    padding-right: var(--space-8);
}
.post-body-content li { 
    margin-bottom: var(--space-2);
    line-height: 1.8;
}
.post-body-content li ul, .post-body-content li ol {
    margin-top: var(--space-2);
    margin-bottom: var(--space-2);
}

/* Table Wrappers & Modern Tables */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--space-8);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.post-body-content table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(var(--color-white) / 0.01);
}

.post-body-content th, .post-body-content td {
    padding: var(--space-4) var(--space-5);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.post-body-content th {
    background: rgba(var(--color-white) / 0.04);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    color: var(--color-primary);
    border-bottom: 2px solid var(--border-color);
}

.post-body-content tr:last-child td {
    border-bottom: none;
}

[dir="rtl"] .post-body-content th, 
[dir="rtl"] .post-body-content td {
    text-align: right;
}

/* FAQ Accordion Styles */
.post-body-content details {
    margin-bottom: var(--space-4);
    background: rgba(var(--color-white) / 0.03);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: var(--transition-standard);
}
.post-body-content details[open] {
    background: rgba(var(--color-white) / 0.05);
    border-color: var(--color-primary);
}
.post-body-content summary {
    padding: var(--space-5);
    font-weight: 800;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.post-body-content summary::after {
    content: '+';
    font-size: 1.5rem;
    color: var(--color-primary);
    transition: transform var(--transition-speed) var(--transition-timing);
}
.post-body-content details[open] summary::after {
    transform: rotate(45deg);
}
.post-body-content details div {
    padding: 0 var(--space-5) var(--space-5);
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Article Link Styles */
.post-body-content a {
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 4px;
    font-weight: 600;
}
.post-body-content a:hover {
    color: var(--text-primary);
}

/* WP Inspired Styles */
.wp-meta-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}
.wp-meta-item i {
    width: 1rem;
    height: 1rem;
    opacity: 0.7;
}
.author-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: var(--space-10);
    margin-top: var(--space-16);
}
.related-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    overflow: hidden;
}
.related-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}
.comment-input {
    background: rgba(var(--color-white) / 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: var(--space-4);
    width: 100%;
    color: var(--text-primary);
}
.comment-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(var(--color-white) / 0.08);
}

/* ==========================================================================
   ACCESSIBILITY & MOTION CONTROL
   ========================================================================== */

/* Visible WCAG Focus Outlines */
a:focus-visible, 
button:focus-visible, 
input:focus-visible, 
textarea:focus-visible, 
details:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 4px;
}

/* Motion Systems Transitions */
.share-btn-round, 
.post-tag, 
.content-wrap, 
.post-body-content a, 
.post-body-content details,
.related-card {
    transition: var(--transition-standard);
}

/* Respect Reduced Motion Settings */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-delay: 0s !important;
        animation-duration: 0s !important;
        animation-iteration-count: 1 !important;
        transition-delay: 0s !important;
        transition-duration: 0s !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */
@media print {
    /* Hide layout chrome, ads, widgets, and links */
    header, 
    footer, 
    .ad-placement, 
    .author-card, 
    .related-card, 
    .comment-input, 
    .share-btn-round, 
    .post-tag, 
    .author-badge, 
    .search-btn, 
    #mobile-menu-btn, 
    #reading-progress {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .content-wrap {
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .article-hero {
        height: auto !important;
        min-height: 0 !important;
        padding-bottom: var(--space-8) !important;
        border-radius: 0 !important;
    }
    
    .article-hero-bg, 
    .article-hero-overlay {
        display: none !important;
    }
    
    .hero-content-wrap {
        padding: 0 !important;
    }
    
    .article-content {
        max-width: 100% !important;
        color: black !important;
    }
}
