/* Dat.Game hub — a scrolling showcase. Colours come from the Dat.Game logo (cream rabbit, black hoodie,
   yellow letters, orange dot). Each section names its own colours (--sec-bg / --sec-fg, set in build.js);
   with JavaScript the sections turn see-through and the body fades between those colours (static/site.js). */
@font-face {
	font-family: "Noto Sans Thai";
	src: url("/fonts/NotoSansThai.ttf") format("truetype");
	font-weight: 100 900;
	font-display: swap;
}
@font-face {
	font-family: "Trirong";
	src: url("/fonts/Trirong-Bold.ttf") format("truetype");
	font-weight: 700;
	font-display: swap;
}

:root {
	--cream: #fff6e0;
	--ink: #1c1a19;
	--yellow: #ffc93c;
	--orange: #ff6a1f;
	--top-fg: var(--ink);
	--pad: clamp(20px, 5vw, 80px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: clip; }
body {
	margin: 0;
	overflow-x: hidden;
	background: var(--yellow);
	color: var(--ink);
	font-family: "Noto Sans Thai", system-ui, sans-serif;
	font-size: 18px;
	line-height: 1.7;
	transition: background-color 0.7s ease;
}
a { color: inherit; }
a:focus-visible { outline: 3px solid var(--orange); outline-offset: 4px; border-radius: 6px; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

[data-bg] { background: var(--sec-bg); color: var(--sec-fg); }
.js [data-bg] { background: transparent; }

/* ---------- top bar ---------- */
.top { position: absolute; inset: 0 0 auto 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; padding: 16px var(--pad); color: var(--top-fg); transition: color 0.5s; pointer-events: none; }
.top a { pointer-events: auto; text-decoration: none; }
.brand { font-weight: 900; font-size: 1.25rem; letter-spacing: -0.01em; }
.lang { font-weight: 700; font-size: 0.9rem; padding: 3px 14px; border: 2px solid currentColor; border-radius: 999px; transition: background-color 0.2s, color 0.2s; }
.lang:hover { background: var(--top-fg); color: var(--yellow); }

/* ---------- opening curtain ---------- */
.loader { display: none; }
.js .loader { display: grid; place-items: center; position: fixed; inset: 0; z-index: 30; background: var(--ink); clip-path: circle(150% at 50% 50%); transition: clip-path 0.8s cubic-bezier(0.7, 0, 0.2, 1); animation: bail 0s 4s forwards; }
.loader img { width: min(220px, 50vw); animation: thump 0.55s ease-in-out infinite alternate; }
.js.ready .loader { clip-path: circle(0% at 50% 50%); pointer-events: none; }
.js.skip .loader { display: none; }
@keyframes thump { from { transform: scale(0.92) rotate(-3deg); } to { transform: scale(1.04) rotate(3deg); } }
@keyframes bail { to { visibility: hidden; } }

/* ---------- hero ---------- */
.hero { position: relative; min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 90px var(--pad) 110px; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(28, 26, 25, 0.16) 2px, transparent 2.5px); background-size: 22px 22px; -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 10%, transparent 72%); mask-image: radial-gradient(ellipse at 50% 40%, #000 10%, transparent 72%); pointer-events: none; }
.hero > * { position: relative; }
.hero-word { position: absolute; left: 50%; top: 11svh; margin-left: -50vw; width: 100vw; display: flex; justify-content: center; gap: 0.12em; font-size: 15.5vw; font-weight: 900; line-height: 0.85; letter-spacing: -0.03em; white-space: nowrap; color: transparent; -webkit-text-stroke: clamp(2px, 0.35vw, 5px) var(--ink); pointer-events: none; user-select: none; }
.hero-word span:last-child { color: var(--cream); }
.hero-logo { width: min(48svh, 74vw); margin-top: 4svh; }
.logo { width: 100%; filter: drop-shadow(0 18px 0 rgba(28, 26, 25, 0.16)); animation: bob 3.4s ease-in-out infinite; }
.hero h1 { font-size: clamp(1.9rem, 5.4vw, 4.2rem); font-weight: 900; line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; margin-top: -1svh; }
.intro { max-width: 30em; margin-top: 12px; font-weight: 600; text-wrap: pretty; }
.cue { position: absolute; left: 50%; bottom: 46px; translate: -50% 0; display: inline-flex; flex-direction: column; align-items: center; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.22em; text-transform: uppercase; text-decoration: none; }
.cue-arrow { font-size: 1.4rem; line-height: 1; animation: drop 1.3s ease-in-out infinite; }
.spark { position: absolute; font-weight: 900; line-height: 1; color: var(--cream); -webkit-text-stroke: 2px var(--ink); pointer-events: none; }
.spark-1 { left: 9%; top: 30%; font-size: clamp(40px, 7vw, 96px); }
.spark-2 { right: 8%; top: 56%; font-size: clamp(32px, 5vw, 72px); color: var(--orange); }
.spark-3 { right: 16%; top: 22%; font-size: clamp(36px, 6vw, 84px); color: var(--ink); -webkit-text-stroke: 0; }
.spark-4 { left: 7%; top: 80%; font-size: clamp(30px, 4.5vw, 64px); color: transparent; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(-12px) rotate(1.5deg); } }
@keyframes drop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
@keyframes pop { 0% { transform: scale(0) rotate(-30deg); } 100% { transform: scale(1) rotate(0deg); } }

/* hero entrance, once the curtain opens */
.js .hero-word, .js .hero h1, .js .hero .intro, .js .hero .cue, .js .spark { opacity: 0; transition: opacity 0.7s ease, transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1), scale 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); }
.js .hero-word { scale: 1.25; }
.js .hero h1, .js .hero .intro { transform: translateY(34px); }
.js:not(.ready) .logo { animation: none; transform: scale(0); }
.js.ready .logo { animation: pop 0.8s cubic-bezier(0.3, 1.5, 0.5, 1) 0.15s both, bob 3.4s ease-in-out 0.95s infinite; }
.js.ready .hero-word { opacity: 1; scale: 1; transition-delay: 0.1s; }
.js.ready .spark { opacity: 1; transition-delay: 0.5s; }
.js.ready .hero h1 { opacity: 1; transform: none; transition-delay: 0.45s; }
.js.ready .hero .intro { opacity: 1; transform: none; transition-delay: 0.6s; }
.js.ready .hero .cue { opacity: 1; transition-delay: 1s; }

