/* Основные мобильные стили (до 768px) */
@media (max-width: 768px) {
    /* Базовые настройки */
    :root {
        --safe-area: max(16px, env(safe-area-inset-right));
        --bottom-safe: max(16px, env(safe-area-inset-bottom));
        --header-height: 44px;
        --section-spacing: 2.5rem;
        --card-padding: 1.5rem;
        --content-padding: 1rem;
        --sber-color: #22A447;
        --oscar-color: #6e45e2;
        --partner-color: #E74C3C;
    }

    html, body {
        width: 100%;
        max-width: 100%;
        min-height: 100vh;
        overscroll-behavior-y: contain;
        position: relative;
        font-size: 15px;
    }

    body {
        padding: 0;
        margin: 0;
        overscroll-behavior-x: none;
    }

    .resume-wrapper {
        width: 100%;
        padding: var(--content-padding) var(--safe-area) 3rem;
        box-sizing: border-box;
        position: relative;
        z-index: 1;
    }

    /* Секции контента */
    .typing-section,
    .tech-stack-section,
    .diplomas-section,
    .projects-section,
    .timeline-section {
        margin-bottom: var(--section-spacing);
        margin: 1rem 0;
    }

    /* Секция технологического стека */
    .tech-stack-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 0.5rem 0 1.5rem;
        padding: 0 var(--safe-area);
        width: 100%;
        height: var(--header-height);
        position: relative;
    }

    .tech-stack-header .section-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        min-width: 0;
        line-height: var(--header-height);
        display: inline-flex;
        align-items: center;
        height: 100%;
        padding-top: 2px;
    }

    .tech-info-circle {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: 12px;
        flex-shrink: 0;
        height: var(--header-height);
        width: var(--header-height);
        position: relative;
        top: -1px;
    }

    .circle-button {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--primary);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 0 15px rgba(110, 69, 226, 0.5);
        border: none;
        outline: none;
        padding: 0;
        position: relative;
    }

    .circle-button i {
        font-size: 1.3rem;
        color: white;
        position: relative;
        top: 1px;
    }

    /* Лента технологий */
    .tech-strip-wrapper {
        width: 100%;
        margin: 1.5rem 0;
        overflow: hidden;
        position: relative;
        z-index: 1;
        height: 140px;
        padding: 0 var(--safe-area);
        box-sizing: border-box;
         -webkit-overflow-scrolling: touch;
    }

    .tech-strip {
        display: flex;
        gap: 1rem;
        padding: 1rem 0;
        animation: scroll 100s linear infinite;
        will-change: transform;
        width: max-content;
    }

    .tech-item {
        flex: 0 0 auto;
        width: 100px;
        height: 100px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: rgba(30, 30, 60, 0.7);
        border-radius: 15px;
        border: 1px solid rgba(110, 69, 226, 0.3);
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
        touch-action: manipulation;
    }

    /* Опыт работы - улучшенные tooltip'ы */
    .timeline-section .section-title {
        padding: 0 var(--safe-area);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 1.5rem;
    }

    .career-track {
        width: 100%;
        margin: 2.5rem 0;
        padding: 0 var(--safe-area);
        position: relative;
        z-index: 40;
    }

    .track-line {
        position: absolute;
        top: 50%;
        left: var(--safe-area);
        right: var(--safe-area);
        height: 3px;
        background: rgba(255,255,255,0.1);
        transform: translateY(-50%);
        z-index: 1;
    }

    .track-milestones {
        position: relative;
        display: flex;
        justify-content: space-between;
        height: 100%;
        z-index: 40;
    }

    .milestone {
        width: 60px;
        height: 60px;
        position: relative;
        cursor: pointer;
    }

    /* Цвета рамок для компаний */
    .milestone[data-company="Сбер"] {
        --company-color: var(--sber-color);
    }
    .milestone[data-company="Oscar Studio"] {
        --company-color: var(--oscar-color);
    }
    .milestone[data-company="Партнёр"] {
        --company-color: var(--partner-color);
    }

    .milestone-marker {
        width: 100%;
        height: 100%;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .marker-outer-ring {
        position: absolute;
        width: 100%;
        height: 100%;
        border-radius: 50%;
        border: 2px solid var(--company-color);
        box-shadow: 0 0 0 3px var(--dark);
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(30, 30, 60, 0.8);
        transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    .company-logo {
        width: 70%;
        height: 70%;
        object-fit: contain;
        filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
        transition: transform 0.3s ease;
    }

    .milestone:hover .marker-outer-ring {
        transform: scale(1.1);
        box-shadow: 0 0 0 3px var(--dark), 0 0 15px var(--company-color);
    }

    .milestone:hover .company-logo {
        transform: scale(1.1);
    }

    .milestone-tooltip {
        position: absolute;
        top: calc(100% - 18px);
        left: 50%;
        transform: translateX(-50%) translateY(5px);
        background: rgba(26, 26, 46, 0.98);
        padding: 1.2rem;
        border-radius: 14px;
        width: 220px;
        max-width: calc(100vw - 2 * var(--safe-area));
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        border: 1px solid var(--company-color);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        z-index: 50;
    }


    .milestone:hover .milestone-tooltip {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(15px);
    }

    .milestone-tooltip-content {
        display: flex;
        flex-direction: column;
        gap: 0.8rem;
    }

    .milestone-position {
        font-weight: 500;
        color: var(--secondary);
        font-size: 0.95rem;
        line-height: 1.4;
    }

    .milestone-company {
        font-weight: 600;
        color: white;
        font-size: 1rem;
        line-height: 1.3;
        margin-bottom: 0.2rem;
    }

    .milestone-period {
        font-weight: 400;
        color: rgba(255, 255, 255, 0.8);
        font-size: 0.85rem;
        line-height: 1.3;
        position: relative;
        padding-top: 0.5rem;
    }

    .milestone-period::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 30px;
        height: 1px;
        background: var(--company-color);
        opacity: 0.5;
    }

    /* Позиционирование для крайних элементов */
    .milestone:first-child .milestone-tooltip {
        left: 0;
        transform: translateX(0) translateY(5px);
    }

    .milestone:first-child:hover .milestone-tooltip {
        transform: translateX(0) translateY(15px);
    }

    .milestone:last-child .milestone-tooltip {
        left: auto;
        right: 0;
        transform: translateX(0) translateY(5px);
    }

    .milestone:last-child:hover .milestone-tooltip {
        transform: translateX(0) translateY(15px);
    }

    /* Кнопка CTA */
    .floating-cta {
        position: fixed;
        bottom: var(--bottom-safe);
        right: var(--safe-area);
        z-index: 100;
    }

    .cta-button {
        padding: 0.8rem 1.2rem;
        font-size: 0.9rem;
    }

    /* Модальное окно технологий */
    .tech-modal-overlay {
        z-index: 1101;
    }

    /* Анимация текста */
    .typing-section {
        padding: 0 var(--safe-area);
        margin: 1.5rem 0 2.5rem;
    }

    .about-text {
        padding: 0;
        margin-top: 1rem;
        text-align: left;
    }

    /* Адаптация для маленьких экранов */
    @media (max-width: 480px) {
        :root {
            --header-height: 40px;
            --section-spacing: 2rem;
            --card-padding: 1.2rem;
            --content-padding: 0.8rem;
        }

        .section-title {
            font-size: 1.5rem;
        }

        .tech-item {
            width: 85px;
            height: 85px;
               touch-action: manipulation;
        }

        .milestone {
            width: 50px;
            height: 50px;
        }

        .milestone-tooltip {
            width: 180px;
            padding: 1rem;
        }

        .milestone-position {
            font-size: 0.9rem;
        }

        .milestone-company {
            font-size: 0.95rem;
        }

        .milestone-period {
            font-size: 0.8rem;
        }

        .circle-button {
            width: 40px;
            height: 40px;
        }

        .circle-button i {
            font-size: 1.1rem;
        }

        .tech-strip-wrapper {
            height: 120px;
            -webkit-overflow-scrolling: touch;
        }

        .tech-stack-header {
            margin: 0.3rem 0 1.2rem;
        }
    }

    /* Специфичные настройки для iOS */
    @supports (-webkit-touch-callout: none) {
        .tech-stack-header .section-title {
            padding-top: 3px;
        }

        .tech-info-circle {
            top: 0;
        }
    }
}

