/* --- PRELOADER CSS --- */
#preloader {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #ffffff 40%, #dee2e6 100%);
    z-index: 99999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.preloader-skip {
    position: absolute;
    top: max(18px, env(safe-area-inset-top));
    right: max(18px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0 0 3px;
    border: 1px solid rgba(25, 42, 53, 0.22);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.72);
    color: #192a35;
    box-shadow: 0 8px 24px rgba(15, 35, 48, 0.12);
    font: 300 32px/1 Arial, sans-serif;
    cursor: pointer;
    z-index: 200;
    opacity: 0.58;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease,
        border-color 0.2s ease, box-shadow 0.2s ease;
}

.preloader-skip:hover,
.preloader-skip:focus-visible,
.preloader-skip.is-prominent {
    opacity: 1;
    background: #fff;
    border-color: rgba(0, 155, 217, 0.55);
    box-shadow: 0 10px 28px rgba(0, 155, 217, 0.2);
    transform: scale(1.06);
}

.preloader-skip:focus-visible {
    outline: 3px solid rgba(0, 155, 217, 0.28);
    outline-offset: 3px;
}

/* Parallax Backgrounds */
.bg-layer {
    position: absolute;
    top: 65px;
    left: 0;
    width: 100%;
    height: 100%;
    background-repeat: repeat-x;
    opacity: 0.6;
}

.bg-skyline {
    background-image: url('../img/preloader/construction_skyline.webp') !important;
    background-position: left bottom;
    background-repeat: repeat-x !important;
    background-size: auto 280px !important;
    z-index: 5;
    opacity: 0.25 !important;
    filter: grayscale(100%) contrast(90%) blur(0.2px);
    position: absolute;
    left: 0;
    width: 200%;
    bottom: 80px;
    height: 320px !important;
    top: auto !important;
}

@media (min-width: 1024px) {
    .bg-skyline {
        background-size: auto 320px !important;
    }
}

/* Ground Layer */
.ground-layer {
    position: absolute;
    bottom: -450px;
    left: 0;
    width: 100%;
    height: 550px;
    background-image: url('../img/preloader/ground_texture.webp');
    background-repeat: repeat-x;
    background-size: auto 105%;
    z-index: 20;
    box-shadow: inset 0 20px 40px rgba(0, 0, 0, 0.05);
    pointer-events: none;
}

.logo-container {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translate3d(-50%, 30px, 0) scale(0.9);
    opacity: 0.01;
    transition: opacity 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), transform 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: opacity, transform;
    z-index: 100;
    text-align: center;
    pointer-events: none;
}

.logo-container.show {
    opacity: 1;
    transform: translate3d(-50%, 0, 0) scale(1);
}

.company-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 250px;
    /* Large fixed width to make identification clearer while keeping ring constant */
    max-width: 250px;
    height: auto;
    filter: drop-shadow(0px 5px 10px rgba(0, 0, 0, 0.1));
    z-index: 10;
}

.preloader-scene {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 450px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    margin-top: 290px;
}

/* Dust Cloud Particles */
.dust {
    position: absolute;
    width: 50px;
    height: 50px;
    background-image: url('../img/preloader/dust_cloud.webp');
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0;
    pointer-events: none;
}

@keyframes puff-anim {
    0% {
        transform: scale(0.6) rotate(0deg);
        opacity: 0.8;
    }

    100% {
        transform: scale(2.0) rotate(20deg) translate(-20px, -30px);
        opacity: 0;
    }
}

@keyframes stone-crush {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2) rotate(10deg);
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* Aggregate Stones */
.stone {
    position: absolute;
    bottom: 78px;
    z-index: 30;
    background-color: transparent !important;
    box-shadow: none !important;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
}

/* The Moving Construct */
.machine-group {
    position: absolute;
    bottom: 58px;
    left: 0;
    width: 350px;
    height: 220px;
    z-index: 40;
    will-change: transform;
}

.excavator-body {
    position: absolute;
    bottom: -65px;
    left: 0;
    width: 350px;
    z-index: 40;
    animation: rumble 0.15s infinite;
}

