/*
 * Motion system — chuyển từ timeline 32s trong Figma (Concept 01).
 * Reveal: translateY(--ry) + opacity, easing cubic-bezier(.22,1,.36,1),
 *         delay/duration = (% trên timeline) × 320ms.
 * Ambient: sway / float / breathe lặp vô hạn, chu kỳ 16s & 32s như Figma.
 */
:root {
  --ease-out-expo: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.42, 0, 0.58, 1);
}

/* ---------- Reveal on view ---------- */
/* Dùng animation (fill-mode backwards) thay vì transition để không xung đột
   với transition/transform riêng (hover, accordion…) của từng component. */
[data-reveal]:not(.is-in) { opacity: 0; }
[data-reveal].is-in {
  animation: nab-reveal var(--rdur, 750ms) var(--ease-out-expo) var(--rd, 0ms) backwards;
}
@keyframes nab-reveal {
  from { opacity: 0; transform: translate3d(0, calc(var(--ry, 20) * 1px), 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
/* Biến thể: reveal kèm scale nhẹ cho ảnh lớn */
[data-reveal="zoom"].is-in { animation-name: nab-reveal-zoom; }
@keyframes nab-reveal-zoom {
  from { opacity: 0; transform: translate3d(0, calc(var(--ry, 20) * 1px), 0) scale(1.04); }
  to { opacity: 1; transform: none; }
}
/* Thẻ kính mờ (backdrop-filter): reveal trực tiếp trên từng thẻ — KHÔNG đặt
   data-reveal lên khung cha, vì opacity < 1 ở cha tắt blur của con → thẻ tối
   rồi "bật" kính mờ đột ngột khi kết thúc. */
[data-reveal="glass"].is-in { animation: nab-reveal-glass var(--rdur, 1000ms) var(--ease-out-expo) var(--rd, 0ms) backwards; }
@keyframes nab-reveal-glass {
  from { opacity: 0; transform: translate3d(0, calc(var(--ry, 18) * 1px), 0) scale(.97); }
  to { opacity: 1; transform: none; }
}
/* Fade đơn (header) */
[data-reveal="fade"].is-in { animation-name: nab-fade; }
@keyframes nab-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Ambient loops ---------- */
/* Breathe: scale 1 → 1.006, chu kỳ 16s (ảnh nền hero, tea banner) */
.anim-breathe { animation: nab-breathe 16s var(--ease-soft) infinite; transform-origin: 50% 50%; }
@keyframes nab-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(var(--breathe, 1.006)); } }

/* Sway X / Float Y: 0 → +a → 0 → -a → 0, chu kỳ 16s */
.anim-sway-x { animation: nab-sway-x 16s var(--ease-soft) infinite; }
@keyframes nab-sway-x {
  0%, 50%, 100% { translate: 0 0; }
  25% { translate: calc(var(--amp, 4) * 1px) 0; }
  75% { translate: calc(var(--amp, 4) * -1px) 0; }
}
.anim-float-y { animation: nab-float-y 16s var(--ease-soft) infinite; }
@keyframes nab-float-y {
  0%, 50%, 100% { translate: 0 0; }
  25% { translate: 0 calc(var(--amp, 3) * 1px); }
  75% { translate: 0 calc(var(--amp, 3) * -1px); }
}

/* Float bất quy tắc (lá trà, điện thoại) — chu kỳ 32s, biên độ chuẩn hoá theo --amp */
.anim-drift { animation: nab-drift 32s var(--ease-soft) infinite; }
@keyframes nab-drift {
  0%, 43.75%, 100% { translate: 0 0; }
  8.75%  { translate: 0 calc(var(--amp, 5) * -1px); }
  18.1%  { translate: 0 calc(var(--amp, 5) * 0.6px); }
  27.5%  { translate: 0 calc(var(--amp, 5) * -0.7px); }
  36.9%  { translate: 0 calc(var(--amp, 5) * 0.4px); }
  56.25% { translate: 0 calc(var(--amp, 5) * -0.7px); }
  68.75% { translate: 0 calc(var(--amp, 5) * 0.5px); }
  81.25% { translate: 0 calc(var(--amp, 5) * -0.7px); }
  93.75% { translate: 0 calc(var(--amp, 5) * 0.4px); }
}

/* Glow mờ phía sau (ellipse hero) */
.anim-glow { animation: nab-glow 8s var(--ease-soft) infinite alternate; }
@keyframes nab-glow { from { opacity: .75; } to { opacity: 1; } }

/* Con trỏ nhấp nháy */
.caret { animation: nab-caret 1s steps(1) infinite; }
@keyframes nab-caret { 50% { opacity: 0; } }

/* ---------- Micro-interactions ---------- */
.lift { transition: transform .5s var(--ease-out-expo), box-shadow .5s var(--ease-out-expo); }
.lift:hover { transform: translateY(-6px); box-shadow: 0 24px 48px -24px rgba(0, 46, 116, .35); }

.img-zoom { overflow: hidden; }
.img-zoom img { transition: transform 1.2s var(--ease-out-expo); }
.img-zoom:hover img { transform: scale(1.05); }

/* Hiệu ứng ánh sáng lướt qua nút vàng */
.btn { position: relative; overflow: hidden; isolation: isolate; }
.btn::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform .9s var(--ease-out-expo);
}
.btn:hover::after { transform: translateX(120%); }

/* Gauge: cung vàng "vẽ" ra khi vào khung nhìn */
.gauge__fill { clip-path: inset(0 0 0 100%); transition: clip-path 1.6s var(--ease-out-expo) .25s; }
.is-in .gauge__fill, .gauge.is-in .gauge__fill { clip-path: inset(0 0 0 0); }

@media (prefers-reduced-motion: reduce) {
  [data-reveal], [data-reveal]:not(.is-in) { opacity: 1; animation: none !important; }
  .anim-breathe, .anim-sway-x, .anim-float-y, .anim-drift, .anim-glow { animation: none; }
  .gauge__fill { clip-path: none; transition: none; }
}
