/* RDR2 Hub — หน้าหลัก (Mobile-first)
   สไตล์: ตะวันตกโบราณ กระดาษเก่า ทองเหลือง สีแดงเข้ม */

:root {
  --ink: #140a07;
  --sepia: #2a140d;
  --brass-hi: #f6dc9a;
  --brass: #c8963e;
  --brass-lo: #7a4e18;
  --blood: #8f1d14;
  --blood-hi: #c23a24;
  --paper: #e9d6a8;
  --paper-dim: #b79f6c;
  --font-display: "Rye", "Mitr", Georgia, serif;
  --font-serif: "IM Fell English SC", "Mitr", Georgia, serif;
  --font-thai: "Mitr", "Noto Sans Thai", system-ui, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-thai);
  overscroll-behavior: none;
}

/* ---------- ฉาก ---------- */
.stage {
  position: relative;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding:
    max(env(safe-area-inset-top), 18px)
    24px
    max(env(safe-area-inset-bottom), 14px);
  overflow: hidden;
  isolation: isolate;
}

.bg {
  position: absolute;
  inset: 0;
  z-index: -3;
  background: var(--ink) url("../assets/bg.svg") center bottom / cover no-repeat;
  animation: bgdrift 28s ease-in-out infinite alternate;
  transform-origin: 50% 100%;
}

@keyframes bgdrift {
  from { transform: scale(1.02); }
  to   { transform: scale(1.09); }
}

/* เกรนฟิล์ม + วิกเน็ต */
.grain {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: 0.16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 38%, rgba(10, 4, 2, 0.72) 100%),
    linear-gradient(to bottom, rgba(10, 4, 2, 0.55) 0%, transparent 28%, transparent 62%, rgba(10, 4, 2, 0.8) 100%);
}

/* ฝุ่น/ประกายไฟลอย */
.embers {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.embers i {
  position: absolute;
  bottom: -10px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffcf7a;
  box-shadow: 0 0 6px 1px rgba(255, 170, 70, 0.8);
  opacity: 0;
  animation: rise linear infinite;
}
@keyframes rise {
  0%   { transform: translate3d(0, 0, 0); opacity: 0; }
  10%  { opacity: 0.9; }
  100% { transform: translate3d(var(--dx, 20px), -78vh, 0); opacity: 0; }
}

/* ---------- โลโก้ ---------- */
.logo {
  margin-top: clamp(6px, 3.5vh, 36px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: fadeDown 1s ease-out both;
}

.logo__emblem {
  width: clamp(110px, 30vh, 190px);
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.7));
}

.logo__kicker {
  margin-top: 10px;
  font-family: var(--font-serif);
  font-size: clamp(11px, 1.7vh, 14px);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--brass);
  text-shadow: 0 1px 0 #000;
}

.logo__title {
  margin-top: 6px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(38px, 7.6vh, 62px);
  line-height: 1;
  letter-spacing: 0.04em;
  color: transparent;
  background: linear-gradient(to bottom, #fff0c0 0%, #f0c25e 38%, #b3771f 62%, #6b4210 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 3px 0 #2a0e05) drop-shadow(0 6px 12px rgba(0, 0, 0, 0.8));
}

.logo__title span {
  display: block;
  margin-top: 4px;
  font-size: 0.5em;
  letter-spacing: 0.14em;
}

.logo__rule {
  margin-top: 14px;
  width: min(240px, 62vw);
  height: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--brass);
}
.logo__rule::before,
.logo__rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, currentColor);
}
.logo__rule::after { transform: scaleX(-1); }
.logo__rule b {
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  background: currentColor;
  box-shadow: 0 0 8px rgba(246, 220, 154, 0.6);
}

.logo__tag {
  margin-top: 10px;
  font-family: var(--font-serif);
  font-size: clamp(12px, 1.8vh, 15px);
  letter-spacing: 0.2em;
  color: var(--paper-dim);
  text-shadow: 0 1px 2px #000;
}

/* ---------- ปุ่ม ---------- */
.cta {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: clamp(16px, 7vh, 64px);
  animation: fadeUp 1.1s 0.25s ease-out both;
}

