/* Matrix Theme Variables */
:root {
    --matrix-green: #00ff41;
    --matrix-dark: #0a0a0a;
    --matrix-darker: #050505;
}

/* Base Styles */
body {
    background-color: var(--matrix-darker);
    color: #ffffff;
    font-family: 'Courier New', monospace;
    overflow-x: hidden;
    position: relative;
}

/* Matrix Canvas */
#matrix {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.3;
}

/* Custom Navbar */
.custom-navbar {
    background: rgba(10, 10, 10, 0.95) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--matrix-green);
    padding: 1rem 0;
    transition: all 0.3s ease;
}

.custom-navbar.scrolled {
    padding: 0.5rem 0;
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.nav-link {
    font-weight: 500;
    margin: 0 0.5rem;
    position: relative;
    transition: color 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--matrix-green);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* Glow Text Effect */
.glow-text {
    text-shadow: 0 0 10px var(--matrix-green),
        0 0 20px var(--matrix-green),
        0 0 40px var(--matrix-green);
    animation: glow-pulse 2s ease-in-out infinite alternate;
}

@keyframes glow-pulse {
    from {
        text-shadow: 0 0 10px var(--matrix-green),
            0 0 20px var(--matrix-green),
            0 0 40px var(--matrix-green);
    }

    to {
        text-shadow: 0 0 15px var(--matrix-green),
            0 0 30px var(--matrix-green),
            0 0 60px var(--matrix-green);
    }
}

/* Hero Section */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    padding-top: 80px;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: var(--matrix-green);
    margin-bottom: 1.5rem;
    text-shadow: 0 0 10px var(--matrix-green);
}

.hero-description {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    opacity: 0.9;
}

/* Hero Image */
.hero-image {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.floating-card {
    position: relative;
    width: 500px;
    height: 500px;
    perspective: 1000px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.profile-img {
    width: 350px;
    height: 350px;
    object-fit: cover;
    border-radius: 20px;
    border: 3px solid var(--matrix-green);
    box-shadow: 
        0 0 30px var(--matrix-green),
        0 0 60px rgba(0, 255, 65, 0.3),
        0 0 100px rgba(0, 255, 65, 0.1);
    animation: float 6s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

/* Статичный градиентный фон без вращения */
.floating-card::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 480px;
    height: 480px;
    background: 
        radial-gradient(
            circle at center,
            rgba(0, 255, 65, 0.1) 0%,
            rgba(0, 255, 65, 0.05) 30%,
            transparent 70%
        );
    border-radius: 30px;
    z-index: 1;
    animation: gradient-pulse 8s ease-in-out infinite;
}

@keyframes gradient-pulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 0.8;
    }
}

.floating-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
}

.floating-element {
    position: absolute;
    background: rgba(0, 255, 65, 0.15);
    border: 2px solid var(--matrix-green);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    animation: float-element 6s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
    backdrop-filter: blur(5px);
}

.floating-element.element-1 {
    top: 40px;
    left: 40px;
    animation-delay: 0s;
}

.floating-element.element-2 {
    top: 40px;
    right: 40px;
    animation-delay: 2s;
}

.floating-element.element-3 {
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    animation-delay: 4s;
}

@keyframes float-element {
    0%, 100% {
        transform: translateY(0px) translateX(0px) scale(1);
        box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
    }
    25% {
        transform: translateY(-30px) translateX(15px) scale(1.1);
        box-shadow: 0 0 30px rgba(0, 255, 65, 0.5);
    }
    50% {
        transform: translateY(-50px) translateX(-10px) scale(1.15);
        box-shadow: 0 0 40px rgba(0, 255, 65, 0.7);
    }
    75% {
        transform: translateY(-30px) translateX(-15px) scale(1.1);
        box-shadow: 0 0 30px rgba(0, 255, 65, 0.5);
    }
}

/* Улучшенная анимация для гифки */
@keyframes float {
    0%, 100% {
        transform: 
            translateY(0px) 
            rotate(1deg)
            scale(1);
        box-shadow: 
            0 0 30px var(--matrix-green),
            0 0 60px rgba(0, 255, 65, 0.3),
            0 0 100px rgba(0, 255, 65, 0.1);
    }
    33% {
        transform: 
            translateY(-20px) 
            rotate(-0.5deg)
            scale(1.02);
        box-shadow: 
            0 0 40px var(--matrix-green),
            0 0 80px rgba(0, 255, 65, 0.4),
            0 0 120px rgba(0, 255, 65, 0.2);
    }
    66% {
        transform: 
            translateY(-35px) 
            rotate(0.5deg)
            scale(1.01);
        box-shadow: 
            0 0 35px var(--matrix-green),
            0 0 70px rgba(0, 255, 65, 0.35),
            0 0 110px rgba(0, 255, 65, 0.15);
    }
}

