/* ==========================================================================
   Section 8 item 04 — Chapter: การนำ AI มาใช้ (.bp-section-8-04)

   Mirrors 8-02/8-03's 2-stage layout with these deltas:
     - Stage A story text highlights brand words with inline `.__brand` spans
       (bold + red) instead of a separate brand label.
     - Stage B has no inline left-column visual. Instead a `.__visual-stack`
       holds `robots-hand` (flush to the stage's bottom-left edge) with
       `ai-chip` positioned above the hand's palm, bouncing with a bubble-like
       float animation.
     - Buttons row has only the back button — this is the final chapter so
       there's no "next" CTA.
   ========================================================================== */

/* --- Section override --------------------------------------------------- */
.bp-section-8-04 {
    display: block;
    padding: 0;
    overflow: hidden;
    min-height: 100vh;
}

/* --- Stages wrapper ----------------------------------------------------- */
.bp-section-8-04__stages {
    display: flex;
    align-items: flex-start;
    width: 200vw;
    min-height: 100vh;
    transform: translateX(0);
    transition: transform 0.7s cubic-bezier(0.77, 0, 0.175, 1);
    will-change: transform;
}
.bp-section-8-04.is-stage-b .bp-section-8-04__stages {
    transform: translateX(-100vw);
}
.bp-section-8-04.is-snap .bp-section-8-04__stages {
    transition: none;
}

/* --- Individual stage --------------------------------------------------- */
.bp-section-8-04__stage {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.bp-section-8-04__stage-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: block;
}
.bp-section-8-04__stage-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ============================================================
   Stage A — white headline + 2 stories + glass CTA
   ============================================================ */
.bp-section-8-04 .bp-section-8-04__inner {
    width: 100%;
    max-width: 1320px;
    padding: 72px 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 36px;
    position: relative;
    z-index: 1;
}

.bp-section-8-04__headline {
    margin: 0;
    color: #ffffff;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.45;
    text-align: center;
    max-width: 860px;
}

/* Desktop: text + logo on a single row. Mobile reverts to vertical stack. */
.bp-section-8-04__story {
    width: 100%;
    max-width: 1100px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 48px;
    align-items: center;
}
.bp-section-8-04__story-text {
    color: #ffffff;
    font-size: 1.05rem;
    line-height: 1.85;
    margin: 0;
}
/* Inline brand highlight (Microsoft / BCG) — bold + red. */
.bp-section-8-04__brand {
    color: #E01C24;
    font-weight: 700;
}

.bp-section-8-04__story-logos {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 40px;
    flex-wrap: wrap;
}
.bp-section-8-04__story-logo {
    height: auto;
    object-fit: contain;
    display: block;
}
.bp-section-8-04__story-logos--single .bp-section-8-04__story-logo {
    width: 220px;
}

.bp-section-8-04__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-width: 220px;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 14px 40px;
}

/* ============================================================
   Stage B (light article) — FULL-WIDTH (not capped at 1320px like other
   chapters). Reason: the robot+chip visual needs to reach the viewport's
   left edge, and the carousel column can use the extra horizontal room.
   Stage A still uses the default capped inner, so only --b is full-width.
   ============================================================ */
