/* ==========================================================
   Solina V1 «Tĩnh lặng» – chuyển động editorial, thuần CSS + JS đo vị trí (rAF), không thư viện
   - Hero: chạy bằng CSS (không chờ JS), chỉ khi html[data-anim="v1"] và không reduce.
   - Còn lại: trạng thái ẩn chỉ áp khi JS đã gắn html.v1-ready (tắt JS / reduce: hiện ngay).
   - Chỉ animate opacity / translate / clip-path (+ transform trên ảnh ở trạng thái chờ);
     không đụng transform / rotate của chữ dọc.
   ========================================================== */
:root {
  --v1-ease: cubic-bezier(.22, 1, .36, 1);      /* chữ, fade-up */
  --v1-ease-io: cubic-bezier(.65, 0, .35, 1);   /* mở ảnh */
  --v1-ease-pen: cubic-bezier(.45, .05, .3, 1); /* nét viết tay */
}

/* Ảnh phóng 1.15 lúc chờ không được tạo tràn ngang (clip, không tạo khung cuộn, không đổi bố cục) */
html[data-anim="v1"] main { overflow-x: clip; }

/* ---------- Header: trong suốt -> be mờ, chậm hơn; ẩn khi cuộn xuống để khung hình không bị che, hiện khi cuộn lên ---------- */
html[data-anim="v1"] .site-header:not(.is-hidden) { transform: none !important; }
html[data-anim="v1"] .site-header::before { transition: opacity .7s var(--v1-ease); }
html[data-anim="v1"] .site-header { transition: color .6s var(--v1-ease), transform .45s var(--v1-ease-io); }

/* ---------- Hero: chữ trượt lên trong mặt nạ + nền thu 1.08 -> 1 ----------
   Nền gốc của .hero vẽ ngay (LCP); chỉ lớp ::before (bản sao nền) zoom. */
@keyframes v1HeroZoom { from { transform: scale(1.08); } to { transform: none; } }
/* mặt nạ: cửa sổ nhìn mở dần lên từ khoảng 2/3 khung chữ, chữ trồi lên theo.
   inset âm ở trạng thái cuối để không cắt nét bay của chữ script */
@keyframes v1MaskUp {
  from { translate: 0 105%; clip-path: inset(-60% -40% 140% -40%); }
  to   { translate: 0 0;    clip-path: inset(-60% -40% -60% -40%); }
}
/* "Art" là phần tử LCP trên mobile: không bắt đầu kín, đã lộ một phần ngay khung đầu */
@keyframes v1MaskUpSoft {
  from { translate: 0 45%; clip-path: inset(-60% -40% 55% -40%); }
  to   { translate: 0 0;   clip-path: inset(-60% -40% -60% -40%); }
}
@keyframes v1FadeUp { from { opacity: 0; translate: 0 24px; } to { opacity: 1; translate: 0 0; } }
@media (prefers-reduced-motion: no-preference) {
  html[data-anim="v1"] .hero::before { animation: v1HeroZoom 2.4s var(--v1-ease) both; }
  html[data-anim="v1"] :is(.hero__the, .hero__art, .hero__of, .hero__being) {
    animation: v1MaskUp 1.1s var(--v1-ease) both;
  }
  html[data-anim="v1"] .hero__the   { animation-delay: .05s; }
  html[data-anim="v1"] .hero__art   { animation-name: v1MaskUpSoft; animation-delay: .17s; }
  html[data-anim="v1"] .hero__of    { animation-delay: .29s; }
  html[data-anim="v1"] .hero__being { animation-delay: .41s; }
  html[data-anim="v1"] .hero__sub   { animation: v1FadeUp 1.1s var(--v1-ease) .85s both; }
  html[data-anim="v1"] :is(.hero__sig-a, .hero__sig-b, .choldings) { animation: v1FadeUp 1.1s var(--v1-ease) 1.15s both; }
  /* chữ ký "Signature": viết tay */
  html[data-anim="v1"] .hero__sig-script { animation: v1Pen 1.6s var(--v1-ease-pen) 1.25s both; }
}
@keyframes v1Pen {
  from { clip-path: inset(-40% 100% -40% -12%); }
  to   { clip-path: inset(-40% -12% -40% -12%); }
}

/* ---------- Reveal chữ: fade-up 32px, 1s ---------- */
:root:root.v1-ready .v1-up {
  transition: opacity 1s var(--v1-ease) var(--v1-d, 0ms), translate 1s var(--v1-ease) var(--v1-d, 0ms);
}
:root:root.v1-ready .v1-up:not(.v1-in) { opacity: 0; translate: 0 32px; }

/* Chữ dọc: không dịch, chỉ mở theo chiều đọc (clip trong toạ độ riêng, chữ xoay 180° vẫn đúng hướng) */
:root:root.v1-ready .v1-vert {
  transition: opacity 1.2s var(--v1-ease) var(--v1-d, 0ms), clip-path 1.6s var(--v1-ease-io) var(--v1-d, 0ms);
}
:root:root.v1-ready .v1-vert:not(.v1-in) { opacity: 0; clip-path: inset(-10% -20% 100% -20%); }
:root:root.v1-ready .v1-vert.v1-in { clip-path: inset(-10% -20% -10% -20%); }

