/* FPL EyeStein — VHS Intro Prototype (INTRO-ANIMATION-PROTOTYPE-01)
   ชั้นนี้แยกเดี่ยวจากเว็บหลักทั้งหมด ไม่แตะ Home/Album/Card/Team/Journey/About
   ถอนออกได้ด้วยการลบสอง tag (<link> + <script>) ที่โหลดไฟล์คู่นี้ — ไม่มีผลต่อเว็บถ้าถอน
   สัดส่วนตามสเปก: โมเดิร์น 80% / VHS 20% — ระยะรวม 1.8-2.0s (สูงสุด 2.2s)
   ลำดับ: tape start(.00-.20) → brand appear(.20-.55) → archive frame(.55-1.35)
          → brand lock(1.35-1.75) → transition(1.75-2.00) → Home */

:root {
  --vhs-bg: #0a0b0c;
  --vhs-text: #ece9e2;
  --vhs-lime: #c3ee4a;
  --vhs-muted: #6b6f74;
}

.vhs-intro {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--vhs-bg);
  display: flex; align-items: center; justify-content: center;
  font-family: "IBM Plex Mono", "SF Mono", "Courier New", monospace;
  color: var(--vhs-text);
  overflow: hidden;
  opacity: 1;
  transition: opacity 240ms ease;
}
.vhs-intro.vhs-exit { opacity: 0; }
.vhs-intro[hidden] { display: none; }

/* จอเลื่อนแทป (tape roll) ตอนออก — ให้ความรู้สึกเทปม้วนก่อนเข้า Home ไม่ใช่ fade เฉย ๆ */
.vhs-intro.vhs-exit .vhs-frame { transform: translateY(-6%); transition: transform 240ms ease; }

.vhs-frame { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }

/* เกรนฟิล์มแบบประหยัด — สั่นความสว่างเบา ๆ ที่ความถี่สูง ไม่ใช่ noise texture จริง (เบากว่ามาก) */
.vhs-grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: repeating-radial-gradient(circle at 30% 20%, rgba(255,255,255,0.02) 0 1px, transparent 1px 3px);
  animation: vhs-flicker 130ms steps(2) infinite;
  mix-blend-mode: overlay;
}
@keyframes vhs-flicker { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.48; } }

/* สแกนไลน์แนวนอนบาง ๆ คงที่ ไม่ขยับ */
.vhs-scanlines {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0px, rgba(255,255,255,0.03) 1px, transparent 1px, transparent 3px);
  opacity: 0.32;
}

/* แถบ tracking กวาดแนวนอน — 2 ครั้งตามสเปก: รอบแรกกลาง archive frame, รอบสองต้น transition ออก */
.vhs-track {
  position: absolute; left: 0; right: 0; height: 12%;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.045) 45%, rgba(195,238,74,0.05) 50%, rgba(255,255,255,0.045) 55%, transparent);
  opacity: 0; pointer-events: none; z-index: 4;
  animation: vhs-track-pass 480ms cubic-bezier(.25,.4,.3,1) both;
  animation-delay: 600ms;
}
.vhs-track.vhs-track-2 { animation-delay: 1680ms; animation-duration: 200ms; }

.vhs-meta {
  position: absolute; font-size: 11px; letter-spacing: 0.08em; color: var(--vhs-muted);
  opacity: 0; animation: vhs-in 180ms ease forwards; animation-delay: 20ms;
}
.vhs-meta-play { top: 22px; left: 22px; color: rgba(236,233,226,0.72); }
.vhs-meta-play .dot { color: var(--vhs-lime); margin-right: 6px; }
/* บั๊ก 2 (PM-BRIEF รอบ 88 ข้อ 2) — ตัวนับเวลาเคยปักมุมขวาล่าง ชนกับปุ่ม SKIP ที่มุมเดียวกัน
   (regression ตั้งแต่รอบ 79 ตอนขยาย padding ของ .vhs-skip ให้ได้ระยะแตะ >=44px)
   ย้ายมามุมซ้ายล่างแทน · **ห้ามลด padding/ขนาดของ .vhs-skip เพื่อเลี่ยงการชน** */
.vhs-meta-time { bottom: 22px; left: 22px; font-variant-numeric: tabular-nums; }
.vhs-meta-sp { top: 22px; right: 22px; }

/* phase 4 (brand lock): ลด noise ของ metadata แทปลงเล็กน้อย ไม่ลบออกทั้งหมด */
.vhs-meta-play, .vhs-meta-sp, .vhs-meta-time {
  animation: vhs-in 180ms ease forwards, vhs-meta-settle 200ms ease forwards;
  animation-delay: 20ms, 1350ms;
}

.vhs-center {
  position: relative; z-index: 5; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 20px;
}

.vhs-title {
  font-size: clamp(28px, 7vw, 56px); font-weight: 700; letter-spacing: 0.02em;
  line-height: 1.05; margin: 0; opacity: 0;
  animation: vhs-title-in 220ms steps(3, end) forwards;
  animation-delay: 140ms;
}

