:root {
    --site-loader-start-left: calc(50vw - 85px);
    --site-loader-start-bottom: calc(50vh - 85px);
    --site-cube-final-width: 100vh;
    --site-cube-final-left: calc(50vw - (var(--site-cube-final-width) / 2));
    --site-cube-final-bottom: -7%;
}

.site-loader {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    background: #131213;
    animation: site-loader-shell 2.1s ease forwards;
    pointer-events: none;
}

.site-loader img {
    position: fixed;
    left: var(--site-loader-start-left);
    bottom: var(--site-loader-start-bottom);
    width: 170px;
    height: auto;
    aspect-ratio: 2076 / 2400;
    max-width: none;
    animation: site-loader-cube 1.7s cubic-bezier(0.77, 0, 0.2, 0.85) forwards;
    will-change: left, bottom, width, opacity, transform;
}

.bg {
    left: var(--site-cube-final-left);
    bottom: var(--site-cube-final-bottom);
    width: var(--site-cube-final-width);
    height: auto;
    aspect-ratio: 2076 / 2400;
    max-width: none;
    opacity: 0.02;
    transform: rotate(360deg);
    transform-origin: center;
    will-change: left, bottom, width, opacity, filter, transform;
}

body.cube-loading .site-loader,
body.cube-loading .site-loader img,
body.cube-loading .main-information-block,
body.cube-loading .row a {
    animation-play-state: paused;
}

body.cube-loading .site-loader img,
body.cube-loading .bg {
    visibility: hidden;
}

body.skip-loader .site-loader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    animation: none;
}

body.skip-loader .main-information-block,
body.skip-loader .row a {
    animation: none;
    opacity: 1;
    transform: none;
}

body.route-cube-transitioning .bg {
    visibility: hidden;
}

body.route-content-pending .bg {
    visibility: hidden;
}

body.route-content-pending .main-information-block {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(0.996);
}

.main-route-cube {
    position: fixed;
    z-index: 5;
    height: auto;
    aspect-ratio: 2076 / 2400;
    max-width: none;
    pointer-events: none;
    transform-origin: center;
    will-change: left, top, width, opacity, transform;
}

body.page-transition-out .main-information-block,
body.page-transition-out .portfolio-page,
body.page-transition-out .aboutme-page,
body.page-transition-out .contact-panel {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px) scale(0.992);
    transition: opacity 0.08s ease, transform 0.08s cubic-bezier(0.77, 0, 0.2, 0.85);
}

.main-information-block {
    position: relative;
    animation: enable 0.65s forwards 1.95s;
    transition: opacity 0.14s ease, transform 0.14s cubic-bezier(0.77, 0, 0.2, 0.85), filter 0.08s ease;
    will-change: opacity, transform, filter;
}

.main-information-block.is-leaving {
    animation: none;
    pointer-events: none;
}

.main-information-block.is-leaving h1,
.main-information-block.is-leaving #advice,
.main-information-block.is-leaving .row a {
    animation: none;
}

.main-information-block.is-returning {
    animation: main-view-in 0.28s cubic-bezier(0.77, 0, 0.2, 0.85) forwards;
}

.main-information-block.is-restored {
    animation: none;
    opacity: 1;
    transform: none;
}

.main-information-block.is-restored.is-returning {
    animation: main-view-in 0.28s cubic-bezier(0.77, 0, 0.2, 0.85) forwards;
}

body.page-transition-out .main-information-block.is-restored {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px) scale(0.992);
}

.main-information-block.is-restored .row a,
.main-information-block.is-returning .row a {
    animation: none;
    opacity: 1;
    transform: none;
}

.row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: max-content;
    max-width: calc(100vw - 32px);
    margin: 25px auto 0;
}

.row a {
    opacity: 0;
    transform: translateY(10px);
    animation: main-button-in 0.42s cubic-bezier(0.77, 0, 0.2, 0.85) forwards;
}

.row a:nth-child(1) {
    animation-delay: 2.08s;
}

.row a:nth-child(2) {
    animation-delay: 2.14s;
}

.row a:nth-child(3) {
    animation-delay: 2.20s;
}

.row a:nth-child(4) {
    animation-delay: 2.26s;
}

.rubikub-title-pop {
    animation: rubikub-title-pop 0.68s cubic-bezier(0.2, 0.88, 0.32, 1.16) both;
}

.rubikub-confetti {
    position: fixed;
    inset: 0;
    z-index: 60;
    pointer-events: none;
    overflow: hidden;
}

.rubikub-confetti-piece {
    position: fixed;
    border-radius: 3px;
    opacity: 0;
    transform: translate3d(0, -24px, 0) rotate(0deg);
    animation-name: rubikub-confetti-fall;
    animation-timing-function: cubic-bezier(0.16, 0.72, 0.24, 1);
    animation-fill-mode: forwards;
    will-change: transform, opacity;
}

.contact-panel {
    position: fixed;
    top: min(calc(50vh + 38px), calc(100vh - 170px));
    left: 50%;
    z-index: 45;
    width: min(360px, calc(100vw - 32px));
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(19, 18, 19, 0.94);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
    opacity: 0;
    overflow: visible;
    pointer-events: none;
    text-align: left;
    transform: translate(-50%, -8px);
    transition: opacity 0.24s ease, transform 0.24s cubic-bezier(0.77, 0, 0.2, 0.85), visibility 0.24s ease;
    visibility: hidden;
}

.contact-panel:not(.is-visible) {
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    overflow: hidden;
}