/* ---------- Chữ script: mask «viết tay» trái -> phải, 1.6s ---------- */
:root:root.v1-ready .v1-script { transition: clip-path 1.6s var(--v1-ease-pen) var(--v1-sd, var(--v1-d, 0ms)); }
:root:root.v1-ready .v1-script:not(.v1-in) { clip-path: inset(-40% 100% -40% -12%); }
:root:root.v1-ready .v1-script.v1-in { clip-path: inset(-40% -12% -40% -12%); }

/* ---------- Ảnh lớn: clip-path trái -> phải 1.4s, ảnh trong thu 1.15 -> 1 ----------
   v1-img = khung được cắt; v1-zoom = ảnh phóng bên trong (có thể trùng khung: v1-solo). */
:root:root.v1-ready .v1-img { transition: clip-path 1.4s var(--v1-ease-io) var(--v1-d, 0ms), opacity .4s linear var(--v1-d, 0ms); }
/* opacity 0 lúc chờ: tránh vệt 1px ở mép trái khi khung đặt ở toạ độ lẻ */
:root:root.v1-ready .v1-img:not(.v1-in) { clip-path: inset(0 100% 0 0); opacity: 0; }
:root:root.v1-ready .v1-img.v1-in { clip-path: inset(0); }
:root:root.v1-ready .v1-zoom { transition: transform 1.4s var(--v1-ease-io) var(--v1-d, 0ms); }
:root:root.v1-ready .v1-img:not(.v1-in) .v1-zoom { transform: scale(1.15); }
/* khung và ảnh là một (ảnh đặt tuyệt đối trên desktop): cắt ngay trên ảnh, bù tỉ lệ 1/1.15 */
:root:root.v1-ready .v1-img.v1-solo { transition: clip-path 1.4s var(--v1-ease-io) var(--v1-d, 0ms), transform 1.4s var(--v1-ease-io) var(--v1-d, 0ms), opacity .4s linear var(--v1-d, 0ms); }
:root:root.v1-ready .v1-img.v1-solo:not(.v1-in) { clip-path: inset(6.52% 93.48% 6.52% 6.52%); transform: scale(1.15); }
/* ảnh nền phủ (signup) chỉ hiện mờ dần */
:root:root.v1-ready .v1-fade { transition: opacity 1.6s var(--v1-ease) var(--v1-d, 0ms); }
:root:root.v1-ready .v1-fade:not(.v1-in) { opacity: 0; }

/* ---------- Đường kẻ mảnh (desktop): vẽ dài ra khi vào khung ---------- */
@media (min-width: 1280px) {
  :root:root.v1-ready .stat.v1-line::before,
  :root:root.v1-ready .unit.v1-line::before,
  :root:root.v1-ready .places.v1-line::before,
  :root:root.v1-ready .contact.v1-line::after {
    transform-origin: 50% 0; transition: scale 1.4s var(--v1-ease-io) var(--v1-ld, 0ms);
  }
  :root:root.v1-ready .stat.v1-line:not(.v1-in)::before,
  :root:root.v1-ready .unit.v1-line:not(.v1-in)::before,
  :root:root.v1-ready .places.v1-line:not(.v1-in)::before,
  :root:root.v1-ready .contact.v1-line:not(.v1-in)::after { scale: 1 0; }
}

/* ---------- Số đếm: giữ chữ số cùng bề rộng ---------- */
html[data-anim="v1"] .counter { font-variant-numeric: tabular-nums; }

/* ---------- Hover ảnh: 1.04, 1.2s ---------- */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  html[data-anim="v1"] :is(.bespoke__img img, .gallery__item img, .unit img, .pe__figure img,
    .collage__item--a img, .collage__item--b img, .collage__item--d img) {
    transition: transform 1.2s var(--v1-ease), clip-path 1.2s var(--v1-ease);
  }
  html[data-anim="v1"] .bespoke__img:hover img { transform: scale(1.04); }
  html[data-anim="v1"] :is(.gallery__item, .unit, .pe__figure, .collage__item--a, .collage__item--b, .collage__item--d):hover img {
    transform: scale(1.04); clip-path: inset(1.923%);
  }
}

/* ---------- v1-done: tắt transition trong lúc dựng trạng thái đầu và khi finishAll() nhảy về trạng thái cuối ---------- */
:root:root.v1-done *, :root:root.v1-done *::before, :root:root.v1-done *::after {
  transition: none !important;
}

/* ---------- Reduced motion: không chuyển động, hiện ngay ---------- */
@media (prefers-reduced-motion: reduce) {
  :root:root.v1-ready :is(.v1-up, .v1-vert, .v1-script, .v1-img, .v1-zoom, .v1-fade) {
    opacity: 1 !important; translate: none !important; clip-path: none !important; transform: none !important; transition: none !important;
  }
}