.btn {
  --h: 64px;
  position: relative;
  appearance: none;
  border: 0;
  background: none;
  cursor: pointer;
  width: min(100%, 320px);
  height: var(--h);
  padding: 0;
  font-family: var(--font-thai);
  color: var(--brass-hi);
  touch-action: manipulation;
  transition: transform 0.15s ease, filter 0.2s ease;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.7));
}

/* กรอบทองเหลือง */
.btn__frame {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, #f6dc9a 0%, #c8963e 35%, #7a4e18 70%, #d9a84e 100%);
  clip-path: polygon(
    14px 0, calc(100% - 14px) 0, 100% 14px,
    100% calc(100% - 14px), calc(100% - 14px) 100%,
    14px 100%, 0 calc(100% - 14px), 0 14px
  );
}

/* พื้นปุ่ม: หนังเข้ม + แดงเลือดหมู */
.btn__face {
  position: absolute;
  inset: 3px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 210, 130, 0.22), transparent 62%),
    linear-gradient(to bottom, #6e170f 0%, #4a0f0a 55%, #2e0905 100%);
  clip-path: polygon(
    12px 0, calc(100% - 12px) 0, 100% 12px,
    100% calc(100% - 12px), calc(100% - 12px) 100%,
    12px 100%, 0 calc(100% - 12px), 0 12px
  );
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.7);
}

/* เส้นขอบใน */
.btn__stitch {
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(246, 220, 154, 0.55);
  clip-path: polygon(
    9px 0, calc(100% - 9px) 0, 100% 9px,
    100% calc(100% - 9px), calc(100% - 9px) 100%,
    9px 100%, 0 calc(100% - 9px), 0 9px
  );
  pointer-events: none;
}

/* ประกายกวาด */
.btn__shine {
  position: absolute;
  inset: 3px;
  overflow: hidden;
  clip-path: polygon(
    12px 0, calc(100% - 12px) 0, 100% 12px,
    100% calc(100% - 12px), calc(100% - 12px) 100%,
    12px 100%, 0 calc(100% - 12px), 0 12px
  );
  pointer-events: none;
}
.btn__shine::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 236, 180, 0.35), transparent);
  animation: shine 4.2s ease-in-out infinite 1.2s;
}
@keyframes shine {
  0%   { left: -60%; }
  45%, 100% { left: 130%; }
}

.btn__label {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 0 #000, 0 0 12px rgba(255, 190, 90, 0.45);
}

.btn__star {
  width: 14px;
  height: 14px;
  fill: var(--brass);
  filter: drop-shadow(0 0 4px rgba(246, 220, 154, 0.7));
}

.btn:hover { filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.75)) brightness(1.1); }
.btn:active { transform: translateY(2px) scale(0.985); filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.8)) brightness(0.95); }
.btn:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 5px; }

.btn__pulse {
  position: absolute;
  inset: -4px;
  border-radius: 10px;
  pointer-events: none;
  box-shadow: 0 0 0 0 rgba(246, 220, 154, 0.45);
  animation: pulse 2.8s ease-out infinite 1.5s;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(246, 220, 154, 0.4); }
  70%, 100% { box-shadow: 0 0 0 16px rgba(246, 220, 154, 0); }
}

/* ---------- เครดิต ---------- */
.credit {
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--paper-dim);
  text-shadow: 0 1px 2px #000;
  text-align: center;
  opacity: 0.9;
  animation: fadeUp 1.2s 0.5s ease-out both;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(max(env(safe-area-inset-bottom), 14px) + 54px);
  transform: translate(-50%, 20px);
  max-width: calc(100% - 48px);
  padding: 10px 18px;
  font-size: 14px;
  color: var(--paper);
  background: rgba(20, 10, 7, 0.92);
  border: 1px solid var(--brass-lo);
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 10;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Animations ---------- */
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* หน้าจอเตี้ย (แนวนอน / มือถือเล็ก) */
@media (max-height: 640px) {
  .logo__emblem { width: 96px; }
  .logo__title { font-size: 34px; }
  .logo__tag { display: none; }
  .btn { --h: 56px; }
  .btn__label { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
