/* ─── Base & scroll ─── */
:root {
    /* Pink neon (dark theme) */
    --accent-1: #fb7185; /* rose-400 */
    --accent-2: #ec4899; /* pink-500 */
    --accent-3: #a21caf; /* fuchsia-700 */
    --accent-soft: rgba(236, 72, 153, 0.35);
}

html {
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #020617;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent-2), var(--accent-3));
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--accent-1), var(--accent-3));
}

::selection {
    background: var(--accent-soft);
    color: #fff;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent-1);
    outline-offset: 3px;
}

/* ─── Ambient background (hero / global) ─── */
.ambient-wrap {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.ambient-wrap .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.45;
    animation: orb-float 18s ease-in-out infinite;
}

.ambient-wrap .orb-1 {
    width: min(90vw, 600px);
    height: min(90vw, 600px);
    background: radial-gradient(circle, var(--accent-2) 0%, transparent 70%);
    top: -15%;
    left: -10%;
    animation-delay: 0s;
}

.ambient-wrap .orb-2 {
    width: min(80vw, 500px);
    height: min(80vw, 500px);
    background: radial-gradient(circle, var(--accent-3) 0%, transparent 70%);
    bottom: -20%;
    right: -15%;
    animation-delay: -6s;
}

.ambient-wrap .orb-3 {
    width: min(60vw, 400px);
    height: min(60vw, 400px);
    background: radial-gradient(circle, var(--accent-1) 0%, transparent 70%);
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    animation-delay: -12s;
    opacity: 0.25;
}

@keyframes orb-float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(4%, 6%) scale(1.05); }
    66% { transform: translate(-3%, 3%) scale(0.95); }
}

.ambient-grid {
    position: absolute;
    inset: -50%;
    background-image:
        linear-gradient(rgba(236, 72, 153, 0.028) 1px, transparent 1px),
        linear-gradient(90deg, rgba(236, 72, 153, 0.028) 1px, transparent 1px);
    background-size: 64px 64px;
    animation: grid-drift 40s linear infinite;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black 20%, transparent 70%);
}

@keyframes grid-drift {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-64px, -64px) rotate(0deg); }
}

/* Grain overlay */
.noise-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Page load */
.page-curtain {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: linear-gradient(135deg, #020617 0%, #0f172a 50%, #020617 100%);
    pointer-events: none;
    animation: curtain-lift 1.2s cubic-bezier(0.76, 0, 0.24, 1) forwards;
    animation-delay: 0.15s;
}

@keyframes curtain-lift {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-100%); opacity: 0; visibility: hidden; }
}

/* ─── Nav ─── */
nav.nav-epic {
    transition:
        transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        background-color 0.4s ease,
        box-shadow 0.4s ease,
        border-color 0.4s ease;
}

nav.nav-epic.nav-hidden {
    transform: translateY(-100%);
}

nav.nav-epic.is-scrolled {
    background-color: rgba(2, 6, 23, 0.92);
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.35),
        0 0 0 1px rgba(236, 72, 153, 0.06);
}

nav.nav-epic::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(251, 113, 133, 0.35) 20%,
        rgba(162, 28, 175, 0.45) 50%,
        rgba(251, 113, 133, 0.35) 80%,
        transparent
    );
    opacity: 0.7;
    animation: nav-line-shimmer 4s ease-in-out infinite;
}

@keyframes nav-line-shimmer {
    0%, 100% { opacity: 0.4; filter: blur(0); }
    50% { opacity: 1; filter: blur(0.5px); }
}

.nav-link-epic {
    position: relative;
    transition: color 0.2s ease;
}

.nav-link-epic::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-1), var(--accent-3));
    transform: translateX(-50%);
    transition: width 0.25s ease;
    border-radius: 2px;
}

.nav-link-epic:hover::after {
    width: 70%;
}

/* Nav CTA — один слой hover, без transform (не конфликтует с layout) */
.nav-cta {
    transition:
        filter 0.2s ease,
        box-shadow 0.2s ease;
}

