/* ==========================================================================
   หน้าแรก — ชั้นเอฟเฟกต์ "ว้าว" v1.0 (4 ธ.ค. 2569)
   ทำงานเมื่อ <html> มีคลาส fx (ใส่โดย assets/js/home-fx.js)
   ผู้ใช้ที่ตั้งค่า "ลดการเคลื่อนไหว" ในเครื่อง จะไม่เห็นเอฟเฟกต์เหล่านี้
   ถ้าต้องการปิดทั้งหมด: ลบ 2 บรรทัดที่เรียก home-fx.css / home-fx.js ใน index.html
   ========================================================================== */

/* ---------- แถบความคืบหน้าการเลื่อนหน้า ---------- */
.fx-progress { position: fixed; left: 0; top: 0; z-index: 3000; height: 3px; width: 100%; transform-origin: 0 50%; transform: scaleX(0); pointer-events: none;
  background: linear-gradient(90deg, #10b26a, var(--gold) 55%, #fff3c4); box-shadow: 0 0 12px rgba(212, 175, 55, .8); }

/* ---------- พักแอนิเมชันหัวเว็บไว้ระหว่างประกาศไว้อาลัย แล้วเล่นเมื่อกดเข้าเว็บ ---------- */
.fx-hold .h-hero *, .fx-hold .h-hero *::before, .fx-hold .h-hero *::after { animation-play-state: paused !important; }

/* ==========================================================================
   HERO
   ========================================================================== */
.fx .h-hero-media { will-change: transform; }
.fx .h-hero-in, .fx .h-hero .h-stats { will-change: transform, opacity; }
.fx-dust { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; }
/* ลำแสงทองกวาดผ่านหัวเว็บ */
.fx .h-hero::after { content: ""; position: absolute; inset: -20% -60%; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 42%, rgba(255, 236, 170, .13) 48%, rgba(255, 255, 255, .22) 50%, rgba(255, 236, 170, .13) 52%, transparent 58%);
  transform: translateX(-60%); animation: fxBeam 9s ease-in-out 1.4s infinite; }
@keyframes fxBeam { 0% { transform: translateX(-60%); } 35%, 100% { transform: translateX(60%); } }
/* ลูกแก้วและป้ายลอยขยับตามเมาส์ */
.fx .h-orb { translate: calc(var(--px, 0) * -60px) calc(var(--py, 0) * -40px); transition: translate .6s var(--ease); }
.fx .h-float { translate: calc(var(--px, 0) * 22px) calc(var(--py, 0) * 18px); transition: translate .4s var(--ease); }
.fx .h-hero-grid { translate: calc(var(--px, 0) * 14px) calc(var(--py, 0) * 10px); transition: translate .6s var(--ease); }

/* ประกายดาวรอบชื่อโรงเรียน */
.fx .h-hero h1 .h-gold { position: relative; }
.fx-spark { position: absolute; width: 1em; height: 1em; pointer-events: none; color: #fff6cf; font-size: var(--s, .32em); left: var(--x); top: var(--y);
  -webkit-text-fill-color: currentColor; filter: drop-shadow(0 0 6px rgba(255, 220, 120, .95)); opacity: 0; animation: fxTwinkle var(--t, 2.8s) ease-in-out var(--dl, 0s) infinite; }
.fx-spark::before { content: "✦"; display: block; line-height: 1; }
@keyframes fxTwinkle { 0%, 100% { opacity: 0; transform: scale(.2) rotate(0deg); } 45% { opacity: 1; transform: scale(1) rotate(90deg); } 60% { opacity: .9; } }

/* คำบรรยายค่อย ๆ ขึ้นทีละวลี */
.fx .h-lead.fx-split { opacity: 1; animation: none; transform: none; }
.fx-w { display: inline-block; opacity: 0; transform: translateY(14px); filter: blur(6px); animation: fxWord .8s var(--ease) forwards; animation-delay: calc(.45s + var(--i) * .07s); }
@keyframes fxWord { to { opacity: 1; transform: none; filter: blur(0); } }

/* ปุ่มทองมีแสงวิ่ง */
.fx .h-btn-gold { position: relative; overflow: hidden; isolation: isolate; }
.fx .h-btn-gold::after { content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, .75), transparent); transform: skewX(-20deg); animation: fxBtnShine 4.2s ease-in-out 2s infinite; }
@keyframes fxBtnShine { 0% { left: -60%; } 30%, 100% { left: 130%; } }

