/* ============================================================
   LOGIN "HORIZON" v8 — Bình minh động + bánh xe bộ phận + ánh kim quét
   ------------------------------------------------------------
   - Nền: lớp đêm tím tĩnh (::before) + lớp bình minh .yl-dawn cao 260vh
     do JS translateY theo tiến trình cuộn (P) — cam dâng dần lên,
     CEO = rực sáng nhưng vẫn chừa tím trên đỉnh.
   - Bộ phận: bánh xe đứng (perspective + rotateX), KHÔNG chạm logo.
   - Ánh kim: 1 làn sóng 6s quét slogan trái → cụm giữa → slogan phải.
   - ĐÃ BỎ: DEMO badge, hint SCROLL, counter, 点击登录, chữ EN phụ.
   UI layer KHÔNG transform → cluster/conveyor/slogan neo đúng viewport.
   ============================================================ */

/* Khi màn login đang active → khoá cuộn body */
body.login-active { overflow: hidden; }

/* Chữ Hán trang đăng nhập: Noto Serif SC 600 (宋体 trang trọng, đầu nét hơi thư pháp;
   SIL OFL 1.1), tự host và chỉ cắt đúng các chữ dùng ở màn này. */
@font-face {
  font-family: 'YDX Hanzi'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../assets/fonts/notoserifsc-600-login-zh.woff2') format('woff2');
  unicode-range: U+0020, U+00B7, U+4E1C, U+4E8B, U+4EBA, U+5165, U+516C, U+5173, U+535A, U+53F7, U+573A, U+5BBE, U+5BC6, U+5E02, U+5F08, U+5F55, U+623F, U+65FA, U+6765, U+6C14, U+767B, U+7801, U+793C, U+8D26, U+8F93, U+90E8, U+9F0E;
}
/* Ánh kim sáng đều từ trên xuống (không còn đáy nâu tối) + viền tối mờ để chữ
   vẫn rõ trên cả nền tím đêm lẫn nền cam bình minh. */
#login {
  --yl-gold: linear-gradient(180deg, #fff6d2 0%, #f8dc84 36%, #ecc04a 72%, #d4a032 100%);
  --yl-shine: rgba(255, 252, 235, 0);
  --yl-lift: drop-shadow(0 0 14px rgba(255, 205, 100, .4));
}
#login { --yl-hanzi: 'YDX Hanzi', 'Noto Serif SC', 'Songti SC', 'SimSun', serif; }

.backend-status {
  position: fixed; inset: 0; z-index: 120;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 50% 70%, rgba(116, 67, 108, .34), transparent 45%),
    linear-gradient(180deg, #150e30, #38204d 70%, #533560);
  color: #fdf3cf; text-align: center;
}
.backend-status-card {
  width: min(420px, 100%); padding: 28px 24px;
  border: 1px solid rgba(243, 213, 118, .34); border-radius: 18px;
  background: rgba(35, 17, 49, .82); box-shadow: 0 24px 70px rgba(15, 6, 28, .5);
}
.backend-status-mark {
  width: 30px; height: 30px; margin: 0 auto 16px; border-radius: 50%;
  border: 2px solid rgba(243, 213, 118, .22); border-top-color: var(--gold-l);
  animation: backendStatusSpin .8s linear infinite;
}
.backend-status p { margin: 0; font-size: 15px; line-height: 1.6; }
.backend-status button {
  margin-top: 18px; min-width: 120px; padding: 10px 18px;
  border: 1px solid var(--gold); border-radius: 10px; cursor: pointer;
  background: linear-gradient(180deg, var(--gold-l), var(--gold));
  color: #2a1c02; font: inherit; font-weight: 800;
}
.backend-status[data-state="error"] .backend-status-card { border-color: rgba(255, 110, 110, .55); }
.backend-status[data-state="error"] .backend-status-mark {
  border: 0; animation: none; color: #ff8e8e; font-size: 28px;
}
.backend-status[data-state="error"] .backend-status-mark::before { content: "!"; }
@keyframes backendStatusSpin { to { transform: rotate(360deg); } }