.bp-section-8-04 .bp-section-8-04__inner--b {
    width: 100%;
    max-width: none;
    padding: 72px 48px;
    color: #171717;
    display: block;
    position: relative;
    z-index: 1;
}
.bp-section-8-04__article {
    display: grid;
    grid-template-columns: 42% 1fr;
    gap: 56px;
    align-items: start;
}
.bp-section-8-04__article-left {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.bp-section-8-04__article-title {
    margin: 0;
    color: #E01C24;
    font-size: 2.3rem;
    font-weight: 800;
    line-height: 1.25;
}
.bp-section-8-04__article-desc {
    margin: 0;
    color: #171717;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.75;
    max-width: 440px;
}

/* --- Visual stack (composite: robots-hand + ai-chip) --------------------
   Stays inside .__article-left (flow order: title → desc → stack → button).
   Since Stage B's inner is now full-width, the only offset between the
   stack's left edge and the viewport's left edge is the inner's 48px
   left padding — undo it with `margin-left: -48px` so the hand reaches
   the edge naturally (no viewport-width math needed). */
.bp-section-8-04__visual-stack {
    position: relative;
    margin-top: 56px;
    margin-right: 0;
    margin-bottom: 8px;
    margin-left: -48px;
    width: min(520px, 42vw);
    max-width: none;
    pointer-events: none;
}
.bp-section-8-04__robots-hand {
    display: block;
    width: 100%;
    height: auto;
}
.bp-section-8-04__ai-chip {
    position: absolute;
    left: 28%;
    bottom: 44%;
    width: 42%;
    max-width: 260px;
    height: auto;
    animation: bp-section-8-04-bounce 4.2s ease-in-out infinite;
    transform-origin: 50% 100%;
    filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.18));
}
/* Bubble-like bounce — rises with a slight overshoot and settles back.
   More energetic than 8-02's float since the chip is meant to read as
   "hopping on the palm". */
@keyframes bp-section-8-04-bounce {
    0%, 100% { transform: translateY(0)     scale(1); }
    40%      { transform: translateY(-14px) scale(1.03); }
    55%      { transform: translateY(-18px) scale(1.04); }
    70%      { transform: translateY(-8px)  scale(1.02); }
}

.bp-section-8-04__article-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 12px;
}

/* Right column — 2 stacked feeds (same pattern as 8-02/8-03) */
.bp-section-8-04__article-right {
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-width: 0;
}
.bp-section-8-04 [data-carousel="articles"] { --bp-per-view: 3; }
.bp-section-8-04 [data-carousel="tiktok"]   { --bp-per-view: 4; }
.bp-section-8-04__feed { min-width: 0; }
.bp-section-8-04__feed + .bp-section-8-04__feed {
    padding-top: 32px;
    border-top: 1px solid #C8C8C8;
}
.bp-section-8-04__feed-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.bp-section-8-04__feed-title {
    margin: 0;
    color: #171717;
    font-size: 1.1rem;
    font-weight: 700;
}
.bp-section-8-04__view-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: #171717;
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    line-height: 1;
    transition: background 0.2s ease, transform 0.2s ease;
}
.bp-section-8-04__view-all:hover {
    background: #E01C24;
    color: #ffffff;
    transform: translateY(-1px);
}
.bp-section-8-04__carousel-shell {
    position: relative;
    width: 100%;
}
.bp-section-8-04__feed-empty {
    width: 100%;
    padding: 24px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px dashed rgba(23, 23, 23, 0.2);
    color: #888;
    font-size: 0.9rem;
    text-align: center;
}

/* Article card */
.bp-section-8-04__article-card {
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    text-decoration: none;
    color: #171717;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    min-height: 240px;
    padding: 10px 10px 0;
}
.bp-section-8-04__article-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    color: #171717;
}
.bp-section-8-04__article-card-image {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #e5e5e5;
    overflow: hidden;
    border-radius: 10px;
}
.bp-section-8-04__article-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.bp-section-8-04__article-card-cta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    align-self: flex-end;
    margin-top: auto;
    padding: 5px 12px;
    border-radius: 999px;
    background: #171717;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1;
    pointer-events: none;
}
.bp-section-8-04__article-card-cta img {
    width: 13px;
    height: 13px;
    display: block;
}
.bp-section-8-04__article-card-body {
    padding: 14px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}
