/**
 * motion.css
 * -----------------------------------------------------------------------------
 * animation ธีมโน้ตบุ๊ก ทำด้วย CSS ล้วน (เบา ไม่มี JS, ไม่มีไฟล์ภาพ)
 *   - หน้าโหลด: โน้ตบุ๊กเปิดฝา + แถบ boot
 *   - การ์ด/วันในปฏิทิน: hover แล้วยกขึ้น เงาลึกขึ้น
 *   - จองสำเร็จ: เช็กมาร์กเด้ง
 *
 * ⚠️ ทุก animation ถูกปิดทั้งหมดเมื่อผู้ใช้ตั้งค่า prefers-reduced-motion: reduce
 *    และ motion ทุกตัวเป็นเพียงการตกแต่ง — ไม่มีอะไรบังการใช้งานจริง
 */

/* ---------- ภาพประกอบโน้ตบุ๊กเปิดฝา ---------- */

.notebook-illustration {
  position: relative;
  width: 96px;
  height: 68px;
  animation: notebook-idle-float 3.6s ease-in-out infinite;
}

.notebook-screen {
  position: absolute;
  inset: 0 0 16px 0;
  border: 2px solid var(--brand-accent);
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #fffaf1, #fff1d9);
  transform-origin: bottom center;
  animation: notebook-lid-open 1.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.notebook-screen::after {
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 22%;
  height: 4px;
  border-radius: 2px;
  background: var(--brand-accent);
  transform-origin: left center;
  animation: notebook-boot-progress 1.6s ease-in-out 0.9s infinite;
}

.notebook-base {
  position: absolute;
  left: -6px;
  right: -6px;
  bottom: 0;
  height: 10px;
  border-radius: 3px;
  background: var(--brand-accent);
  opacity: 0.85;
}

@keyframes notebook-lid-open {
  from {
    transform: rotateX(-78deg);
    opacity: 0.2;
  }
  to {
    transform: rotateX(0deg);
    opacity: 1;
  }
}

@keyframes notebook-idle-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes notebook-boot-progress {
  0% {
    transform: scaleX(0.05);
    opacity: 0.5;
  }
  60% {
    transform: scaleX(1);
    opacity: 1;
  }
  100% {
    transform: scaleX(1);
    opacity: 0.3;
  }
}

/* ---------- การ์ดและวันในปฏิทิน: ยกขึ้นเมื่อ hover ---------- */

.form-card {
  opacity: 0;
  transform: translateY(10px);
  animation: card-rise-in 0.45s ease-out forwards;
  animation-delay: calc(var(--card-index, 0) * 70ms);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.form-card:hover,
.form-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-color: var(--brand-accent);
}

.calendar-cell.is-open {
  transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease;
}

.calendar-cell.is-open:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

@keyframes card-rise-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- จองสำเร็จ ---------- */

.success-panel:not([hidden]) {
  animation: card-rise-in 0.4s ease-out both;
}

.success-check {
  animation: success-check-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes success-check-pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---------- ระหว่างส่งข้อมูล ---------- */

.is-submitting .primary-button {
  animation: submitting-pulse 1.2s ease-in-out infinite;
}

@keyframes submitting-pulse {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.95;
  }
}

/* ---------- เคารพการตั้งค่าลดการเคลื่อนไหวของผู้ใช้ ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .form-card,
  .success-panel:not([hidden]) {
    opacity: 1;
    transform: none;
  }

  .form-card:hover,
  .calendar-cell.is-open:hover {
    transform: none;
  }
}
