/* --- Material Design 3 Tokens (Цветовая схема) --- */
:root {
    /* Базовые цвета (Primary - синий оттенок) */
    --md-sys-color-primary: #0061A4;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #D1E5FF;
    --md-sys-color-on-primary-container: #001D36;

    --md-sys-color-secondary: #535F70;
    --md-sys-color-secondary-container: #D7E3F7;
    --md-sys-color-on-secondary-container: #101C2B;

    --md-sys-color-background: #FDFCFF;
    --md-sys-color-on-background: #1A1C1E;
    
    --md-sys-color-surface: #FDFCFF;
    --md-sys-color-surface-variant: #E1E2EC;
    --md-sys-color-on-surface: #1A1C1E;
    --md-sys-color-on-surface-variant: #44474F;

    --md-sys-color-outline: #74777F;

    /* Типографика */
    --font-family: 'Roboto', sans-serif;
    
    /* Скругления */
    --radius-small: 8px;
    --radius-medium: 12px;
    --radius-large: 16px;
    --radius-xlarge: 28px; /* Для кнопок и больших контейнеров */
    --radius-full: 9999px;

    /* Тени */
    --shadow-1: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px 1px rgba(0,0,0,0.15);
    --shadow-2: 0 1px 2px rgba(0,0,0,0.3), 0 2px 6px 2px rgba(0,0,0,0.15);
}

/* --- Reset & Base --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    line-height: 1.5;

    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    width: 100%;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* --- Typography (MD3 Scale) --- */
.headline-large {
    font-size: 32px;
    font-weight: 400;
    line-height: 40px;
    letter-spacing: 0;
}

.title-medium {
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
    letter-spacing: 0.15px;
}

.body-large {
    font-size: 16px;
    font-weight: 400;
    line-height: 24px;
    letter-spacing: 0.5px;
}

.body-medium {
    font-size: 14px;
    font-weight: 400;
    line-height: 20px;
    letter-spacing: 0.25px;
}

.body-small {
    font-size: 12px;
    font-weight: 400;
    line-height: 16px;
    letter-spacing: 0.4px;
}

/* --- Header / Top App Bar --- */
.top-app-bar {
    background-color: var(--md-sys-color-surface);
    height: 64px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    /* Легкая тень или граница */
    border-bottom: 1px solid var(--md-sys-color-surface-variant);
}

.nav-container {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 22px;
    font-weight: 500;
    color: var(--md-sys-color-primary);
}

.desktop-nav {
    display: none; /* Скрыто на мобильных по умолчанию */
    gap: 8px;
}

@media (min-width: 768px) {
    .desktop-nav {
        display: flex;
    }
    .mobile-menu-toggle {
        display: none;
    }
    .icon-btn {
        display: none;
    }
}

.nav-link {
    padding: 10px 24px;
    border-radius: var(--radius-full);
    font-weight: 500;
    transition: background-color 0.2s;
    color: var(--md-sys-color-on-surface);
}

.nav-link:hover {
    background-color: rgba(103, 80, 164, 0.08); /* Primary с прозрачностью */
}

.nav-link.active {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

/* --- Mobile Drawer --- */
.mobile-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
}

.mobile-drawer-overlay.open {
    opacity: 1;
    visibility: visible;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100%;
    background: var(--md-sys-color-surface);
    z-index: 160;
    transition: left 0.3s ease;
    padding: 20px;
    box-shadow: var(--shadow-2);
}

.mobile-drawer.open {
    left: 0;
}

.drawer-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--md-sys-color-surface-variant);
    font-weight: 500;
    font-size: 18px;
}

.drawer-link {
    display: block;
    padding: 16px;
    margin-bottom: 4px;
    border-radius: var(--radius-full);
    color: var(--md-sys-color-on-surface);
    transition: background 0.2s;
}

.drawer-link:hover {
    background-color: rgba(103, 80, 164, 0.08);
}

.drawer-link.active {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

/* --- Hero Section --- */
.hero-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
    padding: 60px 0;
    align-items: center;
}

@media (min-width: 768px) {
    .hero-section {
        grid-template-columns: 1fr 1fr;
    }
}

.hero-avatar {
    width: 100%;
    max-width: 350px;
    border-radius: var(--radius-xlarge);
    aspect-ratio: 1/1;
    object-fit: cover;
    box-shadow: var(--shadow-1);
    background-color: var(--md-sys-color-surface-variant);
}

.hero-actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* --- Buttons (MD3 Style) --- */
.filled-button {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    padding: 10px 24px;
    border-radius: var(--radius-full);
    font-weight: 500;
    transition: box-shadow 0.2s, background-color 0.2s;
}

.filled-button:hover {
    box-shadow: var(--shadow-1);
    background-color: #504afc; /* Чуть темнее */
}

.tonal-button {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    padding: 10px 24px;
    border-radius: var(--radius-full);
    font-weight: 500;
    transition: box-shadow 0.2s, background-color 0.2s;
}

.tonal-button:hover {
    box-shadow: var(--shadow-1);
    background-color: #d8cde5; /* Чуть темнее */
}