#login {
  position: fixed; inset: 0; z-index: 100; overflow: hidden;
}

/* ---------- LỚP ĐÊM TÍM TĨNH (nền gốc, không còn cam ở đây) ---------- */
#login::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(180deg,
    #150e30 0%, #241546 26%, #33204f 48%,
    #3f2757 68%, #4a2c5c 84%, #533560 100%);
}

/* ---------- LỚP BÌNH MINH — cao 260vh, JS đẩy lên theo P ----------
   Đỉnh lớp = trong suốt (giữ tím), càng xuống càng cam → đáy vàng rực.
   Kèm 1 quầng mấp mé gần đỉnh lớp (thấy ở trang bìa) + mặt trời ở ~79%. */
/* Quy chiếu: layer cao 260vh, JS dịch translateY từ -6vh (bìa) → -150vh (CEO).
   → khung nhìn (100vh) ở BÌA = layer-local [6,106]vh = [2.3%,40.8%];
      khung nhìn ở CEO = layer-local [150,250]vh = [57.7%,96.2%].
   Mốc gradient đặt ĐÚNG theo 2 khung này: đỉnh(0-2%) trong suốt hẳn (giữ
   tím) → 40% ấm nhẹ ("mấp mé cam" = đáy khung nhìn ở bìa) → 58% (đỉnh
   khung nhìn ở CEO, đã ấm) → 96% rực nhất (đáy khung nhìn ở CEO). */
/* Dải sáng NÉN LẠI theo yêu cầu mới: trang bìa gần như TÍM TOÀN BỘ (layer bị
   đẩy xuống +48vh, chỉ mấp mé đáy), đỉnh sáng nhất (CEO, shift -92vh, khung
   nhìn = layer [35.4%,73.8%]) chỉ bằng mức 服务部 của bản trước — dịu, không
   chói. Vùng 27%→33% là "CHÂN TRỜI" chuyển tiếp hẹp tím↔cam — ranh giới mờ
   thấy được, trượt lên theo tay cuộn. Mặt trời đặt 54.5% = tâm khung nhìn CEO. */
.yl-dawn {
  position: absolute; left: 0; top: 0; width: 100%; height: 260vh;
  z-index: 0; pointer-events: none; will-change: transform;
  background:
    linear-gradient(180deg,
      rgba(90, 50, 96, 0) 0%, rgba(90, 50, 96, 0) 6%, rgba(150, 75, 95, .1) 18%,
      rgba(172, 82, 92, .22) 27%, rgba(196, 96, 82, .4) 33%,
      rgba(210, 110, 78, .5) 44%, rgba(226, 132, 84, .6) 56%,
      rgba(240, 158, 98, .72) 70%, rgba(250, 184, 120, .82) 84%,
      rgba(255, 212, 150, .9) 100%);
}

/* ---------- SLIVER TÍM ĐẢM BẢO — luôn còn 1 dải tím trên đỉnh, kể cả
   lúc .yl-dawn kéo lên xa nhất (CEO). Độc lập, không cần tính tay
   translateY chính xác tuyệt đối của .yl-dawn. ---------- */
#login::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(180deg, rgba(21,14,48,.5) 0%, rgba(21,14,48,0) 9vh);
}

/* ---------- Canvas 3D: fixed, trong suốt ---------- */
#login .yl-canvas {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
}

/* ---------- UI LAYER ---------- */
#login .yl-ui {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
}
#login .yl-ui .interactive { pointer-events: auto; }

