:root {
    /* Using a wider container so your large (170%) desktop doesn't bleed out too far */
    --device-wrapper-width: clamp(500px, 40vw, 900px);
}

.parallax-phone-section {
    overflow: visible !important;
    position: relative;
    background-color: transparent;
}

#pin-container {
    max-width: 1800px;
    margin: 0 auto;
    display: flex;
    position: relative;
    height: 100vh;
}

#phone-wrapper {
    width: var(--device-wrapper-width);
    height: 100vh;
    position: relative;
    z-index: 10;
    /* Centers the cluster vertically */
    display: flex;
    align-items: center;
    justify-content: center;
}

#devices-pinned {
    width: 100%;
    /* Keep a consistent drawing area for your percentages */
    aspect-ratio: 1 / 1;
    position: relative;
}

.device-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
}

.device {
    position: absolute;
    opacity: 0;
    visibility: hidden;
    width: var(--d-width);
    top: var(--d-top);
    left: var(--d-left);
    transition: opacity 0.4s ease,
                top 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                left 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.device.visible {
    opacity: 1;
    visibility: visible;
}

.device-frame {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2;
}

.device-screen {
    position: absolute;
    overflow: hidden;
    top: var(--s-top);
    left: var(--s-left);
    width: var(--s-width);
    height: var(--s-height);
    z-index: 1;
    background: #000;
}

.device-screen {
    position: absolute;
    overflow: hidden;
    top: var(--s-top);
    left: var(--s-left);
    width: var(--s-width);
    height: var(--s-height);
    z-index: 1;
    background: #000; /* Fallback for very first load */
}

.device-screen-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: top center;
    will-change: transform, opacity;
}

/* The image from the previous slide */
.device-screen-img.previous {
    z-index: 1;
    opacity: 0;
    transform: translateY(0); /* Stays static in the background */

    background-color: rgba(0, 0, 0, 0.6); /* Adjust 0.6 to make it darker or lighter */
    background-blend-mode: multiply;
    transition: opacity 0.4s ease; /* Smoothly fade the overlay in/out */
}

/* The image for the new slide */
.device-screen-img.current {
    z-index: 2;
    opacity: 0;
    transform: translateY(100%);
}

.device-screen-img.current.static-visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
    z-index: 3;
}

/* Standard animations */
.device-screen-img.current.animating-up {
    animation: slideUpIn 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
.device-screen-img.current.animating-down {
    animation: slideDownIn 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes slideUpIn {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes slideDownIn {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.device-desktop { aspect-ratio: 16 / 9; z-index: 1; }
.device-laptop { aspect-ratio: 16 / 10; z-index: 2; }
.device-tablet { aspect-ratio: 3 / 4; z-index: 3; }
.device-tablet.landscape { aspect-ratio: 16 / 10; }
.device-terminal { aspect-ratio: 9 / 18; z-index: 4; }

.device-simple {
    aspect-ratio: 16 / 9;
    z-index: 5;
    width: 100%;
    top: 0;
    left: 0;
}
.device-simple .device-screen {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

.text-content { flex: 1; padding-left: 2vw; }
.text-section {
    height: 100vh;
    display: flex;
    align-items: center;
    padding: 0 5vw;
}

/* Vertical Scaling fix for 1366x768 / small laptop screens */
@media (max-height: 850px) {
    #devices-pinned {
        transform: scale(0.75); /* Automatically shrinks your layout to fit shorter screens */
    }
}

@media (max-width: 767px) {
    #pin-container { flex-direction: column; height: auto; }
    #phone-wrapper { width: 100%; height: 45vh; }
    .text-section { height: 55vh; }
}
