/* RESET & BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS переменные */
:root {
    --bg: #0a0a0a;
    --fg: #111111;
    --fgo: rgba(20, 20, 20, 0.8);
    --border: #222222;
    --bordero: rgba(40, 40, 40, 0.8);
    --dark-gray: #6b7280;
    --gray: #9ca3af;
    --pg: #e5e5e5;
    --accent: #ffffff;
    --grid-color: rgba(255, 255, 255, 0.04);
}

body.light {
    --bg: #f5f5f5;
    --fg: #ffffff;
    --fgo: rgba(240, 240, 240, 0.9);
    --border: #e5e7eb;
    --bordero: rgba(200, 200, 200, 0.8);
    --dark-gray: #6b7280;
    --gray: #6b7280;
    --pg: #1f2937;
    --accent: #1f2937;
    --grid-color: rgba(0, 0, 0, 0.04);
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--pg);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background 0.3s, color 0.3s;
}

/* СЕТКА НА ФОНЕ */
.grid-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    background-image: 
        linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
    background-size: 50px 50px;
    -webkit-mask-image: linear-gradient(to bottom, white 0%, white 70%, transparent 100%);
    mask-image: linear-gradient(to bottom, white 0%, white 70%, transparent 100%);
}

/* CANVAS (анимированная сетка, опционально) */
#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    filter: blur(1px);
    opacity: 0.15;
}

body.light #bgCanvas {
    opacity: 0.08;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 5%;
    position: relative;
    z-index: 1;
}

/* HERO */
.hero {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.hero-name {
    color: var(--gray);
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.hero-title {
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 600;
    text-transform: uppercase;
    line-height: 0.9;
    letter-spacing: -0.02em;
    color: var(--pg);
}

.hero-subtitle {
    font-size: clamp(1rem, 3vw, 1.1rem);
    color: var(--gray);
    max-width: 600px;
}

.cursor {
    display: inline-block;
    width: 0.5ch;
    transform: translateY(-0.05em);
    font-weight: 300;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* SOCIAL */
.social-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 2rem 0 1.5rem;
}

.social-link {
    color: var(--dark-gray);
    font-size: 1.5rem;
    transition: all 0.3s;
}

.social-link:hover {
    color: var(--pg);
    transform: translateY(-3px);
}

/* BUTTONS */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    border-radius: 40px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--pg);
    color: var(--bg);
}

.btn-primary:hover {
    transform: translateY(-2px);
    filter: brightness(0.9);
}

.btn-secondary {
    background: var(--fg);
    color: var(--pg);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    transform: translateY(-2px);
}

/* CONTACT DROPDOWN */
.contact-dropdown {
    display: none;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s;
}

.contact-dropdown.show {
    display: flex;
}

.contact-dropdown a {
    color: var(--gray);
    text-decoration: none;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    transition: all 0.3s;
}

.contact-dropdown a:hover {
    color: var(--pg);
    background: var(--fg);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* THEME SWITCH */
.theme-switch {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 4rem;
}

.theme-btn {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.4rem 1rem;
    border-radius: 30px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
    color: var(--gray);
    font-family: inherit;
}

.theme-btn:hover {
    border-color: var(--pg);
    color: var(--pg);
}

.theme-btn.active {
    background: var(--pg);
    color: var(--bg);
}

/* SECTIONS */
section {
    margin: 4rem 0;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

@media (min-width: 1024px) {
    section {
        flex-direction: row;
        gap: 4rem;
    }
}

.section-header {
    flex: 0 0 120px;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gray);
    position: sticky;
    top: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (min-width: 1024px) {
    .section-title {
        text-align: right;
        justify-content: flex-end;
    }
}

.section-content {
    flex: 1;
}

/* ABOUT */
.about-text {
    color: var(--gray);
    line-height: 1.8;
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.about-text strong {
    color: var(--pg);
}

.achievements-compact {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    background: var(--fgo);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.3s;
}

.achievement-item:hover {
    border-color: var(--pg);
    transform: translateX(3px);
}

.achievement-item i {
    font-size: 1.2rem;
    color: var(--accent);
}

.achievement-item span {
    font-size: 0.85rem;
    font-weight: 500;
}

/* SKILLS */
.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.5rem 1.5rem;
    border-radius: 30px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
    color: var(--gray);
    font-family: inherit;
}

.tab-btn.active {
    background: var(--pg);
    color: var(--bg);
}

.tab-btn:hover:not(.active) {
    border-color: var(--pg);
    color: var(--pg);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

.tab-content.active {
    display: block;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.skill-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--fgo);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.3s;
}

.skill-card:hover {
    transform: translateY(-2px);
    border-color: var(--pg);
}

.skill-card i {
    font-size: 1.2rem;
    color: var(--accent);
}

.skill-card span {
    font-size: 0.85rem;
    font-weight: 500;
}

/* TIMELINE */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.timeline-item {
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    transition: all 0.3s;
}

.timeline-item:hover {
    transform: translateX(5px);
}

.timeline-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.timeline-year {
    font-size: 0.8rem;
    color: var(--dark-gray);
}

.timeline-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0.25rem 0 0.5rem;
}

.timeline-text {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.timeline-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    font-size: 0.7rem;
    padding: 0.25rem 0.75rem;
    background: var(--fgo);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--gray);
}

