/* css/style.css */

:root {
  --accent: #00ffff;
  --green-ready: #00ff66;
}

html, body {
  height: 100%;
  margin: 0;
  background: #000;
  color: #fff;
  overflow: hidden;
  font-family: Inter, system-ui, Arial;
}

#container {
  position: fixed;
  inset: 0;
  display: none;
  background: #000;
  z-index: 0;
}

#container video {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  z-index: -1 !important;
}

/* --- LOADING SCREEN --- */
#loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  background: linear-gradient(180deg, #020202, #000);
  gap: 16px;
}

.bar-wrap {
  width: 60%;
  max-width: 320px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
}

.bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #0077ff);
  transition: width .25s ease-out;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

#loading-text {
  color: #cbd5e1;
  font-size: 14px;
  letter-spacing: 0.5px;
  text-align: center;
}

#startButton {
  padding: 12px 28px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  font-size: 16px;
  margin-top: 10px;
}

#startButton:active {
  transform: scale(0.96);
}

/* SCAN FRAME */
#scan-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.frame {
  width: 70vmin;
  height: 70vmin;
  position: relative;
}

.corner {
  position: absolute;
  width: 40px;
  height: 40px;
  border-color: #ffffff;
  border-style: solid;
  border-width: 0;
  display: block !important;
}

.tl { top: 0; left: 0; border-top-width: 7px; border-left-width: 7px; }
.tr { top: 0; right: 0; border-top-width: 7px; border-right-width: 7px; }
.bl { bottom: 0; left: 0; border-bottom-width: 7px; border-left-width: 7px; }
.br { bottom: 0; right: 0; border-bottom-width: 7px; border-right-width: 7px; }

.scan-line {
  position: absolute;
  width: 100%;
  height: 5px;
  background: #ffffff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.9); 
  left: 0;
  animation: scan-move 3s ease-in-out infinite alternate;
}

@keyframes scan-move {
  0% { top: 0%; }
  100% { top: 98%; }
}

body.no-scan #scan-frame,
body.no-scan #scan-frame *, 
body.no-scan #scan-frame::before,
body.no-scan #scan-frame::after {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* --- MENU & BUTTONS --- */
#career-menu {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 240px;
  max-width: 360px;
  background: rgba(10, 10, 12, 0.78);
  border: 1px solid rgba(0, 255, 255, 0.12);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 255, 255, 0.05);
  padding: 20px;
  border-radius: 14px;
  z-index: 150;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  backdrop-filter: blur(6px);
}

#career-menu h2 {
  margin: 0;
  color: var(--accent);
  font-size: 20px;
  text-shadow: 0 0 6px rgba(0, 188, 212, 0.15);
}

/* ปรับให้รายการปุ่มเรียงกันสวยงาม */
.career-list {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 10px;
  margin-top: 8px;
}

.career-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(90deg, #0077ff, #00bcd4);
  color: #000;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 188, 212, 0.08);
  transition: transform .12s;
  position: relative;
  overflow: hidden;
}

.career-btn:active {
  transform: translateY(1px);
}

/* ลบ #career-actions ทิ้งเพราะย้ายปุ่มไปใน list แล้ว */

/* ✅ แก้ไขปุ่ม Action ให้เป็นสถานะ "พร้อมใช้งาน" เสมอ */
.action-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  /* สีเริ่มต้นให้แตกต่างจากอาชีพนิดหน่อย หรือจะใช้สีเดียวกันก็ได้ */
  background: linear-gradient(90deg, #00b09b, #96c93d); 
  color: #000;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  
  /* ลบ grayscale และ pointer-events: none ออก เพื่อให้กดได้ทันที */
  filter: none;
  opacity: 1;
  pointer-events: auto;
  box-shadow: 0 4px 15px rgba(0, 255, 100, 0.3);
}

.action-btn:active {
  transform: scale(0.98);
}

#return-row {
  width: 100%;
  margin-top: 6px;
  display: flex;
  justify-content: center;
}

#return-btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  cursor: pointer;
}

/* ปุ่มเมนูหลัก (เริ่มต้นต้อง hidden) */
#homeBtn {
  position: fixed;
  left: 12px;
  top: 12px;
  display: none;
  z-index: 200;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.5);
  color: var(--accent);
  cursor: pointer;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* LOADING BARS INSIDE BUTTONS */
