/* ============================================================
 *  Janiyar Segal — Scroll Storytelling (Final v4.0)
 *  روایت اسکرول «از مذاب تا فولاد» — با تصاویر + موبایل
 * ============================================================ */

/* ============================================================
 *  Wrapper اصلی
 * ============================================================ */
.js-scroll-story {
    position: relative;
    width: 100%;
    background: #050810;
    isolation: isolate;
}

/* ============================================================
 *  Sticky
 * ============================================================ */
.js-scroll-story__sticky {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100svh;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    will-change: transform;
}

/* ============================================================
 *  پس‌زمینه گرادیانی — همیشه نمایش داده می‌شود (زیر تصاویر)
 * ============================================================ */
.js-scroll-story__bg {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(255, 85, 0, 0.5) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 30%, rgba(255, 140, 66, 0.25) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 100%, rgba(100, 116, 139, 0.3) 0%, transparent 60%),
        linear-gradient(135deg, #0a0f1a 0%, #050810 50%, #0a0f1a 100%);
}

.js-scroll-story__bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    will-change: transform;
}
.js-scroll-story__bg-orb--1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #ff5500 0%, transparent 70%);
    top: 20%;
    left: 10%;
}
.js-scroll-story__bg-orb--2 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #ff8c42 0%, transparent 70%);
    bottom: 20%;
    right: 15%;
}
.js-scroll-story__bg-orb--3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #8fa5bf 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.3;
}

/* ============================================================
 *  لایه‌های تصویری — روی گرادیان
 * ============================================================ */
.js-scroll-story__layer {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    will-change: transform, opacity;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.js-scroll-story__layer[data-layer="molten"] {
    opacity: 1;
    visibility: visible;
}

.js-scroll-story__layer img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    will-change: transform;
}

/* فیلترهای مخصوص هر لایه */
.js-scroll-story__layer--molten img {
    filter: brightness(0.7) contrast(1.15) saturate(1.5) hue-rotate(-8deg);
}
.js-scroll-story__layer--cool img {
    filter: brightness(0.6) contrast(1.1) saturate(0.85);
}
.js-scroll-story__layer--billet img {
    filter: brightness(0.55) contrast(1.15) saturate(0.7);
}

/* ============================================================
 *  Overlay — تیره‌سازی برای خوانایی متن
 * ============================================================ */
.js-scroll-story__overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    background:
        linear-gradient(270deg,
            rgba(5, 8, 16, 0.92) 0%,
            rgba(5, 8, 16, 0.7) 40%,
            rgba(5, 8, 16, 0.35) 70%,
            rgba(5, 8, 16, 0.15) 100%
        ),
        linear-gradient(180deg,
            rgba(5, 8, 16, 0.5) 0%,
            rgba(5, 8, 16, 0.15) 40%,
            rgba(5, 8, 16, 0.6) 100%
        );
    pointer-events: none;
}

/* ============================================================
 *  Grid فنی
 * ============================================================ */
.js-scroll-story__grid {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    pointer-events: none;
    opacity: 0.15;
}
.js-scroll-story__grid span {
    border-inline-start: 1px solid rgba(255, 140, 66, 0.5);
    position: relative;
}
.js-scroll-story__grid span:first-child { border-inline-start: none; }
.js-scroll-story__grid span::after {
    content: '';
    position: absolute;
    top: 10%;
    inset-inline-start: -2px;
    width: 4px;
    height: 4px;
    background: #ff8c42;
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(255, 140, 66, 0.8);
}

/* ============================================================
 *  محتوای روایت
 * ============================================================ */
.js-scroll-story__content {
    position: relative;
    z-index: 5;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    pointer-events: none;
    padding: 100px 0 60px;
    box-sizing: border-box;
}

