/* Базовые Material Design 3 токены */
:root {
    --md-primary: #7F745F;
    --md-on-primary: #FFFFFF;
    --md-primary-container: #E8E2D6;
    --md-on-primary-container: #2D2820;
    --md-surface: #FDF8F3;
    --md-on-surface: #1C1B18;
    --md-surface-variant: #E8E3D8;
    --md-on-surface-variant: #4A4740;
    --md-outline-variant: #CCC7BC;
    --md-surface-container-low: #F7F2EC;
    --md-surface-container-high: #EBE6E0;
    --md-surface-container-highest: #E5E0DA;
    --md-motion-easing: cubic-bezier(0.4, 0, 0.2, 1);
    --md-motion-easing-emphasized: cubic-bezier(0.05, 0.7, 0.1, 1.0);
}

body.dark-theme {
    --md-primary: #B8AD96;
    --md-on-primary: #1C1B18;
    --md-primary-container: #4A463C;
    --md-on-primary-container: #E8E2D6;
    --md-surface: #121212;
    --md-on-surface: #E6E1D9;
    --md-surface-variant: #4A4740;
    --md-on-surface-variant: #C9C5BC;
    --md-outline-variant: #4A4740;
    --md-surface-container-low: #1C1B18;
    --md-surface-container-high: #2B2A26;
    --md-surface-container-highest: #363430;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--md-surface-container-low);
    color: var(--md-on-surface);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 40px 20px;
    transition: background-color 0.3s var(--md-motion-easing), color 0.3s ease;
    position: relative;
}

/* Настройки полноэкранного мультимедиа-фона */
.fullscreen-bg {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -2;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
}

.fullscreen-bg-video {
    width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0;
}

.fullscreen-bg-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1; background-color: transparent; backdrop-filter: blur(0px);
    transition: background-color 0.3s, backdrop-filter 0.3s;
}

body.has-custom-bg .fullscreen-bg-overlay {
    background-color: rgba(253, 248, 243, 0.45); backdrop-filter: blur(8px);
}
body.dark-theme.has-custom-bg .fullscreen-bg-overlay {
    background-color: rgba(18, 18, 18, 0.65);
}

/* КАРТОЧКА СТАБИЛЬНОЙ ШИРИНЫ 775px */
.bio-container {
    background-color: var(--md-surface);
    width: 100%; max-width: 775px; border-radius: 36px; padding: 36px; position: relative;
    box-shadow: 0px 12px 40px rgba(0,0,0,0.06); border: 1px solid var(--md-outline-variant);
    transition: background-color 0.3s, border-color 0.3s; z-index: 5;
}

body.dark-theme .bio-container { box-shadow: 0px 16px 45px rgba(0,0,0,0.45); }
.header-controls { position: absolute; top: 24px; right: 24px; }

.md-icon-btn {
    background: none; border: none; cursor: pointer; width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; color: var(--md-on-surface-variant);
    background-color: var(--md-surface-container-low); transition: background-color 0.2s;
}
.md-icon-btn:hover { background-color: var(--md-surface-container-highest); }

/* Шапка профиля */
.profile-header { text-align: center; margin-top: 12px; margin-bottom: 28px; }

.avatar-wrapper {
    position: relative;
    width: 130px; height: 130px;
    margin: 0 auto 18px;
    display: flex; align-items: center; justify-content: center;
}

.avatar {
    width: 100%; height: 100%;
    border-radius: 50%; object-fit: cover; position: relative; z-index: 2;
    border: 4px solid var(--md-surface); transition: border-color 0.3s;
}

/* Классический круглый вращающийся ободок (Всегда стабилен) */
.avatar-glow {
    position: absolute;
    top: -5px; left: -5px; right: -5px; bottom: -5px;
    background: conic-gradient(from 0deg, var(--md-primary), #dfd2b9, var(--md-primary-container), var(--md-primary));
    border-radius: 50%;
    z-index: 1;
    animation: rotateGlow 8s linear infinite;
    filter: blur(2px);
    transition: background 0.3s;
}

@keyframes rotateGlow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.profile-name {
    font-family: 'Roboto Slab', serif; font-size: 2.4rem; font-weight: 700;
    color: var(--md-primary); transition: color 0.3s;
}
.profile-tagline { font-size: 1.15rem; color: var(--md-on-surface-variant); margin-bottom: 16px; }

.profile-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 4px;
}

.md-chip {
    display: inline-flex; 
    align-items: center; 
    gap: 6px; 
    padding: 6px 14px; 
    border-radius: 12px;
    background-color: var(--md-surface-container-high); 
    font-size: 0.85rem; 
    font-weight: 500; 
    border: 1px solid var(--md-outline-variant);
}

