* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #000000;
    --fg: #f5f5f7;
    --muted: #a1a1a6;
    --card: #0a0a0a;
    --border: #1a1a1a;
    --accent: #f492f0;
    --transition-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --transition-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --noise-opacity: 0.08;
    --gradient-1: rgba(244,146,240,.22);
    --gradient-2: rgba(94,66,156,.24);
    --gradient-3: rgba(0,0,0,.22);
    --github-brand: #ffffff;
}

:root[data-theme="light"] {
    --bg: #ffffff;
    --fg: #1d1d1f;
    --muted: #6e6e73;
    --card: #f5f5f7;
    --border: #d2d2d7;
    --accent: #c960c5;
    --noise-opacity: 0.06;
    --gradient-1: rgba(244,146,240,.35);
    --gradient-2: rgba(94,66,156,.38);
    --gradient-3: rgba(0,0,0,.12);
    --github-brand: #1d1d1f;
}

@font-face {
    font-family: raleway_f;
    src: url(../fonts/raleway-regular.woff2);
    font-display: swap;
}

@font-face {
    font-family: raleway_f;
    src: url(../fonts/raleway-black.woff2);
    font-weight: 900;
    font-display: swap;
}

html {
    scroll-behavior: smooth;
    scrollbar-width: none;
}

::-webkit-scrollbar {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .wrapper::before,
    .wrapper::after {
        animation: none !important;
    }
    .wrapper::before {
        opacity: 1 !important;
    }
    .wrapper::after {
        opacity: 0 !important;
    }
}

body {
    background-color: var(--bg);
    color: var(--fg);
    font-family: raleway_f, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background-color 0.3s var(--transition-smooth), color 0.3s var(--transition-smooth);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 999;
    pointer-events: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 150px 150px;
    will-change: transform, opacity;
    opacity: var(--noise-opacity);
    animation: grainPulse 8s ease-in-out infinite;
    transition: opacity 0.3s var(--transition-smooth);
}

@keyframes grainPulse {
    0%, 100% {
        opacity: var(--noise-opacity);
    }
    50% {
        opacity: calc(var(--noise-opacity) * 1.5);
    }
}

.wrapper {
    position: relative;
    z-index: 1;
}

.wrapper::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle 1000px at 85% -10%, var(--gradient-1), transparent 70%),
        radial-gradient(circle 900px at 15% 110%, var(--gradient-2), transparent 70%);
    opacity: 1;
    animation: gradientFade 8s ease-in-out infinite;
}

.wrapper::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle 1000px at 20% 80%, var(--gradient-2), transparent 70%),
        radial-gradient(circle 900px at 80% 20%, var(--gradient-1), transparent 70%);
    opacity: 0;
    animation: gradientFadeAlt 8s ease-in-out infinite;
    animation-delay: 4s;
}

@keyframes gradientFade {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

@keyframes gradientFadeAlt {
    0%, 100% {
        opacity: 0;
    }
    50% {
        opacity: 0.7;
    }
}

.content {
    isolation: isolate;
    position: relative;
    z-index: 1;
}

.content::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, var(--gradient-3) 72%);
    pointer-events: none;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    background-color: rgba(0,0,0,.6);
    border-bottom: 1px solid var(--border);
}

.site-header .nav {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    color: var(--fg);
    text-decoration: none;
    font-weight: 900;
    letter-spacing: .5px;
}

.menu a {
    color: var(--muted);
    text-decoration: none;
    margin-left: 18px;
    transition: color 0.2s ease;
}

.menu a:hover,
.menu a:focus-visible {
    color: var(--fg);
    outline: none;
}

.hero {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: clamp(48px, 12vh, 140px);
    position: relative;
}

.hero__inner {
    max-width: 1100px;
    width: 100%;
    text-align: left;
    padding: 0 24px;
}

.hero h1 {
    font-size: clamp(32px, 6vw, 72px);
    letter-spacing: -1px;
    font-weight: 900;
}

.subtitle {
    margin-top: 10px;
    color: var(--muted);
    font-size: clamp(14px, 2vw, 18px);
}

.hero__cta {
    margin-top: 26px;
}

