/* БАЗОВІ ЗМІННІ (Світла тема) */
:root {
    --bg-color: #ffffff;
    --text-main: #111111;
    --text-muted: #555555;
    --text-accent: #a3a3a3;
    --border-color: #e5e5e5;
    --btn-dark-bg: #1a1a1a;
    --btn-dark-text: #ffffff;
    --nav-bg: rgba(255, 255, 255, 0.9);
    --card-bg: #ffffff;
    --card-hover: #fcfcfc;
    --tag-bg: #f5f5f5;
    --font-main: 'Inter', sans-serif;

    /* Змінні Термінала (Світлі) */
    --term-bg: #ffffff;
    --term-header: #f5f5f5;
    --term-border: #e0e0e0;
    --term-output-bg: #fafafa;
    --term-input-bg: #ffffff;
    --term-text: #111111;
    --term-accent-1: #008060;
    --term-accent-2: #b35900;
    --term-error: #d93025;
}

/* ЗМІННІ ДЛЯ ТЕМНОЇ ТЕМИ */
[data-theme="dark"] {
    --bg-color: #050505;
    --text-main: #f5f5f5;
    --text-muted: #a0a0a0;
    --text-accent: #666666;
    --border-color: #222222;
    --btn-dark-bg: #ffffff;
    --btn-dark-text: #050505;
    --nav-bg: rgba(5, 5, 5, 0.9);
    --card-bg: #0a0a0a;
    --card-hover: #0f0f0f;
    --tag-bg: #1a1a1a;

    /* Змінні Термінала (Темні) */
    --term-bg: #0a0a0a;
    --term-header: #111111;
    --term-border: #222222;
    --term-output-bg: #020202;
    --term-input-bg: #0d0d0d;
    --term-text: #ffffff;
    --term-accent-1: #00ffcc;
    --term-accent-2: #ffff00;
    --term-error: #ff4444;
}

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

body, html {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-main);
    overflow-x: hidden;
    line-height: 1.6;
    scroll-behavior: smooth;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* ================= CANVAS ФОН ================= */
#tech-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

.hero-grid, .top-nav, section, main {
    position: relative;
    z-index: 10;
}

/* ================= ВИПАДНЕ МЕНЮ МОВ ================= */
.lang-dropdown { position: relative; display: inline-block; margin: 0 15px; }
.lang-dropbtn { 
    background: transparent; 
    color: var(--text-main); 
    border: 1px solid var(--border-color); 
    padding: 6px 12px; 
    border-radius: 6px; 
    cursor: pointer; 
    font-family: var(--font-main); 
    font-size: 0.85rem; 
    font-weight: 600; 
    transition: 0.3s; 
    display: flex; 
    align-items: center; 
}
.lang-dropbtn:hover { 
    background: var(--text-main); 
    color: var(--bg-color); 
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.lang-dropdown-content { display: none; position: absolute; right: 0; top: 100%; margin-top: 5px; background-color: var(--card-bg); min-width: 140px; box-shadow: 0px 8px 16px rgba(0,0,0,0.15); border: 1px solid var(--border-color); border-radius: 6px; overflow: hidden; z-index: 1000; }
.lang-dropdown-content a { color: var(--text-main); padding: 10px 16px; text-decoration: none; display: block; font-size: 0.85rem; font-weight: 500; transition: background-color 0.2s; }
.lang-dropdown-content a:hover { background-color: var(--card-hover); color: var(--text-main); }
.lang-dropdown-content.show { display: block; }

/* ================= PRELOADER (THEME-AWARE FLYING LOGO) ================= */
.ms-preloader {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: var(--bg-color); /* Підлаштовується під тему */
    z-index: 9999;
    pointer-events: none; 
   
}

.ms-logo-box {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(2.2); 
    padding: 5px 12px;
    border-radius: 4px;
    overflow: hidden;
    display: inline-flex;
    white-space: nowrap;
}

.ms-logo-text {
    position: relative;
    z-index: 2;
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem; 
    font-weight: 800;
    color: var(--text-main); /* Контрастний до фону текст */
    letter-spacing: 1px;
    opacity: 0;
    animation: 
        textFade 0.5s forwards 0.3s,
        textInvert 0.1s forwards 2.3s;
}

.ms-loader-fill {
    position: absolute;
    bottom: 0; left: 0;
    height: 2px;
    width: 0%;
    background: var(--text-main); /* Квадрат, що заливає фон */
    z-index: 1;
    animation: 
        fillLine 1.2s cubic-bezier(0.8, 0, 0.2, 1) 1.0s forwards,
        fillBox 0.5s cubic-bezier(0.8, 0, 0.2, 1) 2.2s forwards;
}

@keyframes textFade { to { opacity: 1; } }
@keyframes fillLine { 0% { width: 0%; } 100% { width: 100%; } }
@keyframes fillBox { 0% { height: 2px; } 100% { height: 100%; background: var(--text-main); } }
@keyframes textInvert { to { color: var(--bg-color); } } /* Букви стають кольором фону сайту */

/* ================= NAVIGATION ================= */
.top-nav { position: fixed; top: 0; left: 0; width: 100%; padding: 25px 0; z-index: 1000; background: var(--nav-bg); backdrop-filter: blur(10px); border-bottom: 1px solid transparent; transition: 0.3s; }
.nav-container { display: flex; justify-content: space-between; align-items: center; max-width: 1300px; margin: 0 auto; padding: 0 40px; }

/* НОВИЙ ЛОГОТИП У НАВІГАЦІЇ */
.nav-brand { 
    background: var(--text-main); 
    color: var(--bg-color); 
    padding: 5px 12px; 
    font-family: 'Inter', sans-serif; 
    font-weight: 800; 
    font-size: 1.1rem; 
    letter-spacing: 1px; 
    border-radius: 4px; 
    text-decoration: none; 
    display: inline-block; 
    opacity: 0; 
}

.nav-links { display: flex; gap: 20px; align-items: center; }

/* Ефект квадратних дужок при наведенні */
.nav-links a:not(.btn-dark) { 
    color: var(--text-muted); text-decoration: none; font-weight: 500; font-size: 0.95rem; transition: 0.3s; position: relative; padding: 0 4px;
}
.nav-links a:not(.btn-dark)::before,
.nav-links a:not(.btn-dark)::after {
    position: absolute; opacity: 0; color: var(--text-main); transition: all 0.3s cubic-bezier(0.2, 1, 0.3, 1);
}
.nav-links a:not(.btn-dark)::before { content: '['; left: -15px; }
.nav-links a:not(.btn-dark)::after { content: ']'; right: -15px; }
.nav-links a:not(.btn-dark):hover { color: var(--text-main); }
.nav-links a:not(.btn-dark):hover::before { opacity: 1; left: -6px; }
.nav-links a:not(.btn-dark):hover::after { opacity: 1; right: -6px; }

.btn-dark { background: var(--btn-dark-bg); color: var(--btn-dark-text); text-decoration: none; padding: 10px 20px; border-radius: 6px; font-weight: 600; font-size: 0.9rem; transition: 0.3s; border: 1px solid transparent; }
.btn-dark:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,0.15); }
.theme-toggle-btn { background: transparent; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; transition: 0.3s; padding: 5px; }
.theme-toggle-btn:hover { color: var(--text-main); transform: rotate(15deg); }

