/* =========================================================
   CyberSecPlayground - Core Design System v3.3
   ========================================================= */

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }

/* ===== DESIGN TOKENS ===== */
:root {
    /* Colors */
    --bg-0: #06080b;
    --bg-1: #0d1117;
    --bg-2: #11161d;
    --bg-3: #161b22;
    --bg-4: #1c2128;
    --bg-hover: #1f2630;

    --surface-1: rgba(22, 27, 34, 0.6);
    --surface-2: rgba(22, 27, 34, 0.85);
    --glass-bg: rgba(13, 17, 23, 0.72);
    --glass-border: rgba(88, 166, 255, 0.15);

    --border-subtle: rgba(48, 54, 61, 0.5);
    --border-default: #30363d;
    --border-strong: #444c56;
    --border-accent: rgba(88, 166, 255, 0.4);

    --text-primary: #f0f6fc;
    --text-secondary: #c9d1d9;
    --text-tertiary: #8b949e;
    --text-muted: #6e7681;
    --text-inverse: #0d1117;

    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --accent-active: #388bfd;
    --accent-glow: rgba(88, 166, 255, 0.35);
    --accent-soft: rgba(88, 166, 255, 0.08);

    --secondary: #f0b429;
    --secondary-hover: #ffc93c;
    --secondary-glow: rgba(240, 180, 41, 0.35);

    --telegram: #229ED9;
    --telegram-hover: #37b1e6;

    --success: #3fb950;
    --success-soft: rgba(63, 185, 80, 0.12);
    --warning: #d29922;
    --warning-soft: rgba(210, 153, 34, 0.12);
    --danger: #f85149;
    --danger-soft: rgba(248, 81, 73, 0.12);

    /* Gradients */
    --grad-hero: linear-gradient(135deg, #0d2b3e 0%, #161b22 40%, #06080b 100%);
    --grad-accent: linear-gradient(135deg, #58a6ff 0%, #79c0ff 100%);
    --grad-gold: linear-gradient(135deg, #f0b429 0%, #ffc93c 100%);
    --grad-telegram: linear-gradient(135deg, #229ED9 0%, #37b1e6 100%);
    --grad-card-border: linear-gradient(135deg, rgba(88,166,255,0.5), rgba(240,180,41,0.3), rgba(88,166,255,0.1));
    --grad-text: linear-gradient(135deg, #58a6ff 0%, #79c0ff 50%, #f0b429 100%);

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.35);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.45);
    --shadow-xl: 0 16px 40px rgba(0,0,0,0.5);
    --shadow-accent: 0 8px 24px rgba(88, 166, 255, 0.25);
    --shadow-glow: 0 0 30px rgba(88, 166, 255, 0.2);

    /* Radius */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-2xl: 28px;
    --radius-full: 9999px;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

    /* Fluid typography */
    --fs-display: clamp(2.2rem, 7vw + 0.5rem, 5.5rem);
    --fs-h1: clamp(1.75rem, 4vw + 0.5rem, 2.75rem);
    --fs-h2: clamp(1.5rem, 2.5vw + 0.5rem, 2.25rem);
    --fs-h3: clamp(1.1rem, 1vw + 0.85rem, 1.4rem);
    --fs-body: clamp(0.95rem, 0.3vw + 0.88rem, 1.05rem);
    --fs-small: 0.875rem;
    --fs-xs: 0.8rem;
    --fs-2xs: 0.7rem;

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast: 150ms;
    --dur-base: 250ms;
    --dur-slow: 400ms;

    /* Layout */
    --container-xl: 1200px;
    --header-h: 68px;
}

/* ===== BASE ===== */
body {
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-1);
    min-height: 100vh;
    overflow-x: hidden;
    letter-spacing: -0.011em;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% 0%, rgba(88, 166, 255, 0.06), transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 100%, rgba(240, 180, 41, 0.04), transparent 60%);
    pointer-events: none;
    z-index: 0;
}

main, header, footer, section { position: relative; z-index: 1; }

/* ===== LAYOUT ===== */
.container {
    width: 100%;
    max-width: var(--container-xl);
    margin-inline: auto;
    padding-inline: clamp(1rem, 4vw, 2rem);
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

p { color: var(--text-secondary); }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--dur-fast) var(--ease-smooth);
}
a:hover { color: var(--accent-hover); }

::selection { background: var(--accent-soft); color: var(--accent-hover); }

/* ===== SKIP LINK ===== */
.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 9999;
    padding: 0.75rem 1.25rem;
    background: var(--accent);
    color: var(--text-inverse);
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: top var(--dur-base) var(--ease-out);
}
.skip-link:focus { top: 1rem; }

/* ===== SECTIONS ===== */
.section {
    padding: clamp(2rem, 4vw, 3.5rem) 0;
    position: relative;
}
.section + .section { border-top: 1px solid var(--border-subtle); }
.section-alt {
    background: var(--bg-0);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.section-header {
    text-align: center;
    max-width: 720px;
    margin: 0 auto clamp(1.5rem, 3vw, 2.25rem);
    padding-inline: 0.5rem;
}
.section-eyebrow {
    display: inline-block;
    font-size: var(--fs-2xs);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.6rem;
    padding: 0.28rem 0.8rem;
    background: var(--accent-soft);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-full);
}
.section-title {
    font-size: var(--fs-h2);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}
