/* ==========================================================================
   Section 8 item 01 — Chapter: การลดต้นทุนอย่างมีประสิทธิภาพ (.bp-section-8-01)

   Architecture:
   - Outer section is 100vh but uses `display: block` + `overflow: hidden`
     so the 200vw-wide stages child can slide horizontally without leaking.
   - `.bp-section-8-01__stages` is a 2-col flex (Stage A | Stage B), each
     100vw wide. `.is-stage-b` toggles `translateX(-100vw)` on the wrapper.
   - `.is-snap` kills the transform transition so the stage can snap back
     to A on scroll-away without a visible slide.
   ========================================================================== */

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

/* --- Stages wrapper (slides horizontally on toggle) ----------------------
   align-items: flex-start prevents Stage A from stretching to match a taller
   Stage B on mobile (where per-view 1 + 9:16 tiktok cards make Stage B ~1400px
   tall). Without this, Stage A's flex-centered content drifts down. */
.bp-section-8-01__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-01.is-stage-b .bp-section-8-01__stages {
    transform: translateX(-100vw);
}
.bp-section-8-01.is-snap .bp-section-8-01__stages {
    transition: none;
}

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

/* ============================================================
   Stage A (dark intro) — headline + Toyota/Ford + glass CTA
   ============================================================ */