/* ==============================================================
   ÁNH KIM 1 ĐƯỜNG CHÉO — mỗi 6s quét 1 lượt: slogan TRÁI → tên công ty →
   tên bộ phận → slogan PHẢI, theo hướng góc trên-trái xuống góc dưới-phải.
   Dải sáng nghiêng 45° (gradient 135deg), phần tử nào cũng dùng chung chu
   kỳ 6s, chỉ khác animation-delay để nối thành MỘT đường chạy liên tục.

   Toán background-position: background-size 240% nên ảnh RỘNG hơn khung →
   offset = pos% × (khung − ảnh) < 0 khi pos tăng ⇒ pos GIẢM = dải chạy
   THUẬN chiều (trái→phải / trên→dưới). Vì vậy chạy 240% → −140%, ngược
   với bản cũ (−140% → 240%) vốn quét ngược phải→trái.
   Lớp shine đè lên lớp gradient vàng, cùng clip vào chữ; mỗi chặng quét
   hết 26% chu kỳ (~1.56s) rồi nghỉ tới vòng sau.
   ============================================================== */
@keyframes ylShineX {          /* chữ NẰM NGANG: quét trái → phải */
  0%   { background-position: 240% 0, 0 0; }
  26%  { background-position: -140% 0, 0 0; }
  100% { background-position: -140% 0, 0 0; }
}
@keyframes ylShineY {          /* chữ DỰNG ĐỨNG: quét trên → dưới */
  0%   { background-position: 0 240%, 0 0; }
  26%  { background-position: 0 -140%, 0 0; }
  100% { background-position: 0 -140%, 0 0; }
}

/* ==============================================================
   CỤM LOGO (trên) — cover TO (scale 1.45 do JS), dept thu về 1.0
   ============================================================== */
.yl-cluster {
  position: absolute; left: 50%; top: 0; z-index: 8;
  transform: translateX(-50%);       /* JS set thêm Y + scale */
  transform-origin: 50% 0;           /* scale nở từ đỉnh — tâm logo tính được chính xác */
  display: flex; flex-direction: column; align-items: center;
  width: max-content; max-width: 92vw;
  pointer-events: none;
  will-change: transform;
}

.yl-logo {
  display: flex; flex-direction: column; align-items: center; gap: 4px;   /* sát logo hơn (fix11) */
  text-align: center;
  transition: gap .4s var(--ease-out);
}

/* ĐÃ XOÁ .yl-sweep (thanh sáng quét riêng của logo — thủ phạm "vệt sáng
   vuông bao phủ" quanh logo khi bị chụp giữa nhịp quét). Ánh kim vẫn còn
   trên slogan/tên/bộ phận. Emblem.png đã crop sát hình (bỏ đệm 60px đẩy
   tên ra xa) + diệt nền ma alpha<30 → crest theo TỈ LỆ THẬT của ảnh. */
.yl-crest {
  position: relative;
  width: clamp(120px, 25vmin, 240px);
  pointer-events: none;
}
.yl-crest img {
  width: 100%; height: auto; display: block; position: relative; z-index: 1;
  filter: drop-shadow(0 8px 28px rgba(212,175,55,.22));
}

.yl-name { display: flex; flex-direction: column; align-items: center; gap: 4px; transform-origin: top center; }
.yl-name .cnbig {
  font-family: var(--yl-hanzi); font-synthesis: none;
  font-size: clamp(38px, 5.4vmin, 64px); font-weight: 600; letter-spacing: .16em;
  background-image:
    linear-gradient(135deg, var(--yl-shine) 44%, rgba(255,252,235,.8) 50%, var(--yl-shine) 56%),
    var(--yl-gold);
  background-size: 240% 100%, 100% 100%;
  background-position: -140% 0, 0 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: var(--yl-lift);
  /* chặng 2/4 (tên công ty nằm CAO hơn tên bộ phận nên sáng trước) */
  animation: ylShineX 6s linear .47s infinite;
}

/* ==============================================================
   BÁNH XE BỘ PHẬN — giữa màn, quỹ đạo trống quay (perspective+rotateX)
   Hành trình dọc ngắn (~26%H), KHÔNG bao giờ chạm logo.
   ============================================================== */