/* Buttons */
.btn-glow {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-glow::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0,255,65,0.2) 0%, transparent 60%);
    opacity: 0;
    transition: all 0.5s ease;
}

.btn-glow:hover::before {
    opacity: 1;
    transform: scale(1.2);
}

.btn-glow:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,255,65,0.2);
}

/* Bootstrap Button Overrides */
.btn-primary {
    background-color: var(--matrix-green);
    border-color: var(--matrix-green);
}

.btn-primary:hover {
    background-color: #00cc34;
    border-color: #00cc34;
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,255,65,0.2);
}

.btn-outline-primary {
    color: var(--matrix-green);
    border-color: var(--matrix-green);
}

.btn-outline-primary:hover {
    background-color: var(--matrix-green);
    color: var(--matrix-dark);
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,255,65,0.2);
}

.text-primary {
    color: var(--matrix-green) !important;
}

/* Skills Section */
.skills-section {
    padding-top: 5rem;
    padding-bottom: 5rem;
}

.section-title {
    text-align: center;
    margin-bottom: 3rem;
}

.skill-card {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.skill-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 20px var(--matrix-green);
}

.skill-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.skill-percent {
    color: var(--matrix-green);
}

.matrix-progress {
    background: rgba(255, 255, 255, 0.1);
    height: 8px;
}

.progress-bar {
    background: var(--matrix-green);
}

/* Projects Section */
.projects-preview,
.projects-page {
    padding-top: 5rem;
    padding-bottom: 5rem;
}

.project-card {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-10px);
}

.project-image {
    position: relative;
    height: 250px;
    overflow: hidden;
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.project-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-card:hover .project-overlay {
    opacity: 1;
}

.project-tech {
    text-align: center;
}

.project-content {
    padding: 1rem;
    flex-grow: 1;
}

/* Footer */
.custom-footer {
    background: rgba(10, 10, 10, 0.95);
    border-top: 1px solid var(--matrix-green);
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.social-link {
    color: var(--matrix-green);
    font-size: 1.5rem;
    transition: color 0.3s ease;
}

.social-link:hover {
    color: #ffffff;
}

/* Diary Section */
.diary-section,
.contacts-section {
    padding-top: 5rem;
    padding-bottom: 5rem;
    margin-top: 3rem;
}

.diary-card {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.diary-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 20px var(--matrix-green);
}

.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 0.5rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--matrix-green);
}

.timeline-date {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.5rem;
}