/* ================= HERO SECTION ================= */
.hero-section { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 100px 40px 40px 40px; }
.hero-grid { max-width: 1300px; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center; }
.status-badge { display: inline-flex; align-items: center; gap: 8px; font-family: monospace; font-size: 0.8rem; padding: 6px 12px; border: 1px solid var(--border-color); border-radius: 20px; margin-bottom: 30px; color: var(--text-muted); background: var(--card-bg); }
.dot { width: 6px; height: 6px; background-color: #00e676; border-radius: 50%; display: block; box-shadow: 0 0 5px rgba(0,230,118,0.5); }
.hero-content h1 { font-size: 4.5rem; font-weight: 800; line-height: 1.05; letter-spacing: -2px; margin-bottom: 30px; color: var(--text-main); }
.text-accent { color: var(--text-accent); }
.hero-content p { font-size: 1.15rem; color: var(--text-muted); max-width: 500px; margin-bottom: 40px; font-weight: 400; line-height: 1.7; }
.hero-actions { display: flex; align-items: center; gap: 20px; }
.icon-link { color: var(--text-muted); font-size: 1.4rem; transition: 0.3s; text-decoration: none; }
.icon-link:hover { color: var(--text-main); transform: translateY(-2px); }
.hero-visual { display: flex; justify-content: flex-end; position: relative; }
.logo-container { position: relative; width: 450px; height: 450px; }

/* ================= ANIMATIONS ================= */
.fade-up { opacity: 0; transform: translateY(30px); }
body.loaded .fade-up { animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
body.loaded .delay-1 { animation-delay: 0.1s; } body.loaded .delay-2 { animation-delay: 0.3s; } body.loaded .delay-3 { animation-delay: 0.5s; } body.loaded .delay-4 { animation-delay: 0.7s; }
@keyframes slideUp { to { opacity: 1; transform: translateY(0); } }

/* Анімація малювання SVG логотипа (якщо він є на сторінці) */
.animated-logo path, .animated-logo rect { stroke-dasharray: 400; stroke-dashoffset: 400; }
body.loaded .draw-box { animation: drawSVG 2.5s cubic-bezier(0.8, 0, 0.2, 1) 0.5s forwards; }
body.loaded .draw-m { animation: drawSVG 2s cubic-bezier(0.8, 0, 0.2, 1) 1s forwards; }
body.loaded .draw-s { animation: drawSVG 2s cubic-bezier(0.8, 0, 0.2, 1) 1.2s forwards; }
body.loaded .draw-line { animation: drawSVG 1.5s cubic-bezier(0.8, 0, 0.2, 1) 1.5s forwards; }
@keyframes drawSVG { to { stroke-dashoffset: 0; } }

/* ================= 3-COLUMN SKILLS ================= */
.section-container { max-width: 1300px; margin: 0 auto; padding: 80px 40px; }
.skills-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; margin-top: 20px; }
.skill-column { display: flex; flex-direction: column; background: var(--card-bg); border: 1px solid var(--border-color); padding: 40px; border-radius: 12px; transition: 0.3s; position: relative; z-index: 10; box-shadow: 0 4px 20px rgba(0,0,0,0.02); }
.skill-column:hover { transform: translateY(-5px); border-color: var(--text-main); background: var(--card-hover); box-shadow: 0 10px 30px rgba(0,0,0,0.06); }
.skill-num { font-family: monospace; color: var(--text-accent); font-size: 0.9rem; margin-bottom: 20px; letter-spacing: 1px; }
.skill-column h3 { font-size: 1.3rem; font-weight: 700; margin-bottom: 15px; color: var(--text-main); }
.skill-column p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.7; }
.skill-column strong { color: var(--text-main); font-weight: 600; }