.bp-section-8-01 .bp-section-8-01__inner {
    width: 100%;
    max-width: 1320px;
    padding: 72px 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

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

.bp-section-8-01__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-01__story-text {
    color: #ffffff;
    font-size: 1.05rem;
    line-height: 1.8;
    margin: 0;
}
.bp-section-8-01__story-brand {
    font-weight: 800;
    font-size: 1.15rem;
    margin-right: 4px;
}
.bp-section-8-01__story-brand--toyota { color: #E01C24; }
.bp-section-8-01__story-brand--ford   { color: #1C63DD; }

/* Logo sits upper-right (behind), car sits lower-left (in front) — overlap heavily. */
.bp-section-8-01__story-visual {
    position: relative;
    width: 100%;
    height: 230px;
}
.bp-section-8-01__story-logo {
    position: absolute;
    top: 0;
    right: 12%;
    width: 260px;
    height: auto;
    object-fit: contain;
    z-index: 1;
    opacity: 0.95;
}
.bp-section-8-01__story-car {
    position: absolute;
    bottom: 0;
    left: 4%;
    width: 70%;
    max-width: 340px;
    height: auto;
    object-fit: contain;
    z-index: 2;
}
.bp-section-8-01__story[data-brand="ford"] .bp-section-8-01__story-logo {
    top: -20px;
}

/* CTA uses shared .bp-btn-glass. */
.bp-section-8-01__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 2-column content
   ============================================================ */
/* Bump specificity so this wins against the generic .bp-section-8-01__inner rule.
   Content stays constrained to 1320px like the other sections; the gear-left
   decorative bleed is handled at the stage level so it still touches the
   viewport edge regardless of this inner cap. */
.bp-section-8-01 .bp-section-8-01__inner--b {
    width: 100%;
    max-width: 1320px;
    padding: 72px 48px;
    color: #171717;
    display: block;
}
.bp-section-8-01__article {
    display: grid;
    grid-template-columns: 42% 1fr;
    gap: 56px;
    align-items: start;
}

/* Left column — title + desc + gear + buttons */
.bp-section-8-01__article-left {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.bp-section-8-01__article-title {
    margin: 0;
    color: #E01C24;
    font-size: 2.3rem;
    font-weight: 800;
    line-height: 1.25;
}
.bp-section-8-01__article-desc {
    margin: 0;
    color: #171717;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.75;
    max-width: 440px;
}

/* Center gear — decorative, centered horizontally in the left column. Runs a
   subtle "tada" pulse (scale + wobble) every ~5s so it catches the eye
   without feeling busy. The long tail of the keyframe is static so the gear
   spends most of its time at rest. */
.bp-section-8-01__gear-center {
    display: block;
    width: 440px;
    max-width: 90%;
    height: auto;
    margin: 24px auto;
    transform-origin: 50% 50%;
    /* Calm, continuous clockwise rotation — fits the gear motif without
       being showy. 30s per full turn is slow enough to feel ambient. */
    animation: bp-section-8-01-gear-spin 30s linear infinite;
    pointer-events: none;
}
@keyframes bp-section-8-01-gear-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Left gear — anchored to the STAGE's left-bottom corner (viewport edge),
   not the article column. Sits above the stage bg, behind the article inner. */
.bp-section-8-01__gear-left {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 28vw;
    height: auto;
    z-index: 1;
    opacity: 0.9;
    pointer-events: none;
}

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

/* Right column — 2 stacked feeds: articles carousel + tiktok carousel. */
.bp-section-8-01__article-right {
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-width: 0;
}
/* Desktop defaults — previously set via inline `style="--bp-per-view: X"` on
   the template, which outranks every media query. Keep them in CSS so the
   tablet / mobile media queries below can actually override. */
.bp-section-8-01 [data-carousel="articles"] { --bp-per-view: 3; }
.bp-section-8-01 [data-carousel="tiktok"]   { --bp-per-view: 4; }
.bp-section-8-01__feed { min-width: 0; }
/* Second feed (TikTok) gets a top border + spacing to visually separate
   "บทความล่าสุด" from "วิดีโอที่แนะนำ". */
.bp-section-8-01__feed + .bp-section-8-01__feed {
    padding-top: 32px;
    border-top: 1px solid #C8C8C8;
}
.bp-section-8-01__feed-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.bp-section-8-01__feed-title {
    margin: 0;
    color: #171717;
    font-size: 1.1rem;
    font-weight: 700;
}
/* "ดูทั้งหมด" header pill — replaces the old arrow-nav slot in the feed header.
   Dark capsule on light bg, with a small ↗ arrow icon. */
.bp-section-8-01__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-01__view-all:hover {
    background: #E01C24;
    color: #ffffff;
    transform: translateY(-1px);
}
/* Carousel shell — the carousel track fills 100% width; prev/next arrows are
   absolute-positioned and overlay the carousel's left/right edges so we don't
   lose any horizontal room to a dedicated arrow column. */
.bp-section-8-01__carousel-shell {
    position: relative;
    width: 100%;
}
/* Side arrows just frame the PNG — the icon artwork already carries its own
   circular styling, so no extra background / shadow here. Centered vertically
   over the carousel. */
.bp-carousel-btn--side,
.bp-carousel-btn--side:hover,
.bp-carousel-btn--side:disabled {
    position: absolute;
    top: 50%;
    /* Keep the vertical-centering transform in ALL states — the shared
       .bp-carousel-btn:hover / :disabled rules would otherwise overwrite it
       with translateY(-1px) / none and make the arrow jump on hover when
       disabled (the "flicker" the user saw). */
    transform: translateY(-50%);
    z-index: 2;
    width: 40px;
    height: 40px;
    background: transparent;
    transition: opacity 0.2s ease;
}
.bp-carousel-btn--side img { width: 100%; height: 100%; }
.bp-carousel-btn--side[data-carousel-prev] { left: 0; }
.bp-carousel-btn--side[data-carousel-next] { right: 0; }

.bp-section-8-01__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 — inner padding around the image so it sits INSIDE the card
   with rounded corners on all four sides (rather than flush to the card edge). */
.bp-section-8-01__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-01__article-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    color: #171717;
}
.bp-section-8-01__article-card-image {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #e5e5e5;
    overflow: hidden;
    border-radius: 10px;
}
.bp-section-8-01__article-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* "อ่านต่อ" pill — mirrors the Section 7 CTA (dark #171717 pill, white text,
   arrow icon). Sits at the bottom-right of the card body, pushed down by
   `margin-top: auto`. Decorative — the whole card is the click target. */
.bp-section-8-01__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-01__article-card-cta img {
    width: 13px;
    height: 13px;
    display: block;
}
.bp-section-8-01__article-card-body {
    padding: 14px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}
.bp-section-8-01__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-01__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;
}

/* TikTok card — preview placeholder, opens modal on click */
.bp-tiktok-card {
    position: relative;
    aspect-ratio: 9 / 16;
    border-radius: 12px;
    overflow: hidden;
    border: none;
    padding: 0;
    cursor: pointer;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.12), transparent 55%),
        linear-gradient(135deg, #202020 0%, #050505 100%);
    color: #fff;
    font-family: inherit;
    display: block;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}
.bp-tiktok-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
/* Real TikTok cover image — shows the full image (object-fit: contain) so
   non-9:16 covers aren't cropped. The dark gradient on .bp-tiktok-card
   fills any letterbox bands, which reads cleanly against TikTok's usually
   bright imagery. Play glyph + brand badge layer over it. */
.bp-tiktok-card__thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}
.bp-tiktok-card__play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    line-height: 0;
}
.bp-tiktok-card__play-img {
    display: block;
    width: 56px;
    height: 56px;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
}
.bp-tiktok-card__brand {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 22px;
    height: 22px;
    object-fit: contain;
    pointer-events: none;
}
.bp-tiktok-card__label {
    position: absolute;
    bottom: 10px;
    left: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.5px;
    pointer-events: none;
}

