/* ================================================
   banner-animation.css — Ragnarok x Let's Get Rich
   วางต่อจาก scrollreveal.css ใน <head>

   หมายเหตุ: ใช้ property แบบแยก (translate / rotate / scale)
   เพื่อไม่ให้ทับกับ transform เดิมของ banner.css และ scrollreveal.css
================================================ */

.bannerMainLayout {
    --mx: 0;
    /* ค่า parallax แกน X (-1 ถึง 1) ถูกอัปเดตจาก JS */
    --my: 0;
    /* ค่า parallax แกน Y (-1 ถึง 1) */
}

/* ─────────────────────
   1) พื้นหลัง + ฉากหลัก
───────────────────── */
@keyframes bnFrameDrift {
    from {
        scale: 1;
    }

    to {
        scale: 1.015;
    }
}

@keyframes bnMainBreathe {

    0%,
    100% {
        scale: 1;
        rotate: 0deg;
    }

    50% {
        scale: 1.018;
        rotate: .5deg;
    }
}

.bannerFrameLayout {
    translate: calc(var(--mx) * -3px) calc(var(--my) * -2px);
    animation: bnFrameDrift 20s ease-in-out infinite alternate;
}

.bannerMainFrameLayout {
    translate: calc(var(--mx) * 16px) calc(var(--my) * 10px);
    animation: bnMainBreathe 9s ease-in-out infinite;
}

/* ─────────────────────
   2) ไอเท็มลอยได้ (เหรียญ / แผนที่ / ลูกเต๋า)
───────────────────── */
@keyframes bnPop {
    0% {
        opacity: 0;
        scale: 0;
    }

    60% {
        opacity: 1;
        scale: 1.18;
    }

    100% {
        opacity: 1;
        scale: 1;
    }
}

@keyframes bnFloatA {

    0%,
    100% {
        translate: 0 0;
        rotate: -3deg;
    }

    50% {
        translate: 6px -18px;
        rotate: 4deg;
    }
}

@keyframes bnFloatB {

    0%,
    100% {
        translate: 0 0;
        rotate: 3deg;
    }

    33% {
        translate: -8px -12px;
        rotate: -3deg;
    }

    66% {
        translate: 5px -20px;
        rotate: 2deg;
    }
}

@keyframes bnFloatC {

    0%,
    100% {
        translate: 0 0;
        rotate: 0deg;
    }

    50% {
        translate: -6px -22px;
        rotate: -6deg;
    }
}

/* ลูกเต๋า: เด้ง 2 จังหวะ แล้วพัก */
@keyframes bnDiceBounce {

    0%,
    55%,
    100% {
        translate: 0 0;
    }

    15% {
        translate: 0 -34px;
    }

    30% {
        translate: 0 0;
    }

    40% {
        translate: 0 -12px;
    }

    48% {
        translate: 0 0;
    }
}

@keyframes bnDiceTumble {

    0%,
    55%,
    100% {
        rotate: 0 0 1 0deg;
    }

    15% {
        rotate: 0 0 1 24deg;
    }

    30% {
        rotate: 0 0 1 -8deg;
    }

    40% {
        rotate: 0 0 1 10deg;
    }

    48% {
        rotate: 0 0 1 0deg;
    }
}

/* เหรียญ: หมุน 360° แล้วหยุดพัก */
@keyframes bnCoinSpin {
    0% {
        rotate: y 0deg;
    }

    30%,
    100% {
        rotate: y 360deg;
    }
}

.bannerObj {
    perspective: 700px;
    animation:
        bnPop .9s cubic-bezier(.34, 1.56, .64, 1) var(--d, .6s) both,
        var(--float, bnFloatA) var(--dur, 6s) ease-in-out calc(var(--d, .6s) * -1) infinite;
}

/* parallax ชั้นใน (ใช้ transform ที่ img เพื่อไม่ชนกับ animation ชั้นนอก) */
.bannerObj img {
    --depth: 24;
    transform: translate(calc(var(--mx) * var(--depth) * 1px), calc(var(--my) * var(--depth) * 1px));
    will-change: transform;
}

.bannerObjectCoin_1 {
    --d: .7s;
    --float: bnFloatA;
    --dur: 6s;
}

.bannerObjectCoin_2 {
    --d: .85s;
    --float: bnFloatB;
    --dur: 7s;
}

