/* ============================================================
   decor.css — ลูกเล่นตกแต่ง (ใช้ทุกหน้า)
   ดาวตก + รอยเมาส์ประกายดาว + ยาน UFO + หุ่นยนต์ลากย้ายได้
   ============================================================ */

/* แคนวาสดาวตก อยู่หลังเนื้อหา (เหนือพื้นหลัง) */
#fxBack{ position:fixed; inset:0; z-index:0; pointer-events:none; }
/* แคนวาสประกายเมาส์ อยู่หน้าสุด ไม่ขวางการคลิก */
#fxFront{ position:fixed; inset:0; z-index:9998; pointer-events:none; }

/* ---------- ค่อยๆ เฟดลูกเล่นเข้าตอนโหลด (กันเด้งมาพร้อมกัน) ---------- */
#fxBack, #stars, #aurora,
#botWrap, #themeBtn, #fxBtn{
  opacity:0; transition:opacity 1.1s ease;
}
body.fx-ready #fxBack,
body.fx-ready #stars{ opacity:1; }
body.fx-ready #aurora{ opacity:.5; }
body.fx-ready #botWrap{ opacity:1; }
body.fx-ready #themeBtn,
body.fx-ready #fxBtn{ opacity:1; }
/* หุ่น/ปุ่ม เฟดช้ากว่านิดให้ไล่ลำดับ */
body.fx-ready #botWrap{ transition:opacity 1s ease .35s; }
body.fx-ready #themeBtn{ transition:opacity .8s ease .5s; }
body.fx-ready #fxBtn{ transition:opacity .8s ease .62s; }
body.fx-ready[data-mode="light"] #aurora{ opacity:.28; }

/* ยาน UFO — เฟดเข้า/ออกนุ่มแทนการตัดวับ */
#ufo{ position:fixed; top:0; left:0; z-index:3; width:96px; height:54px;
      pointer-events:none; opacity:0; will-change:transform;
      transition:opacity .8s ease;
      filter:drop-shadow(0 6px 14px rgba(0,0,0,.45)); }
#ufo.fly{ opacity:1; }

/* หุ่นยนต์: ตอนถูกลาก ปิดอนิเมชันลอย + เปลี่ยนเคอร์เซอร์ */
#botWrap.bot-dragging{ animation:none !important; cursor:grabbing !important;
                       transform:none !important; transition:none !important; }
#botWrap.bot-placed{ animation:none !important; }
#botWrap.bot-placed:hover{ transform:translateY(-6px) scale(1.04); transition:transform .2s; }

/* ---------- โหมดปาร์ตี้ (โค้ดลับ Konami) ---------- */
body.party{ animation:partyHue 1.2s linear infinite, partyShake .28s ease-in-out infinite !important; }
@keyframes partyHue{ 0%{filter:hue-rotate(0deg) saturate(1.4)}
                     100%{filter:hue-rotate(360deg) saturate(1.4)} }
@keyframes partyShake{ 0%,100%{ transform:translate(0,0) }
                       25%{ transform:translate(-4px,2px) rotate(-.4deg) }
                       50%{ transform:translate(4px,-2px) }
                       75%{ transform:translate(-2px,-3px) rotate(.4deg) } }
#botWrap.bot-dance{ animation:botDance .5s ease-in-out infinite !important; }
@keyframes botDance{ 0%,100%{ transform:translateY(0) rotate(-12deg) scale(1.1); }
                     50%{ transform:translateY(-22px) rotate(12deg) scale(1.15); } }

/* ตัวอักษรเด้งตามจังหวะ */
.party-bounce{ display:inline-block; animation:partyBounce .4s ease-in-out infinite !important;
               animation-delay:var(--pd,0s) !important; }
@keyframes partyBounce{ 0%,100%{ transform:translateY(0) scale(1); }
                        40%{ transform:translateY(-10px) scale(1.12); } }

/* แสงดิสโก้กวาดจอ */
#discoLights{ position:fixed; inset:0; z-index:9997; pointer-events:none; overflow:hidden;
              mix-blend-mode:screen; }
#discoLights span{ position:absolute; top:50%; left:50%; width:60vmax; height:18vmax;
                   transform-origin:left center; border-radius:50%; filter:blur(40px); opacity:.55; }
#discoLights span:nth-child(1){ background:radial-gradient(closest-side,#ff5d8f,transparent);
                                animation:disco 3.2s linear infinite; }
#discoLights span:nth-child(2){ background:radial-gradient(closest-side,#5cc8ff,transparent);
                                animation:disco 3.2s linear infinite -0.8s; }
#discoLights span:nth-child(3){ background:radial-gradient(closest-side,#23d5ab,transparent);
                                animation:disco 3.2s linear infinite -1.6s; }
#discoLights span:nth-child(4){ background:radial-gradient(closest-side,#ffd166,transparent);
                                animation:disco 3.2s linear infinite -2.4s; }
@keyframes disco{ 0%{ transform:rotate(0) } 100%{ transform:rotate(360deg) } }