/* "EYE TEST ARCHIVE" — บรรทัดรองใต้ชื่อแบรนด์ เส้นลูกน้ำใต้บรรทัดนี้ (accent) ปรากฏช่วง brand lock */
.vhs-archive {
  position: relative;
  font-size: clamp(11px, 2.4vw, 13px); letter-spacing: 0.16em; color: var(--vhs-lime);
  opacity: 0; margin-top: 2px; padding-bottom: 10px;
  animation: vhs-in 200ms ease forwards; animation-delay: 320ms;
}
.vhs-accent-line {
  position: absolute; left: 50%; bottom: 0; height: 2px; width: 0;
  background: var(--vhs-lime); transform: translateX(-50%);
  animation: vhs-accent-grow 260ms ease forwards; animation-delay: 1350ms;
}

.vhs-season, .vhs-gw {
  font-size: clamp(11px, 2.6vw, 13px); letter-spacing: 0.14em; color: var(--vhs-muted);
  opacity: 0; animation: vhs-in 200ms ease forwards;
}
.vhs-season { animation-delay: 560ms; margin-top: 6px; }
.vhs-gw { animation-delay: 640ms; }

/* จอสั่นสั้น ๆ ตอนเผยชื่อ (80-120ms) แล้วนิ่งทันที ไม่ใช่สั่นตลอด */
@keyframes vhs-title-in {
  0% { opacity: 0; transform: translateX(0); }
  10% { opacity: 1; transform: translateX(-3px); }
  40% { transform: translateX(2px); }
  65% { transform: translateX(-1px); }
  85% { transform: translateX(0); }
  100% { opacity: 1; transform: translateX(0); }
}
@keyframes vhs-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes vhs-meta-settle { from { opacity: 1; } to { opacity: 0.6; } }
@keyframes vhs-accent-grow { from { width: 0; } to { width: 64px; } }
@keyframes vhs-track-pass {
  0% { opacity: 0; top: -12%; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; top: 100%; }
}

.vhs-skip {
  position: absolute; z-index: 6; bottom: 18px; right: 18px;
  font-family: inherit; font-size: 11px; letter-spacing: 0.08em;
  color: var(--vhs-muted); background: none; border: 1px solid rgba(255,255,255,0.14);
  border-radius: 3px; padding: 16px 14px; cursor: pointer;
  /* PM-BRIEF รอบ 79 ข้อ 5 (ระยะแตะ ≥44px) — ปุ่มนี้ลอยอยู่มุมจอเดี่ยว ๆ ไม่มี
     งบความสูงแถวที่ต้องแบ่งปันกับใคร (ต่างจาก .menu a ใน header) จึงขยาย
     padding จริงตรง ๆ ได้โดยไม่กระทบเลย์เอาต์อื่น */
  opacity: 0; animation: vhs-in 180ms ease forwards; animation-delay: 480ms;
  transition: color 150ms ease, border-color 150ms ease;
}
.vhs-skip:hover, .vhs-skip:focus-visible { color: var(--vhs-text); border-color: rgba(255,255,255,0.32); }

@media (max-width: 480px) {
  .vhs-meta { font-size: 10px; }
  .vhs-meta-play { left: 16px; top: 16px; }
  .vhs-meta-sp { right: 16px; top: 16px; }
  .vhs-meta-time { left: 16px; bottom: 16px; }
  .vhs-skip { bottom: 14px; right: 14px; }
}

/* บั๊ก 1 (PM-BRIEF รอบ 88 ข้อ 1) — กันหน้าเว็บจริงแวบให้เห็นก่อนม่านขึ้น
   `intro-vhs.js` เติมคลาสนี้ที่บรรทัดแรกที่รันจริง (ก่อน DOMContentLoaded) เฉพาะตอนที่
   จะเล่นอินโทรจริงเท่านั้น · ซ่อนเฉพาะลูกของ body ที่ไม่ใช่ตัวม่าน ไม่ได้ซ่อน body เอง
   จึงไม่กระทบสีพื้น/ฟอนต์ที่ม่านใช้อยู่

   ใช้ `visibility: hidden` ไม่ใช่ `display: none` เพราะ display จะทำให้เลย์เอาต์ถูกคำนวณ
   ใหม่ทั้งหน้าสองรอบ (ซ่อนแล้วโชว์) ส่วน visibility กันการมองเห็นโดยที่กล่องยังอยู่ที่เดิม
   พอถอดคลาสออกจึงไม่มีการกระตุกของเลย์เอาต์

   ถ้า `intro-vhs.js` โหลดไม่สำเร็จ (404/ถูกบล็อก) คลาสนี้จะไม่ถูกเติมเลย เนื้อหาจึงแสดงปกติ
   ไม่มีทางเกิดจอขาวค้าง — เป็นเงื่อนไข fail-open ที่ RT8-05 คุมไว้อยู่แล้ว */
html.vhs-intro-lock body > *:not(.vhs-intro) { visibility: hidden; }

/* prefers-reduced-motion: ตัดทุกความไม่เสถียร/กวาดแนวนอนออก เหลือแค่ชื่อแบรนด์นิ่ง ๆ ~260ms */
@media (prefers-reduced-motion: reduce) {
  .vhs-grain, .vhs-track { display: none; }
  .vhs-title { animation: vhs-in 120ms ease forwards; animation-delay: 0ms; }
  .vhs-archive { animation-delay: 100ms; }
  .vhs-season { animation-delay: 140ms; }
  .vhs-gw { animation-delay: 160ms; }
  .vhs-accent-line { animation-delay: 160ms; animation-duration: 100ms; }
  .vhs-meta { animation-delay: 0ms; }
  .vhs-meta-play, .vhs-meta-sp, .vhs-meta-time { animation-delay: 0ms, 0ms; }
}