.btn {
    display: inline-block;
    padding: 12px 18px;
    border-radius: 999px;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    letter-spacing: .2px;
    background-color: #1f1f1f;
    border: 1px solid #2a2a2a;
    transition: all 0.3s var(--transition-smooth);
    cursor: pointer;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn--primary {
    background-color: var(--accent);
    border-color: rgba(244,146,240,.35);
}

.btn--primary:hover,
.btn--primary:focus-visible {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(244,146,240,.3);
}

.links-section {
    padding: 0 20px;
}

.section-title {
    max-width: 1100px;
    margin: 0 auto 18px;
    color: var(--muted);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-weight: 700;
}

.links-grid {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    max-width: 1100px;
    margin: 10px auto 0;
}

.link-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--fg);
    text-decoration: none;
    transition: transform .25s ease, border-color .25s ease, background .25s ease, box-shadow .25s ease;
    visibility: hidden;
    will-change: transform;
}

.link-card:hover,
.link-card:focus-visible {
    transform: translateY(-2px);
    border-color: #2c2c2c;
    background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
    box-shadow: 0 10px 30px -10px rgba(0,0,0,.6);
    outline: none;
}

.link-card:focus-visible {
    box-shadow: 0 10px 30px -10px rgba(0,0,0,.6), 0 0 0 2px rgba(244,146,240,.35);
}

.link-card i {
    font-size: 18px;
    width: 22px;
    text-align: center;
    transition: color 0.3s ease, transform 0.3s var(--transition-bounce);
}

.link-card:hover i,
.link-card:focus-visible i {
    color: var(--brand);
    transform: scale(1.1);
}

.link-card span {
    font-weight: 600;
}

.link-card.telegram { --brand: #229ED9; }
.link-card.youtube { --brand: #FF0000; }
.link-card.instagram { --brand: #E1306C; }
.link-card.vk { --brand: #4C75A3; }
.link-card.spotify { --brand: #1DB954; }
.link-card.github { --brand: var(--github-brand); }
.link-card.email { --brand: #7b5fb8; }

.site-footer {
    border-top: 1px solid var(--border);
}

.site-footer .footer__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 26px 20px;
    color: var(--muted);
    font-size: 14px;
}

.hero__links .section-title {
    max-width: none;
    margin: 26px 0 10px;
}

.hero__links .links-grid {
    max-width: 760px;
    margin: 0;
}

.projects {
    margin-top: 24px;
    margin-bottom: 24px;
}

.projects-title {
    color: var(--muted);
    font-size: 13px;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-bottom: 10px;
    font-weight: 700;
}

.projects-row {
    list-style: none;
    position: relative;
    gap: 12px;
    min-height: 300px;
}

.projects-row > li {
    position: absolute;
    transition: top 0.3s ease, left 0.3s ease;
}

.project-card {
    background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    color: var(--fg);
    min-height: 110px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform .25s ease, border-color .25s ease, background .25s ease, box-shadow .25s ease;
    will-change: transform;
    visibility: hidden;
    cursor: default;
}

.projects-row a.project-card,
.projects-row article.project-card {
    text-decoration: none;
    color: inherit;
    display: flex;
    cursor: pointer;
}

.projects-row article.project-card {
    cursor: default;
}

.project-card:hover,
.projects-row a.project-card:focus-visible {
    transform: scale(1.03);
    border-color: #2c2c2c;
    background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
    box-shadow: 0 8px 24px -8px rgba(0,0,0,.5);
}

.projects-row a.project-card:focus-visible {
    outline: none;
    box-shadow: 0 8px 24px -8px rgba(0,0,0,.5), 0 0 0 2px rgba(244,146,240,.35);
}

.project-card h3 {
    font-size: 14px;
    font-weight: 700;
}

.project-card p {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.35;
}

@media (prefers-reduced-motion: reduce) {
    .project-card {
        transition: border-color .25s ease, background .25s ease;
    }
    .project-card:hover,
    .projects-row a.project-card:focus-visible {
        transform: none;
    }
    .link-card:hover,
    .link-card:focus-visible {
        transform: none;
    }
}

.spotify-title {
    color: var(--muted);
    font-size: 13px;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-bottom: 10px;
    transition: all 0.4s var(--transition-smooth);
    will-change: transform, opacity, filter;
    position: relative;
    font-weight: 700;
    text-shadow: 0 0 20px rgba(244, 146, 240, 0);
}

.github-stats {
    margin-top: 24px;
    margin-bottom: 24px;
}

.github-stats-title {
    color: var(--muted);
    font-size: 13px;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-bottom: 10px;
    font-weight: 700;
}

.github-stats-card {
    background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    transition: transform .25s ease, border-color .25s ease, background .25s ease, box-shadow .25s ease;
    max-width: 500px;
    display: inline-block;
}

.github-stats-card:hover {
    transform: translateY(-2px);
    border-color: #2c2c2c;
    background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
    box-shadow: 0 10px 30px -10px rgba(0,0,0,.6);
}

.github-stats-card img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
    .github-stats-card:hover {
        transform: none;
    }
}

.spotify-widget-container {
    margin-bottom: 27px;
}

@media (min-width: 769px) {
    .spotify-widget-container {
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 100;
        width: 300px;
        margin-bottom: 0;
    }
}

#spotify-now-playing {
    position: relative;
    height: 152px;
    border-radius: 12px;
    overflow: hidden;
}

#spotify-now-playing .np-placeholder,
#spotify-now-playing iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    border: none;
    transition: opacity 0.4s ease-in-out;
}

#spotify-now-playing .np-placeholder {
    opacity: 1;
    z-index: 2;
}

#spotify-now-playing iframe {
    opacity: 0;
    z-index: 1;
}