/* ========== ПРОЕКТЫ - ИСПРАВЛЕННАЯ СЕТКА ========== */
.projects {
    margin: 4rem 0;
}

.filter-buttons {
    display: flex;
    justify-content: flex-start;
    gap: 0.75rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-btn {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.5rem 1.5rem;
    border-radius: 40px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
    color: var(--gray);
    font-family: inherit;
}

.filter-btn:hover {
    border-color: var(--pg);
    color: var(--pg);
    transform: translateY(-2px);
}

.filter-btn.active {
    background: var(--pg);
    color: var(--bg);
}

/* ГЛАВНОЕ ИСПРАВЛЕНИЕ: projects-grid — СЕТКА, а не flex-колонка */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.project-card {
    display: flex;
    flex-direction: column;
    background: var(--fgo);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    text-decoration: none;
    color: inherit;
    backdrop-filter: blur(4px);
}

.project-card:hover {
    transform: translateY(-8px);
    border-color: var(--pg);
    box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.4);
}

.project-img {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.project-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.project-card:hover .project-img img {
    transform: scale(1.05);
}

.project-img span {
    font-size: 3rem;
}

.project-info {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.project-info h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
    color: var(--pg);
}

.project-info p {
    font-size: 0.85rem;
    color: var(--gray);
    line-height: 1.5;
    margin: 0;
}

.project-tag {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.25rem 0.8rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    border-radius: 30px;
    color: var(--pg);
    width: fit-content;
    margin-top: 0.25rem;
}

.no-projects {
    text-align: center;
    padding: 3rem;
    color: var(--gray);
    background: var(--fgo);
    border-radius: 20px;
    border: 1px solid var(--border);
    grid-column: 1 / -1;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .projects-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 1rem;
    }
    
    .filter-buttons {
        justify-content: center;
    }
}

@media (max-width: 560px) {
    .projects-grid {
        grid-template-columns: 1fr;
    }
}

/* GITHUB STATS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.stat-card {
    text-align: center;
    padding: 1.2rem;
    background: var(--fgo);
    border: 1px solid var(--border);
    border-radius: 16px;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--pg);
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--pg);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.github-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 1rem;
    padding: 0.7rem;
    background: var(--fgo);
    border: 1px solid var(--border);
    border-radius: 40px;
    color: var(--pg);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.github-button:hover {
    border-color: var(--pg);
    background: var(--fg);
    transform: translateY(-2px);
}

/* FOOTER */
.footer {
    margin-top: 5rem;
    padding: 2rem 0;
    border-top: 1px solid var(--border);
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gray);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    border-radius: 30px;
    transition: all 0.3s;
}

.footer-link:hover {
    color: var(--pg);
    background: var(--fg);
}

.footer-sep {
    color: var(--border);
}

.footer-copyright p {
    color: var(--dark-gray);
    font-size: 0.7rem;
}

/* ОБЩАЯ АДАПТИВНОСТЬ */
@media (max-width: 768px) {
    .container {
        padding: 0 1.5rem;
    }
    
    .hero {
        min-height: 60vh;
    }
    
    .hero-title {
        font-size: clamp(2.5rem, 8vw, 4rem);
    }
    
    .skills-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .achievements-compact {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 200px;
        justify-content: center;
    }
    
    .contact-dropdown {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .skills-grid {
        grid-template-columns: 1fr;
    }
    
    .social-links {
        gap: 1rem;
    }
}

.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--fgo);
    border: 1px solid var(--border);
    color: var(--pg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.2s ease;
    opacity: 0;
    visibility: hidden;
    z-index: 1000;
    font-size: 1.4rem;
    backdrop-filter: blur(4px);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px);
    border-color: var(--pg);
    background: var(--pg);
    color: var(--bg);
}

/* Плавное появление карточек при скролле (не ломает сетку) */
.project-card {
    transition: opacity 0.5s ease, transform 0.5s ease, border-color 0.3s ease;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }
}