.timeline-content h5 {
    margin-bottom: 0.5rem;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.status-badge.completed {
    background: rgba(0, 255, 0, 0.2);
    color: var(--matrix-green);
}

.status-badge.in-progress {
    background: rgba(255, 165, 0, 0.2);
    color: orange;
}

.course-progress {
    margin-bottom: 1rem;
}

/* Contact Form */
.contact-form {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.contact-form:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 20px var(--matrix-green);
}

.form-control {
    background: rgba(0, 0, 0, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.form-label {
    color: rgba(255, 255, 255, 0.7);
}

.contact-info {
    background: rgba(0, 0, 0, 0.5);
    padding: 2rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.contact-info:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 20px var(--matrix-green);
}

.contact-icon {
    color: var(--matrix-green);
}

/* Project Filters */
.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

/* Mobile Improvements */
.form-control {
    min-height: 44px;
}

.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .timeline {
        padding-left: 1.5rem;
    }

    .timeline-item::before {
        left: -1.2rem;
        width: 10px;
        height: 10px;
    }
}

@media (max-width: 576px) {
    .filter-buttons {
        flex-direction: column;
        align-items: center;
    }

    .filter-buttons .btn {
        min-width: 200px;
    }
}

.custom-navbar {
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-left: env(safe-area-inset-left);
    isolation: isolate;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 1.5rem;
    container-type: inline-size;
}

@container (min-width: 400px) {
    .project-card {
        display: flex;
        flex-direction: row;
    }
}

@container (min-width: 600px) {
    .project-card {
        flex-direction: column;
    }
}

/* Resume Download Styles */
.resume-download {
    text-align: center;
    animation: fadeInUp 0.8s ease 0.5s both;
    margin-top: 4rem;
}

.resume-download .btn {
    min-width: 200px;
    font-weight: 600;
    border-width: 2px;
    padding: 0.75rem 1.5rem;
    border-color: var(--matrix-green);
    color: var(--matrix-green);
    background: transparent;
    animation: float 6s ease-in-out infinite;
}

.resume-download .btn:hover {
    background-color: var(--matrix-green);
    color: var(--matrix-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 255, 0, 0.3);
}

/* Fade In Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive for Resume Button */
@media (max-width: 768px) {
    .resume-download {
        margin-top: 3rem !important;
    }
    
    .resume-download .btn {
        width: 100%;
        max-width: 280px;
    }

    .profile-img {
        width: 250px;
        height: 250px;
    }
}

/* Адаптивные изображения */
.responsive-img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Поддержка Retina дисплеев */
.retina-img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Object-fit свойства для контейнеров */
.object-fit-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.object-fit-contain {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Адаптивная галерея проектов */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 1.5rem;
    container-type: inline-size;
}

/* Адаптивные контейнеры для изображений */
.image-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
}

.image-container.ratio-16-9 {
    aspect-ratio: 16 / 9;
}

.image-container.ratio-1-1 {
    aspect-ratio: 1 / 1;
}

.image-container.ratio-4-3 {
    aspect-ratio: 4 / 3;
}

/* Адаптивные формы */
.adaptive-form .form-control {
    font-size: 16px;
    min-height: 44px;
}

.adaptive-form .form-label {
    font-size: 14px;
    margin-bottom: 8px;
}

/* Адаптивные таблицы */
.adaptive-table {
    width: 100%;
    overflow-x: auto;
    display: block;
}

.adaptive-table table {
    min-width: 600px;
    width: 100%;
}

/* Медиа-запросы для специфических улучшений */
@media (max-width: 768px) {
    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
        gap: 1rem;
    }
    
    .image-container.mobile-full {
        aspect-ratio: unset;
        height: auto;
        max-height: 50vh;
    }
    
    /* Улучшения для touch устройств */
    .btn, .form-control, .nav-link {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Уменьшаем opacity матрицы на мобильных */
    #matrix {
        opacity: 0.15;
    }
    
    /* Адаптивность для floating-card */
    .floating-card {
        width: 350px;
        height: 350px;
    }
    
    .profile-img {
        width: 250px;
        height: 250px;
    }
    
    .floating-card::before {
        width: 320px;
        height: 320px;
    }
    
    .floating-element {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
    
    .floating-element.element-1 {
        top: 20px;
        left: 20px;
    }
    
    .floating-element.element-2 {
        top: 20px;
        right: 20px;
    }
    
    .floating-element.element-3 {
        bottom: 20px;
    }
}

@media (max-width: 480px) {
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-buttons .btn {
        margin: 2px 0;
    }
    
    .floating-card {
        width: 300px;
        height: 300px;
    }
    
    .profile-img {
        width: 220px;
        height: 220px;
    }
    
    .floating-card::before {
        width: 270px;
        height: 270px;
    }
}

/* Поддержка высоких DPI экранов */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .high-dpi-img {
        image-rendering: -webkit-optimize-contrast;
        transform: translateZ(0);
    }
}

/* Lazy loading стили */
.lazy-img {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-img.loaded {
    opacity: 1;
}

/* Адаптивная типографика */
.adaptive-text {
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    line-height: 1.6;
}

/* Контейнерные запросы для проектов */
@container (min-width: 400px) {
    .project-card {
        display: grid;
        grid-template-columns: 1fr 2fr;
        gap: 1rem;
    }
}

@container (max-width: 399px) {
    .project-card {
        display: flex;
        flex-direction: column;
    }
}

/* Стили для адаптивных фильтров проектов */
.filter-buttons .btn {
    margin: 0 5px 10px;
    transition: all 0.3s ease;
    border-color: var(--matrix-green);
    color: var(--matrix-green);
}

.filter-buttons .btn:hover {
    background: rgba(0, 255, 0, 0.1);
    transform: translateY(-2px);
}

.filter-buttons .btn.active {
    background: var(--matrix-green);
    color: var(--matrix-dark);
    border-color: var(--matrix-green);
}

.project-meta .badge {
    font-size: 0.7rem;
}

/* Fallback для браузеров без поддержки контейнерных запросов */
.mobile-layout .project-card {
    display: flex;
    flex-direction: column;
}

/* Улучшения для плавности анимации */
.floating-card {
    will-change: transform;
    transform: translateZ(0);
}

.profile-img {
    will-change: transform;
    transform: translateZ(0);
}

.floating-element {
    will-change: transform;
    transform: translateZ(0);
}

/* Оптимизация для слабых устройств */
@media (prefers-reduced-motion: reduce) {
    .floating-card::before,
    .profile-img,
    .floating-element {
        animation-duration: 0.1s;
        animation-iteration-count: 1;
    }
}

/* Улучшение контрастности для доступности */
@media (prefers-contrast: high) {
    .floating-element {
        background: rgba(0, 255, 65, 0.3);
        border: 3px solid var(--matrix-green);
    }
    
    .profile-img {
        border: 4px solid var(--matrix-green);
    }
}

/* Улучшенный градиент для темной темы */
@media (prefers-color-scheme: dark) {
    .floating-card::before {
        background: 
            radial-gradient(
                circle at center,
                rgba(0, 255, 65, 0.12) 0%,
                rgba(0, 255, 65, 0.06) 30%,
                transparent 70%
            );
    }
}