.bp-section-8-04__article-card-title {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.4;
    color: #171717;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.bp-section-8-04__article-card-excerpt {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.55;
    color: #555;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Tablet ------------------------------------------------------------- */
@media (max-width: 1024px) {
    .bp-section-8-04 .bp-section-8-04__inner { padding: 56px 32px; gap: 28px; }
    .bp-section-8-04__headline { font-size: 1.65rem; }
    .bp-section-8-04__story-text { font-size: 1rem; line-height: 1.75; }
    .bp-section-8-04__story-logos--single .bp-section-8-04__story-logo { width: 180px; }
    .bp-section-8-04__story-logos { gap: 32px; }

    .bp-section-8-04 .bp-section-8-04__inner--b { padding: 56px 32px; }
    .bp-section-8-04__article { grid-template-columns: 44% 1fr; gap: 36px; }
    .bp-section-8-04__article-title { font-size: 1.85rem; }

    .bp-section-8-04__visual-stack {
        margin-left: -32px;       /* tablet inner padding is 32px */
        width: min(480px, 46vw);
    }
    .bp-section-8-04 [data-carousel="articles"] { --bp-per-view: 2; }
    .bp-section-8-04 [data-carousel="tiktok"]   { --bp-per-view: 3; }
}

/* --- Mobile ------------------------------------------------------------- */
@media (max-width: 768px) {
    .bp-section-8-04 .bp-section-8-04__inner { padding: 48px 20px; gap: 24px; }
    .bp-section-8-04__headline { font-size: 1.2rem; line-height: 1.55; }

    /* Collapse desktop 2-col story into vertical centered stack. */
    .bp-section-8-04__story {
        grid-template-columns: 1fr;
        gap: 20px;
        text-align: center;
    }
    .bp-section-8-04__story-text { font-size: 0.95rem; line-height: 1.75; }
    .bp-section-8-04__story-logos { gap: 24px; justify-content: center; }
    .bp-section-8-04__story-logos--single .bp-section-8-04__story-logo { width: 160px; }

    .bp-section-8-04__cta { min-width: 180px; font-size: 1rem; padding: 12px 32px; }

    .bp-section-8-04 .bp-section-8-04__inner--b { padding: 48px 20px; }

    /* Stage B mobile flow — title → desc → carousels → visual → button.
       `display: contents` lifts article-left's children into the flex stack
       so we can `order` them relative to article-right. */
    .bp-section-8-04__article {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
        gap: 28px;
        width: 100%;
        align-items: stretch;
    }
    .bp-section-8-04__article-left { display: contents; }
    .bp-section-8-04__article-title { order: 1; font-size: 1.5rem; text-align: center; }
    .bp-section-8-04__article-desc  { order: 2; font-size: 0.95rem; text-align: center; margin: 0 auto; max-width: 440px; }
    .bp-section-8-04__article-right { order: 3; width: 100%; align-self: stretch; }
    .bp-section-8-04__article-buttons {
        order: 5;
        justify-content: center;
        margin-top: 4px;
        width: 100%;
        align-self: stretch;
    }

    /* Mobile: flush to the LEFT edge — undo the inner's 20px left padding
       with `margin-left: -20px`. `align-self: flex-start` overrides the
       parent flex's stretched children so the stack keeps its intrinsic
       width on the left side instead of centering. */
    .bp-section-8-04__visual-stack {
        order: 4;
        width: 280px;
        max-width: 70%;
        margin-top: 0;
        margin-right: 0;
        margin-bottom: 0;
        margin-left: -20px;
        align-self: flex-start;
    }

    .bp-section-8-04__feed-title { font-size: 1.1rem; }
    .bp-section-8-04__article-card { min-height: 220px; }

    .bp-section-8-04 [data-carousel="articles"] { --bp-per-view: 1; }
    .bp-section-8-04 [data-carousel="tiktok"]   { --bp-per-view: 1; }

    /* Mobile vertical stack — replace horizontal slide with stacked stages.
       See section-8-01 for rationale. */
    .bp-section-8-04__stages {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        min-height: 0;
        transform: none !important;
        transition: none;
    }
    .bp-section-8-04__stage {
        width: 100%;
        overflow: hidden;
    }
}
