/* ===========================================================================
   EGHTESAD24 — DESIGN SYSTEM v3.0
   Modern Editorial · Premium · Minimal · Financial News
   
   Inspired by: Bloomberg, The Verge, Apple
   Principles: Clarity, Density, Hierarchy, Speed
   
   This file replaces ALL previous CSS variables and base styles.
   =========================================================================== */

/* ===========================================================================
   1. DESIGN TOKENS
   =========================================================================== */

:root {
    /* --- 1.1 Color Primitives --- */
    --navy-900: #0A0E1A;
    --navy-800: #0F172A;
    --navy-700: #1E293B;
    --navy-600: #334155;
    --navy-500: #475569;
    --navy-400: #64748B;
    --navy-300: #94A3B8;
    --navy-200: #CBD5E1;
    --navy-100: #E2E8F0;
    --navy-50: #F1F5F9;

    --blue-600: #1D4ED8;
    --blue-500: #2563EB;
    --blue-400: #3B82F6;
    --blue-300: #60A5FA;
    --blue-100: #DBEAFE;
    --blue-50: #EFF6FF;

    --red-600: #B91C1C;
    --red-500: #DC2626;
    --red-400: #F87171;
    --red-100: #FEE2E2;

    --green-600: #15803D;
    --green-500: #16A34A;
    --green-400: #4ADE80;
    --green-100: #DCFCE7;

    --amber-600: #D97706;
    --amber-500: #F59E0B;
    --amber-400: #FBBF24;
    --amber-100: #FEF3C7;

    --purple-500: #8B5CF6;
    --purple-400: #A78BFA;
    --purple-100: #EDE9FE;

    --cyan-500: #06B6D4;
    --cyan-100: #CFFAFE;

    /* --- 1.2 Semantic Colors (Light Mode) --- */
    --bg-base: #FFFFFF;
    --bg-subtle: #F8FAFC;
    --bg-muted: #F1F5F9;
    --bg-elevated: #FFFFFF;
    --bg-overlay: rgba(10, 14, 26, 0.6);

    --text-primary: #0A0E1A;
    --text-secondary: #334155;
    --text-tertiary: #64748B;
    --text-inverse: #FFFFFF;
    --text-link: #2563EB;
    --text-breaking: #DC2626;

    --border-default: #E2E8F0;
    --border-strong: #CBD5E1;
    --border-focus: #3B82F6;

    --accent-brand: #2563EB;
    --accent-brand-hover: #1D4ED8;
    --accent-breaking: #DC2626;
    --accent-success: #16A34A;
    --accent-warning: #F59E0B;
    --accent-purple: #8B5CF6;

    /* --- 1.3 Typography Scale --- */
    /* Based on 1.250 (Major Third) modular scale */
    --font-sans: 'Vazirmatn', 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'Sarasa Mono SC', 'JetBrains Mono', monospace;

    --text-2xs: 0.625rem;   /* 10px - badges, fine print */
    --text-xs: 0.6875rem;   /* 11px - meta, labels */
    --text-sm: 0.8125rem;   /* 13px - body small, excerpts */
    --text-base: 0.9375rem; /* 15px - body, card titles */
    --text-md: 1.0625rem;   /* 17px - body large */
    --text-lg: 1.25rem;     /* 20px - section headings */
    --text-xl: 1.5rem;      /* 24px - hero secondary */
    --text-2xl: 1.75rem;    /* 28px - hero main */
    --text-3xl: 2rem;       /* 32px - article title */
    --text-4xl: 2.5rem;     /* 40px - display */

    --leading-none: 1;
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    --leading-loose: 1.8;

    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --weight-extrabold: 800;

    /* --- 1.4 Spacing Scale --- */
    /* Based on 4px base unit */
    --space-0: 0;
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.5rem;    /* 24px */
    --space-6: 2rem;      /* 32px */
    --space-7: 2.5rem;    /* 40px */
    --space-8: 3rem;      /* 48px */
    --space-9: 4rem;      /* 64px */
    --space-10: 5rem;     /* 80px */

    /* --- 1.5 Border Radius --- */
    --radius-sm: 0.3125rem;   /* 5px */
    --radius-md: 0.5rem;      /* 8px */
    --radius-lg: 0.75rem;     /* 12px */
    --radius-xl: 1rem;        /* 16px */
    --radius-2xl: 1.25rem;    /* 20px */
    --radius-full: 9999px;

    /* --- 1.6 Shadows --- */
    --shadow-xs: 0 1px 2px 0 rgba(10, 14, 26, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(10, 14, 26, 0.08), 0 1px 2px -1px rgba(10, 14, 26, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(10, 14, 26, 0.08), 0 2px 4px -2px rgba(10, 14, 26, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(10, 14, 26, 0.08), 0 4px 6px -4px rgba(10, 14, 26, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(10, 14, 26, 0.1), 0 8px 10px -6px rgba(10, 14, 26, 0.06);
    --shadow-2xl: 0 25px 50px -12px rgba(10, 14, 26, 0.25);
    --shadow-inner: inset 0 2px 4px 0 rgba(10, 14, 26, 0.05);

    /* --- 1.7 Transitions --- */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.45, 0, 0.15, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    --duration-fast: 120ms;
    --duration-normal: 200ms;
    --duration-slow: 400ms;

    --transition-color: color var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
    --transition-transform: transform var(--duration-normal) var(--ease-out);
    --transition-shadow: box-shadow var(--duration-normal) var(--ease-out);
    --transition-all: all var(--duration-normal) var(--ease-out);

    /* --- 1.8 Layout --- */
    --container-max: 1280px;
    --container-narrow: 768px;
    --container-wide: 1440px;
    --header-height: 4.5rem;
    --sidebar-width: 320px;

    /* --- 1.9 Z-Index --- */
    --z-base: 1;
    --z-dropdown: 50;
    --z-sticky: 80;
    --z-header: 100;
    --z-overlay: 200;
    --z-modal: 300;
    --z-toast: 400;
}

/* --- Dark Mode Overrides --- */
body.dark-mode {
    --bg-base: #0A0E1A;
    --bg-subtle: #0F172A;
    --bg-muted: #1E293B;
    --bg-elevated: #111827;
    --bg-overlay: rgba(0, 0, 0, 0.7);

    --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-tertiary: #64748B;
    --text-inverse: #0A0E1A;

    --border-default: #1E293B;
    --border-strong: #334155;

    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

/* ===========================================================================
   2. BASE RESET & TYPOGRAPHY
   =========================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    background: var(--bg-subtle);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
    transition: background-color var(--duration-normal) var(--ease-out), color var(--duration-normal) var(--ease-out);
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; transition: var(--transition-color); }
button { font-family: inherit; cursor: pointer; border: 0; background: none; }
ul, ol { list-style: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }

::selection { background: var(--blue-100); color: var(--blue-600); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-muted); }
::-webkit-scrollbar-thumb { background: var(--navy-300); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--navy-400); }

:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* Heading System */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--weight-bold);
    line-height: var(--leading-tight);
    letter-spacing: -0.005em;
    color: var(--text-primary);
}
h1 { font-size: var(--text-3xl); font-weight: var(--weight-extrabold); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

/* ===========================================================================
   3. LAYOUT PRIMITIVES
   =========================================================================== */

.container { width: 100%; max-width: var(--container-max); margin: 0 auto; padding: 0 var(--space-4); }
@media (min-width: 768px) { .container { padding: 0 var(--space-5); } }

.section { padding: var(--space-6) 0; }
.section-sm { padding: var(--space-5) 0; }

/* ===========================================================================
   4. COMPONENTS
   =========================================================================== */

/* --- 4.1 Buttons --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm); font-weight: var(--weight-semibold);
    border-radius: var(--radius-md);
    transition: var(--transition-all);
    white-space: nowrap; min-height: 2.5rem;
}
.btn-primary { background: var(--accent-brand); color: var(--text-inverse); }
.btn-primary:hover { background: var(--accent-brand-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--bg-muted); color: var(--text-primary); }
.btn-secondary:hover { background: var(--navy-100); }
.btn-outline { border: 1px solid var(--border-strong); color: var(--text-primary); }
.btn-outline:hover { border-color: var(--accent-brand); color: var(--accent-brand); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-muted); color: var(--text-primary); }
.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); min-height: 2rem; }
.btn-lg { padding: var(--space-3) var(--space-5); font-size: var(--text-md); min-height: 3rem; }

/* --- 4.2 Badges --- */
.badge {
    display: inline-flex; align-items: center; gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-2xs); font-weight: var(--weight-bold);
    border-radius: var(--radius-sm);
    line-height: 1.4; letter-spacing: 0.01em;
}
.badge-breaking { background: var(--accent-breaking); color: #fff; }
.badge-breaking .dot { width: 5px; height: 5px; border-radius: var(--radius-full); background: #fff; animation: pulse-dot 1.5s infinite; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.badge-category { color: #fff; }

/* --- 4.3 Cards --- */
.ds-card {
    background: var(--bg-elevated); border: 1px solid var(--border-default);
    border-radius: var(--radius-lg); overflow: hidden;
    transition: var(--transition-transform), var(--transition-shadow), border-color var(--duration-fast) var(--ease-out);
}
.ds-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.ds-card-image { position: relative; overflow: hidden; background: var(--bg-muted); }
.ds-card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 400ms var(--ease-out); }
.ds-card:hover .ds-card-image img { transform: scale(1.04); }
.ds-card-body { padding: var(--space-3) var(--space-4); }
.ds-card-title { font-size: var(--text-base); font-weight: var(--weight-bold); line-height: var(--leading-snug); color: var(--text-primary); }
.ds-card:hover .ds-card-title { color: var(--accent-brand); }
.ds-card-meta { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-tertiary); }

/* --- 4.4 Inputs --- */
.input {
    width: 100%; padding: var(--space-2) var(--space-3);
    background: var(--bg-base); border: 1px solid var(--border-default);
    border-radius: var(--radius-md); color: var(--text-primary);
    font-size: var(--text-sm); transition: var(--transition-color);
    outline: none;
}
.input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--blue-100); }

/* --- 4.5 Section Heading --- */
.ds-section-head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
    margin-bottom: var(--space-4); padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--text-primary);
}
.ds-section-title { font-size: var(--text-lg); font-weight: var(--weight-extrabold); display: flex; align-items: center; gap: var(--space-2); }
.ds-section-title::before { content: ''; width: 4px; height: 1.25rem; background: var(--accent-breaking); border-radius: var(--radius-full); }