.yl-conveyor {
  position: fixed; inset: 0; z-index: 7; pointer-events: none;
  perspective: 900px; perspective-origin: 50% 50%;
}
.yl-conv-item {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center;
  /* width:max-content — absolute + left:50% sẽ chặn shrink-to-fit còn nửa
     màn, khiến chữ CJK bọc dòng trên màn hẹp (bài học fix8) */
  width: max-content; max-width: 94vw;
  text-align: center; opacity: 0; pointer-events: none;
  will-change: transform, opacity;
}
.cv-title {
  position: relative; cursor: pointer;
  font-family: var(--yl-hanzi); font-synthesis: none; font-weight: 600;
  /* nhỏ thêm một nấc nữa (yêu cầu fix11) */
  font-size: clamp(78px, 21vmin, 188px); line-height: 1; letter-spacing: .06em;
  white-space: nowrap;
  background-image:
    linear-gradient(135deg, var(--yl-shine) 44%, rgba(255,252,235,.8) 50%, var(--yl-shine) 56%),
    var(--yl-gold);
  background-size: 240% 100%, 100% 100%;
  background-position: -140% 0, 0 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  /* chặng 3/4 của đường chéo */
  animation: ylShineX 6s linear .95s infinite;
  filter: var(--yl-lift);
  transition: filter 0.2s;
}
.cv-title:hover { filter: var(--yl-lift) brightness(1.1); }
.cv-title.lat {
  font-family: 'YDX Serif', Georgia, serif; font-weight: 700;
  font-size: clamp(84px, 22vmin, 198px); letter-spacing: .04em;
}

/* ==============================================================
   SLOGAN CÂU ĐỐI — 旺气东来 TRÁI, 博弈之鼎 PHẢI (anh Đăng đổi lại 25/07)
   Trái mở đường ánh kim (0s), phải khép đường (1.9s). Các mốc delay
   0 / .47 / .95 / 1.9s đặt theo ĐÚNG tỉ lệ khoảng cách thật trên màn
   dọc trục chéo (x+y): slogan trái 560 → tên cty 850 → bộ phận 1150 →
   slogan phải 1740, nên ánh sáng chạy đều tay, không bị hụt nhịp.
   Chữ dựng đứng nên dải sáng quét DỌC (ylShineY): background-size đổi
   thành 100% 240% và background-position dịch theo trục Y.
   ============================================================== */
.yl-edge {
  position: fixed; top: 50%; z-index: 6;
  transform: translateY(-50%);
  writing-mode: vertical-rl; text-orientation: upright;
  font-family: var(--yl-hanzi); font-synthesis: none;
  font-size: clamp(34px, 6vmin, 58px); font-weight: 600; letter-spacing: .55em;
  background-image:
    linear-gradient(135deg, var(--yl-shine) 44%, rgba(255,252,235,.8) 50%, var(--yl-shine) 56%),
    var(--yl-gold);
  background-size: 100% 240%, 100% 100%;
  background-position: 0 -140%, 0 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: ylShineY 6s linear infinite;
  pointer-events: none;
  filter: var(--yl-lift);
}
/* chặng 1/4 và 4/4 của đường chéo */
.yl-edge.l { left: clamp(20px, calc(50vw - 600px), 9vw); animation-delay: 0s; }
.yl-edge.r { right: clamp(20px, calc(50vw - 600px), 9vw); animation-delay: 1.9s; }

/* ==============================================================
   FORM ĐĂNG NHẬP — thế đúng chỗ item bánh xe, backdrop mờ nhẹ
   ============================================================== */
.yl-formwrap {
  position: fixed; inset: 0; z-index: 15; display: none;
}
.yl-formwrap.open { display: block; }
.yl-formwrap .backdrop {
  position: absolute; inset: 0;
  /* KHÔNG blur/tối nền (anh Đăng bỏ) — chỉ là lớp bắt click-để-đóng vô hình */
  background: transparent;
}
.yl-formwrap .panel {
  position: absolute;
  transform: translateX(-50%);          /* chỉ căn giữa ngang; JS neo TOP */
  width: 100%;
}
@keyframes ylFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Bảng GỌN TINH TẾ, thuần Trung (fix13): chỉ tên bộ phận + 2 ô + nút.
   Vẫn tông mận-tím ấm trong mờ + viền chỉ vàng đồng bộ bình minh. */