#spotify-now-playing.is-loaded .np-placeholder {
    opacity: 0;
    z-index: 1;
    pointer-events: none;
}

#spotify-now-playing.is-loaded iframe {
    opacity: 1;
    z-index: 2;
}

.np-placeholder {
    background-color: rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.np-placeholder::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    animation: shimmer 1.5s infinite linear;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.spotify-title.loading {
    position: relative;
    animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.spotify-title.fade-out {
    opacity: 0;
    transform: translateY(-12px) scale(0.95);
    filter: blur(4px);
    transition: all 0.5s cubic-bezier(0.4, 0, 1, 1);
}

.spotify-title.fade-in {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
    transition: all 0.6s cubic-bezier(0, 0, 0.2, 1);
    animation: titleSlideIn 0.6s cubic-bezier(0, 0, 0.2, 1);
    text-shadow: 0 0 20px rgba(244, 146, 240, 0.3);
}

@keyframes titleSlideIn {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(1.05);
        filter: blur(4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@media (max-width: 768px) {
    .links-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    .projects-row {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

@media (max-width: 640px) {
    body {
        height: auto;
        overflow-x: hidden;
    }

    .hero {
        height: auto;
        min-height: 90vh;
        padding-top: clamp(32px, 4vh, 80px);
    }

    .hero__inner {
        padding: 0 16px;
    }

    .links-grid {
        grid-template-columns: 1fr;
    }

    .projects-row {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 10px;
    }

    .project-card {
        min-height: auto;
        padding: 12px;
    }

    .project-card h3 {
        font-size: 13px;
    }

    .project-card p {
        font-size: 12px;
    }
}

@media (max-width: 375px) {
    .hero h1 {
        font-size: clamp(28px, 8vw, 48px);
    }
    .subtitle {
        font-size: clamp(13px, 4vw, 16px);
    }
    .projects-row {
        grid-template-columns: 1fr;
    }
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@supports (backdrop-filter: blur(20px)) {
    .site-header {
        backdrop-filter: saturate(180%) blur(20px);
    }
}

.theme-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

.theme-toggle:hover {
    transform: scale(1.05);
    border-color: var(--accent);
    box-shadow: 0 6px 16px rgba(0,0,0,.3);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle__icon {
    width: 22px;
    height: 22px;
    position: absolute;
    transition: all 0.3s var(--transition-smooth);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.theme-toggle__icon--sun {
    opacity: 0;
    transform: rotate(90deg) scale(0);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f5f5f7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Cline x1='12' y1='1' x2='12' y2='3'/%3E%3Cline x1='12' y1='21' x2='12' y2='23'/%3E%3Cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'/%3E%3Cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'/%3E%3Cline x1='1' y1='12' x2='3' y2='12'/%3E%3Cline x1='21' y1='12' x2='23' y2='12'/%3E%3Cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'/%3E%3Cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'/%3E%3C/svg%3E");
}

.theme-toggle__icon--moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f5f5f7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
}

:root[data-theme="light"] .theme-toggle__icon--sun {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d1d1f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Cline x1='12' y1='1' x2='12' y2='3'/%3E%3Cline x1='12' y1='21' x2='12' y2='23'/%3E%3Cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'/%3E%3Cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'/%3E%3Cline x1='1' y1='12' x2='3' y2='12'/%3E%3Cline x1='21' y1='12' x2='23' y2='12'/%3E%3Cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'/%3E%3Cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'/%3E%3C/svg%3E");
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

:root[data-theme="light"] .theme-toggle__icon--moon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d1d1f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

@media (max-width: 768px) {
    .theme-toggle {
        top: 16px;
        left: auto;
        right: 16px;
        width: 44px;
        height: 44px;
    }
    
    .theme-toggle__icon {
        width: 20px;
        height: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .theme-toggle,
    .theme-toggle__icon {
        transition: none;
    }
}