.bannerObjectCoin_3 {
    --d: 1s;
    --float: bnFloatC;
    --dur: 5.5s;
}

.bannerObjectMap {
    --d: 1.1s;
    --float: bnFloatB;
    --dur: 8s;
}

.bannerObject {
    --d: 1.2s;
    --float: bnFloatA;
    --dur: 6.5s;
}

.bannerObjectDice {
    --d: 1.3s;
    --float: bnDiceBounce;
    --dur: 5s;
}

.bannerObjectCoin_1 img {
    --depth: 34;
}

.bannerObjectCoin_2 img {
    --depth: 44;
}

.bannerObjectCoin_3 img {
    --depth: 28;
}

.bannerObjectMap img {
    --depth: 20;
}

.bannerObject img {
    --depth: 26;
}

.bannerObjectDice img {
    --depth: 38;
}

/* เหรียญประกายทอง + หมุนสลับจังหวะ */
.bannerObjectCoin_1 img,
.bannerObjectCoin_2 img,
.bannerObjectCoin_3 img {
    filter: drop-shadow(0 0 10px rgba(255, 214, 120, .5));
}

.bannerObjectCoin_1 img {
    animation: bnCoinSpin 6s ease-in-out 2.0s infinite;
}

.bannerObjectCoin_2 img {
    animation: bnCoinSpin 7s ease-in-out 3.4s infinite;
}

.bannerObjectCoin_3 img {
    animation: bnCoinSpin 5.5s ease-in-out 4.2s infinite;
}

.bannerObjectDice img {
    animation: bnDiceTumble 5s ease-in-out calc(1.3s * -1) infinite;
    filter: drop-shadow(0 10px 8px rgba(0, 0, 0, .5));
}

/* ─────────────────────
   3) โลโก้
───────────────────── */
@keyframes bnLogoFloat {

    0%,
    100% {
        translate: 0 0;
    }

    50% {
        translate: 0 -8px;
    }
}

@keyframes bnLogoGlow {

    0%,
    100% {
        filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .45));
    }

    50% {
        filter: drop-shadow(0 6px 22px rgba(255, 210, 120, .55));
    }
}

@keyframes bnXPulse {

    0%,
    100% {
        scale: 1;
        text-shadow: 0 0 0 rgba(242, 210, 137, 0);
    }

    50% {
        scale: 1.22;
        text-shadow: 0 0 18px rgba(242, 210, 137, .95);
    }
}

.bannerContentLogoRoc {
    animation: bnLogoFloat 5s ease-in-out 1.6s infinite;
}

.bannerContentLogoLgr {
    animation: bnLogoFloat 5s ease-in-out 4.1s infinite;
}

.bannerContentLogoRoc img,
.bannerContentLogoLgr img {
    animation: bnLogoGlow 4s ease-in-out infinite;
}

.bannerContentLogoX span {
    display: inline-block;
    animation: bnXPulse 3s ease-in-out infinite;
}

/* ─────────────────────
   4) ปุ่ม: ไหลเข้าทีละปุ่ม + แสงวิ่ง + ตอบสนองเมื่อกด
   (ต้องมี scrollreveal.js เติมคลาส .in-view ให้กลุ่มปุ่ม)
───────────────────── */
@keyframes bnBtnIn {
    from {
        opacity: 0;
        translate: 60px 0;
        scale: .8;
    }

    to {
        opacity: 1;
        translate: 0 0;
        scale: 1;
    }
}

@keyframes bnShine {

    0%,
    55% {
        left: -80%;
    }

    100% {
        left: 140%;
    }
}

.bannerButtonMainLayout .btn {
    opacity: 0;
    cursor: pointer;
}

.bannerButtonMainLayout.in-view .btn {
    animation: bnBtnIn .7s cubic-bezier(.34, 1.56, .64, 1) both;
}

.bannerButtonMainLayout.in-view .btn:nth-child(1) {
    animation-delay: .35s;
}

.bannerButtonMainLayout.in-view .btn:nth-child(2) {
    animation-delay: .45s;
}

.bannerButtonMainLayout.in-view .btn:nth-child(3) {
    animation-delay: .55s;
}

.bannerButtonMainLayout.in-view .btn:nth-child(4) {
    animation-delay: .65s;
}

.bannerButtonMainLayout.in-view .btn:nth-child(5) {
    animation-delay: .75s;
}

