/* ===== Christmas Theme (drop-in) =====
   ใช้งาน: ใส่ <link rel="stylesheet" href="christmas.css"> และ <script src="christmas.js" defer></script>
   ทุกอย่างทำงานเมื่อ <html> มี class "xmas" (christmas.js ใส่ให้อัตโนมัติ / ปิดได้ด้วยปุ่ม 🎄)
   ปรับสีได้ที่ตัวแปรด้านล่าง ไม่แตะ layout เดิมของเว็บ */

:root {
  --xmas-red: #c8102e;
  --xmas-red-dark: #8e0c21;
  --xmas-green: #146b3a;
  --xmas-green-dark: #0b4226;
  --xmas-gold: #f2c14e;
  --xmas-snow: #ffffff;
  --xmas-ink: #1d2a24;
  --xmas-cream: #fff8ee;
}

/* ---------- พื้นหลังและโทนรวม ---------- */
html.xmas body {
  background-color: var(--xmas-cream);
  background-image:
    radial-gradient(circle at 10% 20%, rgba(200, 16, 46, .06) 0 120px, transparent 121px),
    radial-gradient(circle at 90% 80%, rgba(20, 107, 58, .07) 0 160px, transparent 161px);
  background-attachment: fixed;
}

/* ---------- แถบไฟประดับด้านบน ---------- */
.xmas-lights {
  position: fixed; top: 0; left: 0; right: 0; height: 26px;
  display: flex; justify-content: space-around; align-items: flex-start;
  pointer-events: none; z-index: 9998; overflow: hidden;
}
.xmas-lights::before {            /* สายไฟ */
  content: ""; position: absolute; top: -10px; left: -2%; right: -2%; height: 20px;
  border-bottom: 2px solid #2b2b2b; border-radius: 0 0 50% 50% / 0 0 100% 100%;
  opacity: .55;
}
.xmas-lights i {
  position: relative; top: 8px; width: 9px; height: 14px; border-radius: 50%;
  animation: xmas-twinkle 1.6s ease-in-out infinite;
}
.xmas-lights i::before {          /* ขั้วหลอด */
  content: ""; position: absolute; top: -4px; left: 2px; width: 5px; height: 5px;
  background: #444; border-radius: 1px;
}
.xmas-lights i:nth-child(4n+1) { background: var(--xmas-red);   --glow: rgba(200,16,46,.8); }
.xmas-lights i:nth-child(4n+2) { background: var(--xmas-gold);  --glow: rgba(242,193,78,.85); animation-delay: .4s; }
.xmas-lights i:nth-child(4n+3) { background: #2fb36b;           --glow: rgba(47,179,107,.8);  animation-delay: .8s; }
.xmas-lights i:nth-child(4n+4) { background: #3b8bff;           --glow: rgba(59,139,255,.8);  animation-delay: 1.2s; }
@keyframes xmas-twinkle {
  0%, 100% { opacity: 1;  box-shadow: 0 2px 10px 2px var(--glow); }
  50%      { opacity: .35; box-shadow: none; }
}

/* ---------- หิมะตก ---------- */
.xmas-snow {
  position: fixed; inset: 0; pointer-events: none; z-index: 9997; overflow: hidden;
}
.xmas-snow span {
  position: absolute; top: -20px; color: var(--xmas-snow);
  text-shadow: 0 0 3px rgba(0, 0, 0, .25);
  animation: xmas-fall linear infinite;
  user-select: none;
}
@keyframes xmas-fall {
  0%   { transform: translate(0, -20px) rotate(0deg); }
  50%  { transform: translate(var(--drift, 30px), 50vh) rotate(180deg); }
  100% { transform: translate(0, 105vh) rotate(360deg); }
}

/* ---------- ปุ่มเปิด/ปิดธีม ---------- */
.xmas-toggle {
  position: fixed; right: 16px; bottom: 16px; z-index: 9999;
  width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--xmas-gold);
  background: var(--xmas-green); color: #fff; font-size: 22px; line-height: 1;
  cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  transition: transform .2s ease;
}
.xmas-toggle:hover { transform: scale(1.08) rotate(-8deg); }
html:not(.xmas) .xmas-toggle { background: #777; border-color: #bbb; filter: grayscale(1); }

/* ---------- ตกแต่งองค์ประกอบทั่วไป (opt-in แบบปลอดภัย) ---------- */
/* ใส่ class เหล่านี้ให้องค์ประกอบที่ต้องการ หรือให้ skill map selector ของเว็บมาแทน */
html.xmas .xmas-header,
html.xmas header.xmas-auto {
  background: linear-gradient(135deg, var(--xmas-red), var(--xmas-red-dark)) !important;
  color: #fff !important;
  position: relative;
}
html.xmas .xmas-header::after {   /* หิมะเกาะขอบล่าง */
  content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 10px;
  background: radial-gradient(circle at 8px 0, #fff 7px, transparent 8px) repeat-x;
  background-size: 18px 10px; pointer-events: none;
}
html.xmas .xmas-card {
  border-top: 4px solid var(--xmas-red) !important;
  box-shadow: 0 6px 18px rgba(20, 107, 58, .12);
}
html.xmas .xmas-btn {
  background: var(--xmas-green) !important; border-color: var(--xmas-green-dark) !important;
  color: #fff !important;
}
html.xmas .xmas-btn:hover { background: var(--xmas-green-dark) !important; }
html.xmas .xmas-accent { color: var(--xmas-red) !important; }
html.xmas .xmas-hat { position: relative; }
html.xmas .xmas-hat::before {     /* หมวกซานต้าบนมุมองค์ประกอบ */
  content: "🎅"; position: absolute; top: -14px; left: -10px; font-size: 22px;
  transform: rotate(-18deg); pointer-events: none;
}

/* ---------- โหมดมืด ---------- */
@media (prefers-color-scheme: dark) {
  html.xmas.xmas-respect-dark body { background-color: #0f1d17; }
}

/* ---------- ผู้ใช้ที่ตั้งค่าลดการเคลื่อนไหว ---------- */
@media (prefers-reduced-motion: reduce) {
  .xmas-snow { display: none; }
  .xmas-lights i { animation: none; }
}

@media print {
  .xmas-lights, .xmas-snow, .xmas-toggle { display: none !important; }
}