/* --- 4.6 Pagination --- */
.ds-pagination { display: flex; align-items: center; justify-content: center; gap: var(--space-1); }
.ds-page-btn {
    display: flex; align-items: center; justify-content: center;
    min-width: 2.25rem; height: 2.25rem; padding: 0 var(--space-2);
    font-size: var(--text-sm); font-weight: var(--weight-semibold);
    border-radius: var(--radius-md); border: 1px solid var(--border-default);
    background: var(--bg-elevated); color: var(--text-secondary);
    transition: var(--transition-all);
}
.ds-page-btn:hover { border-color: var(--accent-brand); color: var(--accent-brand); }
.ds-page-btn.active { background: var(--text-primary); color: var(--text-inverse); border-color: var(--text-primary); }

/* --- 4.7 Alerts --- */
.ds-alert { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--text-sm); }
.ds-alert-info { background: var(--blue-50); color: var(--blue-600); }
.ds-alert-success { background: var(--green-100); color: var(--green-600); }
.ds-alert-warning { background: var(--amber-100); color: var(--amber-600); }
.ds-alert-error { background: var(--red-100); color: var(--red-600); }

/* --- 4.8 Tables --- */
.ds-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.ds-table th { text-align: right; padding: var(--space-2) var(--space-3); font-weight: var(--weight-bold); color: var(--text-secondary); border-bottom: 2px solid var(--border-strong); }
.ds-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-default); color: var(--text-primary); }
.ds-table tr:hover td { background: var(--bg-muted); }