/* --- Info Grid (Cards) --- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    padding-bottom: 60px;
}

.card {
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-surface-variant); /* Тонкая рамка вместо тени в MD3 */
    border-radius: var(--radius-medium);
    padding: 24px;
    transition: box-shadow 0.2s;
    display: flex;
    margin-bottom: 2%;
}

.card-content {
    flex: 1;
}

.card:hover {
    box-shadow: var(--shadow-1);
}

.card h3 {
    margin-bottom: 8px;
}

.card img {
    display: block;
    max-width: 120px;
    width: 100%;
    height: auto;
    flex-shrink: 0;
    border-radius: var(--radius-xlarge);
    
}

.card-icon {
    width: 40px;
    height: 40px;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-radius: 50%; /* Круглые иконки */
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

/* --- Footer --- */
.footer {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    text-align: center;
    padding: 24px;
    margin-top: auto;
}

/* --- Icon Button --- */
.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-sys-color-on-surface);
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: rgba(0,0,0,0.05);
}

/* --- Стили для аватарки рядом с заголовком --- */

.hero-intro {
    display: flex;
    align-items: center; /* Выравнивание по центру по вертикали */
    gap: 20px; /* Расстояние между текстом и фото */
    margin-bottom: 16px; /* Отступ снизу до описания */
    flex-wrap: wrap; /* Чтобы на очень маленьких экранах переносилось */
}

.hero-avatar-inline {
    width: 64px;  /* Размер аватарки */
    height: 64px;
    border-radius: 50%; /* Делает картинку идеально круглой */
    object-fit: cover; /* Чтобы фото не сплющивалось */
    border: 2px solid var(--md-sys-color-primary-container); /* Красивая рамка в цвет темы */
    box-shadow: var(--shadow-1);
}

/* Адаптив: если экран очень узкий, аватарка уйдет под текст */
@media (max-width: 400px) {
    .hero-intro {
        justify-content: center;
        text-align: center;
        flex-direction: column;
        gap: 10px;
    }
}

/* --- Page Header --- */
.page-header {
    margin: 48px 0 24px;
}

.page-header:first-child {
    margin-top: 32px;
}

/* --- Education Timeline --- */
.timeline {
    position: relative;
    padding-left: 20px;
    max-width: 800px;
}

/* Вертикальная линия */
.timeline::before {
    content: '';
    position: absolute;
    left: 29px; /* Центрируем относительно точки */
    top: 10px;
    bottom: 0;
    width: 2px;
    background-color: var(--md-sys-color-surface-variant);
}

.timeline-item {
    position: relative;
    margin-bottom: 32px;
    padding-left: 20px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

/* Точка на таймлайне */
.timeline-dot {
    position: absolute;
    left: 0;
    top: 24px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--md-sys-color-primary);
    border: 3px solid var(--md-sys-color-background);
    z-index: 1;
}

.timeline-content {
    margin-left: 20px;
}

.timeline-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--md-sys-color-on-surface-variant);
}

.timeline-header .material-symbols-outlined {
    font-size: 20px;
}

.title-large {
    font-size: 22px;
    font-weight: 400;
    line-height: 28px;
    margin-bottom: 4px;
}

/* --- Skills Chips --- */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
    border: 1px solid transparent;
}

.chip:hover {
    background-color: #d0c5e8; /* Чуть темнее при наведении */
    cursor: default;
    color: black;
}

/* --- Hobbies Grid --- */
.hobbies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    padding-bottom: 60px;
}

.hobby-card {
    text-align: center;
    padding: 32px 24px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.hobby-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-2);
}

.hobby-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hobby-icon .material-symbols-outlined {
    font-size: 28px;
}

/* --- Outlined Button (для GitHub) --- */
.outlined-button {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    padding: 10px 24px;
    border-radius: var(--radius-full);
    font-weight: 500;
    border: 1px solid var(--md-sys-color-outline);
    transition: all 0.2s;
}

.outlined-button:hover {
    background-color: rgba(0, 97, 164, 0.08); /* Primary с прозрачностью */
    border-color: var(--md-sys-color-primary);
}

/* --- Gallery Grid --- */
.gallery-section {
    padding-bottom: 60px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.gallery-item {
    border-radius: var(--radius-large);
    overflow: hidden;
    background-color: var(--md-sys-color-surface);
    box-shadow: var(--shadow-1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-2);
}

.gallery-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3; /* Соотношение сторон фото */
    overflow: hidden;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.05); /* Увеличение фото при наведении */
}

/* Оверлей с иконкой зума */
.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 97, 164, 0.4); /* Полупрозрачный синий */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.gallery-overlay .material-symbols-outlined {
    font-size: 48px;
    color: white;
}

/* Подпись под фото */
.gallery-caption {
    padding: 16px;
    background-color: var(--md-sys-color-surface);
}

.gallery-caption p {
    color: var(--md-sys-color-on-surface);
}

/* --- Modal (Lightbox) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background-color: var(--md-sys-color-surface);
    border-radius: var(--radius-large);
    padding: 16px;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.open .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.modal-close .material-symbols-outlined {
    font-size: 32px;
}

.modal-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--radius-medium);
}

.modal-caption {
    text-align: center;
    color: var(--md-sys-color-on-surface);
    margin-top: 16px;
    padding: 0 16px;
}

/* --- Reports Section --- */
.reports-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 60px;
}