/* แสงสีขาวพาดผ่านปุ่ม */
.btn.primary::before {
    content: "";
    position: absolute;
    top: 0;
    left: -80%;
    z-index: -1;
    width: 45%;
    height: 100%;
    background: linear-gradient(105deg, transparent, rgba(255, 255, 255, .75), transparent);
    transform: skewX(-20deg);
    animation: bnShine 4.5s ease-in-out infinite;
}

.bannerButtonMainLayout .btn:nth-child(2)::before {
    animation-delay: .4s;
}

.bannerButtonMainLayout .btn:nth-child(3)::before {
    animation-delay: .8s;
}

.bannerButtonMainLayout .btn:nth-child(4)::before {
    animation-delay: 1.2s;
}

.bannerButtonMainLayout .btn:nth-child(5)::before {
    animation-delay: 1.6s;
}

.btn.primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 0 #082d8d, 0 10px 22px rgba(242, 210, 137, .45);
    filter: brightness(1.06);
}

.btn.primary:hover::before {
    animation-duration: 1.1s;
}

.btn.primary:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #082d8d;
}

.btn.primary:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

/* ─────────────────────
   5) แคนวาสประกายทอง (สร้างจาก JS)
───────────────────── */
.bannerSparkCanvas {
    position: absolute;
    inset: 0;
    z-index: 4;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ================================================
   6) MOBILE (.bannerMb) — เฉพาะจอ ≤ 575.98px
   ตรงกับ responsive.css ที่สลับมาใช้ดีไซน์มือถือ
   ใช้ --mx / --my จาก JS ทำ parallax เบาๆ
================================================ */

/* ─────────────────────
   KEYFRAMES
───────────────────── */
@keyframes bmPop {
    from {
        opacity: 0;
        scale: 0;
    }

    to {
        opacity: 1;
        scale: 1;
    }
}

@keyframes bmFrameBreathe {

    0%,
    100% {
        scale: 1;
    }

    50% {
        scale: 1.03;
    }
}

@keyframes bmFloatA {

    0%,
    100% {
        translate: 0 0;
        rotate: -2deg;
    }

    50% {
        translate: 0 -10px;
        rotate: 2deg;
    }
}

@keyframes bmFloatB {

    0%,
    100% {
        translate: 0 0;
        rotate: 3deg;
    }

    50% {
        translate: 0 -8px;
        rotate: -3deg;
    }
}

/* แผนที่: แสงทองเรืองสลับสว่างตามขอบภาพ (ไม่ขยับตำแหน่ง) */
@keyframes bmMapGlow {

    0%,
    100% {
        filter: brightness(1) drop-shadow(0 0 0 rgba(255, 214, 120, 0));
    }

    50% {
        filter: brightness(1.12) drop-shadow(0 0 16px rgba(255, 214, 120, 0.5));
    }
}

/* โพริงกระโดด: ย่อตัว → ดีดขึ้น → ลงจอดยุบ → นิ่ง → พัก */
@keyframes bmPoringHop {

    0%,
    60%,
    100% {
        translate: 0 0;
        scale: 1 1;
    }

    10% {
        translate: 0 0;
        scale: 1.1 0.88;
    }

    25% {
        translate: 0 -22px;
        scale: 0.94 1.08;
    }

    40% {
        translate: 0 0;
        scale: 1.12 0.86;
    }

    50% {
        translate: 0 0;
        scale: 0.97 1.03;
    }
}

@keyframes bmPoringBreath {

    0%,
    100% {
        scale: 1 1;
    }

    50% {
        scale: 1.04 0.96;
    }
}

@keyframes bmCoinSpin {
    0% {
        rotate: y 0deg;
    }

    30%,
    100% {
        rotate: y 360deg;
    }
}

/* แตะ: โพริงเด้งแรงๆ / เหรียญหมุนเร็ว */
@keyframes bmTapHop {
    0% {
        translate: 0 0;
        scale: 1 1;
    }

    25% {
        translate: 0 -34px;
        scale: 0.9 1.15;
    }

    55% {
        translate: 0 0;
        scale: 1.18 0.82;
    }

    75% {
        scale: 0.96 1.05;
    }

    100% {
        translate: 0 0;
        scale: 1 1;
    }
}

@keyframes bmTapSpin {
    from {
        rotate: y 0deg;
    }

    to {
        rotate: y 720deg;
    }
}

