/* ===== Preloader ===== */

.ct-preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background-color: var(--color-primary);
    color: var(--color-secondary);
    display: flex;
    align-items: stretch;
    justify-content: center;
    pointer-events: auto;
    transition: opacity 600ms ease;
    will-change: opacity;
}

.ct-preloader.is-leaving {
    opacity: 0;
    pointer-events: none;
}

.ct-preloader.is-removed {
    display: none;
}

/* Hide page scroll while preloader is on */
html.ct-preloader-active,
body.ct-preloader-active {
    overflow: hidden;
}

.ct-preloader__grid {
    position: relative;
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
    padding: 40px 24px 140px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: 1fr;
    align-items: end;
    gap: 24px;
}

.ct-preloader__tagline {
    display: flex;
    flex-direction: column;
    font-family: var(--base-font);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.02em;
    line-height: 1.05;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    align-self: end;
    justify-self: start;

    /* entrance state */
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 700ms ease, transform 700ms ease;
    transition-delay: 120ms;
}

.ct-preloader__tagline span {
    display: block;
}

.ct-preloader__tagline-since,
.ct-preloader__tagline-year {
    align-self: end;
}

.ct-preloader__tagline-year {
    text-align: right;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
}

.ct-preloader__center {
    grid-column: 2;
    align-self: center;
    justify-self: center;
}

.ct-preloader__rings {
    position: relative;
    width: 360px;
    height: 360px;
    color: var(--color-secondary);
}

.ct-preloader__ring {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform, opacity, filter;

    /* entrance state */
    opacity: 0;
    transform: scale(3);
    filter: blur(40px);
    transition: opacity 800ms ease, transform 800ms ease, filter 800ms ease;
}

.ct-preloader__ring svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.ct-preloader__ring--cw-fast svg {
    animation: ct-spin-cw 1.2s ease-in-out infinite;
    width: 56%;
    height: 56%;
}

.ct-preloader__ring--ccw-slow svg {
    animation: ct-spin-ccw 20s linear infinite;
    width: 76%;
    height: 76%;
}

.ct-preloader__ring--cw-slowest svg {
    animation: ct-spin-cw 40s linear infinite;
}

.ct-preloader__counter {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--base-font);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.02em;
    color: var(--color-secondary);

    /* entrance state */
    opacity: 0;
    transform: scale(3);
    filter: blur(40px);
    transition: opacity 800ms ease, transform 800ms ease, filter 800ms ease;
    transition-delay: 100ms;
}

.ct-preloader__counter-suffix {
    margin-left: 2px;
    opacity: 0.7;
}

.ct-preloader__brand {
    align-self: end;
    justify-self: end;
    font-family: var(--secondary-font);
    font-weight: bold;
    font-size: 22px;
    line-height: 1;
    color: var(--color-secondary);
    padding-bottom: 4px;

    /* entrance state */
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 700ms ease, transform 700ms ease;
    transition-delay: 120ms;
}

/* === entrance animation triggered by JS adding .is-revealed === */
.ct-preloader.is-revealed .ct-preloader__tagline,
.ct-preloader.is-revealed .ct-preloader__brand {
    opacity: 1;
    transform: translateX(0);
}

.ct-preloader.is-revealed .ct-preloader__ring,
.ct-preloader.is-revealed .ct-preloader__counter {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
}

@keyframes ct-spin-cw {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes ct-spin-ccw {
    from { transform: rotate(0deg); }
    to   { transform: rotate(-360deg); }
}

@media (max-width: 1024px) {
    .ct-preloader__rings {
        width: 280px;
        height: 280px;
    }

    .ct-preloader__counter {
        font-size: 16px;
    }

    .ct-preloader__brand {
        font-size: 18px;
    }

    .ct-preloader__tagline {
        font-size: 12px;
    }
}

@media (max-width: 600px) {
    .ct-preloader__grid {
        padding: 28px 18px 80px;
    }

    .ct-preloader__rings {
        width: 220px;
        height: 220px;
    }

    .ct-preloader__counter {
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ct-preloader__ring--cw-fast svg,
    .ct-preloader__ring--ccw-slow svg,
    .ct-preloader__ring--cw-slowest svg {
        animation: none;
    }

    .ct-preloader__tagline,
    .ct-preloader__brand,
    .ct-preloader__ring,
    .ct-preloader__counter {
        transition: opacity 200ms linear;
        transform: none;
        filter: none;
    }
}