/* วาบแสงตอนพิมพ์ "disco" */
.disco-flash{ position:fixed; inset:0; z-index:9996; pointer-events:none;
              background:radial-gradient(circle at 50% 50%, rgba(255,255,255,.5), transparent 60%);
              animation:discoFlash .5s ease-out forwards; }
@keyframes discoFlash{ 0%{ opacity:0; } 15%{ opacity:1; } 100%{ opacity:0; } }

/* หุ่นตีลังกา (เซอร์ไพรส์ดับเบิลคลิก 3 ที) */
#botWrap.bot-flip{ animation:botFlip 1.2s cubic-bezier(.5,.05,.3,1) !important; }
@keyframes botFlip{ 0%{ transform:translateY(0) rotate(0); }
                    30%{ transform:translateY(-60px) rotate(180deg) scale(1.1); }
                    60%{ transform:translateY(-60px) rotate(540deg) scale(1.1); }
                    100%{ transform:translateY(0) rotate(720deg); } }


/* ============================================================
   อารมณ์หุ่นยนต์
   ============================================================ */
#botWrap.bot-happy{ animation:botHappy .5s ease-in-out 0s 4 !important; }
@keyframes botHappy{ 0%,100%{ transform:translateY(0); } 50%{ transform:translateY(-26px) scale(1.06); } }
#botWrap.bot-startled{ animation:botShake .4s ease-in-out 0s 3 !important; }
@keyframes botShake{ 0%,100%{ transform:translateX(0) rotate(0); }
                     25%{ transform:translateX(-7px) rotate(-5deg); }
                     75%{ transform:translateX(7px) rotate(5deg); } }
#botWrap.bot-sleep{ animation:botSleep 3.5s ease-in-out infinite !important; }
@keyframes botSleep{ 0%,100%{ transform:rotate(-6deg) translateY(0); }
                     50%{ transform:rotate(-6deg) translateY(4px); } }
#botWrap.bot-sleep .eye{ animation:none; }   /* หลับตา (เส้นแบน) ทำผ่าน scaleY */
#botWrap.bot-sleep #eyeTrack{ transform:scaleY(.12); transform-origin:center; }

/* ป้าย Zzz */
.bot-zzz{ position:absolute; top:-6px; right:6px; font-size:18px; font-weight:700;
          color:#cdd3ff; text-shadow:0 2px 6px rgba(0,0,0,.5);
          opacity:0; pointer-events:none; }
.bot-zzz.show{ animation:zzzFloat 2.2s ease-in-out infinite; }
@keyframes zzzFloat{ 0%{ opacity:0; transform:translateY(0) scale(.7); }
                     30%{ opacity:1; } 100%{ opacity:0; transform:translateY(-26px) scale(1.3); } }

/* กล่องครุ่นคิด (จุดสามจุด) */
.bot-think{ position:absolute; top:-4px; right:0; display:none; gap:4px;
            padding:6px 9px; border-radius:12px 12px 12px 3px;
            background:rgba(30,33,60,.7); border:1px solid rgba(255,255,255,.2); }
.bot-think.show{ display:flex; }
.bot-think span{ width:6px; height:6px; border-radius:50%; background:#23d5ab;
                 animation:thinkDot 1s infinite; }
.bot-think span:nth-child(2){ animation-delay:.2s; }
.bot-think span:nth-child(3){ animation-delay:.4s; }
@keyframes thinkDot{ 0%,100%{ opacity:.3; transform:translateY(0); }
                     50%{ opacity:1; transform:translateY(-4px); } }

/* ============================================================
   เลี้ยงหุ่น (mini-game) — HUD + หัวใจ
   ============================================================ */
#petHud{ position:absolute; bottom:-30px; left:50%; transform:translateX(-50%);
         width:108px; opacity:0; transition:opacity .25s; pointer-events:none; }
#botWrap:hover #petHud{ opacity:1; pointer-events:auto; }
#petHud .ph-bar{ height:7px; border-radius:5px; background:rgba(255,255,255,.18);
                 overflow:hidden; border:1px solid rgba(255,255,255,.2); }
#petHud .ph-bar i{ display:block; height:100%; width:70%;
                   background:linear-gradient(90deg,#23d5ab,#7be0a0); transition:width .3s, background .3s; }
#petHud .ph-row{ display:flex; align-items:center; justify-content:space-between; margin-top:4px; }
#petHud .ph-pts{ font-size:11px; color:#fff; text-shadow:0 1px 3px rgba(0,0,0,.6); }
#petHud .ph-feed{ width:24px; height:24px; border-radius:8px; cursor:pointer; padding:0;
                  font-size:13px; line-height:1; border:1px solid rgba(255,255,255,.25);
                  background:rgba(255,255,255,.14); transition:.15s; }
#petHud .ph-feed:hover{ background:rgba(255,209,102,.4); transform:scale(1.12); }
.pet-heart{ position:absolute; top:6px; font-size:16px; pointer-events:none;
            animation:petHeart 1.2s ease-out forwards; }
@keyframes petHeart{ 0%{ opacity:0; transform:translateY(0) scale(.5); }
                     20%{ opacity:1; } 100%{ opacity:0; transform:translateY(-54px) scale(1.2); } }

