.how-it-works {
    padding: clamp(50px, 8vw, 100px) 0;
    position: relative;
    overflow: hidden;
    background: #ffffff; 
}

.how-header {
    text-align: center;
    margin-bottom: clamp(40px, 10vw, 80px);
    position: relative;
    padding: 0 20px;
    z-index: 2;
}

.section-title {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 800;
    color: var(--dark-teal);
    margin-bottom: 15px;
}

.section-slogan {
    font-size: clamp(0.9rem, 2.5vw, 1.25rem);
    color: var(--text-sec);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    max-width: 800px;
    margin: 0 auto;
}

.slogan-logo {
    height: clamp(20px, 4vw, 32px);
    width: auto;
}

.decorative-squares {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 1400px; 
    height: 100%;
    pointer-events: none;
}

.sq {
    position: absolute;
    border-radius: clamp(6px, 1.2vw, 12px);
    opacity: 0.12;
    filter: blur(0.3px);
}

/* المربع الكبير في اليسار */
.sq-1 {
    width: clamp(50px, 7vw, 85px);
    height: clamp(50px, 7vw, 85px);
    background: var(--primary-cyan);
    top: 15%;
    left: 8%;
    transform: rotate(-15deg);
}

/* المربع الأصغر أسفل الكبير في اليسار */
.sq-2 {
    width: clamp(25px, 4vw, 45px);
    height: clamp(25px, 4vw, 45px);
    background: var(--dark-teal);
    top: 95%;
    left: 12%;
    transform: rotate(20deg);
    opacity: 0.08;
}

/* اليمين: فوق، صغير وبعيد نسبياً */
.sq-3 {
    width: clamp(20px, 3vw, 30px);
    height: clamp(20px, 3vw, 30px);
    background: var(--primary-cyan);
    top: 5%;
    right: 15%;
    transform: rotate(10deg);
}

/* اليمين: أسفل الأول، أكبر وموزع بدقة */
.sq-4 {
    width: clamp(40px, 6vw, 65px);
    height: clamp(40px, 6vw, 65px);
    background: var(--primary-cyan);
    top: 35%;
    right: 18%;
    transform: rotate(-10deg);
    opacity: 0.15;
}

/* اليمين: صغير جداً */
.sq-5 {
    width: clamp(16px, 2vw, 20px);
    height: clamp(16px, 2vw, 20px);
    background: var(--dark-teal);
    top: 100%;
    right: 17%;
    transform: rotate(30deg);
    border-radius: 28%;
}

/* اليمين: مربع متوسط بعيد عن العنوان وعن البقية */
.sq-6 {
    width: clamp(30px, 4vw, 45px);
    height: clamp(30px, 4vw, 45px);
    background: var(--primary-cyan);
    top: 100%;
    right: 40%;
    transform: rotate(-25deg);
    opacity: 0.07;
}

/* مربع يقترب من اليسار ولكن ليس تماماً (شارد) */
.sq-7 {
    width: clamp(20px, 3vw, 35px);
    height: clamp(20px, 3vw, 35px);
    background: var(--primary-cyan);
    bottom: 15%;
    left: 35%;
    transform: rotate(15deg);
    opacity: 0.05;
}

@media (max-width: 768px) {
    .sq-6, .sq-7, .sq-5 {
        display: none; 
    }
    .sq-1 { left: 2%; top: 10%; }
    .sq-4 { right: 2%; }
}
/*========================================
  HOW IT WORKS SECTION STEPS AND VISUAL
========================================*/
.how-content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(30px, 5vw, 80px);
    align-items: flex-start;
    margin-top: 50px;
    align-items: stretch;
}

.how-steps-part {
    position: relative;
    padding-right: 50px;
}

.how-visual-part {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%; 
}

.step-image-wrapper {
    position: relative;
    z-index: 5;
    width: 85%; 
    aspect-ratio: 16 / 10;
    max-height: 600px; 
    overflow: hidden;
    cursor: zoom-in;
    margin: auto;
    border-radius: 20px;
    background: #f9f9f9;
}