/* ===========================================================================
   5. ANIMATIONS & MICRO-INTERACTIONS
   =========================================================================== */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-in-right { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes scale-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

.animate-fade-in { animation: fade-in var(--duration-normal) var(--ease-out) both; }
.animate-slide-up { animation: slide-up var(--duration-slow) var(--ease-out) both; }
.animate-slide-in-right { animation: slide-in-right var(--duration-normal) var(--ease-out) both; }
.animate-scale-in { animation: scale-in var(--duration-normal) var(--ease-out) both; }

/* Scroll Reveal */
.reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out); will-change: opacity, transform; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ===========================================================================
   6. UTILITIES
   =========================================================================== */

.text-2xs { font-size: var(--text-2xs); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }

.font-normal { font-weight: var(--weight-normal); }
.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold { font-weight: var(--weight-bold); }
.font-extrabold { font-weight: var(--weight-extrabold); }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-brand { color: var(--accent-brand); }
.text-breaking { color: var(--accent-breaking); }

.bg-base { background: var(--bg-base); }
.bg-subtle { background: var(--bg-subtle); }
.bg-muted { background: var(--bg-muted); }
.bg-elevated { background: var(--bg-elevated); }

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.shadow-xs { box-shadow: var(--shadow-xs); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

.tabular { font-variant-numeric: tabular-nums; }

/* ===========================================================================
   7. RESPONSIVE BREAKPOINTS
   =========================================================================== */
/* Mobile First: Base styles target mobile (375px+) */
/* sm: 640px | md: 768px | lg: 1024px | xl: 1280px | 2xl: 1440px */

/* ===========================================================================
   8. ACCESSIBILITY
   =========================================================================== */

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; top: -100px; right: var(--space-4); z-index: var(--z-toast);
    background: var(--text-primary); color: var(--text-inverse);
    padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
    font-weight: var(--weight-bold); transition: top var(--duration-fast) var(--ease-out);
}
.skip-link:focus { top: var(--space-4); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .reveal { opacity: 1 !important; transform: none !important; }
}

/* ===========================================================================
   9. PRINT
   =========================================================================== */

@media print {
    .no-print { display: none !important; }
    body { background: #fff !important; color: #000 !important; }
}