/* เดินเล่น */
#botWrap.bot-walking{ animation:botWalk .4s ease-in-out infinite !important; }
@keyframes botWalk{ 0%,100%{ margin-top:0; } 50%{ margin-top:-6px; } }

/* ============================================================
   ออโรร่า (แสงเหนือ)
   ============================================================ */
#aurora{ position:fixed; top:0; left:0; right:0; height:42vh; z-index:0;
         pointer-events:none; overflow:hidden; opacity:.5; filter:blur(34px); }
#aurora span{ position:absolute; top:-22%; height:150%; width:46%; border-radius:50%;
              mix-blend-mode:screen; opacity:.7; }
#aurora span:nth-child(1){ left:-6%; background:radial-gradient(closest-side,rgba(35,213,171,.9),transparent);
                           animation:auroraA 11s ease-in-out infinite; }
#aurora span:nth-child(2){ left:30%; background:radial-gradient(closest-side,rgba(109,93,252,.8),transparent);
                           animation:auroraB 14s ease-in-out infinite; }
#aurora span:nth-child(3){ left:62%; background:radial-gradient(closest-side,rgba(92,200,255,.8),transparent);
                           animation:auroraA 13s ease-in-out infinite reverse; }
@keyframes auroraA{ 0%,100%{ transform:translateX(0) scaleY(1); opacity:.5; }
                    50%{ transform:translateX(8%) scaleY(1.25); opacity:.85; } }
@keyframes auroraB{ 0%,100%{ transform:translateX(0) scaleY(1.1); opacity:.6; }
                    50%{ transform:translateX(-7%) scaleY(.85); opacity:.9; } }
body[data-mode="light"] #aurora{ opacity:.28; }

/* ปิดผ่าน master toggle (DOM/CSS-based) */
body.fx-off-aurora   #aurora{ display:none; }
body.fx-off-fireflies #fxBack{ }   /* หิ่งห้อยคุมใน JS */
body.fx-off-bot #botWrap, body.fx-off-bot #botBubble{ display:none !important; }

/* ============================================================
   แผงตั้งค่าเปิด/ปิดลูกเล่น (ปุ่ม ⚙️ มุมซ้ายล่าง เหนือปุ่มธีม)
   ============================================================ */
#fxBtn{ position:fixed; left:80px; bottom:24px; z-index:60; width:48px; height:48px;
        border-radius:50%; cursor:pointer; display:grid; place-items:center; font-size:21px;
        color:#fff; background:rgba(255,255,255,.12); border:1px solid rgba(255,255,255,.22);
        backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px);
        box-shadow:0 8px 24px rgba(0,0,0,.35); transition:.2s; }
#fxBtn:hover{ transform:rotate(90deg) scale(1.08); background:rgba(255,255,255,.22); }
body[data-mode="light"] #fxBtn{ color:#1c2030; background:rgba(255,255,255,.7); border-color:rgba(0,0,0,.1); }

#fxPanel{ position:fixed; left:22px; bottom:82px; z-index:61; width:236px; max-height:70vh;
          overflow-y:auto; padding:16px; border-radius:18px; color:#fff;
          background:rgba(30,33,60,.78); backdrop-filter:blur(22px) saturate(160%);
          -webkit-backdrop-filter:blur(22px) saturate(160%);
          border:1px solid rgba(255,255,255,.2); box-shadow:0 16px 44px rgba(0,0,0,.5);
          opacity:0; transform:translateY(10px) scale(.96); pointer-events:none; transition:.22s; }
#fxPanel.show{ opacity:1; transform:translateY(0) scale(1); pointer-events:auto; }
body[data-mode="light"] #fxPanel{ background:rgba(255,255,255,.9); color:#1c2030; border-color:rgba(0,0,0,.08); }
#fxPanel .fx-h{ font-size:14px; font-weight:700; margin-bottom:10px; }
#fxPanel .fx-g{ font-size:11px; opacity:.6; margin:12px 0 5px; letter-spacing:.3px; }
#fxPanel .fx-item{ display:flex; align-items:center; justify-content:space-between;
                   padding:6px 8px; border-radius:9px; font-size:13px; cursor:pointer; transition:.12s; }
#fxPanel .fx-item:hover{ background:rgba(255,255,255,.08); }
body[data-mode="light"] #fxPanel .fx-item:hover{ background:rgba(0,0,0,.05); }
#fxPanel .fx-item input{ width:34px; height:18px; cursor:pointer; accent-color:#6d5dfc; }
#fxPanel .fx-foot{ display:flex; gap:8px; margin-top:14px; }
#fxPanel .fx-foot button{ flex:1; padding:8px; border-radius:10px; cursor:pointer; font-size:12px;
                          color:inherit; background:rgba(255,255,255,.1); border:1px solid rgba(255,255,255,.2);
                          transition:.15s; }
#fxPanel .fx-foot button:hover{ background:rgba(255,255,255,.2); }
body[data-mode="light"] #fxPanel .fx-foot button{ background:rgba(0,0,0,.05); border-color:rgba(0,0,0,.12); }
@media (max-width:560px){ #fxBtn{ left:auto; right:80px; bottom:24px; } #fxPanel{ left:auto; right:22px; bottom:82px; } }