.image-side-fade {
    position: absolute;
    top: 0;
    width: 15%;
    height: 100%;
    z-index: 6;
    pointer-events: none;
    transition: opacity 0.4s ease;
    opacity: 1;
}
.fade-right { right: 0; background: linear-gradient(to left, #ffffff, transparent); }
.fade-left { left: 0; background: linear-gradient(to right, #ffffff, transparent); }

.image-side-fade.hide-fade {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.step-badges-container-new {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-dynamic-loader {
    --color-one: var(--primary-cyan);
    --color-two: var(--dark-teal);
    --color-three: rgba(20, 229, 209, 0.5);
    --color-four: rgba(7, 60, 59, 0.5);
    --color-five: rgba(20, 229, 209, 0.2);
    --time-animation: 2s;
    
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    
    /* جعل الحجم متجاوب مثل القديم */
    width: clamp(70px, 15vw, 110px);
    height: clamp(70px, 15vw, 110px);
    
    border-radius: 50%;
    box-shadow: 0 0 25px 0 var(--color-three), 0 20px 50px 0 var(--color-four);
    animation: step-colorize calc(var(--time-animation) * 3) ease-in-out infinite,
               float-icon 3s infinite ease-in-out; /* إضافة حركة الطفو القديمة */
}

.step-dynamic-loader::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border-top: solid 1px var(--color-one);
    border-bottom: solid 1px var(--color-two);
    background: linear-gradient(180deg, var(--color-five), var(--color-four));
    box-shadow: inset 0 10px 10px 0 var(--color-three), inset 0 -10px 10px 0 var(--color-four);
    z-index: -1;
}

.step-loader-box {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, var(--color-one) 30%, var(--color-two) 70%);
    mask: url(#step-clipping-mask);
    -webkit-mask: url(#step-clipping-mask);
}

.step-loader-svg {
    position: absolute;
    width: 0; height: 0; 
}

.step-loader-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 35%;
    height: auto;
    z-index: 5;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* الأنميشن الخاص بالـ Mask */
#step-clipping-mask {
    filter: contrast(15);
    animation: step-roundness calc(var(--time-animation) / 2) linear infinite;
}

#step-clipping-mask polygon { filter: blur(7px); transform-origin: 50% 50%; }

#step-clipping-mask polygon:nth-child(1) {
    transform-origin: 75% 25%;
    transform: rotate(90deg);
}

#step-clipping-mask polygon:nth-child(2) {
    transform-origin: 50% 50%;
    animation: step-rotation var(--time-animation) linear infinite reverse;
}

#step-clipping-mask polygon:nth-child(3) {
    transform-origin: 50% 60%;
    animation: step-rotation var(--time-animation) linear infinite;
    animation-delay: calc(var(--time-animation) / -3);
}

#step-clipping-mask polygon:nth-child(4) {
    transform-origin: 40% 40%;
    animation: step-rotation var(--time-animation) linear infinite reverse;
}

#step-clipping-mask polygon:nth-child(5) {
    transform-origin: 40% 40%;
    animation: step-rotation var(--time-animation) linear infinite reverse;
    animation-delay: calc(var(--time-animation) / -2);
}

#step-clipping-mask polygon:nth-child(6) {
    transform-origin: 60% 40%;
    animation: step-rotation var(--time-animation) linear infinite;
}

#step-clipping-mask polygon:nth-child(7) {
    transform-origin: 60% 40%;
    animation: step-rotation var(--time-animation) linear infinite;
    animation-delay: calc(var(--time-animation) / -1.5);
}

@keyframes step-rotation { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@keyframes step-roundness {
    0%, 100% { filter: contrast(15); }
    20%, 40% { filter: contrast(3); }
}

@keyframes step-colorize {
    0%, 100% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(-45deg); }
}

@media (max-width: 480px) {
    .step-dynamic-loader {
        width: 65px;
        height: 65px;
    }
}

/* Lightbox Style */
.lightbox {
    display: none;
    position: fixed;
    z-index: 2000;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.lightbox-content {
    margin: auto;
    display: block;
    width: auto;
    height: auto;
    max-width: 95vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 15px;
    animation: zoom 0.3s;
}

@keyframes zoom { from {transform:scale(0)} to {transform:scale(1)} }

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.step-img {
    width: 100%;
    height: 100%;
    object-fit: cover; 
    border-radius: 20px;
    display: block;
    transition: all 0.5s ease-in-out;
    opacity: 0; 
}

.step-img.active {
    opacity: 1;
}

.magnifier-glass {
    position: absolute;
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: none;
    width: 150px;
    height: 150px;
    display: none;
    z-index: 10;
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    background-repeat: no-repeat;
    pointer-events: none;
}

.custom-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
    z-index: 8;
}

@keyframes spin { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } }

.timeline-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 60px;
}

.timeline-svg {
    position: absolute;
    right: -25px;
    top: 0;
    width: 40px;
    height: 100%;
    z-index: 1;
}

.base-line {
    fill: none;
    stroke: #eee;
    stroke-width: 4;
    stroke-linecap: round;
}

.progress-line {
    fill: none;
    stroke: var(--primary-cyan);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 0.5s ease;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 25px;
    position: relative;
    z-index: 2;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.5;
}

.step-item.active {
    opacity: 1;
    transform: translateX(-10px);
}

.step-number {
    min-width: 55px;
    height: 55px;
    background: white;
    border: 2px solid #eee;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: var(--text-sec);
    transition: all 0.4s ease;
    position: relative;
}

.step-item.active .step-number {
    background: var(--primary-cyan);
    color: white;
    border-color: var(--primary-cyan);
    box-shadow: 0 0 20px rgba(20, 229, 209, 0.4);
}

.step-info h3 {
    color: var(--dark-teal);
    font-size: 1.4rem;
    margin-bottom: 5px;
}

.step-info p {
    color: var(--text-sec);
    font-size: 0.95rem;
    max-width: 400px;
}

@media (max-width: 992px) {
    .how-content-grid { grid-template-columns: 1fr; }
    .how-steps-part { padding-right: 30px; order: 2; }
    .how-visual-part { order: 1; }
}