@keyframes bmBtnIn {
    from {
        opacity: 0;
        translate: 0 28px;
        scale: 0.85;
    }

    to {
        opacity: 1;
        translate: 0 0;
        scale: 1;
    }
}

/* ─────────────────────
   MOBILE ONLY
───────────────────── */
@media (max-width: 575.98px) {

    /* ── ฉากหลักมือถือ: โชว์ทันที แค่หายใจ + parallax เบาๆ ── */
    .bannerMb_Frame {
        translate: calc(var(--mx) * -6px) calc(var(--my) * -4px);
        animation: bmFrameBreathe 12s ease-in-out infinite;
    }

    /* ── ไอเท็มมือถือ: ป๊อปเข้า + ลอย ── */
    .bannerPoring_1,
    .bannerPoring_2,
    .bannerCoin_1,
    .bannerCoin_2 {
        perspective: 600px;
        -webkit-tap-highlight-color: transparent;
        animation:
            bmPop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) var(--d, 0.5s) both,
            var(--bm-float, bmFloatA) var(--bm-dur, 6s) ease-in-out calc(var(--d, 0.5s) * -1) infinite;
    }

    /* แผนที่ = พื้นฉาก: โชว์ทันที ไม่ลอย ไม่เลื่อนขึ้น
       เลื่อนซ้ายขวาเบาๆ ตาม parallax (ภาพกว้าง 700px จึงไม่เกิดขอบแหว่ง) */
    .bannerMap {
        translate: calc(var(--mx) * 18px) 0;
    }

    .bannerPoring_1 {
        --d: 0.7s;
        --bm-float: none;
    }

    .bannerPoring_2 {
        --d: 0.9s;
        --bm-float: bmFloatA;
        --bm-dur: 6s;
    }

    .bannerCoin_1 {
        --d: 1.1s;
        --bm-float: bmFloatB;
        --bm-dur: 5s;
    }

    .bannerCoin_2 {
        --d: 1.3s;
        --bm-float: bmFloatA;
        --bm-dur: 5.5s;
    }

    /* parallax ชั้นใน (ที่ img เพื่อไม่ชนกับ animation ชั้นนอก) */
    .bannerMb img {
        --depth: 10;
        transform: translate(calc(var(--mx) * var(--depth) * 1px), calc(var(--my) * var(--depth) * 1px));
        transform-origin: 50% 100%;
        will-change: transform;
    }

    .bannerMb_Frame img {
        transform: none;
        will-change: auto;
    }

    .bannerMap img {
        transform: none;
        will-change: auto;
        animation: bmMapGlow 6s ease-in-out infinite;
    }

    .bannerPoring_1 img {
        --depth: 16;
        animation: bmPoringHop 3.6s ease-in-out 1.4s infinite;
    }

    .bannerPoring_2 img {
        --depth: 12;
        animation: bmPoringBreath 4s ease-in-out infinite;
    }

    .bannerCoin_1 img,
    .bannerCoin_2 img {
        --depth: 20;
        transform-origin: 50% 50%;
        filter: drop-shadow(0 0 8px rgba(255, 214, 120, 0.55));
    }

    .bannerCoin_1 img {
        animation: bmCoinSpin 5s ease-in-out 2s infinite;
    }

    .bannerCoin_2 img {
        animation: bmCoinSpin 6s ease-in-out 3.2s infinite;
    }

    /* ── แตะแล้วตอบสนอง (JS ใส่ .is-tap) ── */
    .bannerPoring_1,
    .bannerPoring_2,
    .bannerCoin_1,
    .bannerCoin_2 {
        cursor: pointer;
    }

    .bannerPoring_1.is-tap img,
    .bannerPoring_2.is-tap img {
        animation: bmTapHop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .bannerCoin_1.is-tap img,
    .bannerCoin_2.is-tap img {
        animation: bmTapSpin 0.8s ease-out;
    }

    /* ── ปุ่ม: ไล่ขึ้นจากด้านล่างแทนไหลจากขวา (มือถือเรียงเป็นแถว) ── */
    .bannerButtonMainLayout.in-view .btn {
        animation-name: bmBtnIn;
    }
}

/* ─────────────────────
   ประกายตอนแตะ (สร้างจาก JS)
───────────────────── */
.bmTapSpark {
    position: absolute;
    z-index: 8;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle, #fffbe3 0%, #f2d97c 40%, rgba(242, 217, 124, 0) 70%);
}