/* ============================
   LIZIU DSA - Design System
   main.css - Variables, reset, typography, base components
   ============================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ---- CSS Variables ---- */
:root {
    /* Primary - Vibrant Purple */
    --primary-50: #F5F3FF;
    --primary-100: #EDE9FE;
    --primary-200: #DDD6FE;
    --primary-300: #C4B5FD;
    --primary-400: #A78BFA;
    --primary-500: #8B5CF6;
    --primary-600: #7C3AED;
    --primary-700: #6D28D9;
    --primary: #8B5CF6;
    --primary-gradient: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%);
    --primary-gradient-hover: linear-gradient(135deg, #A78BFA 0%, #7C3AED 100%);

    /* Difficulty Colors */
    --easy: #10B981;
    --easy-bg: #D1FAE5;
    --easy-text: #065F46;
    --medium: #F59E0B;
    --medium-bg: #FEF3C7;
    --medium-text: #92400E;
    --hard: #EF4444;
    --hard-bg: #FEE2E2;
    --hard-text: #991B1B;

    /* Semantic Colors */
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;

    /* Neutrals */
    --white: #FFFFFF;
    --gray-50: #FAFBFC;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    /* Surfaces */
    --bg: #FAFBFC;
    --surface: #FFFFFF;
    --surface-hover: #F9FAFB;
    --border: #E5E7EB;
    --border-light: #F3F4F6;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

    /* Type Scale - Major Third (1.25) */
    --text-xs: 0.64rem;     /* 10.24px */
    --text-sm: 0.8rem;      /* 12.8px */
    --text-base: 1rem;      /* 16px */
    --text-md: 1.125rem;    /* 18px */
    --text-lg: 1.25rem;     /* 20px */
    --text-xl: 1.563rem;    /* 25px */
    --text-2xl: 1.953rem;   /* 31.25px */
    --text-3xl: 2.441rem;   /* 39px */
    --text-4xl: 3.052rem;   /* 48.8px */

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

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-purple: 0 4px 14px rgba(139, 92, 246, 0.25);
    --shadow-purple-lg: 0 10px 25px rgba(139, 92, 246, 0.3);

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-2xl: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-index scale */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-nav: 1000;
    --z-modal: 1100;
    --z-toast: 1200;
}

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

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

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--gray-900);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, svg {
    display: block;
    max-width: 100%;
}

button {
    font-family: inherit;
    cursor: pointer;
}

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

a:hover {
    color: var(--primary-700);
}

ul, ol {
    list-style: none;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.25;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

h1 { font-size: var(--text-4xl); margin-bottom: var(--sp-6); }
h2 { font-size: var(--text-3xl); margin-bottom: var(--sp-5); }
h3 { font-size: var(--text-2xl); margin-bottom: var(--sp-4); }
h4 { font-size: var(--text-xl); margin-bottom: var(--sp-3); }
h5 { font-size: var(--text-lg); margin-bottom: var(--sp-3); }
h6 { font-size: var(--text-md); margin-bottom: var(--sp-2); }

p {
    margin-bottom: var(--sp-4);
    color: var(--gray-700);
    line-height: 1.7;
}

strong { font-weight: 600; }

/* ---- Layout ---- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--sp-6);
}

.container-narrow {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--sp-6);
}

.section {
    padding: var(--sp-16) 0;
}

.section + .section {
    padding-top: 0;
}

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--sp-6);
    transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-flat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--sp-6);
}

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.4;
}

.badge-primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-easy {
    background: var(--easy-bg);
    color: var(--easy-text);
}

.badge-medium {
    background: var(--medium-bg);
    color: var(--medium-text);
}

.badge-hard {
    background: var(--hard-bg);
    color: var(--hard-text);
}

.badge-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--gray-600);
}

/* Difficulty dot */
.difficulty-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.difficulty-dot.easy { background: var(--easy); }
.difficulty-dot.medium { background: var(--medium); }
.difficulty-dot.hard { background: var(--hard); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-6);
    font-size: var(--text-base);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary-gradient);
    color: var(--white);
    box-shadow: var(--shadow-purple);
}

.btn-primary:hover {
    background: var(--primary-gradient-hover);
    box-shadow: var(--shadow-purple-lg);
    transform: translateY(-1px);
    color: var(--white);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--white);
}

.btn-sm {
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-sm);
}

.btn-lg {
    padding: var(--sp-4) var(--sp-8);
    font-size: var(--text-lg);
}

/* ---- Callouts ---- */
.callout {
    padding: var(--sp-4) var(--sp-5);
    border-radius: var(--radius-lg);
    border-left: 4px solid;
    margin-bottom: var(--sp-6);
}

.callout-info {
    background: #EFF6FF;
    border-left-color: var(--info);
    color: #1E40AF;
}

.callout-success {
    background: #ECFDF5;
    border-left-color: var(--success);
    color: #065F46;
}

.callout-warning {
    background: #FFFBEB;
    border-left-color: var(--warning);
    color: #92400E;
}

.callout-danger {
    background: #FEF2F2;
    border-left-color: var(--danger);
    color: #991B1B;
}

.callout-purple {
    background: var(--primary-50);
    border-left-color: var(--primary);
    color: var(--primary-700);
}

.callout h4 {
    font-size: var(--text-base);
    margin-bottom: var(--sp-2);
}

.callout p:last-child {
    margin-bottom: 0;
}

/* ---- Code (inline) ---- */
code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--gray-100);
    color: var(--primary-700);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
}

pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

/* ---- Tables ---- */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: var(--sp-6);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

thead {
    background: var(--gray-50);
}

th {
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--border);
}

td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-light);
    color: var(--gray-600);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--gray-50);
}

/* ---- Progress Bar ---- */
.progress {
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress-thin {
    height: 3px;
}

/* ---- Toggle / Details ---- */
details {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--sp-4);
}

details summary {
    padding: var(--sp-4);
    cursor: pointer;
    font-weight: 500;
    color: var(--gray-700);
    transition: color var(--transition);
    list-style: none;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::before {
    content: '▸';
    display: inline-block;
    margin-right: var(--sp-2);
    transition: transform var(--transition);
}

details[open] summary::before {
    transform: rotate(90deg);
}

details[open] summary {
    color: var(--primary);
    border-bottom: 1px solid var(--border-light);
}

details > *:not(summary) {
    padding: var(--sp-4);
}

/* ---- Spinner ---- */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---- Animations ---- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.animate-fade-in { animation: fadeIn 0.4s ease-out both; }
.animate-fade-in-up { animation: fadeInUp 0.5s ease-out both; }

/* Stagger children */
.stagger-children > * {
    animation: fadeInUp 0.4s ease-out both;
}
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }

/* Scroll-triggered */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- 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;
}

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

/* ---- Utility ---- */
.text-center { text-align: center; }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }
.text-muted { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.font-mono { font-family: var(--font-mono); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }

.mt-4 { margin-top: var(--sp-4); }
.mt-8 { margin-top: var(--sp-8); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-8 { margin-bottom: var(--sp-8); }
.hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    :root {
        --text-4xl: 2.25rem;
        --text-3xl: 1.875rem;
        --text-2xl: 1.5rem;
    }

    .container {
        padding: 0 var(--sp-4);
    }

    .section {
        padding: var(--sp-12) 0;
    }
}

@media (max-width: 480px) {
    :root {
        --text-4xl: 1.875rem;
        --text-3xl: 1.5rem;
    }
}