.lab-card {
    padding: 24px;
}

.lab-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.lab-icon {
    width: 48px;
    height: 48px;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lab-icon .material-symbols-outlined {
    font-size: 24px;
}

.lab-screenshot {
    margin-bottom: 24px;
    border-radius: var(--radius-medium);
    overflow: hidden;
    border: 1px solid var(--md-sys-color-surface-variant);
}

.screenshot-image {
    width: 100%;
    height: auto;
    display: block;
}

/* --- Lab Action Chips --- */
.lab-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.action-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.action-chip:hover {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.action-chip .material-symbols-outlined {
    font-size: 18px;
}

/* --- ТЕМНАЯ ТЕМА --- */

/* Переопределяем цвета, когда у body есть атрибут data-theme="dark" */
[data-theme="dark"] {
    --md-sys-color-primary: #D0BCFF;
    --md-sys-color-on-primary: #381E72;
    --md-sys-color-primary-container: #4F378B;
    --md-sys-color-on-primary-container: #EADDFF;

    --md-sys-color-secondary: #CCC2DC;
    --md-sys-color-secondary-container: #4A4458;
    --md-sys-color-on-secondary-container: #E8DEF8;

    --md-sys-color-background: #141218;
    --md-sys-color-on-background: #E6E1E5;
    
    --md-sys-color-surface: #141218;
    --md-sys-color-surface-variant: #49454F;
    --md-sys-color-on-surface: #E6E1E5;
    --md-sys-color-on-surface-variant: #CAC4D0;

    --md-sys-color-outline: #938F99;
}

/* Стили для кнопки переключения темы */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--md-sys-color-on-surface);
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.theme-toggle:hover {
    background-color: var(--md-sys-color-surface-variant);
}

.theme-toggle .material-symbols-outlined {
    font-size: 24px;
}

/* --- Интерактивная карточка (для пасхалки) --- */
.hobby-card.clickable {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.hobby-card.clickable:hover {
    transform: translateY(-8px); /* Чуть сильнее всплывает */
    box-shadow: var(--shadow-2);
}

.hobby-card.clickable:hover .hobby-icon {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

/* --- Музыкальное модальное окно --- */
#musicModal .music-modal-content {
    background: var(--md-sys-color-surface);
    padding: 32px;
    border-radius: var(--radius-large);
    max-width: 500px;
    width: 90%;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

#musicModal.open .music-modal-content {
    transform: scale(1);
}

/* --- Рулетка (Slot Machine) --- */
.slot-machine {
    overflow: hidden; 
    height: 354px;
    position: relative;
    background: var(--md-sys-color-surface-variant);
    border-radius: var(--radius-medium);
    border: 2px solid var(--md-sys-color-primary);
    isolation: isolate;
}

.slot-row {
    display: flex;
    position: absolute;
    width: max-content;
    backface-visibility: hidden;
    gap: 16px;
}

/* Анимации рядов */
.row-1 {
    top: 15px;
    animation: scrollDown 10s linear infinite;
}

.row-2 {
    top: 115px;
    animation: scrollUp 10s linear infinite;
}

.row-3 {
    top: 215px;
    animation: scrollDown 10s linear infinite;
}

.row-1, .row-2, .row-3 {
    z-index: auto; /* или не указывать */
}

@keyframes scrollDown {
    0% {
      transform: translateX(0);
    }
    100% {
      transform: translateX(calc(-50% - 8px));
    }
}

@keyframes scrollUp {
    0% {
      transform: translateX(calc(-50% - 8px));
    }
    100% {
      transform: translateX(0);
    }
}

.slot-row img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-small);
    box-shadow: var(--shadow-1);
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
    transition: transform 0.3s ease, z-index 0.3s ease;
}

/* Увеличение картинки при наведении */
.slot-row img:hover {
    transform: scale(1.5);
    z-index: 999;
    box-shadow: var(--shadow-2);
}

/* Остановка анимации при наведении на любую картинку */
.slot-row:has(img:hover) {
    animation-play-state: paused;
}

/* Клон картинки */
.hover-clone {
    position: fixed; /* поверх всего */
    pointer-events: none; /* не мешает мыши */
    transform-origin: center center;
    transition: transform 0.3s ease, left 0.3s ease, top 0.3s ease;
    z-index: 9999;
    border-radius: var(--radius-small);
    box-shadow: var(--shadow-2);
}
.hover-clone.show {
    opacity: 1;          /* плавное появление */
    transform: scale(1.5); /* плавное увеличение */
}

/* --- Album Page --- */
.album-header {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 32px;
    align-items: start;
}

@media (max-width: 768px) {
    .album-header {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

.album-cover {
    width: 100%;
    border-radius: var(--radius-large);
    box-shadow: var(--shadow-2);
}

.album-actions {
    display: flex;
    gap: 12px;
}

@media (max-width: 768px) {
    .album-actions {
        justify-content: center;
    }
}

.track-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sort-buttons {
    padding-bottom: 2%;
}