/* Анимации */
@keyframes scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(calc(-100% - 1rem)); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
    .tech-strip {
        animation: none;
    }
}

@media (max-width: 768px) {
    .tech-modal {``
        display: flex;
        flex-direction: column;
        height: 100%;
        max-height: none;
        padding: 0;
        border-radius: 0;
    }

    .tech-modal h3 {
        position: sticky;
        top: 0;
        background: rgba(30, 30, 60, 0.95);
        padding: 1.5rem;
        margin: 0;
        z-index: 1;
        border-bottom: 1px solid var(--primary);
    }

    .close-modal {
        position: fixed;
        top: 15px;
        right: 15px;
        z-index: 2;
    }

    .tech-grid {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .tech-modal-overlay.active {
        display: flex;
        align-items: stretch;
    }

    .tech-modal-overlay {
        padding: 0;
    }
}

@media (max-width: 480px) {
    .tech-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
        padding: 0.8rem;
    }

    .tech-modal h3 {
        padding: 1.2rem;
        font-size: 1.3rem;
    }
}

/* Улучшения для модального окна дипломов */
@media (max-width: 768px) {
    .diploma-modal-overlay {
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(15px);
        padding: 5px;
    }

    /* Гарантируем, что контент не выходит за границы */
    .diploma-modal-content > * {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Улучшаем отображение SVG/изображений дипломов */
    .diploma-modal-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}