/* ---------- running tape ---------- */
.tape { position: relative; z-index: 2; width: 108vw; max-width: none; margin: -34px 0 -34px -4vw; padding: 10px 0; background: var(--ink); color: var(--yellow); rotate: -2deg; overflow: hidden; box-shadow: 0 8px 0 rgba(28, 26, 25, 0.2); }
.tape-run { display: flex; gap: 0.9em; width: max-content; font-size: clamp(1.1rem, 2.6vw, 2rem); font-weight: 900; white-space: nowrap; text-transform: uppercase; transform: translateX(var(--shift, 0px)); animation: run 40s linear infinite; }
.tape-run span:nth-child(4n + 3) { color: var(--cream); }
@keyframes run { to { translate: -50% 0; } }

/* ---------- game stages ---------- */
.stage { position: relative; min-height: 100svh; display: grid; grid-template-columns: 1.3fr 1fr; align-items: center; gap: clamp(28px, 5vw, 90px); padding: 140px var(--pad) 120px; overflow: hidden; }
.stage:nth-of-type(even) .stage-art { order: 2; }
.stage:nth-of-type(even) { grid-template-columns: 1fr 1.3fr; }
.stage-no { position: absolute; right: 2vw; top: 50%; translate: 0 calc(-50% + var(--s, 0) * 90px); font-size: 44vw; font-weight: 900; line-height: 0.8; letter-spacing: -0.05em; color: transparent; -webkit-text-stroke: 3px currentColor; opacity: 0.2; pointer-events: none; user-select: none; }
.stage:nth-of-type(even) .stage-no { right: auto; left: 2vw; }
.stage-art { position: relative; display: block; border: 4px solid var(--ink); border-radius: clamp(16px, 2.4vw, 32px); overflow: hidden; box-shadow: clamp(8px, 1.2vw, 18px) clamp(8px, 1.2vw, 18px) 0 var(--yellow); transform: perspective(1200px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) rotate(calc((1 - var(--p, 1)) * -8deg)) scale(calc(0.74 + 0.26 * var(--p, 1))); transition: transform 0.2s ease-out, box-shadow 0.2s; will-change: transform; }
.stage-art img { width: 100%; }
a.stage-art:hover { box-shadow: clamp(12px, 1.8vw, 26px) clamp(12px, 1.8vw, 26px) 0 var(--orange); }
.stage-text { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.kicker { font-size: 0.85rem; font-weight: 800; letter-spacing: 0.24em; text-transform: uppercase; color: var(--yellow); }
.stage h3 { font-size: clamp(3rem, 7.4vw, 7rem); font-weight: 900; line-height: 1; letter-spacing: -0.02em; }
.stage-pikbaan h3 { font-size: clamp(2.6rem, 6vw, 5.6rem); line-height: 1.15; }
.stage-littlewat h3 { font-family: "Trirong", "Noto Sans Thai", serif; font-weight: 700; letter-spacing: 0; }
.stage-line { font-size: clamp(1.2rem, 2vw, 1.6rem); font-weight: 800; }
.stage-body { max-width: 28em; opacity: 0.85; text-wrap: pretty; }
.tag { font-size: 0.9rem; font-weight: 700; padding: 2px 14px; border: 2px solid currentColor; border-radius: 999px; }
.btn { display: inline-block; margin-top: 10px; padding: 12px 26px; font-size: 1.1rem; font-weight: 900; text-decoration: none; color: var(--ink); background: var(--yellow); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 5px 5px 0 var(--sec-fg, var(--ink)); transition: transform 0.15s ease-out, box-shadow 0.15s, background-color 0.15s; }
.btn:hover { background: var(--cream); box-shadow: 8px 8px 0 var(--orange); }
.btn span { display: inline-block; transition: transform 0.2s; }
.btn:hover span { transform: translateX(6px); }

.mystery { aspect-ratio: 1200 / 630; display: grid; place-items: center; background: repeating-linear-gradient(-45deg, rgba(255, 246, 224, 0.07) 0 18px, transparent 18px 36px); background-size: 200% 200%; animation: slide 6s linear infinite; }
.mystery span { font-size: clamp(6rem, 18vw, 15rem); font-weight: 900; line-height: 1; color: var(--yellow); -webkit-text-stroke: 4px var(--ink); animation: bob 2.6s ease-in-out infinite; }
.stage-locked .stage-art { border-style: dashed; border-color: var(--cream); box-shadow: none; }
@keyframes slide { to { background-position: 51px 0; } }

/* text that slides up as it comes into view */
.js .reveal { opacity: 0; transform: translateY(36px); transition: opacity 0.7s ease, transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }
.js .reveal.in { opacity: 1; transform: none; }
.reveal:nth-child(2) { transition-delay: 0.08s; }
.reveal:nth-child(3) { transition-delay: 0.16s; }
.reveal:nth-child(4) { transition-delay: 0.24s; }
.reveal:nth-child(5) { transition-delay: 0.32s; }
.reveal:nth-child(6) { transition-delay: 0.4s; }

/* ---------- the end: follow and contact ---------- */
.end { position: relative; padding: 150px var(--pad) 0; overflow: hidden; }
.end .kicker { margin-bottom: 18px; }
.links { list-style: none; margin-bottom: 90px; border-bottom: 2px solid rgba(255, 246, 224, 0.25); }
.links a { display: flex; justify-content: space-between; align-items: center; padding: 0.12em 0.1em; font-size: clamp(2.2rem, 7.4vw, 6rem); font-weight: 900; line-height: 1.25; letter-spacing: -0.02em; text-decoration: none; border-top: 2px solid rgba(255, 246, 224, 0.25); transition: padding 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.2s, color 0.2s; }
.links a:hover, .links a:focus-visible { padding-left: 0.45em; padding-right: 0.3em; background: var(--yellow); color: var(--ink); }
.arrow { display: inline-block; font-size: 0.7em; transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
.links a:hover .arrow { transform: rotate(45deg) scale(1.2); }
.mail a { font-size: clamp(1.3rem, 4.4vw, 3rem); font-weight: 900; text-decoration-color: var(--yellow); text-decoration-thickness: 0.12em; text-underline-offset: 0.18em; overflow-wrap: anywhere; }
.mail a:hover { color: var(--yellow); }
.copy { margin-top: 90px; font-size: 0.85rem; opacity: 0.6; }
.end-word { margin: 10px 0 -0.19em calc(var(--pad) * -1); width: 100vw; text-align: center; font-size: 19.5vw; font-weight: 900; line-height: 0.9; letter-spacing: -0.04em; white-space: nowrap; color: var(--yellow); pointer-events: none; user-select: none; }
.end .copy { position: relative; }
.end-word { order: 9; }
.end { display: flex; flex-direction: column; }

/* ---------- the dot that follows the pointer (mouse only) ---------- */
.cursor { display: none; }
@media (hover: hover) and (pointer: fine) {
	.js .cursor { display: block; position: fixed; left: 0; top: 0; z-index: 20; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--orange); border: 2px solid var(--ink); pointer-events: none; opacity: 0; transition: width 0.2s, height 0.2s, margin 0.2s, background-color 0.2s, opacity 0.3s; }
	.js .cursor.on { opacity: 1; }
	.js .cursor.big { width: 64px; height: 64px; margin: -32px 0 0 -32px; background: rgba(255, 201, 60, 0.25); border-color: var(--orange); }
}

/* ---------- small screens ---------- */
@media (max-width: 820px) {
	.stage, .stage:nth-of-type(even) { grid-template-columns: 1fr; align-content: center; padding: 120px var(--pad) 100px; }
	.stage:nth-of-type(even) .stage-art { order: 0; }
	.stage-no { top: 70px; translate: 0 calc(var(--s, 0) * 50px); font-size: 60vw; }
	.hero-word { top: 13svh; }
	.hero-logo { width: min(40svh, 78vw); }
	.end { padding-top: 110px; }
}

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, *::before, *::after { animation: none !important; transition: none !important; }
	.js .reveal, .js .hero-word, .js .hero h1, .js .hero .intro, .js .hero .cue, .js .spark { opacity: 1; transform: none; scale: 1; }
	.js:not(.ready) .logo { transform: none; }
	.stage-art { transform: none; }
}

/* A visit that skips the curtain (seen already this session) shows the logo at once, with no pop. */
.js.skip .logo { animation: bob 3.4s ease-in-out infinite; }
