/* ============================================
   Mesh — Base Design System
   Enterprise-grade dark theme
   ============================================ */

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

/* ============================================
   CSS Custom Properties
   ============================================ */
:root {
    /* Backgrounds */
    --bg-primary: #0a0a0f;
    --bg-secondary: #0e0e16;
    --bg-card: #12121a;
    --bg-code: #0d0d14;

    /* Text */
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;

    /* Accents */
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.08);
    --accent-green: #22c55e;
    --accent-green-glow: rgba(34, 197, 94, 0.08);
    --accent-cyan: #67e8f9;
    --accent-yellow: #facc15;
    --accent-red: #ef4444;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #a78bfa 50%, #818cf8 100%);
    --gradient-green: linear-gradient(135deg, #22c55e 0%, #4ade80 100%);

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-subtle: rgba(255, 255, 255, 0.04);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s ease;

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

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4), 0 6px 10px rgba(0, 0, 0, 0.25);
}

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

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

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-secondary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100vh;
}

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

input,
button,
textarea,
select {
    font: inherit;
    color: inherit;
}

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

a:hover {
    color: var(--accent-hover);
}

ul, ol {
    list-style: none;
}

table {
    border-collapse: collapse;
    width: 100%;
}

/* ============================================
   Base Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(2.25rem, 5vw, 3.5rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

h2 {
    font-size: clamp(1.75rem, 3.5vw, 2.5rem);
    font-weight: 700;
}

h3 {
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
}

h4 {
    font-size: 1.125rem;
    font-weight: 600;
}

h5 {
    font-size: 0.95rem;
    font-weight: 600;
}

h6 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

p {
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 65ch;
}

strong, b {
    font-weight: 600;
    color: var(--text-primary);
}

small {
    font-size: 0.85rem;
}

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--bg-code);
    color: var(--accent-cyan);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

pre {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    background: var(--bg-code);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    overflow-x: auto;
    line-height: 1.6;
}

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

blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.25rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 2rem 0;
}

::selection {
    background: rgba(99, 102, 241, 0.3);
    color: var(--text-primary);
}

/* ============================================
   Container
   ============================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.container--narrow {
    max-width: 800px;
}

.container--wide {
    max-width: 1400px;
}

@media (min-width: 768px) {
    .container {
        padding: 0 2rem;
    }
}

/* ============================================
   Section Padding
   ============================================ */
.section {
    padding: 5rem 0;
}

.section--lg {
    padding: 7rem 0;
}

.section--sm {
    padding: 3rem 0;
}

@media (max-width: 768px) {
    .section {
        padding: 3.5rem 0;
    }

    .section--lg {
        padding: 4.5rem 0;
    }
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-base);
    white-space: nowrap;
    user-select: none;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Primary */
.btn--primary {
    background: var(--gradient-primary);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2), var(--shadow-sm);
}

.btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.35), var(--shadow-md);
    color: #ffffff;
}

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

/* Secondary */
.btn--secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn--secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
    transform: translateY(-1px);
}

/* Ghost */
.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.btn--ghost:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

/* Green variant */
.btn--green {
    background: var(--gradient-green);
    color: #ffffff;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.2), var(--shadow-sm);
}

.btn--green:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.35), var(--shadow-md);
    color: #ffffff;
}

/* Sizes */
.btn--sm {
    padding: 0.45rem 1rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn--lg {
    padding: 0.9rem 2rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    transition: all var(--transition-base);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card--flat {
    border-color: var(--border-subtle);
}

.card--flat:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border-color);
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 100px;
    border: 1px solid;
    line-height: 1.2;
}

.badge--purple,
.badge {
    color: var(--accent);
    background: var(--accent-glow);
    border-color: rgba(99, 102, 241, 0.2);
}

.badge--green {
    color: var(--accent-green);
    background: var(--accent-green-glow);
    border-color: rgba(34, 197, 94, 0.2);
}

.badge--yellow {
    color: var(--accent-yellow);
    background: rgba(250, 204, 21, 0.08);
    border-color: rgba(250, 204, 21, 0.2);
}

.badge--red {
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
}

.badge--cyan {
    color: var(--accent-cyan);
    background: rgba(103, 232, 249, 0.08);
    border-color: rgba(103, 232, 249, 0.2);
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-muted { color: var(--text-muted); }
.text-primary { color: var(--text-primary); }
.text-accent { color: var(--accent); }
.text-green { color: var(--accent-green); }

.font-mono { font-family: var(--font-mono); }

.mx-auto { margin-left: auto; margin-right: auto; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.gap-4 { gap: 2rem; }

.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;
}

.hidden { display: none; }

/* ============================================
   Scrollbar (WebKit)
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) var(--bg-primary);
}

/* ============================================
   Focus & Accessibility
   ============================================ */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@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;
    }
}

/* ── Tooltip ────────────────────────────────── */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent, #00d4aa);
    color: #0a0e1a;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: help;
    position: relative;
    margin-left: 0.4rem;
    vertical-align: middle;
    line-height: 1;
}
.tooltip-text {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: 340px;
    padding: 1rem 1.2rem;
    background: #1a1f35;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: #d1d5db;
    font-size: 0.82rem;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1a1f35;
}
.tooltip-icon:hover .tooltip-text,
.tooltip-icon:focus .tooltip-text {
    display: block;
}
@media (max-width: 600px) {
    .tooltip-text {
        width: 260px;
        left: auto;
        right: -10px;
        transform: none;
    }
    .tooltip-text::after {
        left: auto;
        right: 16px;
        transform: none;
    }
}