/* --- Tablet ------------------------------------------------------------- */
@media (max-width: 1024px) {
    .bp-section-8-01 .bp-section-8-01__inner { padding: 56px 32px; gap: 24px; }
    .bp-section-8-01__headline { font-size: 1.65rem; }
    .bp-section-8-01__story { gap: 28px; }
    .bp-section-8-01__story-visual { height: 200px; }
    .bp-section-8-01__story-logo { width: 210px; right: 10%; }
    .bp-section-8-01__story-car  { max-width: 280px; left: 2%; }
    .bp-section-8-01__story[data-brand="ford"] .bp-section-8-01__story-logo { top: -16px; }

    .bp-section-8-01 .bp-section-8-01__inner--b { padding: 56px 32px; }
    .bp-section-8-01__article { grid-template-columns: 44% 1fr; gap: 36px; }
    .bp-section-8-01__article-title { font-size: 1.85rem; }
    .bp-section-8-01__gear-center { width: 360px; }
    .bp-section-8-01__gear-left   { width: 220px; max-width: 24vw; }
    .bp-carousel-btn--side { width: 36px; height: 36px; }
    /* Tighten carousel density on tablet: 2 articles/view, 3 tiktoks/view */
    .bp-section-8-01 [data-carousel="articles"] { --bp-per-view: 2; }
    .bp-section-8-01 [data-carousel="tiktok"]   { --bp-per-view: 3; }
}

/* --- Mobile ------------------------------------------------------------- */
@media (max-width: 768px) {
    .bp-section-8-01 .bp-section-8-01__inner { padding: 48px 20px; gap: 22px; }
    .bp-section-8-01__headline { font-size: 1.2rem; line-height: 1.5; }
    .bp-section-8-01__headline br { display: none; }

    .bp-section-8-01__story {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .bp-section-8-01__story-text { font-size: 0.95rem; line-height: 1.75; text-align: left; }
    .bp-section-8-01__story-brand { font-size: 1.05rem; }

    .bp-section-8-01__story-visual { height: 160px; }
    .bp-section-8-01__story-logo { width: 170px; top: 0; right: 8%; }
    .bp-section-8-01__story-car  { width: 68%; max-width: 240px; left: 2%; }
    .bp-section-8-01__story[data-brand="ford"] .bp-section-8-01__story-logo { top: -10px; }

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

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

    /* Stage B mobile flow: title → desc → article-right → buttons.
       `display: contents` on .article-left makes its children (title, desc,
       gear, buttons) direct flex items of .article so `order` can place the
       buttons below article-right without touching the DOM. */
    .bp-section-8-01__article {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
        gap: 28px;
        width: 100%;
        align-items: stretch;
    }
    .bp-section-8-01__article-left { display: contents; }
    .bp-section-8-01__article-title { order: 1; font-size: 1.5rem; text-align: center; }
    .bp-section-8-01__article-desc  { order: 2; font-size: 0.95rem; text-align: center; margin: 0 auto; max-width: 440px; }
    .bp-section-8-01__article-right { order: 3; width: 100%; align-self: stretch; }
    .bp-section-8-01__gear-center {
        order: 4;
        display: block;
        width: 220px;
        max-width: 60%;
        margin: 0 auto;
    }
    .bp-section-8-01__article-buttons {
        order: 5;
        justify-content: center;
        margin-top: 4px;
        width: 100%;
        align-self: stretch;
    }
    .bp-section-8-01__gear-left { width: 160px; max-width: 40vw; opacity: 0.8; }
    .bp-section-8-01__feed-title { font-size: 1.1rem; }
    .bp-section-8-01__article-card { min-height: 220px; }

    /* 1 card per view for both carousels. Side arrows + native swipe paginate. */
    .bp-section-8-01 [data-carousel="articles"] { --bp-per-view: 1; }
    .bp-section-8-01 [data-carousel="tiktok"]   { --bp-per-view: 1; }

    /* Mobile vertical stack — replace horizontal slide with stacked stages.
       Each stage is a snap target (set in landing-base.css). The wrapper
       drops its 200vw width + transform so stages flow vertically. */
    .bp-section-8-01__stages {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        min-height: 0;
        transform: none !important;
        transition: none;
    }
    .bp-section-8-01__stage {
        width: 100%;
        overflow: hidden;
    }
}