.js-scroll-story__container {
    width: 100%;
    max-width: 1320px;
    margin-inline: auto;
    padding: 0 clamp(20px, 4vw, 48px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 60px;
    align-items: center;
    pointer-events: auto;
    box-sizing: border-box;
}

/* ============================================================
 *  هدر
 * ============================================================ */
.js-scroll-story__header {
    grid-column: 1 / -1;
    margin-bottom: 20px;
}
.js-scroll-story__eyebrow {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 4px;
    color: #ff8c42;
    text-transform: uppercase;
    margin-bottom: 12px;
    position: relative;
    padding-inline-start: 40px;
}
.js-scroll-story__eyebrow::before {
    content: '';
    position: absolute;
    top: 50%;
    inset-inline-start: 0;
    width: 28px;
    height: 1px;
    background: #ff8c42;
    transform: translateY(-50%);
}
.js-scroll-story__main-title {
    font-size: clamp(28px, 4vw, 48px);
    font-weight: 900;
    color: #fff;
    margin: 0;
    letter-spacing: -1px;
    line-height: 1.15;
    text-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

/* ============================================================
 *  مراحل
 * ============================================================ */
.js-scroll-story__steps {
    grid-column: 1 / 2;
    position: relative;
    min-height: 320px;
}

.js-scroll-story__step {
    position: absolute;
    top: 0;
    inset-inline-start: 0;
    inset-inline-end: 0;
    display: flex;
    gap: 20px;
    align-items: flex-start;
    opacity: 0;
    visibility: hidden;
    will-change: opacity, transform;
}

.js-scroll-story__step-num {
    font-size: 48px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -2px;
    font-family: 'Inter', system-ui, sans-serif;
    direction: ltr;
    flex-shrink: 0;
    padding-top: 4px;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.js-scroll-story__step-body {
    flex: 1;
    min-width: 0;
    padding-top: 6px;
}
.js-scroll-story__step-label {
    display: inline-block;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 10px;
}
.js-scroll-story__step-title {
    font-size: clamp(20px, 2.2vw, 28px);
    font-weight: 900;
    color: #fff;
    line-height: 1.3;
    margin: 0 0 14px;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}
.js-scroll-story__step-desc {
    font-size: clamp(14px, 1.2vw, 16px);
    line-height: 1.9;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
    max-width: 500px;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

/* ============================================================
 *  نوار پیشرفت
 * ============================================================ */
.js-scroll-story__progress {
    grid-column: 1 / 2;
    margin-top: 32px;
    height: 2px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}
.js-scroll-story__progress-bar {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #ff8c42 0%, #ff5500 100%);
    transform: scaleX(0);
    transform-origin: right center;
    border-radius: 2px;
    box-shadow: 0 0 12px rgba(255, 140, 66, 0.6);
}

/* ============================================================
 *  خروج
 * ============================================================ */
.js-scroll-story__exit {
    position: absolute;
    bottom: 30px;
    inset-inline-start: 50%;
    transform: translateX(-50%);
    z-index: 6;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 4px;
    text-transform: uppercase;
    pointer-events: none;
}
.js-scroll-story__exit-line {
    width: 1px;
    height: 30px;
    background: linear-gradient(180deg, #ff8c42 0%, transparent 100%);
}

/* ============================================================
 *  تبلت — 1024px و پایین‌تر
 * ============================================================ */
@media (max-width: 1024px) {
    .js-scroll-story__container {
        grid-template-columns: 1fr;
        gap: 32px;
    }
    .js-scroll-story__steps,
    .js-scroll-story__progress {
        grid-column: 1 / -1;
    }
    .js-scroll-story__overlay {
        background:
            linear-gradient(270deg,
                rgba(5, 8, 16, 0.9) 0%,
                rgba(5, 8, 16, 0.75) 50%,
                rgba(5, 8, 16, 0.5) 100%
            );
    }
}

/* ============================================================
 *  موبایل — 720px و پایین‌تر
 * ============================================================ */
@media (max-width: 720px) {
    /* ★ در موبایل، pin را غیرفعال می‌کنیم و به صورت عادی نمایش می‌دهیم */
    .js-scroll-story__sticky {
        height: auto;
        min-height: auto;
        padding: 60px 0;
    }

    .js-scroll-story__bg-orb {
        filter: blur(50px);
        opacity: 0.4;
    }

    .js-scroll-story__layer {
        position: absolute;
        opacity: 0.35; /* در موبایل، تصاویر محو‌تر هستند تا متن خوانا باشد */
        z-index: 1;
    }

    .js-scroll-story__overlay {
        background:
            linear-gradient(180deg,
                rgba(5, 8, 16, 0.9) 0%,
                rgba(5, 8, 16, 0.85) 50%,
                rgba(5, 8, 16, 0.95) 100%
            );
        z-index: 3;
    }

    .js-scroll-story__content {
        padding: 40px 0;
        position: relative;
        height: auto;
        min-height: auto;
    }

    .js-scroll-story__container {
        padding: 0 20px;
        gap: 20px;
        display: block;
    }

    .js-scroll-story__header {
        margin-bottom: 24px;
    }

    /* ★ در موبایل، همه مراحل به صورت عادی نمایش داده می‌شوند (نه absolute) */
    .js-scroll-story__steps {
        min-height: auto;
        position: relative;
        display: flex;
        flex-direction: column;
        gap: 32px;
    }

    .js-scroll-story__step {
        position: relative !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        flex-direction: column;
        gap: 10px;
        padding-bottom: 24px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    .js-scroll-story__step:last-child {
        border-bottom: none;
    }

    .js-scroll-story__step-num {
        font-size: 36px;
    }
    .js-scroll-story__step-title {
        font-size: 18px;
    }
    .js-scroll-story__step-desc {
        font-size: 13.5px;
        line-height: 1.85;
    }

    /* نوار پیشرفت در موبایل مخفی */
    .js-scroll-story__progress {
        display: none;
    }

    .js-scroll-story__grid {
        opacity: 0.08;
    }

    .js-scroll-story__exit {
        display: none;
    }
}

/* ============================================================
 *  موبایل کوچک — 480px
 * ============================================================ */
@media (max-width: 480px) {
    .js-scroll-story__sticky {
        padding: 40px 0;
    }
    .js-scroll-story__main-title {
        font-size: 24px;
    }
    .js-scroll-story__step-num {
        font-size: 30px;
    }
    .js-scroll-story__step-title {
        font-size: 16.5px;
    }
    .js-scroll-story__step-desc {
        font-size: 13px;
    }
}

/* ============================================================
 *  Reduced motion
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .js-scroll-story__sticky {
        height: auto;
        min-height: auto;
        padding: 60px 0;
    }
    .js-scroll-story__step {
        position: relative !important;
        opacity: 1 !important;
        visibility: visible !important;
        margin-bottom: 32px;
    }
    .js-scroll-story__progress-bar {
        transform: scaleX(1);
    }
    .js-scroll-story__bg-orb {
        animation: none;
    }
}