/*
 * หน้าแรก
 *  1) .ov       ภาพรวม The CheemsRed: สำรับการ์ด 3 ใบ เลื่อนออกทีละใบตามการ scroll (ใช้ --p จาก scrub.js)
 *  2) .cx-reveal แอนิเมชันโมดูล Corehex ที่เล่นครั้งเดียวเมื่อเลื่อนมาถึง
 */
.ov { position: relative; height: 380svh; background: #101010; color: #f6efe6; }
.home-page .ov :is(h2, p, span, b, li, a, small) { font-family: "Anuphan", sans-serif; }
.ov-stage {
  position: sticky; top: 0; height: 100svh; min-height: 600px; overflow: hidden; box-sizing: border-box;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center;
  gap: clamp(24px, 5vw, 90px); padding: 96px clamp(22px, 7vw, 120px) 40px;
  background: radial-gradient(60% 55% at 22% 50%, rgba(255, 52, 59, .16), transparent 70%), #101010;
}

/* ---- สำรับการ์ด ---- */
.ov-deck {
  --o0: clamp(0, (var(--p, 0) - .30) / .08, 1);
  --o1: clamp(0, (var(--p, 0) - .63) / .08, 1);
  position: relative; width: min(100%, 430px); aspect-ratio: 4 / 5; justify-self: center;
}
.ov-card {
  --o: 0; --d: var(--i);
  position: absolute; inset: 0; border-radius: 26px; overflow: hidden; isolation: isolate;
  box-shadow: 0 30px 60px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .14);
  transform-origin: 20% 100%;
  transform:
    translate(calc(var(--o) * -34%), calc(var(--d) * -3.2% - var(--o) * 26%))
    scale(calc(1 - var(--d) * .045))
    rotate(calc(var(--o) * -16deg + var(--d) * 1.6deg));
  opacity: calc(1 - var(--o));
  z-index: calc(10 - var(--i));
}
.ov-card.c0 { --o: var(--o0); --d: 0; }
.ov-card.c1 { --o: var(--o1); --d: calc(1 - var(--o0)); }
.ov-card.c2 { --o: 0; --d: calc(2 - var(--o0) - var(--o1)); }
.ov-tag {
  position: absolute; left: 22px; top: 20px; margin: 0; padding: 7px 14px; border-radius: 99px;
  font-size: 12px; letter-spacing: .26em; font-weight: 800; color: #101010; background: #fff; z-index: 5;
}
.ov-sub { position: absolute; left: 24px; bottom: 22px; margin: 0; z-index: 5; font-size: 14px; letter-spacing: .06em; font-weight: 700; color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .45); }