.section-title .accent {
    background: var(--grad-text);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.section-description {
    color: var(--text-tertiary);
    font-size: var(--fs-small);
    line-height: 1.65;
    max-width: 620px;
    margin-inline: auto;
}

/* ===== SCROLL REVEAL (robust) ===== */
.reveal,
.reveal-left,
.reveal-right {
    opacity: 0;
    transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
    will-change: opacity, transform;
}
.reveal { transform: translateY(24px); }
.reveal-left { transform: translateX(-30px); }
.reveal-right { transform: translateX(30px); }

.reveal-stagger > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.reveal.in-view,
.reveal.visible,
.reveal-left.in-view,
.reveal-left.visible,
.reveal-right.in-view,
.reveal-right.visible {
    opacity: 1;
    transform: translate(0, 0);
}

.reveal-stagger.in-view > *,
.reveal-stagger.visible > * {
    opacity: 1;
    transform: translateY(0);
}

.reveal-stagger.in-view > *:nth-child(1),
.reveal-stagger.visible > *:nth-child(1) { transition-delay: 0.05s; }
.reveal-stagger.in-view > *:nth-child(2),
.reveal-stagger.visible > *:nth-child(2) { transition-delay: 0.1s; }
.reveal-stagger.in-view > *:nth-child(3),
.reveal-stagger.visible > *:nth-child(3) { transition-delay: 0.15s; }
.reveal-stagger.in-view > *:nth-child(4),
.reveal-stagger.visible > *:nth-child(4) { transition-delay: 0.2s; }
.reveal-stagger.in-view > *:nth-child(5),
.reveal-stagger.visible > *:nth-child(5) { transition-delay: 0.25s; }
.reveal-stagger.in-view > *:nth-child(6),
.reveal-stagger.visible > *:nth-child(6) { transition-delay: 0.3s; }

/* Failsafe: reveal after 3s if JS fails */
@keyframes forceReveal {
    to { opacity: 1; transform: none; }
}
.reveal:not(.in-view):not(.visible),
.reveal-left:not(.in-view):not(.visible),
.reveal-right:not(.in-view):not(.visible) {
    animation: forceReveal 0s linear 3s forwards;
}
.reveal-stagger:not(.in-view):not(.visible) > * {
    animation: forceReveal 0s linear 3s forwards;
}

/* ===== SKELETON ===== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-3) 0%, var(--bg-4) 50%, var(--bg-3) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-card { height: 180px; border-radius: var(--radius-lg); }

/* ===== LOADER ===== */
.loader {
    text-align: center;
    padding: 1.5rem;
    font-size: 1rem;
    color: var(--text-muted);
}

/* ===== ERRORS ===== */
.error-msg {
    color: var(--danger);
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-24px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}
@keyframes rotate {
    to { transform: rotate(360deg); }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
@keyframes gradientSlide {
    to { background-position: 200% center; }
}
@keyframes glowPulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(3); opacity: 0; }
}
@keyframes shimmerBadge {
    to { left: 100%; }
}
@keyframes glitchShift {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 1px); }
    40% { transform: translate(-1px, -1px); }
    60% { transform: translate(2px, 1px); }
    80% { transform: translate(1px, -1px); }
    100% { transform: translate(0); }
}

/* ===== ACCESSIBILITY ===== */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}
:focus:not(:focus-visible) { outline: none; }

.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;
}

@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, .reveal-left, .reveal-right, .reveal-stagger > * {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
    --bg-0: #ffffff;
    --bg-1: #f6f8fa;
    --bg-2: #eef1f5;
    --bg-3: #ffffff;
    --bg-4: #f0f3f6;
    --bg-hover: #e6eaef;
    --border-subtle: #e0e5eb;
    --border-default: #d0d7de;
    --border-strong: #b7bec7;
    --text-primary: #1f2328;
    --text-secondary: #383d43;
    --text-tertiary: #656d76;
    --text-muted: #6e7781;
    --text-inverse: #ffffff;
    --accent: #0969da;
    --accent-hover: #218bff;
    --accent-soft: rgba(9, 105, 218, 0.08);
    --accent-glow: rgba(9, 105, 218, 0.25);
    --success-soft: rgba(26, 127, 55, 0.12);
    --warning-soft: rgba(154, 103, 0, 0.12);
    --danger-soft: rgba(207, 34, 46, 0.12);
    --surface-1: rgba(255, 255, 255, 0.7);
    --surface-2: rgba(255, 255, 255, 0.9);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(9, 105, 218, 0.15);
    --grad-hero: linear-gradient(135deg, #e8f2ff 0%, #f6f8fa 40%, #ffffff 100%);
}
[data-theme="light"] body { background: var(--bg-1); color: var(--text-primary); }
[data-theme="light"] body::before { opacity: 0.3; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    :root {
        --header-h: 60px;
    }
}