.nav-cta:hover {
    filter: brightness(1.06);
    box-shadow: 0 12px 28px -10px rgba(236, 72, 153, 0.42);
}

.nav-cta:active {
    filter: brightness(0.98);
}

/* Mobile menu panel */
#mobile-menu {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition:
        max-height 0.5s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.35s ease;
}

#mobile-menu.is-open {
    max-height: 320px;
    opacity: 1;
    pointer-events: auto;
}

/* ─── Hero ─── */
.hero-glow-ring {
    position: absolute;
    width: min(140vw, 900px);
    height: min(140vw, 900px);
    left: 50%;
    top: 45%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        transparent,
        rgba(236, 72, 153, 0.16),
        transparent,
        rgba(162, 28, 175, 0.12),
        transparent,
        rgba(251, 113, 133, 0.09),
        transparent
    );
    animation: hero-ring-spin 20s linear infinite;
    filter: blur(40px);
    pointer-events: none;
}

@keyframes hero-ring-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.hero-badge {
    animation: badge-pop 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s both;
}

@keyframes badge-pop {
    from {
        opacity: 0;
        transform: scale(0.85) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.hero-title .word {
    display: inline-block;
    opacity: 0;
    transform: translateY(1.1em) rotateX(-25deg);
    animation: word-rise 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hero-title .block:first-child .word:nth-child(1) { animation-delay: 0.18s; }
.hero-title .block:first-child .word:nth-child(2) { animation-delay: 0.26s; }
.hero-title .block:last-child .word:nth-child(1) { animation-delay: 0.38s; }
.hero-title .block:last-child .word:nth-child(2) { animation-delay: 0.46s; }
.hero-title .block:last-child .word:nth-child(3) { animation-delay: 0.54s; }

@keyframes word-rise {
    to {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
}

.hero-sub {
    opacity: 0;
    animation: fade-up 0.9s ease 0.85s forwards;
}

.hero-cta {
    opacity: 0;
    animation: fade-up 0.9s ease 1.05s forwards;
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(28px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Подсказка скролла — только иконка слегка двигается, подпись стабильна */
.hero-scroll-icon {
    animation: scroll-hint-nudge 2.4s ease-in-out infinite;
}

@keyframes scroll-hint-nudge {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

.gradient-text-epic {
    background: linear-gradient(
        120deg,
        #fff 0%,
        #fecdd3 22%,
        var(--accent-1) 42%,
        #f5d0fe 62%,
        var(--accent-2) 82%,
        #fff 100%
    );
    background-size: 220% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: gradient-flow 6s ease infinite;
}

@keyframes gradient-flow {
    0%, 100% { background-position: 0% center; }
    50% { background-position: 100% center; }
}

/* ─── Buttons — без scale и «бликов», один предсказуемый hover ─── */
.btn-epic {
    transition:
        filter 0.2s ease,
        box-shadow 0.2s ease;
}

.btn-epic:hover {
    filter: brightness(1.05);
    box-shadow: 0 14px 32px -12px rgba(236, 72, 153, 0.42);
}

.btn-epic:active {
    filter: brightness(0.97);
    transition-duration: 0.08s;
}

.btn-ghost-epic {
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.btn-ghost-epic:hover {
    border-color: rgba(251, 113, 133, 0.35);
    box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.45);
}

.btn-ghost-epic:active {
    background-color: rgba(15, 23, 42, 0.95);
}

/* Текстовая ссылка на проект */
.link-project {
    transition: color 0.2s ease, opacity 0.2s ease;
}

.link-project:hover {
    color: #fda4af;
}

.link-project:active {
    opacity: 0.9;
}

/* ─── Section titles ─── */
.section-label {
    display: inline-block;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent-1);
    opacity: 0;
    transform: translateY(12px);
    transition:
        opacity 0.6s ease,
        transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.section-label.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.section-title-bar {
    width: 0;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent-2), var(--accent-3));
    margin: 1rem auto 0;
    transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.section-title-bar.is-visible {
    width: 4rem;
}

.section-title-bar.left {
    margin: 1rem 0 0;
}

.section-title-bar.left.is-visible {
    width: 3.5rem;
}

/* ─── Reveal on scroll ─── */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    filter: blur(8px);
    transition:
        opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.85s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.85s ease;
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
}

.reveal-left {
    opacity: 0;
    transform: translateX(-36px);
    transition:
        opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal-left.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(36px);
    transition:
        opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal-right.is-visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.94);
    transition:
        opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal-scale.is-visible {
    opacity: 1;
    transform: scale(1);
}

/* Stagger children */
.stagger-children.is-visible > *:nth-child(1) { transition-delay: 0.05s; }
.stagger-children.is-visible > *:nth-child(2) { transition-delay: 0.12s; }
.stagger-children.is-visible > *:nth-child(3) { transition-delay: 0.19s; }
.stagger-children.is-visible > *:nth-child(4) { transition-delay: 0.26s; }
.stagger-children.is-visible > *:nth-child(5) { transition-delay: 0.33s; }
.stagger-children.is-visible > *:nth-child(6) { transition-delay: 0.4s; }

.stagger-children > * {
    opacity: 0;
    transform: translateY(24px);
    transition:
        opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.stagger-children.is-visible > * {
    opacity: 1;
    transform: translateY(0);
}

/* ─── Skill cards ─── */
.skill-card {
    position: relative;
    overflow: hidden;
    transition:
        transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.4s ease,
        box-shadow 0.45s ease;
}

.skill-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.06),
        transparent
    );
    transition: left 0.55s ease;
}

.skill-card:hover::before {
    left: 100%;
}

.skill-card:hover {
    transform: translateY(-3px);
    box-shadow:
        0 16px 36px -18px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(34, 211, 238, 0.1);
}

.skill-card-glow {
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.45s ease;
    background: linear-gradient(
        135deg,
        rgba(34, 211, 238, 0.25),
        transparent 40%,
        transparent 60%,
        rgba(167, 139, 250, 0.2)
    );
    z-index: 0;
    pointer-events: none;
}

.skill-card:hover .skill-card-glow {
    opacity: 1;
}

.skill-card > * {
    position: relative;
    z-index: 1;
}

/* ─── Project showcase ─── */
/* Avoid 3D transform on the frame — it skews layout and makes the image look “shifted”. */
.project-frame {
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.project-frame:hover {
    transform: translateY(-2px);
}

.project-img-wrap {
    overflow: hidden;
    isolation: isolate;
}

.project-img-wrap img {
    transition: transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
    transform-origin: center center;
}

.project-frame:hover .project-img-wrap img {
    transform: scale(1.05);
}

/* ─── Contact cards ─── */
.contact-card {
    transition:
        transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
        border-color 0.35s ease,
        box-shadow 0.4s ease;
}

.contact-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px -16px rgba(236, 72, 153, 0.14);
}

/* ─── Footer ─── */
.footer-icon {
    transition: transform 0.35s ease, color 0.25s ease;
}

.footer-icon:hover {
    color: var(--accent-1);
}

/* Legacy */
.animate-fade-in {
    animation: fade-in 0.8s ease-out forwards;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Z-index stacking for content above ambient */
main,
nav,
footer {
    position: relative;
    z-index: 2;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .page-curtain,
    .ambient-wrap .orb,
    .ambient-grid,
    .hero-glow-ring,
    .gradient-text-epic,
    nav.nav-epic::after {
        animation: none !important;
    }

    .hero-title .word,
    .hero-badge,
    .hero-sub,
    .hero-cta {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .hero-scroll-icon {
        animation: none !important;
    }

    .reveal,
    .reveal-left,
    .reveal-right,
    .reveal-scale,
    .stagger-children > * {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
        transition: none !important;
    }

    .btn-epic:hover,
    .btn-ghost-epic:hover,
    .skill-card:hover,
    .contact-card:hover,
    .project-frame:hover {
        transform: none !important;
    }

    .project-frame:hover .project-img-wrap img {
        transform: none !important;
    }
}