/* การ์ดจดหมายข่าวในหัวเว็บ: ขอบทองหมุน */
.fx .h-tilt::before { content: ""; position: absolute; inset: -2px; z-index: -1; border-radius: 28px; padding: 2px; pointer-events: none;
  background: conic-gradient(from var(--fxa, 0deg), transparent 0 60%, rgba(243, 215, 116, .95) 75%, #fff 80%, rgba(243, 215, 116, .95) 85%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: fxSpin 5s linear infinite; }
@property --fxa { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes fxSpin { to { --fxa: 360deg; } }

/* ตัวเลขสถิติ: เด้งและเรืองแสงเมื่อนับเสร็จ */
.fx .h-stat { position: relative; transition: background .4s; }
.fx .h-stat:hover { background: rgba(255, 255, 255, .06); }
.fx .h-stat dd > span { display: inline-block; }
.fx .h-stat dd > span.fx-pop { animation: fxPop .7s var(--ease); }
@keyframes fxPop { 40% { transform: scale(1.18); color: var(--gold-2); text-shadow: 0 0 24px rgba(243, 215, 116, .9); } }
.fx .h-stat::after { content: ""; position: absolute; left: 20px; right: 20px; bottom: 0; height: 2px; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, var(--gold), transparent); transition: transform 1.2s var(--ease) .2s; }
.fx .h-stat.fx-on::after { transform: scaleX(1); }

/* ปุ่มเลื่อนลง */
.fx-down { position: absolute; left: 50%; bottom: 128px; z-index: 2; translate: -50% 0; width: 28px; height: 46px; border-radius: 16px; border: 2px solid rgba(255, 255, 255, .5); display: none; opacity: 0; animation: hRise 1s var(--ease) 1.4s forwards; }
.fx-down::after { content: ""; position: absolute; left: 50%; top: 9px; width: 4px; height: 9px; margin-left: -2px; border-radius: 2px; background: var(--gold-2); animation: hWheel 1.8s infinite; }
@media (min-width: 1200px) and (min-height: 820px) { .fx .fx-down { display: block; } }

/* ==========================================================================
   หัวข้อแต่ละส่วน
   ========================================================================== */
.fx .h-title em { background-image: linear-gradient(110deg, var(--em) 0%, var(--em-400) 25%, var(--gold) 45%, #f9e7a1 50%, var(--gold) 55%, var(--em-400) 75%, var(--em) 100%); background-size: 250% auto; animation: fxTitleShine 7s linear infinite; }
.fx .h-awards .h-title em { background-image: linear-gradient(110deg, var(--gold) 0%, #fff3c4 25%, #f9e7a1 45%, #fff 50%, #f9e7a1 55%, #fff3c4 75%, var(--gold) 100%); }
@keyframes fxTitleShine { to { background-position: -250% center; } }
.fx .h-title::after { content: ""; display: block; width: 0; height: 4px; margin: 16px auto 0; border-radius: 4px; background: linear-gradient(90deg, var(--em-400), var(--gold), #f9e7a1); box-shadow: 0 0 14px rgba(212, 175, 55, .55); transition: width 1.1s var(--ease) .35s; }
.fx .h-head.is-left .h-title::after, .fx .h-guide .h-title::after { margin-left: 0; }
.fx .is-in .h-title::after, .fx .is-in.h-title::after { width: 88px; }
.fx .h-eyebrow i { display: inline-block; transition: transform .9s var(--ease) .2s; transform: rotate(-200deg) scale(.4); }
.fx .is-in .h-eyebrow i, .fx .h-eyebrow.is-in i { transform: none; }

/* ==========================================================================
   ค่อย ๆ ปรากฏ (ต่อยอดจาก .rv เดิม) — แต่ละแบบตามชนิดเนื้อหา
   ========================================================================== */
/* fx-anim ใส่ให้เฉพาะช่วงที่กำลังปรากฏ แล้วถอดออก เพื่อให้เอฟเฟกต์ตอนชี้เมาส์ของการ์ดยังไวเหมือนเดิม */
.fx .rv.fx-anim { transition: opacity .9s var(--ease), transform 1s var(--ease), filter .9s var(--ease), clip-path 1.1s var(--ease) !important; transition-delay: var(--d, 0s) !important; }
.fx .rv:not(.is-in) { filter: blur(5px); }
.fx .h-head.rv:not(.is-in) { transform: translateY(34px) scale(.97); }
.fx .h-tile.rv:not(.is-in), .fx .h-dept.rv:not(.is-in), .fx .h-svc.rv:not(.is-in), .fx .h-craft.rv:not(.is-in), .fx .h-exam-grid .rv:not(.is-in) { transform: translateY(46px) scale(.92); }
.fx .h-prog.rv:not(.is-in), .fx .h-award.rv:not(.is-in) { transform: perspective(900px) translateY(60px) rotateX(22deg); transform-origin: 50% 100%; }
.fx .h-entry.rv:nth-child(odd):not(.is-in), .fx .h-dir-photo.rv:not(.is-in), .fx .h-feature.rv:not(.is-in) { transform: translateX(-60px); }
.fx .h-entry.rv:nth-child(even):not(.is-in), .fx .h-latest.rv:not(.is-in), .fx .h-dir > .rv:not(.h-dir-photo):not(.is-in) { transform: translateX(60px); }
.fx .h-tf.rv { clip-path: inset(0 0 0 0 round 22px); }
.fx .h-tf.rv:not(.is-in) { transform: scale(1.04); filter: none; clip-path: inset(100% 0 0 0 round 22px); }
.fx .h-guide.rv:not(.is-in), .fx .h-mom.rv:not(.is-in), .fx .h-foot-cta.rv:not(.is-in) { transform: translateY(40px) scale(.96); }
/* ห้องทำงานครู (เดิมไม่มี .rv) */
.fx .tp-inner.fx-rv { transition: opacity 1s var(--ease), transform 1s var(--ease); }
.fx .tp-inner.fx-rv:not(.is-in) { opacity: 0; transform: translateY(50px) scale(.97); }
.fx .tp-inner.fx-rv .tp-card, .fx .tp-inner.fx-rv .tp-link { transition: opacity .9s var(--ease) .3s, transform .9s var(--ease) .3s; }
.fx .tp-inner.fx-rv .tp-card + .tp-card, .fx .tp-inner.fx-rv .tp-link + .tp-link { transition-delay: .45s; }
.fx .tp-inner.fx-rv:not(.is-in) .tp-card, .fx .tp-inner.fx-rv:not(.is-in) .tp-link { opacity: 0; transform: translateY(40px); }

/* ==========================================================================
   การ์ด: เอียงสามมิติ + แสงวาบ (เดสก์ท็อป) · แสงวาบอย่างเดียว (มือถือ)
   ========================================================================== */
.fx .h-dept { position: relative; overflow: hidden; }
.fx .h-exam-fig { position: relative; }
.fx-shine { position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit; overflow: hidden; }
.fx-shine::before { content: ""; position: absolute; top: -50%; bottom: -50%; left: -75%; width: 50%; transform: skewX(-22deg) translateX(0);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent); opacity: 0; }
a:hover > .fx-shine::before, article:hover > .fx-shine::before, figure:hover > .fx-shine::before, .fx-shine.go::before { opacity: 1; transform: skewX(-22deg) translateX(520%); transition: transform .9s var(--ease), opacity .2s; }
.fx-glare { position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit; opacity: 0; transition: opacity .3s;
  background: radial-gradient(380px circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, .28), transparent 50%); mix-blend-mode: soft-light; }
.fx-tilting > .fx-glare { opacity: 1; }
.fx-tilting { z-index: 2; }

/* ไอคอนบนการ์ดลอยเบา ๆ */
.fx .h-prog-ic, .fx .h-dept > i { animation: fxFloat 4.5s ease-in-out infinite; }
.fx .h-prog:nth-child(2) .h-prog-ic, .fx .h-dept:nth-child(2) > i { animation-delay: -1.1s; }
.fx .h-prog:nth-child(3) .h-prog-ic, .fx .h-dept:nth-child(3) > i { animation-delay: -2.2s; }
.fx .h-prog:nth-child(4) .h-prog-ic, .fx .h-dept:nth-child(4) > i { animation-delay: -3.3s; }
.fx .h-dept:nth-child(5) > i { animation-delay: -4s; }
@keyframes fxFloat { 50% { transform: translateY(-6px); } }
.fx .h-prog:hover .h-prog-code { transform: translateX(-14px) scale(1.08); }

/* ห้องทำงานครู: ขอบเรืองแสงหมุนรอบการ์ด + เลขปีลอย */
.fx .tp-card::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; padding: 2px; pointer-events: none; opacity: .0; transition: opacity .4s;
  background: conic-gradient(from var(--fxa, 0deg), transparent 0 55%, var(--gold) 70%, #fff6cf 75%, var(--gold) 80%, transparent 95%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: fxSpin 4s linear infinite; }
.fx .tp-card:hover::after, .fx .tp-new::after { opacity: 1; }
.fx .tp-card:hover .tp-year { transform: translate(-10px, -8px) scale(1.06); }
.fx .tp-cta { position: relative; overflow: hidden; }

/* ทำเนียบความภูมิใจ: ดาวระยิบพื้นหลัง + เหรียญแกว่ง */
.fx .h-awards::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background-image: radial-gradient(1.6px 1.6px at 12% 18%, #fff6cf, transparent), radial-gradient(1.4px 1.4px at 28% 72%, #fff, transparent), radial-gradient(1.8px 1.8px at 46% 34%, #f3d774, transparent),
    radial-gradient(1.3px 1.3px at 63% 82%, #fff, transparent), radial-gradient(1.7px 1.7px at 78% 22%, #fff6cf, transparent), radial-gradient(1.4px 1.4px at 91% 61%, #f3d774, transparent),
    radial-gradient(1.2px 1.2px at 6% 88%, #fff, transparent), radial-gradient(1.5px 1.5px at 55% 8%, #fff, transparent);
  animation: fxStars 4s ease-in-out infinite alternate; }
@keyframes fxStars { from { opacity: .25; } to { opacity: .75; } }
.fx .h-medal { animation: fxSwing 3.2s ease-in-out infinite; transform-origin: 50% 0; }
@keyframes fxSwing { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }

/* โลโก้โรงเรียนปลายทาง: ลอยสลับกัน */
.fx .h-logos img { animation: fxFloat 4s ease-in-out infinite; transition: transform .3s, filter .3s; }
.fx .h-logos img:nth-of-type(2n) { animation-delay: -2s; }
.fx .h-logos img:hover { filter: drop-shadow(0 8px 14px rgba(212, 175, 55, .55)); }

/* ตัวเลขแนะแนว */
.fx .h-guide-stats > div { transition: transform .35s var(--ease), box-shadow .35s; }
.fx .h-guide-stats > div:hover { transform: translateY(-6px) scale(1.03); box-shadow: 0 18px 30px -18px rgba(184, 134, 11, .7); }

/* ภาพผู้อำนวยการ: วงแหวนทองหมุน */
.fx .h-dir-photo::after { content: ""; position: absolute; inset: -34px; border-radius: 50%; pointer-events: none; z-index: -1;
  background: conic-gradient(from var(--fxa, 0deg), transparent 0 70%, rgba(212, 175, 55, .75) 85%, transparent 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px)); mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  animation: fxSpin 7s linear infinite; }
.fx .h-dir-photo { isolation: isolate; }

/* ==========================================================================
   ปุ่ม: ระลอกคลื่นเมื่อแตะ
   ========================================================================== */
.fx-ripple { position: absolute; border-radius: 50%; pointer-events: none; transform: scale(0); opacity: .45; background: currentColor; animation: fxRipple .65s ease-out forwards; z-index: 4; }
@keyframes fxRipple { to { transform: scale(1); opacity: 0; } }
.fx .h-btn, .fx .h-exam-go, .fx .tp-cta { position: relative; overflow: hidden; }

/* ==========================================================================
   แสงตามเมาส์บนพื้นเข้ม (เดสก์ท็อป)
   ========================================================================== */
.fx-aura { position: fixed; left: 0; top: 0; z-index: 1; width: 560px; height: 560px; margin: -280px 0 0 -280px; border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity .5s;
  background: radial-gradient(circle, rgba(243, 215, 116, .16) 0%, rgba(16, 178, 106, .08) 35%, transparent 65%); mix-blend-mode: screen; will-change: transform; }
.fx-aura.on { opacity: 1; }

/* ==========================================================================
   ท้ายเว็บ: เส้นทองไหล
   ========================================================================== */
.fx .h-foot::before { background-size: 200% 100%; animation: fxFlow 6s linear infinite; background-image: linear-gradient(90deg, var(--em), var(--gold), #fff3c4, var(--gold), var(--em)); }
@keyframes fxFlow { to { background-position: -200% 0; } }
.fx .h-social a { transition: transform .3s var(--ease); }
.fx .h-social a:hover { transform: translateY(-4px) rotate(-8deg); }

/* ==========================================================================
   มือถือ / เครื่องที่ไม่มีเมาส์
   ========================================================================== */
@media (max-width: 767px) {
  .fx .rv:not(.is-in) { filter: none; }
  .fx .h-entry.rv:nth-child(odd):not(.is-in), .fx .h-dir-photo.rv:not(.is-in), .fx .h-feature.rv:not(.is-in), .fx .h-entry.rv:nth-child(even):not(.is-in), .fx .h-latest.rv:not(.is-in), .fx .h-dir > .rv:not(.h-dir-photo):not(.is-in) { transform: translateY(40px); }
  .fx .h-dir-photo::after { inset: -22px; }
  .fx-down { display: none !important; }
}
/* ปุ่มเปิด/ปิดเอฟเฟกต์ท้ายหน้า */
.fx-toggle { display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(212, 175, 55, .35); background: rgba(255, 255, 255, .05); color: rgba(236, 253, 245, .8); font: 500 .82rem 'Sarabun', sans-serif; padding: 5px 12px; border-radius: 999px; cursor: pointer; transition: background .25s, border-color .25s; }
.fx-toggle:hover { background: rgba(212, 175, 55, .16); border-color: var(--gold); }
.fx-toggle i { color: var(--gold-2); }
.fx-toggle b { color: #fff; font-weight: 600; }
@media print { .fx-progress, .fx-dust, .fx-aura { display: none !important; } }