.career-btn .btn-bottom-bar,
.action-btn .btn-bottom-bar {
  pointer-events: none;
  position: absolute;
  left: 0; bottom: 0;
  height: 4px;
  width: 100%;
  background: rgba(0,0,0,0.3);
}

.career-btn .btn-bottom-inner,
.action-btn .btn-bottom-inner {
  height: 100%;
  width: 0%;
  background: #fff;
  transition: width 0.3s ease;
}

/* ========================================= */
/* --- ส่วน Gesture Guide Overlay --- */
/* ========================================= */
.gesture-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: none; align-items: center; justify-content: center;
  pointer-events: none;
}
.gesture-container {
  position: relative; width: 220px; height: 220px;
  display: flex; align-items: center; justify-content: center;
}

/* --- Common Hand Styles --- */
.hand-icon {
  width: 45px; height: 45px; color: #fff;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,0.8));
  position: absolute;
}
.gesture-text {
  position: absolute; bottom: -50px; width: 100%; text-align: center;
  color: #fff; font-size: 14px; text-shadow: 0 2px 4px rgba(0,0,0,1);
  font-weight: bold; letter-spacing: 0.5px;
}
.gesture-group {
  position: absolute; width: 100%; height: 100%;
  opacity: 0; 
}

/* --- Phase 1: ROTATE (0s - 4s) --- */
.rotate-group {
  animation: phase-show 8s forwards; 
}
.single-hand {
  bottom: 20px; right: 20px;
  animation: hand-swipe 4s ease-in-out infinite; 
}

/* --- Phase 2: ZOOM (4s - 8s) --- */
.zoom-group {
  animation: phase-show 8s forwards; 
  animation-delay: 4s; 
}
.hand-left {
  bottom: 20px; left: 40px;
  transform: scaleX(-1);
  animation: hand-zoom-left 4s ease-in-out infinite;
}
.hand-right {
  top: 40px; right: 40px;
  animation: hand-zoom-right 4s ease-in-out infinite;
}

/* --- Cube Behavior --- */
.demo-cube-wrap { width: 60px; height: 60px; perspective: 400px; }
.demo-cube {
  width: 100%; height: 100%; position: relative; transform-style: preserve-3d;
  animation: cube-action 8s ease-in-out forwards; 
}
.face {
  position: absolute; width: 60px; height: 60px;
  border: 2px solid #00ffff; background: rgba(0, 255, 255, 0.15);
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
}
/* Face Positions */
.face.front  { transform: rotateY(0deg) translateZ(30px); }
.face.back   { transform: rotateY(180deg) translateZ(30px); }
.face.right  { transform: rotateY(90deg) translateZ(30px); }
.face.left   { transform: rotateY(-90deg) translateZ(30px); }
.face.top    { transform: rotateX(90deg) translateZ(30px); }
.face.bottom { transform: rotateX(-90deg) translateZ(30px); }

/* --- Keyframes Animations --- */
@keyframes phase-show {
  0%, 45% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes hand-swipe {
  0% { transform: translate(0,0); opacity: 0; }
  10% { opacity: 1; }
  25% { transform: translate(-40px, 0); } 
  50% { transform: translate(40px, 0); }  
  75% { transform: translate(0, -40px); } 
  90% { transform: translate(0, 0); opacity: 1; }
  100% { opacity: 0; }
}

@keyframes hand-zoom-left {
  0%, 100% { transform: translate(20px, -20px) scaleX(-1); opacity: 0; }
  10%, 90% { opacity: 1; }
  50% { transform: translate(-30px, 30px) scaleX(-1); } 
}
@keyframes hand-zoom-right {
  0%, 100% { transform: translate(-20px, 20px); opacity: 0; }
  10%, 90% { opacity: 1; }
  50% { transform: translate(30px, -30px); } 
}

@keyframes cube-action {
  0% { transform: rotateY(0) rotateX(0) scale(1); }
  12% { transform: rotateY(-45deg); }
  25% { transform: rotateY(45deg); }
  37% { transform: rotateX(45deg); }
  50% { transform: rotateY(0) rotateX(0) scale(0.6); } 
  75% { transform: rotateY(0) rotateX(0) scale(1.4); } 
  100% { transform: rotateY(0) rotateX(0) scale(1); }
}