@keyframes rumble {
    0% {
        transform: translateY(0px) rotate(0deg);
    }

    50% {
        transform: translateY(-1.5px) rotate(0.1deg);
    }

    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

.excavator-hub {
    width: 100%;
    height: auto;
    filter: drop-shadow(10px 10px 15px rgba(0, 0, 0, 0.3));
}

/* Wheels */
.wheel {
    position: absolute;
    z-index: 45;
    background-image: url('../img/preloader/loader_wheel_v2.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.wheel.rear {
    left: 76px;
    width: 90px;
    height: 90px;
    bottom: 20px;
}

.wheel.front {
    right: 90px;
    width: 68px;
    height: 68px;
    bottom: 20px;
}

/* Bucket Composition - Now Independent */
.bucket-wrapper {
    position: absolute;
    left: 280px;
    bottom: 61px;
    /* Aligned closer to stones horizon (78px) */
    width: 80px;
    height: 80px;
    z-index: 35;
    pointer-events: none;
    transform-origin: left bottom;
    will-change: transform;
}

.bucket-pile {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.5s;
    position: relative;
}

/* Bucket Levels - Unified and Lowered to touch ground */
.bucket-pile.pile-level-1 {
    top: 12px;
    /* Adjusted from 32px to be just below ground line */
    z-index: 35;
}

.bucket-pile.pile-level-2 {
    top: 12px;
    /* Unified */
    z-index: 35;
}

.bucket-pile.pile-level-3 {
    top: 12px;
    /* Unified */
    z-index: 35;
}

.bucket-pile.pile-level-4 {
    top: 12px;
    /* Unified */
    z-index: 35;
}

/* Hide Class */
.preloader-hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-text {
    position: absolute;
    bottom: 40px;
    width: 100%;
    text-align: center;
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.85rem;
    color: #888;
    font-weight: 500;
    letter-spacing: 8px;
    text-transform: uppercase;
    z-index: 50;
    animation: pulse-text 2s infinite;
}

@keyframes pulse-text {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* Progress bar on top */
.top-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 6px;
    background: #009BD9;
    width: 100%;
    transform: scaleX(0);
    transform-origin: left;
    z-index: 200;
    box-shadow: 0 2px 15px rgba(0, 155, 217, 0.4);
    will-change: transform;
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 1024px) {
    .preloader-scene {
        height: 400px;
    }
}

@media (max-width: 768px) {
    .machine-group {
        transform: scale(0.7);
        transform-origin: bottom left;
        bottom: 42px;
    }

    .preloader-scene {
        height: 350px;
    }

    .company-logo {
        width: 210px;
        /* Mid-point sizing for tablet devices */
        max-width: 210px;
    }

    .bucket-wrapper {
        left: 196px;
        bottom: 56px;
        /* Adjusted for tablet horizon */
    }

    .loading-text {
        font-size: 0.75rem;
        bottom: 30px;
    }

    .ground-layer {
        height: 600px;
        bottom: -540px;
        background-repeat: no-repeat;
        background-position: top center;
        background-size: cover;
        background-color: transparent;
    }

    .bg-skyline {
        background-size: auto 90%;
    }
}

/* --- DESKTOP SPECIFIC RESPONSIVE (1025px+) --- */
@media (min-width: 1025px) {
    .logo-container {
        top: 20px;
        /* En üste yaklaştırıldı */
        transform: translate3d(-50%, 0, 0) scale(0.9);
    }

    .logo-container.show {
        transform: translate3d(-50%, 0, 0) scale(1);
    }

    .pl {
        /* Yörünge çapını daraltmak için font boyutunu küçülttük */
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .machine-group {
        transform: scale(0.55);
        transform-origin: bottom left;
        bottom: 25px;
    }

    .preloader-scene {
        height: 320px;
    }

    .company-logo {
        width: 180px;
        /* Balanced for bold appearance on mobile */
        max-width: 180px;
    }

    .bucket-wrapper {
        left: 154px;
        bottom: 25px;
        /* Lowered from 38px to ensure stones touch the ground on mobile */
    }

    .ground-layer {
        height: 600px;
        bottom: -550px;
        background-position: center bottom;
        background-size: cover;
    }

    .bg-skyline {
        bottom: 20px;
        background-size: auto 95px;
    }

    .stone {
        bottom: 28px;
    }
}

/* --- COMPLEX ROLLING BALL ANIMATION --- */
.pl {
    position: relative;
    width: 16em;
    height: 16em;
    font-size: 32px;
    /* Increased back for a larger, more visible ring assembly */
}

@media (max-width: 768px) {
    .pl {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .pl {
        font-size: 20px;
    }
}

.pl__ball,
.pl__ball-inner-shadow,
.pl__ball-side-shadows,
.pl__ball-texture,
.pl__inner-ring,
.pl__outer-ring,
.pl__track-cover {
    border-radius: 50%;
}

.pl__ball,
.pl__ball-inner-shadow,
.pl__ball-outer-shadow,
.pl__ball-side-shadows,
.pl__ball-texture,
.pl__ball-texture:before,
.pl__inner-ring,
.pl__outer-ring,
.pl__track-cover {
    position: absolute;
}

.pl__ball,
.pl__ball-inner-shadow,
.pl__ball-outer-shadow,
.pl__ball-texture:before,
.pl__track-cover {
    animation: ball 3s linear infinite;
}

.pl__ball {
    top: calc(50% - 1.0em);
    left: calc(50% - 1.0em);
    transform: rotate(0) translateY(-6.5em);
    width: 2.0em;
    height: 2.0em;
    z-index: 5;
}

.pl__ball-inner-shadow {
    animation-name: ballInnerShadow;
    box-shadow:
        0 0.1em 0.2em hsla(0, 0%, 0%, 0.3),
        0 0 0.2em hsla(0, 0%, 0%, 0.1) inset,
        0 -1em 0.5em hsla(0, 0%, 0%, 0.15) inset;
    width: 100%;
    height: 100%;
}

.pl__ball-outer-shadow {
    animation-name: ballOuterShadow;
    background-image: linear-gradient(hsla(0, 0%, 0%, 0.15), hsla(0, 0%, 0%, 0));
    border-radius: 0 0 50% 50% / 0 0 100% 100%;
    filter: blur(2px);
    top: 50%;
    left: 0;
    width: 100%;
    height: 250%;
    transform: rotate(20deg);
    transform-origin: 50% 0;
    z-index: -2;
}

.pl__ball-side-shadows {
    background-color: hsla(0, 0%, 0%, 0.1);
    filter: blur(2px);
    width: 100%;
    height: 100%;
    transform: scale(0.75, 1.1);
    z-index: -1;
}

.pl__ball-texture {
    overflow: hidden;
    width: 100%;
    height: 100%;
    transform: translate3d(0, 0, 0);
}

.pl__ball-texture:before {
    animation-name: ballTexture;
    animation-duration: 0.25s;
    background: url("../img/preloader/ground_texture.webp") 0 0 / 50% 100%;
    content: "";
    display: block;
    filter: brightness(1.05);
    top: 0;
    right: 0;
    width: 200%;
    height: 100%;
}

.pl__inner-ring {
    box-shadow:
        0 -0.25em 0.5em hsla(0, 0%, 100%, 0.4),
        0 0.5em 0.75em hsla(0, 0%, 100%, 0.4) inset,
        0 0.5em 0.375em hsla(0, 0%, 0%, 0.15),
        0 -0.5em 0.75em hsla(0, 0%, 0%, 0.15) inset;
    top: 2.375em;
    left: 2.375em;
    width: calc(100% - 4.75em);
    height: calc(100% - 4.75em);
}

.pl__outer-ring {
    box-shadow:
        0 -0.45em 0.375em hsla(0, 0%, 0%, 0.15),
        0 0.5em 0.75em hsla(0, 0%, 0%, 0.15) inset,
        0 0.25em 0.5em hsla(0, 0%, 100%, 0.4),
        0 -0.5em 0.75em hsla(0, 0%, 100%, 0.4) inset;
    top: 0.75em;
    left: 0.75em;
    width: calc(100% - 1.5em);
    height: calc(100% - 1.5em);
}

.pl__track-cover {
    animation-name: trackCover;
    background-image: conic-gradient(rgba(255, 255, 255, 1) 210deg, rgba(255, 255, 255, 0) 270deg);
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Animations */
@keyframes ball {
    from {
        transform: rotate(0) translateY(-6.5em);
    }

    50% {
        transform: rotate(180deg) translateY(-6em);
    }

    to {
        transform: rotate(360deg) translateY(-6.5em);
    }
}

@keyframes ballInnerShadow {
    from {
        transform: rotate(0);
    }

    to {
        transform: rotate(-360deg);
    }
}

@keyframes ballOuterShadow {
    from {
        transform: rotate(20deg);
    }

    to {
        transform: rotate(-340deg);
    }
}

@keyframes ballTexture {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(50%);
    }
}

@keyframes trackCover {
    from {
        transform: rotate(0);
    }

    to {
        transform: rotate(360deg);
    }
}