.yl-form {
  width: min(320px, calc(100vw - 40px));
  margin: 0 auto;
  background: linear-gradient(168deg, rgba(74, 38, 78, .88) 0%, rgba(46, 24, 58, .92) 55%, rgba(38, 19, 50, .94) 100%);
  border: 1px solid rgba(243, 213, 118, .38);
  border-radius: var(--r-xl);
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 200, .18),
    0 0 0 1px rgba(60, 30, 70, .35),
    0 18px 60px rgba(30, 12, 40, .55),
    0 0 34px rgba(243, 180, 90, .14);
  padding: var(--sp-5) var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3);
}
.yl-form .who { display: flex; align-items: center; margin-bottom: 2px; }
.yl-form .who b {
  font-family: var(--yl-hanzi); font-synthesis: none; font-weight: 600;
  font-size: 22px; letter-spacing: .18em;
  background: var(--yl-gold);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.yl-form .who .x {
  margin-left: auto; background: none; border: 0; color: rgba(243, 213, 118, .5);
  font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: var(--r-sm);
}
.yl-form .who .x:hover { color: var(--gold-l); background: rgba(243, 213, 118, .1); }

.yl-field { display: flex; flex-direction: column; gap: 5px; }
.yl-field .label {
  font-size: var(--fs-label); font-weight: 700; letter-spacing: .22em;
  color: rgba(243, 213, 118, .6);
}
.yl-field .inp {
  height: 38px; padding: 0 var(--sp-3); border-radius: var(--r-md);
  background: rgba(20, 9, 30, .55); border: 1px solid rgba(243, 213, 118, .22);
  color: #fdf3cf; font-family: var(--mono); font-size: 15px;
  transition: border-color var(--mo-fast), box-shadow var(--mo-fast);
}
.yl-field .inp:focus {
  outline: none; border-color: rgba(243, 213, 118, .75);
  box-shadow: 0 0 0 3px rgba(243, 213, 118, .16);
}
.yl-field .inp::placeholder { color: rgba(243, 213, 118, .35); font-size: 13px; }
.yl-field .inp.shake { animation: shake .28s var(--ease-io); }

.yl-form .lerr { color: var(--bad); font-size: var(--fs-label); min-height: 15px; }
.yl-form #yl-go {
  font-size: 15px; letter-spacing: .3em; text-indent: .3em; margin-top: 2px;
}

/* ==============================================================
   NI HAO! — 10 nét SVG vẽ tay riêng biệt (xem NIHAO_STROKES trong JS),
   viết tuần tự bằng stroke-dashoffset do gsap lái trong playTransition
   (fix15, thay bản mask-sweep chữ ký cursive của fix13).
   ============================================================== */
.yl-nihao {
  position: fixed; left: 50%; top: 50%; z-index: 9;
  transform: translate(-50%, -52%);
  width: clamp(360px, 70vmin, 880px); height: auto;
  overflow: visible; pointer-events: none;
  opacity: 0;
}
/* Nét bút: MỎNG ĐỀU tuyệt đối — không có chỗ đậm chỗ mảnh như phông
   thư pháp cũ. Đầu và khớp nét bo tròn để ra cảm giác bút bi/bút gel. */
.yl-ink {
  fill: none; stroke: #fff; stroke-width: 6.5;
  stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, .5));
}

/* ==============================================================
   RESPONSIVE
   ============================================================== */
@media (max-width: 720px) {
  .yl-edge.l { left: 10px; }
  .yl-edge.r { right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .yl-name .cnbig, .cv-title, .yl-edge { animation: none !important; }
  .cv-title { transition: none; }
}