/* МУЗЫКАЛЬНЫЙ ПЛЕЕР */
.music-player {
    background-color: var(--md-surface-container-low); border-radius: 24px; padding: 16px; margin-bottom: 32px;
    border: 1px solid var(--md-outline-variant); display: flex; align-items: center; gap: 16px;
}
.player-cover-area { width: 64px; height: 64px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.track-cover { width: 100%; height: 100%; object-fit: cover; border-radius: 14px; border: 1px solid var(--md-outline-variant); animation: pulseCover 2s infinite ease-in-out; }
.fallback-icon-wrapper { width: 100%; height: 100%; background-color: var(--md-primary-container); border-radius: 14px; display: flex; align-items: center; justify-content: center; transition: background-color 0.3s; }
.disc-icon { color: var(--md-primary); font-size: 2rem; animation: pulseCover 2s infinite ease-in-out; transition: color 0.3s; }

@keyframes pulseCover {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50% { transform: scale(1.08); opacity: 1; }
}

.player-content-area { flex-grow: 1; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.track-title { font-size: 0.95rem; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.track-author { font-size: 0.8rem; color: var(--md-on-surface-variant); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.player-controls { display: flex; align-items: center; gap: 12px; }
.player-btn {
    background-color: var(--md-primary); border: none; width: 40px; height: 40px; border-radius: 50%;
    color: var(--md-on-primary); cursor: pointer; display: flex; justify-content: center; align-items: center; flex-shrink: 0;
    transition: background-color 0.3s, color 0.3s;
}

/* ПОЛЗУНОК-ВОЛНА ANDROID */
.progress-container { flex: 1; height: 24px; position: relative; cursor: pointer; display: flex; align-items: center; }
.progress-track { position: absolute; left: 0; right: 0; top: 10px; height: 4px; background-color: var(--md-surface-container-highest); border-radius: 2px; }
.progress-bar-flat { position: absolute; left: 0; top: 10px; height: 4px; width: 0%; background-color: var(--md-primary); border-radius: 2px; opacity: 1; transition: opacity 0.25s var(--md-motion-easing), background-color 0.3s; }
.progress-bar-wave {
    position: absolute; left: 0; top: 2px; height: 20px; width: 0%; background-color: var(--md-primary);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 20'%3E%3Cpath d='M 0 10 Q 10 2, 20 10 T 40 10' fill='none' stroke='black' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 20'%3E%3Cpath d='M 0 10 Q 10 2, 20 10 T 40 10' fill='none' stroke='black' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E");
    -webkit-mask-repeat: repeat-x; mask-repeat: repeat-x; -webkit-mask-size: 32px 20px; mask-size: 32px 20px; opacity: 0; transition: opacity 0.25s var(--md-motion-easing), background-color 0.3s;
}
.music-player.is-playing .progress-bar-flat { opacity: 0; }
.music-player.is-playing .progress-bar-wave { opacity: 1; animation: moveAndroidWave 0.8s linear infinite; }

@keyframes moveAndroidWave {
    from { -webkit-mask-position-x: 0px; mask-position-x: 0px; }
    to { -webkit-mask-position-x: 32px; mask-position-x: 32px; }
}

.progress-thumb {
    position: absolute; left: 0%; top: 12px; width: 12px; height: 12px; background-color: var(--md-primary); border-radius: 50%; transform: translate(-50%, -50%) scale(0);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s; box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.25); z-index: 10;
}
.progress-container:hover .progress-thumb, .progress-container.is-dragging .progress-thumb { transform: translate(-50%, -50%) scale(1); }
.progress-thumb::after { content: ''; position: absolute; inset: -10px; border-radius: 50%; background-color: var(--md-primary); opacity: 0; transform: scale(0.6); transition: transform 0.2s, opacity 0.2s; }
.progress-container.is-dragging .progress-thumb::after { opacity: 0.16; transform: scale(1); }
.progress-container.is-dragging .progress-bar-flat, .progress-container.is-dragging .progress-bar-wave, .progress-container.is-dragging .progress-thumb { transition: none !important; }
.time-display { font-size: 0.8rem; color: var(--md-on-surface-variant); min-width: 32px; }

/* Вкладки (Tabs) */
.material-tabs { display: flex; background-color: var(--md-surface-container-high); border-radius: 16px; padding: 4px; margin-bottom: 28px; }
.tab-btn { flex: 1; background: none; border: none; padding: 12px; color: var(--md-on-surface-variant); font-size: 1rem; font-weight: 600; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 8px; border-radius: 12px; transition: all 0.2s ease; }
.tab-btn.active { background-color: var(--md-surface); color: var(--md-primary); box-shadow: 0px 4px 12px rgba(0,0,0,0.05); }
.tab-pane { display: none; animation: fadeIn 0.35s var(--md-motion-easing-emphasized) forwards; }
.tab-pane.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Блоки контента */
.info-block { margin-bottom: 28px; }
.block-title { font-family: 'Roboto Slab', serif; font-size: 1.2rem; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; color: var(--md-primary); transition: color 0.3s; }
.block-text { font-size: 0.98rem; line-height: 1.65; color: var(--md-on-surface-variant); }

/* Навыки в две колонки */
.skills-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.skill-card { background-color: var(--md-surface-container-low); border-radius: 16px; padding: 20px; border: 1px solid var(--md-outline-variant); transition: box-shadow .2s, transform .2s, border-color .2s; }
.skill-card:hover { box-shadow: 0px 6px 16px rgba(0,0,0,0.06); transform: translateY(-2px); border-color: var(--md-primary); }
.skill-card__icon { width: 44px; height: 44px; background-color: var(--md-primary-container); border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; transition: background-color 0.3s; }
.skill-card__icon span { font-size: 1.5rem; color: var(--md-primary); transition: color 0.3s; }
.skill-card__name { font-weight: 600; font-size: 1rem; margin-bottom: 8px; }
.skill-card__bar-track { height: 6px; background-color: var(--md-surface-container-highest); border-radius: 3px; overflow: hidden; }
.skill-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--md-primary), #9B8E78); border-radius: 3px; transition: width 1.2s var(--md-motion-easing-emphasized); }

/* Проекты в две колонки */
.tab-hint { font-size: 0.8rem; color: var(--md-on-surface-variant); text-align: center; margin-bottom: 16px; }
.projects-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.project-card { background-color: var(--md-surface-container-low); border-radius: 20px; border: 1px solid var(--md-outline-variant); overflow: hidden; display: flex; flex-direction: column; }
.project-card__thumb { position: relative; height: 160px; background-color: var(--md-surface-container-high); }
.project-card__default { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; z-index: 1; transition: opacity 0.3s; }
.project-card__icon { width: 48px; height: 48px; border-radius: 14px; background-color: var(--p-icon-bg); display: flex; align-items: center; justify-content: center; }
.project-card__icon span { font-size: 1.6rem; color: var(--p-icon-color); }
.project-card__badge { font-size: 0.75rem; font-weight: 700; background-color: var(--md-surface-container-highest); padding: 4px 12px; border-radius: 10px; }
.project-card__screenshot { position: absolute; inset: 0; opacity: 0; transition: opacity 0.3s var(--md-motion-easing); z-index: 2; }
.project-card__screenshot img { width: 100%; height: 100%; object-fit: cover; }
.project-card:hover .project-card__screenshot { opacity: 1; }
.project-card:hover .project-card__default { opacity: 0; }
.project-card__body { padding: 20px; flex-grow: 1; display: flex; flex-direction: column; }
.project-card__body h3 { font-size: 1.1rem; margin-bottom: 6px; }
.project-card__body p { font-size: 0.9rem; color: var(--md-on-surface-variant); margin-bottom: 14px; line-height: 1.55; flex-grow: 1; }
.project-card__links { display: flex; gap: 10px; }
.project-link { font-size: 0.8rem; font-weight: 600; text-decoration: none; padding: 8px 16px; border-radius: 20px; transition: background-color 0.2s; }
.project-link--source { background-color: var(--md-surface-container-highest); color: var(--md-on-surface); }
.project-link--source:hover { background-color: var(--md-primary-container); }
.project-link--demo { background-color: var(--md-primary); color: var(--md-on-primary); transition: background-color 0.3s, color 0.3s; }
.project-link--demo:hover { filter: brightness(1.08); }
.project-link--wip { color: var(--md-on-surface-variant); border: 1px dashed var(--md-outline-variant); font-style: italic; }

/* Соцсети */
.social-grid { display: flex; flex-direction: column; gap: 12px; }
.social-card { display: flex; align-items: center; padding: 16px 20px; background-color: var(--md-surface-container-low); border-radius: 16px; border: 1px solid var(--md-outline-variant); text-decoration: none; color: inherit; transition: transform 0.2s, background-color 0.2s; }
.social-card:hover { transform: scale(1.008); background-color: var(--md-surface-container-high); }
.social-card .material-symbols-rounded:first-child { font-size: 1.8rem; margin-right: 14px; }
.social-info-text { flex: 1; display: flex; flex-direction: column; }
.social-name { font-weight: 600; font-size: 1rem; }
.social-handle { font-size: 0.85rem; color: var(--md-on-surface-variant); }
.arrow { color: var(--md-outline-variant); font-size: 1.3rem; }

.tg-icon { color: #24A1DE; }
.dc-icon { color: #5865F2; }
.gh-icon { color: var(--md-primary); transition: color 0.3s; }
.tt-icon { color: #EE1D52; }

.compact-footer { margin-top: 32px; border-top: 1px solid var(--md-outline-variant); padding-top: 24px; text-align: center; }
.copyright { font-size: 0.8rem; color: var(--md-on-surface-variant); }

.project-card.touch-preview .project-card__screenshot { opacity: 1; }
.project-card.touch-preview .project-card__default    { opacity: 0; }

@media (max-width: 768px) {
    .skills-grid, .projects-list { grid-template-columns: 1fr; }
    .bio-container { padding: 24px 20px; }
}