/* การ์ด 1: เกม — ท้องฟ้า ตัวเมือง หมอก (ขยับตามสกรอลล์) */
.ov-card.c0 { background: #2d8cff; }
.ov-sky { position: absolute; inset: 0; background: linear-gradient(#1b7dff, #5db6ff 55%, #cfeeff); transform: translateY(calc(var(--p, 0) * -6%)); }
.ov-town { position: absolute; left: -30%; bottom: -4%; width: 160%; max-width: none; transform: translateX(calc(var(--p, 0) * -14%)) scale(1.02); }
.ov-fog { position: absolute; inset: auto 0 0 0; height: 55%; background: linear-gradient(to top, rgba(240, 250, 255, .75), transparent); z-index: 2; }
.ov-tl { position: absolute; left: 50%; top: 34%; width: 74%; translate: -50% 0; z-index: 3; filter: drop-shadow(0 4px 0 rgba(10, 58, 138, .35)); }

/* การ์ด 2: แบรนด์ — ป้ายโฆษณาในโลกเกม */
.ov-card.c1 { background: linear-gradient(#ff7a59, #ff3d6e 60%, #b21f5c); }
.ov-board {
  position: absolute; left: 12%; right: 12%; top: 24%; height: 34%; border-radius: 14px; background: #fff7ea; z-index: 3;
  display: grid; place-items: center; box-shadow: 0 14px 0 rgba(120, 20, 60, .35); transform: translateY(calc(var(--p, 0) * -10px)) rotate(-2deg);
}
.ov-board b { font-size: clamp(22px, 3.2vw, 34px); font-weight: 900; letter-spacing: .02em; color: #b21f5c; text-align: center; line-height: 1.1; padding: 0 12px; }
.ov-board b span { font-family: inherit; }
.ov-board i { position: absolute; right: 14px; top: 12px; width: 18px; height: 18px; border-radius: 50%; background: #ffcf3d; }
.ov-post { position: absolute; top: 56%; width: 14px; height: 24%; background: #7a1d46; z-index: 2; }
.ov-post.l { left: 26%; } .ov-post.r { right: 26%; }
.ov-hill { position: absolute; left: -10%; right: -10%; bottom: -14%; height: 36%; border-radius: 50% 50% 0 0; background: #8d1a4c; z-index: 4; }
.ov-conf { position: absolute; width: 14px; height: 14px; border-radius: 3px; z-index: 4; animation: ov-fall 5s linear infinite; }
.ov-conf.k1 { left: 14%; top: 12%; background: #ffcf3d; animation-delay: -1s; }
.ov-conf.k2 { left: 34%; top: 8%; background: #3fd0ff; border-radius: 50%; animation-delay: -3s; }
.ov-conf.k3 { left: 58%; top: 14%; background: #fff; animation-delay: -2s; }
.ov-conf.k4 { left: 78%; top: 6%; background: #7dffb1; animation-delay: -4s; }
.ov-conf.k5 { left: 88%; top: 16%; background: #ffcf3d; border-radius: 50%; animation-delay: -.5s; }
@keyframes ov-fall { 0% { transform: translateY(0) rotate(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(320px) rotate(260deg); opacity: 0; } }

/* การ์ด 3: ระบบ — Corehex */
.ov-card.c2 { background: radial-gradient(70% 60% at 50% 40%, #1d3a66, #0b1424); }
.ov-hexes {
  position: absolute; inset: 0; opacity: .5; z-index: 0;
  background:
    linear-gradient(60deg, transparent 47%, rgba(80, 170, 255, .22) 48% 52%, transparent 53%),
    linear-gradient(-60deg, transparent 47%, rgba(80, 170, 255, .22) 48% 52%, transparent 53%);
  background-size: 64px 111px; background-position: 0 calc(var(--p, 0) * 140px);
}
.ov-core { position: absolute; left: 50%; top: 42%; width: 40%; translate: -50% -50%; z-index: 3; filter: drop-shadow(0 0 28px rgba(60, 160, 255, .6)); transform: rotate(calc(var(--p, 0) * 120deg)); }
.ov-mm { position: absolute; width: 27%; z-index: 4; filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .5)); }
.ov-mm.m1 { left: 8%; top: 18%; transform: translateY(calc(var(--p, 0) * 12px)); }
.ov-mm.m2 { right: 8%; top: 22%; transform: translateY(calc(var(--p, 0) * -10px)); }
.ov-mm.m3 { left: 36%; top: 56%; transform: translateY(calc(var(--p, 0) * 8px)); }

/* ---- ข้อความ ---- */
.ov-copy { position: relative; min-height: 420px; display: grid; align-content: center; }
.ov-eyebrow { margin: 0 0 22px; font-size: 12px; letter-spacing: .3em; color: #ff5a60; }
.ov-chaps { position: relative; height: clamp(250px, 38svh, 340px); }
.ov-chap {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-start;
  --in: clamp(0, (var(--p, 0) - var(--a)) / .06, 1);
  --out: clamp(0, (var(--p, 0) - var(--b) + .06) / .06, 1);
  opacity: calc(var(--in) * (1 - var(--out) * (1 - var(--last))));
  pointer-events: none;
}
.ov-chap a { pointer-events: auto; }
.ov-n { margin: 0 0 12px; font-size: 13px; letter-spacing: .24em; color: #ffcf3d; }
.ov-chap h2 { margin: 0 0 16px; font-size: clamp(30px, 3.8vw, 56px); line-height: 1.14; font-weight: 800; letter-spacing: -.01em; }
.ov-chap h2 span { font-family: inherit !important; }
.ov-mask { display: block; overflow: hidden; padding: .08em 0; }
.ov-line { display: block; transform: translateY(calc((1 - var(--in)) * 105% - var(--out) * 105% * (1 - var(--last)))); }
.ov-p { margin: 0 0 22px; max-width: 30em; font-size: clamp(15px, 1.35vw, 18px); line-height: 1.8; color: #cfc6bd; transform: translateY(calc((1 - var(--in)) * 20px)); }
.ov-chap .text-link { align-self: flex-start; }
.ov-rail { list-style: none; margin: 18px 0 0; padding: 0; display: flex; gap: 8px; }
.ov-rail li {
  flex: 1; padding-top: 10px; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: rgba(255, 255, 255, .42);
  border-top: 2px solid rgba(255, 255, 255, .16); position: relative;
  --on: clamp(0, (var(--p, 0) - var(--a)) / .08, 1);
}
.ov-rail li::before { content: ""; position: absolute; left: 0; top: -2px; height: 2px; width: calc(var(--on) * 100%); background: #ff343b; }
.ov-rail li span { font-family: inherit; }
.ov-founded { margin: 18px 0 0; font-size: 13px; color: #a89f95; }
.ov-founded a { color: #ffcf3d; text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 900px) {
  .ov { height: 360svh; }
  .ov-stage { grid-template-columns: 1fr; grid-template-rows: auto 1fr; gap: 12px; padding: 84px 22px 24px; align-content: start; }
  .ov-deck { width: min(62%, 40svh * .8); max-height: 40svh; }
  .ov-copy { min-height: 0; align-content: start; }
  .ov-eyebrow { margin-bottom: 10px; font-size: 11px; }
  .ov-chaps { height: 190px; }
  .ov-chap h2 { font-size: 26px; margin-bottom: 8px; }
  .ov-p { font-size: 14px; line-height: 1.6; margin-bottom: 12px; }
  .ov-rail { margin-top: 8px; }
  .ov-founded { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .ov { height: auto; }
  .ov-stage { position: relative; height: auto; display: block; }
  .ov-deck { margin: 0 auto 28px; }
  .ov-chap { position: relative; opacity: 1; margin-bottom: 26px; }
  .ov-chaps { height: auto; }
  .ov-line, .ov-p { transform: none; }
  .ov-conf { animation: none; }
}

/* ================= Corehex: เล่นครั้งเดียว ================= */
.cx-reveal {
  position: relative; width: 100%; max-width: 480px; aspect-ratio: 400 / 320; align-self: center; justify-self: center; margin: 12px 24px 12px 0; overflow: visible;
}
.cx-reveal > * { position: absolute; }
.cxr-hex, .cxr-links { inset: 0; width: 100%; height: 100%; overflow: visible; }
.cxr-hex .hx { fill: rgba(22, 126, 211, .07); stroke: #3d9be0; stroke-width: 1.4; opacity: 0; transform-box: fill-box; transform-origin: center; }
.cxr-links path { fill: none; stroke: #167ed3; stroke-width: 2; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.cxr-core { left: 50%; top: 50%; width: 21%; translate: -50% -50%; opacity: 0; z-index: 3; filter: drop-shadow(0 8px 14px rgba(19, 68, 102, .35)); }
.cxr-ring { left: 50%; top: 50%; width: 30%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; border: 2px solid #3d9be0; opacity: 0; }
.cxr-t { --x: 24%; --y: 31%; left: var(--x); top: var(--y); width: 24%; translate: -50% -50%; opacity: 0; z-index: 4; filter: drop-shadow(0 12px 12px rgba(19, 68, 102, .28)); }
.cxr-t.t2 { --x: 76%; --y: 31%; }
.cxr-t.t3 { --x: 50%; --y: 82.5%; }
.cxr-sweep { inset: -10% auto -10% -30%; width: 22%; transform: skewX(-18deg); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .9), transparent); opacity: 0; z-index: 6; mix-blend-mode: soft-light; }

.cx-reveal.is-in .hx { animation: cxr-hex .7s cubic-bezier(.2, .9, .3, 1.2) both; animation-delay: calc(var(--k) * .09s); }
.cx-reveal.is-in .cxr-core { animation: cxr-core .9s cubic-bezier(.2, 1.3, .4, 1) .15s both; }
.cx-reveal.is-in .cxr-ring.r1 { animation: cxr-ring 1.1s ease-out .55s both; }
.cx-reveal.is-in .cxr-ring.r2 { animation: cxr-ring 1.1s ease-out .95s both; }
.cx-reveal.is-in .cxr-links path { animation: cxr-draw .6s ease-out both; }
.cx-reveal.is-in .cxr-links path:nth-child(1) { animation-delay: .75s; }
.cx-reveal.is-in .cxr-links path:nth-child(2) { animation-delay: .9s; }
.cx-reveal.is-in .cxr-links path:nth-child(3) { animation-delay: 1.05s; }
.cx-reveal.is-in .cxr-t { animation: cxr-dock .85s cubic-bezier(.2, 1.25, .35, 1) both; }
.cx-reveal.is-in .cxr-t.t1 { animation-delay: .85s; }
.cx-reveal.is-in .cxr-t.t2 { animation-delay: 1s; }
.cx-reveal.is-in .cxr-t.t3 { animation-delay: 1.15s; }
.cx-reveal.is-in .cxr-sweep { animation: cxr-sweep 1.1s ease-in-out 1.9s both; }
@keyframes cxr-hex { from { opacity: 0; transform: scale(.4) rotate(-30deg); } to { opacity: 1; transform: none; } }
@keyframes cxr-core { from { opacity: 0; transform: scale(.2) rotate(-200deg); } to { opacity: 1; transform: none; } }
@keyframes cxr-ring { 0% { opacity: .9; transform: scale(.3); } 100% { opacity: 0; transform: scale(3.4); } }
@keyframes cxr-draw { to { stroke-dashoffset: 0; } }
@keyframes cxr-dock { from { left: 50%; top: 50%; opacity: 0; scale: .2; } 18% { opacity: 1; } to { left: var(--x); top: var(--y); opacity: 1; scale: 1; } }
@keyframes cxr-sweep { 0% { left: -30%; opacity: 0; } 20% { opacity: 1; } 100% { left: 120%; opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .cx-reveal .hx, .cx-reveal .cxr-core, .cx-reveal .cxr-t { opacity: 1; }
  .cx-reveal .cxr-links path { stroke-dashoffset: 0; }
  .cx-reveal.is-in * { animation: none !important; }
}
@media (max-width: 700px) { .cx-reveal { margin: 8px auto 20px; max-width: 360px; } }

/* รูปที่มี width/height attribute ต้องให้ความสูงอัตโนมัติ ไม่งั้นภาพยืด */
.ov-card img, .cx-reveal img { height: auto; }
@media (max-width: 900px) {
  .ov-deck { width: calc(34svh * .8); max-height: 34svh; }
  .ov-eyebrow { letter-spacing: .14em; margin-bottom: 8px; }
  .ov-chaps { height: 236px; }
  .ov-p { font-size: 13px; line-height: 1.55; margin-bottom: 10px; }
  .ov-chap h2 { font-size: 24px; margin-bottom: 6px; }
  .ov-n { margin-bottom: 6px; }
  .ov-sub { font-size: 11px; left: 14px; bottom: 14px; right: 10px; }
  .ov-tag { left: 14px; top: 14px; font-size: 10px; padding: 5px 10px; }
}
@media (max-width:900px){.ov-chaps{height:262px}}
