/* ============================================================
   AI Section — home-ai-section.css
   ============================================================ */

/* ----------------------------------------------------------
   Keyframes
   ---------------------------------------------------------- */
@keyframes aiEngineSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes aiEngineSpinSecondary {
    from {
        transform: rotate(-90deg);
    }

    to {
        transform: rotate(270deg);
    }
}

@keyframes aiCasesTrackFadeOut {
    from {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }

    to {
        opacity: 0;
        transform: translate3d(-32px, 0, 0);
    }
}

@keyframes aiCasesTrackFadeIn {
    from {
        opacity: 0;
        transform: translate3d(32px, 0, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes aiCasesTrackFadeOutReverse {
    from {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }

    to {
        opacity: 0;
        transform: translate3d(32px, 0, 0);
    }
}

@keyframes aiCasesTrackFadeInReverse {
    from {
        opacity: 0;
        transform: translate3d(-32px, 0, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes aiCasesTrackFadeOutReduced {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes aiCasesTrackFadeInReduced {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ----------------------------------------------------------
   Base (fallback for narrow viewports — no breakage)
   ---------------------------------------------------------- */
.page-template-home {
    .ai-section {
        margin-top: 72px;
        padding: 0;
        background: var(--white-primary);
    }

    .ai-section__wrapper {
        background: var(--beige-light);
    }

    .ai-section__inner {
        max-width: 1440px;
        margin-inline: auto;
        width: 100%;
        box-sizing: border-box;
        padding: 72px 0;
        display: flex;
        flex-direction: column;
        gap: 30px;
    }

    /* ---- Shared typography ---- */
    .ai-section__eyebrow {
        font-family: "Inter", sans-serif;
        font-weight: 500;
        font-size: 12px;
        line-height: 1.4;
        text-transform: uppercase;
        color: var(--dark-50);
        letter-spacing: 0.02em;
        margin: 0;
    }

    .ai-section__title {
        font-family: "Poppins", serif;
        font-weight: 600;
        font-size: 38px;
        line-height: 1.2;
        color: var(--dark-80);
        margin: 0;
        max-width: 620px;
    }

    .ai-section__description {
        font-family: "Inter", sans-serif;
        font-weight: 400;
        font-size: 16px;
        line-height: 22.4px;
        color: var(--dark-50);
        margin: 0;
        max-width: 620px;
    }

    .ai-section__divider {
        display: block;
        width: 64px;
        height: 1px;
        background: var(--green-primary);
        flex-shrink: 0;
    }

    .ai-section__highlight {
        font-family: "Inter", sans-serif;
        font-weight: 600;
        font-size: 20px;
        line-height: 24px;
        color: var(--green-primary);
        text-align: center;
        vertical-align: middle;
        max-width: 900px;
        margin: 0 auto;
    }

    /* ---- Intro card (base: stacked) ---- */
    .ai-section__intro-card {
        display: flex;
        flex-direction: column;
        gap: 72px;
        background: var(--beige-light);
        border-radius: 16px;
        padding: 16px 48px;
    }

    .ai-section__intro-content {
        display: flex;
        flex-direction: column;
        gap: 24px;
    }

    /* ---- Features list (base: single column) ---- */
    .ai-section__features {
        list-style: none;
        margin: 0;
        padding: 0;
        display: grid;
        grid-template-columns: 1fr;
        gap: 24px;

        li {
            display: flex;
            align-items: center;
            gap: 12px;

            img {
                width: 18px;
                height: 18px;
                flex-shrink: 0;
                object-fit: contain;
            }

            span {
                font-family: "Inter", sans-serif;
                font-weight: 600;
                font-size: 16px;
                line-height: 22.4px;
                color: var(--dark-80);
            }
        }
    }

    .ai-section__diagram {
        position: relative;
        width: 100%;
        aspect-ratio: 636 / 542;
        align-self: center;
        max-width: 720px;
    }

    .ai-diagram__composition {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: contain;
        pointer-events: none;
    }

    /* Engine center */
    .ai-diagram__engine {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 256px;
        height: 256px;
    }

    .ai-diagram__engine-orb {
        position: absolute;
        inset: 0;
        width: 256px;
        height: 256px;
        pointer-events: none;
    }

    .ai-diagram__engine-orb--primary {
        z-index: 1;
        background: url('../../../images/ai-section/ai-circle.png') center / contain no-repeat;
        animation: aiEngineSpin 32s cubic-bezier(0.45, 0.12, 0.55, 0.88) infinite alternate;
    }

    .ai-diagram__engine-orb--secondary {
        z-index: 2;
        transform: scaleY(-1);
        opacity: 0.92;
    }

    .ai-diagram__engine-orb--secondary::before {
        content: "";
        position: absolute;
        inset: 0;
        background: url('../../../images/ai-section/ai-circle.png') center / contain no-repeat;
        animation: aiEngineSpinSecondary 32s cubic-bezier(0.45, 0.12, 0.55, 0.88) infinite alternate;
    }

    .ai-diagram__engine-symbol {
        position: absolute;
        top: 80px;
        left: 50%;
        transform: translateX(-50%);
        width: 99px;
        height: 91.19px;
        background: url('../../../images/ai-section/ai-symbol.png') center / contain no-repeat;
        z-index: 3;
        pointer-events: none;
    }

    .ai-diagram__engine-sparkle {
        position: absolute;
        top: 70px;
        left: 88px;
        width: 24px;
        height: 24px;
        z-index: 4;
        pointer-events: none;
    }

    @media (prefers-reduced-motion: reduce) {
        .ai-diagram__engine-orb--primary,
        .ai-diagram__engine-orb--secondary::before {
            animation: none;
        }
    }

    /* ---- Practice block (base: stacked) ---- */
    .ai-section__practice-header {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 24px;
        text-align: center;
        padding-inline: 128px;
    }

    .ai-section__practice-subtitle {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 16px;
        text-align: center;

        h3 {
            font-family: "Inter", sans-serif;
            font-weight: 600;
            font-size: 24px;
            line-height: 1.2;
            color: var(--dark-80);
            margin: 0;
        }
    }

    /* ---- Cases (Native pager) ---- */
    .ai-section__cases {
        --ai-cases-clip-gutter: 56px;

        box-sizing: border-box;
        width: 100%;
        max-width: 1184px;
        margin-inline: auto;
        padding: 0 0 8px;
        overflow: visible;
    }

    .ai-section__cases-track {
        --ai-cases-item-height: auto;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 24px;
        opacity: 1;
        transform: translate3d(0, 0, 0);
        align-content: start;
    }

    .ai-section__cases-track--pager-out {
        animation: aiCasesTrackFadeOut 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
    }

    .ai-section__cases-track--pager-out.ai-section__cases-track--pager-reverse {
        animation-name: aiCasesTrackFadeOutReverse;
    }

    .ai-section__cases-track--pager-at-0 {
        opacity: 0;
        transform: translate3d(32px, 0, 0);
        animation: none;
    }

    .ai-section__cases-track--pager-at-0.ai-section__cases-track--pager-reverse {
        transform: translate3d(-32px, 0, 0);
    }

    .ai-section__cases-track--pager-in {
        animation: aiCasesTrackFadeIn 360ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
    }

    .ai-section__cases-track--pager-in.ai-section__cases-track--pager-reverse {
        animation-name: aiCasesTrackFadeInReverse;
    }

    @media (prefers-reduced-motion: reduce) {
        .ai-section__cases-track--pager-out {
            animation-name: aiCasesTrackFadeOutReduced;
            animation-duration: 140ms;
            animation-timing-function: ease;
        }

        .ai-section__cases-track--pager-in {
            animation-name: aiCasesTrackFadeInReduced;
            animation-duration: 140ms;
            animation-timing-function: ease;
        }
    }

    .ai-section__cases-controls {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 28px;
        margin-top: 15px;
        padding-bottom: 8px;
    }

    .ai-section__cases-pagination {
        position: static;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }

    .ai-section__cases-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        border: none;
        padding: 0;
        background: var(--gray-50);
        cursor: pointer;
    }

    .ai-section__cases-dot.is-active {
        background: var(--dark-100);
    }

    .ai-section__cases-prev,
    .ai-section__cases-next {
        position: static;
        margin: 0;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        padding: 0;
        border: none;
        background: transparent;
        color: var(--dark-100);
        cursor: pointer;
    }

    .ai-section__cases-prev::after,
    .ai-section__cases-next::after {
        content: "";
        display: block;
        width: 23px;
        height: 23px;
        background: url('../../../images/ai-section/arrow.svg') center / contain no-repeat;
    }

    .ai-section__cases-prev::after {
        transform: scaleX(-1);
    }

    .ai-section__cases-prev.is-disabled,
    .ai-section__cases-next.is-disabled {
        opacity: 0.25;
        cursor: default;
        pointer-events: none;
    }

    .ai-case {
        background: var(--white-primary);
        border-radius: 2px;
        box-shadow: 0 12px 100px 0 var(--shadow-card);
        padding: 24px 32px;
        min-height: 206px;
        display: flex;
        flex-direction: column;
        gap: 16px;
        width: 100%;
        max-width: none;
        margin-inline: 0;
    }

    .ai-case[hidden] {
        display: none !important;
    }

    .ai-section__cases-controls[hidden] {
        display: none !important;
    }

    .ai-case__title {
        font-family: "Inter", sans-serif;
        font-weight: 600;
        font-size: 20px;
        line-height: 24px;
        color: var(--dark-100);
        margin: 0;
    }

    .ai-case__description {
        font-family: "Inter", sans-serif;
        font-weight: 400;
        font-size: 16px;
        line-height: 24px;
        color: var(--dark-80);
        margin: 0;
    }

    .ai-case__flow {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        margin-top: auto;
    }

    .ai-case__chip {
        padding: 8px 12px;
        border: 1px solid var(--gray-50);
        border-radius: 4px;
        font-family: "Inter", sans-serif;
        font-weight: 400;
        font-size: 12px;
        line-height: 1.2;
        color: var(--dark-100);
    }

    .ai-case__arrow {
        color: var(--dark-80);
        font-family: "Inter", sans-serif;
        font-weight: 200;
        font-size: 14px;
        line-height: 24px;
    }

    /* ---- Deploy block (base: stacked) ---- */
    .ai-section__deploy {
        position: relative;
        overflow: hidden;
        border-radius: 8px;
        background: var(--beige-primary) url('../../../images/ai-section/ai-banner.png') center / cover no-repeat;
        min-height: 305px;
        max-width: 1184px;
        margin: 0 auto;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        padding: 40px 72px;
        gap: 24px;
    }

    .ai-section__deploy-content {
        display: flex;
        flex-direction: column;
        gap: 16px;
        z-index: 1;
        position: relative;

        .ai-section__eyebrow {
            color: var(--dark-80);
            letter-spacing: 0;
        }

        .ai-section__title {
            color: var(--dark-80);
        }

        .ai-section__description {
            font-weight: 500;
            font-size: 18px;
            line-height: 25.2px;
            color: var(--dark-80);
        }

        .btn-default {
            align-self: flex-start;
            padding: 16px 32px;
            margin-top: 25px;

            @media (min-width: 769px) {
                &:hover {
                    border-color: transparent;
                    color: var(--white-primary);
                }
            }
        }
    }

    .ai-section__deploy-actions {
        display: flex;
        align-items: center;
        gap: 40px;
        flex-wrap: wrap;
        margin-top: -24px;

        .btn-text::after {
            top: 180%;
        }

        @media (min-width: 769px) {
            .btn-default:hover .btn-text {
                transform: translateY(-180%);
            }
        }
    }

    .ai-section__deploy-tags {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        gap: 48px;
        z-index: 1;
        position: relative;

        li {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;

            img {
                width: 32px;
                height: 32px;
                object-fit: contain;
            }

            span {
                font-family: "Inter", sans-serif;
                font-weight: 600;
                font-size: 15px;
                line-height: 20px;
                color: var(--dark-100);
                text-align: center;
            }
        }
    }

    .ai-section__practice {
        width: 100%;
        max-width: 1160px;
        margin-inline: auto;
    }
}

@media (max-width: 1200px) {
    .page-template-home .ai-section__intro {
        background: var(--ai-section-mobile-bg);
    }

    .page-template-home .ai-section__intro-card {
        background: transparent;
        border-radius: 0;
    }

    .page-template-home .ai-section__inner {
        width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        padding: 32px 8px;
        gap: 32px;
    }
}

@media (min-width: 560px) and (max-width: 1280px) {
    .page-template-home .ai-section__inner {
        padding: 64px 0;
    }
}

@media (max-width: 768px) {
    .page-template-home .ai-section__wrapper {
        background: transparent;
    }

    .page-template-home .ai-section__practice-header {
        display: block;
        padding: 0;
    }

    .page-template-home .ai-section__practice .ai-section__title,
    .page-template-home .ai-section__practice .ai-section__highlight,
    .page-template-home .ai-section__practice .ai-section__description,
    .page-template-home .ai-section__practice .ai-section__practice-subtitle {
        margin-top: 24px;
    }

    .page-template-home .ai-section__diagram {
        display: none;
    }

    .page-template-home .ai-section__cases-track {
        align-items: stretch;
    }

    .page-template-home .ai-case {
        min-height: var(--ai-cases-item-height, auto);
        height: 100%;
    }

    .page-template-home .ai-case__flow {
        margin-top: auto;
    }

    .page-template-home .ai-section__intro-card {
        padding: 32px 24px;
    }

    .page-template-home .ai-section__title {
        font-size: 28px;
        line-height: 120%;
    }

    .page-template-home .ai-section__deploy {
        background: var(--ai-deploy-mobile-gradient);
        box-sizing: border-box;
        padding: 24px 80px;
        min-height: 0;
        width: calc(100% + 96px);
        max-width: none;
        margin-left: -48px;
        margin-right: -48px;
    }

    .page-template-home .ai-section__deploy-content {
        width: 100%;
        box-sizing: border-box;
    }

    .page-template-home .ai-section__deploy .ai-section__divider {
        display: none;
    }

    .page-template-home .ai-section__deploy-tags {
        flex-direction: column;
        flex-wrap: nowrap;
        justify-content: center;
        align-items: center;
        gap: 24px;
        width: 100%;
    }

    .page-template-home .ai-section__deploy-actions {
        flex-direction: column-reverse;
        align-items: flex-start;
        gap: 24px;
        margin-top: 0;

        .btn-default {
            margin: 0 auto;
        }
    }

    .page-template-home .ai-section__cases {
        --ai-cases-clip-gutter: 28px;
        margin-top: 8px;
    }
}

@media (max-width: 760px) {
    .page-template-home .ai-section__practice-header {
        padding-left: 24px;
        padding-right: 24px;
    }
}

@media (min-width: 769px) {
    .page-template-home .ai-section__wrapper {
        background: transparent;
    }

    .page-template-home .ai-section__practice-subtitle h3 {
        margin-top: 24px;
    }

    .page-template-home .ai-section__practice-subtitle .ai-section__divider {
        margin-bottom: 24px;
    }
}

@media (max-width: 560px) {
    .page-template-home .ai-section {
        margin-top: 32px;
    }

    .page-template-home .ai-section__highlight {
        font-size: 24px;
        line-height: 24px;
    }

    .page-template-home .ai-section__features li span {
        font-size: 14px;
    }

    .page-template-home .ai-case__title {
        font-size: 28px;
        line-height: 120%;
    }

    .page-template-home .ai-case__chip {
        font-size: 12px;
        line-height: 120%;
    }

    .page-template-home .ai-case {
        padding: 24px;
    }

    .page-template-home .ai-section__deploy {
        box-sizing: border-box;
        padding: 24px 42px;
        width: calc(100% + 32px);
        margin-left: -16px;
        margin-right: -16px;
    }

    .page-template-home .ai-section__deploy-actions .btn-text {
        font-size: 16px;
    }

    .page-template-home .ai-diagram__engine-orb {
        width: 200px;
        height: 200px;
    }
}

@media (min-width: 1024px) {
    .page-template-home .ai-section__cases-track {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ----------------------------------------------------------
   Desktop layout (≥ 1200px)
   ---------------------------------------------------------- */
@media (min-width: 1200px) {
    .page-template-home {
        .ai-section__description {
            max-width: 721px;
        }

        /* Intro card: side-by-side */
        .ai-section__intro-card {
            --ai-intro-gap: 72px;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            gap: var(--ai-intro-gap);
        }

        .ai-section__intro-content {
            flex: 0 0 calc((100% - var(--ai-intro-gap)) * 0.45);
            max-width: calc((100% - var(--ai-intro-gap)) * 0.45);
            min-width: 0;
        }

        /* Features: 2 columns */
        .ai-section__features {
            display: flex;
            flex-wrap: wrap;
            gap: 24px;

            li {
                flex: 0 0 auto;
            }
        }

        /* Diagram: fixed size */
        .ai-section__diagram {
            flex: 0 0 calc((100% - var(--ai-intro-gap)) * 0.55);
            max-width: calc((100% - var(--ai-intro-gap)) * 0.55);
            min-width: 0;
            width: 100%;
            height: auto;
            aspect-ratio: 636 / 542;
        }

        /* Deploy: flow layout */
        .ai-section__deploy {
            min-height: 305px;
            flex-direction: row;
            padding: 40px 72px;
            align-items: flex-start;
            justify-content: flex-start;
            gap: 48px;
        }
    }
}