/* ================= PROJECT CARDS ================= */
.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 30px; }
.project-card { background: var(--card-bg); border: 1px solid var(--border-color); padding: 40px; text-decoration: none; color: var(--text-main); transition: 0.3s; display: flex; flex-direction: column; justify-content: space-between; min-height: 300px; }
.project-card:hover { border-color: var(--text-main); background: var(--card-hover); transform: translateY(-5px); box-shadow: 0 10px 30px rgba(0,0,0,0.05); }
.project-card h3 { font-size: 1.4rem; font-weight: 700; margin-bottom: 15px; }
.project-card p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }
.tag-group { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 25px; }
.tag { background: var(--tag-bg); padding: 6px 12px; font-size: 0.75rem; font-family: monospace; color: var(--text-muted); border-radius: 4px; }

footer { text-align: center; padding: 60px 20px; border-top: 1px solid var(--border-color); margin-top: 50px; position: relative; z-index: 10; }
.footer-text { font-size: 0.85rem; color: var(--text-muted); }

/* ================= RESPONSIVE ================= */
.nav-toggle, .nav-toggle-label { display: none; }
@media (max-width: 1024px) {
    .nav-container { padding: 0 20px; }
    .hero-content h1 { font-size: 3.8rem; }
    .hero-grid { gap: 30px; }
    .logo-container { width: 350px; height: 350px; }
    .nav-links a:not(.btn-dark) { font-size: 0.85rem; }
}
@media (max-width: 768px) {
    .hero-grid { grid-template-columns: 1fr; text-align: center; gap: 40px; }
    .hero-content h1 { font-size: clamp(2.2rem, 8vw, 3.2rem); overflow-wrap: break-word; hyphens: auto; }
    .hero-content p { margin: 0 auto 40px auto; font-size: 1rem; }
    .hero-actions { justify-content: center; flex-wrap: wrap; }
    .skills-grid { grid-template-columns: 1fr; gap: 30px; }
    .project-grid { grid-template-columns: 1fr; }
    .hero-visual { display: none; /* Ховаємо великий SVG логотип на мобільних, щоб не займав місце */ }

    .nav-toggle-label { display: block; cursor: pointer; z-index: 1001; padding: 10px; }
    .nav-toggle-label span, .nav-toggle-label span::before, .nav-toggle-label span::after { display: block; background: var(--text-main); height: 2px; width: 25px; position: relative; transition: 0.3s; }
    .nav-toggle-label span::before, .nav-toggle-label span::after { content: ''; position: absolute; }
    .nav-toggle-label span::before { bottom: 8px; }
    .nav-toggle-label span::after { top: 8px; }

    .nav-links { position: fixed; top: 0; right: -100%; width: 100%; height: 100vh; background: var(--bg-color); flex-direction: column; justify-content: center; gap: 25px; transition: 0.4s; }
    .nav-toggle:checked ~ .nav-links { right: 0; }
    .nav-toggle:checked ~ .nav-toggle-label span { background: transparent; }
    .nav-toggle:checked ~ .nav-toggle-label span::before { transform: rotate(45deg); bottom: 0; }
    .nav-toggle:checked ~ .nav-toggle-label span::after { transform: rotate(-45deg); top: 0; }
}

/* ================= МИТТЄВЕ ПРИХОВУВАННЯ ПРЕЛОАДЕРА (ДЛЯ СЕСІЇ) ================= */
html.skip-preloader .ms-preloader {
    display: none !important;
}
html.skip-preloader .nav-brand {
    opacity: 1 !important;
}