.contact-panel.is-visible {
    height: auto;
    padding: 10px;
    border-width: 1px;
    opacity: 1;
    overflow: visible;
    pointer-events: auto;
    transform: translate(-50%, 0);
    visibility: visible;
}

.contact-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 2px 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.contact-close {
    display: inline-grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.78);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    font: inherit;
    line-height: 1;
}

.contact-close:hover {
    color: #fff;
    border-color: rgba(98, 178, 243, 0.45);
    background: rgba(98, 178, 243, 0.10);
}

.contact-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.contact-action {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    width: 100%;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    color: #fff;
    background: rgba(255, 255, 255, 0.035);
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    line-height: 1.1;
    text-align: left;
    text-decoration: none;
    transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.contact-action:hover {
    border-color: rgba(98, 178, 243, 0.45);
    background: rgba(98, 178, 243, 0.10);
    transform: translateY(-1px);
}

.contact-action-primary {
    border-color: rgba(98, 178, 243, 0.40);
    background: rgba(98, 178, 243, 0.12);
}

.contact-badge {
    display: inline-grid;
    min-width: 28px;
    height: 22px;
    place-items: center;
    border-radius: 5px;
    color: #62b2f3;
    background: rgba(98, 178, 243, 0.12);
    font-size: 11px;
    font-weight: 700;
}

.portfolio-page,
.aboutme-page {
    opacity: 0;
    transform: translateY(30px) scale(0.972);
    transition: opacity 0.62s ease, transform 0.62s cubic-bezier(0.77, 0, 0.2, 0.85);
    will-change: opacity, transform;
}

.portfolio-page.is-visible,
.aboutme-page.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.portfolio-page.is-closing,
.aboutme-page.is-closing {
    transform: translateY(12px) scale(0.992);
    transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.77, 0, 0.2, 0.85);
}

.portfolio-page,
.aboutme-page {
    width: min(760px, calc(100vw - 32px));
    margin: 96px auto 64px;
}

.cards-title,
.title-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 48px;
    padding-bottom: 8px;
}

.cards-title h1,
.title-block h1 {
    left: auto;
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    line-height: 1.04;
}

.cl-btn {
    position: relative;
    right: auto;
    left: auto;
    order: 2;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.025);
    opacity: 0.78;
    transition: opacity 0.22s ease, border-color 0.22s ease, background 0.22s ease, transform 0.22s ease;
}

.cl-btn:hover {
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.06);
    opacity: 1;
    transform: scale(1.03);
}

.cl-btn:active {
    transform: scale(0.96);
}

.cl-btn::before,
.cl-btn::after {
    content: "";
    position: absolute;
    z-index: 2;
    top: 50%;
    left: 50%;
    width: 13px;
    height: 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.74);
    transition: background 0.22s ease;
}

.cl-btn::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.cl-btn::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.cl-btn:hover::after,
.cl-btn:hover::before {
    background: #fff;
}

.cl-btn:hover::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.cl-btn:hover::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.main-panel-open .bg {
    opacity: 0.025;
}

body.panel-cube-loading .bg {
    z-index: 25;
}

@keyframes site-loader-cube {
    0% {
        left: var(--site-loader-start-left);
        bottom: var(--site-loader-start-bottom);
        width: 170px;
        opacity: 0;
        transform: rotate(0deg) scale(0.72);
    }
    35% {
        left: var(--site-loader-start-left);
        bottom: var(--site-loader-start-bottom);
        width: 170px;
        opacity: 1;
        transform: rotate(160deg) scale(1);
    }
    100% {
        left: var(--site-cube-final-left);
        bottom: var(--site-cube-final-bottom);
        width: var(--site-cube-final-width);
        opacity: 0.02;
        transform: rotate(360deg) scale(1);
    }
}

@keyframes main-button-in {
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes main-view-out {
    100% {
        opacity: 0;
        transform: translateY(-8px) scale(0.99);
    }
}

@keyframes main-view-in {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.99);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes rubikub-title-pop {
    0% {
        transform: translateY(0) scale(1);
    }
    34% {
        transform: translateY(-2px) scale(1.035);
    }
    70% {
        transform: translateY(1px) scale(0.992);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

@keyframes rubikub-confetti-fall {
    0% {
        opacity: 0;
        transform: translate3d(0, -24px, 0) rotate(0deg);
    }
    8% {
        opacity: 0.92;
    }
    76% {
        opacity: 0.86;
    }
    100% {
        opacity: 0;
        transform: translate3d(var(--confetti-x), var(--confetti-y), 0) rotate(var(--confetti-rotate));
    }
}

@keyframes site-loader-shell {
    0%, 78% {
        opacity: 1;
        visibility: visible;
    }
    100% {
        opacity: 0;
        visibility: hidden;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-loader,
    .site-loader img,
    .main-route-cube,
    .rubikub-title-pop,
    .rubikub-confetti-piece,
    .main-information-block,
    .row a,
    .contact-panel,
    .portfolio-page,
    .aboutme-page {
        animation: none;
        opacity: 1;
        transform: none;
        transition: none;
    }

    .site-loader {
        opacity: 0;
        visibility: hidden;
    }
}

@media screen and (max-width: 620px) {
    .main-information-block {
        width: 100%;
        margin: 245px 0 0;
        padding: 0 14px;
    }

    .main-information-block h1 {
        font-size: 68px;
        line-height: 1;
    }

    .row a {
        font-size: 14px;
        padding: 8px;
    }

    .portfolio-page,
    .aboutme-page {
        width: calc(100vw - 24px);
        margin: 70px auto 42px;
    }
}

@media screen and (max-width: 420px) {
    .main-information-block h1 {
        font-size: 62px;
    }
}