/* ========== КНОПКА НАВЕРХ ========== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(20, 20, 20, 0.9);
    border: 1px solid #333;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    z-index: 1000;
    font-size: 1.4rem;
    backdrop-filter: blur(4px);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px);
    border-color: #fff;
    background: #fff;
    color: #000;
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }
}

/* КНОПКА ТЕМЫ В УГЛУ */
.corner-theme-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--fgo);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(8px);
    font-size: 1.5rem;
    color: var(--pg);
}

.corner-theme-btn:hover {
    transform: scale(1.05);
    border-color: var(--pg);
}

@media (max-width: 768px) {
    .corner-theme-btn {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}
/* ========== ЛИПКИЙ ЗАГОЛОВОК ДЛЯ ТЕЛЕФОНОВ (КОМПАКТНЫЙ) ========== */
@media (max-width: 768px) {
    .section-header {
        position: sticky;
        top: 0;
        background: var(--bg);
        z-index: 100;
        padding: 0.25rem 0 !important;
        margin: 0 !important;
        backdrop-filter: blur(8px);
        border-bottom: 1px solid var(--border);
    }
    
    .section-title {
        margin: 0 !important;
        padding: 0.2rem 0 !important;
        font-size: 0.7rem !important;
        justify-content: flex-start !important;
        text-align: left !important;
        gap: 0.3rem !important;
    }
    
    .section-title i {
        font-size: 0.8rem !important;
    }
    
    /* Чтобы контент не заезжал под заголовок */
    .section-content {
        scroll-margin-top: 40px;
    }
    
    /* Плавный скролл */
    html {
        scroll-behavior: smooth;
    }
}
/* SECTIONS - КОМПАКТНЫЕ ЗАГОЛОВКИ */
section {
    margin: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 1024px) {
    section {
        flex-direction: row;
        gap: 2rem;
    }
}

.section-header {
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    line-height: 1;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gray);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}

.section-title i {
    font-size: 0.85rem;
    margin: 0;
    padding: 0;
}

@media (max-width: 768px) {
    section {
        margin: 3rem 0;
        gap: 2rem;
    }
    
    .section-header {
        padding: 1.25rem 0 !important;
    }
    
    .section-title {
        font-size: 1rem !important;
        gap: 0.5rem !important;
    }
    
    .section-title i {
        font-size: 1rem !important;
    }
}

/* ========== СЕТКА НАВЫКОВ - 3 КОЛОНКИ ========== */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.skill-card {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--fgo);
    border: 1px solid var(--border);
    border-radius: 14px;
    transition: all 0.3s;
    width: 100%;
    box-sizing: border-box;
}

.skill-card i {
    font-size: 1.2rem;
    color: var(--accent);
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.skill-card span {
    font-size: 0.85rem;
    font-weight: 500;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Планшеты - 2 колонки */
@media (max-width: 900px) {
    .skills-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.7rem;
    }
}

/* Телефоны - 1 колонка */
@media (max-width: 560px) {
    .skills-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .skill-card {
        padding: 0.6rem 0.8rem;
    }
    
    .skill-card i {
        font-size: 1rem;
    }
    
    .skill-card span {
        font-size: 0.8rem;
    }
}


/* ========== БАЗОВЫЕ СТИЛИ ДЛЯ CODEWARS (ДЕСКТОП) ========== */
.codewars .stats-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem;
}

.codewars .stat-card {
    text-align: center;
    padding: 1.2rem;
    background: var(--fgo);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.codewars .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--pg);
}

.codewars .stat-label {
    font-size: 0.7rem;
    color: var(--gray);
    text-transform: uppercase;
}

.codewars .github-button {
    display: flex;
    width: 100%;
    margin-top: 1rem;
    padding: 0.7rem;
    background: var(--fgo);
    border: 1px solid var(--border);
    border-radius: 40px;
    color: var(--pg);
    text-decoration: none;
    justify-content: center;
    gap: 0.5rem;
}

/* Десктопные стили (поверх мобильных) */
@media (min-width: 769px) {
    .codewars .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Мобильные стили */
@media (max-width: 768px) {
    .codewars .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.8rem;
    }
}
/* ========== УВЕЛИЧЕНИЕ ОТСТУПОВ МЕЖДУ БЛОКАМИ ========== */
section {
    margin-bottom: 6rem !important;
    margin-top: 6rem !important;
}

/* Для мобильных устройств - чуть меньше */
@media (max-width: 768px) {
    section {
        margin-bottom: 4rem !important;
        margin-top: 4rem !important;
    }
}

/* Дополнительный отступ перед футером */
.footer {
    margin-top: 6rem !important;
}

/* Отступы между GitHub и Codewars */
.github {
    margin-bottom: 4rem !important;
}

.codewars {
    margin-top: 2rem !important;
}