/* ICS Digital Twin Review – design system dùng chung cho mọi trang.
   Hướng: HUD vận hành trên nền navy, mô hình 3D là nhân vật chính, rất ít chữ.
   Khoá: một họ chữ (Be Vietnam Pro 400/700), token màu ICS, không chữ xám/nhạt,
   không giảm opacity chữ, không text-wrap: balance, không viền màu một cạnh. */

@font-face {
  font-family: "Be Vietnam Pro";
  src: url("../assets/be-vietnam-pro-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("../assets/be-vietnam-pro-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* Thương hiệu */
  --navy: #0d0e3a;
  --night: #0a0f3d;
  --deep: #060926;
  --blue: #1f4dff;
  --blue-hover: #3a63ff;
  --cyan: #00d8ff;
  --cyan-light: #5ce6ff;
  --sky: #b3d5ff;
  --ice: #d9e6ff;
  --white: #ffffff;
  /* Bề mặt và đường kẻ */
  --panel: #0e1348;
  --panel-solid: #0b103fee;
  --line: #262d7a;
  --line-strong: #3a44a8;
  /* Trạng thái: chỉ cho dữ liệu, luôn kèm nhãn chữ */
  --ok: #3ddc97;
  --warning: #ffc857;
  --risk: #ff6b5e;

  /* Thang chữ: 5 bậc cho cả site */
  --fs-display: clamp(1.75rem, 0.6rem + 5vw, 4.25rem);
  --fs-title: clamp(1.25rem, 1.05rem + 1vw, 1.75rem);
  --fs-body: 0.9375rem;
  --fs-small: 0.8125rem;
  --fs-hud: 0.6875rem;

  --gutter: clamp(16px, 4vw, 48px);
  --radius: 3px;
  --tap: 44px;
  --bar: 52px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* Thứ tự lớp */
  --z-hud: 5;
  --z-sticky: 30;
  --z-sheet: 50;
  --z-full: 60;

  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--white);
}

*, *::before, *::after { box-sizing: border-box; }
/* Chuyển trang mượt giữa trang gốc và bảng vận hành (trình duyệt hỗ trợ thì dùng, không thì bỏ qua) */
@view-transition { navigation: auto; }
::view-transition-group(vt-cover) { animation-duration: 520ms; animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }
@media (prefers-reduced-motion: reduce) { ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none; } }

html { -webkit-text-size-adjust: 100%; background: var(--deep); }
body {
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(ellipse 70% 55% at 100% 0%, #2152ff3d, transparent 70%),
    radial-gradient(ellipse 55% 45% at 0% 100%, #2152ff24, transparent 70%),
    var(--night);
  background-attachment: fixed;
  font-size: var(--fs-body);
  line-height: 1.55;
  overflow-x: hidden;
}
img, svg, canvas { display: block; max-width: 100%; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--cyan-light); outline-offset: 3px; }

.wrap { width: min(1280px, 100% - var(--gutter) * 2); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Chữ ---------- */
/* Nhãn HUD: chữ nhỏ in hoa, giãn chữ. Chỉ dùng cho nhãn kỹ thuật ngắn, không dùng cho câu. */
.hud {
  font-size: var(--fs-hud);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan-light);
}
.hud.plain { color: var(--ice); }
.display { font-size: var(--fs-display); font-weight: 700; line-height: 1.04; letter-spacing: -0.04em; }
.title { font-size: var(--fs-title); font-weight: 700; line-height: 1.2; letter-spacing: -0.025em; }
.body { color: var(--ice); }
.small { font-size: var(--fs-small); color: var(--ice); }
.num { font-weight: 700; letter-spacing: -0.03em; line-height: 1; }

/* ---------- Thanh trên ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  height: var(--bar);
  border-bottom: 1px solid var(--line);
  background: var(--deep);
}
.topbar .wrap { display: flex; align-items: center; gap: 14px; height: 100%; }
.brand { display: flex; align-items: center; gap: 14px; min-height: var(--tap); flex: none; }
.brand img { width: 58px; height: 26px; object-fit: contain; }
.brand .hud { padding-left: 14px; border-left: 1px solid var(--line); }
.topbar .spacer { flex: 1; }
.back { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: var(--tap); min-height: var(--tap); padding-inline: 4px; }
.back svg { width: 16px; height: 16px; }
.back:hover { color: var(--white); }

.lang { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: var(--radius); }
.lang button {
  min-width: var(--tap); min-height: var(--tap); padding-inline: 8px;
  font-size: var(--fs-hud); font-weight: 700; letter-spacing: 0.12em; color: var(--ice);
}
.lang button[aria-pressed="true"] { background: var(--blue); color: var(--white); }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 10px 18px;
  border: 1px solid var(--blue); border-radius: var(--radius);
  background: var(--blue); color: var(--white);
  font-size: var(--fs-small); font-weight: 700; line-height: 1.2;
  transition: background-color 220ms var(--ease), border-color 220ms var(--ease);
}
.btn:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.btn.ghost { background: transparent; border-color: var(--line-strong); }
.btn.ghost:hover { border-color: var(--cyan-light); background: transparent; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- Trang tổng quan ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 48px; align-items: end; padding-block: clamp(28px, 6vw, 80px) clamp(22px, 3.4vw, 44px); }
.hero .display { margin-top: 12px; max-width: 16ch; }
.hero .display em { font-style: normal; color: var(--cyan-light); }
.hero .body { margin-top: 14px; max-width: 46ch; font-size: clamp(1rem, 0.95rem + 0.35vw, 1.1875rem); }

.scan { display: grid; grid-template-columns: auto auto; gap: 14px; align-items: end; }
.scan .qr { width: 132px; height: 132px; padding: 8px; background: var(--white); border-radius: var(--radius); }
.scan .qr svg { width: 100%; height: 100%; }
.scan p { max-width: 12ch; font-size: var(--fs-small); font-weight: 700; line-height: 1.35; }

.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(10px, 1.2vw, 16px); padding-bottom: clamp(28px, 5vw, 64px); }
.tile {
  position: relative; display: block; overflow: hidden;
  grid-column: span 2; aspect-ratio: 0.86;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--deep);
  transition: border-color 260ms var(--ease);
}
.tile.lead { grid-column: span 6; aspect-ratio: 2.7; }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 700ms var(--ease); }
.tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, #060926 10%, #060926f2 46%, #06092600 82%); }
.tile.lead::after { background: linear-gradient(to right, #060926 0%, #060926d9 34%, #06092600 70%); }
.tile:hover, .tile:focus-visible { border-color: var(--cyan-light); }
.tile:hover img { transform: scale(1.04); }
.tile-index { position: absolute; z-index: 1; left: 12px; top: 12px; display: grid; place-items: center; height: 36px; padding-inline: 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--deep); }
.tile-open {
  position: absolute; z-index: 1; right: 12px; top: 12px;
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--deep);
  transition: background-color 260ms var(--ease), border-color 260ms var(--ease);
}
.tile-open svg { width: 16px; height: 16px; }
.tile:hover .tile-open { background: var(--blue); border-color: var(--blue); }
.tile-text { position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; display: grid; gap: 4px; padding: clamp(14px, 1.6vw, 22px); }
.tile.lead .tile-text { top: 0; right: auto; width: min(100%, 460px); align-content: end; }
.tile-text .title { font-size: clamp(1.25rem, 1rem + 1.1vw, 1.875rem); }
.tile.lead .title { font-size: clamp(1.6rem, 1.1rem + 2.4vw, 3rem); letter-spacing: -0.035em; line-height: 1.05; }
.tile-stats { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.tile-stats li { display: flex; align-items: baseline; gap: 6px; font-size: var(--fs-small); color: var(--ice); }
.tile-stats b { font-size: 1.125rem; letter-spacing: -0.02em; color: var(--white); }

.footer { border-top: 1px solid var(--line); padding-block: 18px; }
.footer .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; }
.footer img { width: 58px; height: 26px; object-fit: contain; }

/* ---------- Trình xem 3D ---------- */
.viewer { display: grid; grid-template-rows: minmax(0, 1fr) auto; height: calc(100svh - var(--bar)); min-height: 460px; }
.stage { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(ellipse 90% 60% at 50% 112%, #2152ff3d, transparent 70%), linear-gradient(#0a0f3d, #060926); touch-action: none; }
.stage canvas { width: 100%; height: 100%; cursor: grab; outline-offset: -3px; }
.stage canvas:active { cursor: grabbing; }
.stage.is-full { position: fixed; inset: 0; z-index: var(--z-full); }

/* Khung ngắm bốn góc: dấu hiệu nhận diện của màn hình vận hành */
.stage::before, .stage::after { content: ""; position: absolute; z-index: var(--z-hud); width: 18px; height: 18px; pointer-events: none; border: 0 solid var(--cyan); }
.stage::before { left: 10px; bottom: 10px; border-left-width: 1px; border-bottom-width: 1px; }
.stage::after { right: 10px; bottom: 10px; border-right-width: 1px; border-bottom-width: 1px; }

.stage-id { position: absolute; z-index: var(--z-hud); left: var(--gutter); top: 14px; right: 72px; display: grid; gap: 2px; pointer-events: none; }
/* Nền tối dần phía sau tên mô hình để chữ luôn đọc được trên mô hình sáng màu */
.stage-id::before { content: ""; position: absolute; z-index: -1; inset: -14px -72px -44px calc(var(--gutter) * -1); background: linear-gradient(#060926f2 20%, #06092600); }
.stage-id .title { font-size: clamp(1.25rem, 1rem + 1.6vw, 2.125rem); letter-spacing: -0.03em; }
.stage-id .small { color: var(--ice); }

.tools { position: absolute; z-index: var(--z-hud); right: 12px; top: 12px; display: grid; gap: 6px; }
.tool {
  display: grid; place-items: center; width: var(--tap); height: var(--tap);
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-solid);
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease);
}
.tool:hover { border-color: var(--cyan-light); }
.tool[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); }
.tool svg { width: 20px; height: 20px; }

.toggles { position: absolute; z-index: var(--z-hud); left: var(--gutter); bottom: 14px; right: 64px; display: flex; flex-wrap: wrap; gap: 6px; }
.toggle {
  min-height: var(--tap); padding: 6px 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-solid);
  font-size: var(--fs-small); font-weight: 700;
}
.toggle:hover { border-color: var(--cyan-light); }
.toggle[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); }

.hint {
  position: absolute; z-index: var(--z-hud); left: 50%; bottom: 66px; translate: -50% 0;
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel-solid);
  font-size: var(--fs-small); font-weight: 700; white-space: nowrap; pointer-events: none;
  transition: opacity 500ms var(--ease);
}
.hint.is-gone { opacity: 0; }

.loading { position: absolute; z-index: var(--z-hud); inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; background: #060926e6; }
.loading .num { font-size: clamp(2.5rem, 2rem + 3vw, 4rem); }
.loading .bar { width: min(220px, 56vw); height: 2px; background: var(--line); }
.loading .bar i { display: block; height: 100%; width: 0; background: var(--cyan); transition: width 160ms linear; }

/* Dải chọn mô hình dưới sân khấu */
.dock { min-width: 0; border-top: 1px solid var(--line); background: var(--deep); padding: 10px 0 max(10px, env(safe-area-inset-bottom)); }
.dock-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-inline: var(--gutter); scroll-snap-type: x proximity; }
.dock-row::-webkit-scrollbar { display: none; }
.pick {
  flex: none; scroll-snap-align: start; display: grid; gap: 1px; align-content: center; text-align: left;
  min-height: var(--tap); padding: 6px 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  font-size: var(--fs-small); font-weight: 700; line-height: 1.25;
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease);
}
.pick:hover { border-color: var(--sky); }
.pick[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); }
.pick .hud { color: var(--cyan-light); letter-spacing: 0.12em; }
.pick[aria-pressed="true"] .hud { color: var(--white); }
.dock.is-single { display: none; }
.side-brief { display: none; }

/* ---------- Phần tóm tắt dưới trình xem ---------- */
.brief { display: grid; gap: clamp(22px, 3.2vw, 40px); padding-block: clamp(26px, 4.4vw, 60px); }
.brief-lead { display: grid; gap: 10px; }
.brief-lead .title { max-width: 30ch; font-size: clamp(1.25rem, 0.9rem + 1.9vw, 2.375rem); letter-spacing: -0.03em; line-height: 1.12; }
.brief-lead .body { max-width: 60ch; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border-block: 1px solid var(--line); }
.stat { display: grid; gap: 6px; align-content: start; padding: 18px 16px 18px 0; }
.stat .num { font-size: clamp(1.9rem, 1.4rem + 2.2vw, 3rem); }
.stat .small { max-width: 20ch; }

.points { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px clamp(18px, 3vw, 40px); counter-reset: p; }
.point { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 2px 12px; counter-increment: p; }
.point::before { content: counter(p, decimal-leading-zero); grid-row: span 2; padding-top: 3px; font-size: var(--fs-hud); font-weight: 700; letter-spacing: 0.12em; color: var(--cyan-light); }
.point h3 { font-size: 1rem; line-height: 1.3; }
.point p { font-size: var(--fs-small); color: var(--ice); }

.fold { border-top: 1px solid var(--line); }
.fold summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); cursor: pointer; list-style: none; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary svg { width: 16px; height: 16px; transition: rotate 260ms var(--ease); }
.fold[open] summary svg { rotate: 45deg; }
.fold ul { display: grid; gap: 8px; padding-bottom: 16px; max-width: 80ch; }
.fold li { font-size: var(--fs-small); color: var(--ice); overflow-wrap: anywhere; }

.others { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.other { display: grid; gap: 2px; min-height: 64px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); transition: border-color 220ms var(--ease); }
.other:hover { border-color: var(--cyan-light); }
.other b { font-size: 1rem; line-height: 1.25; }
.brief-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Màn hình rộng ---------- */
@media (min-width: 1000px) {
  :root { --bar: 56px; }
  .viewer { grid-template-rows: none; grid-template-columns: minmax(0, 1fr) 300px; }
  .dock { border-top: 0; border-left: 1px solid var(--line); padding: 16px 0; overflow-y: auto; }
  .dock-row { flex-direction: column; overflow: visible; padding-inline: 16px; }
  .pick { width: 100%; }
  .dock.is-single { display: block; }
  .dock.is-single .dock-row { display: none; }
  .side-brief { display: grid; gap: 20px; padding: 20px 16px 0; margin-top: 16px; border-top: 1px solid var(--line); }
  .dock.is-single .side-brief { margin-top: 0; padding-top: 4px; border-top: 0; }
  .side-brief .title { font-size: 1.25rem; line-height: 1.25; }
  .side-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 14px; padding-top: 18px; border-top: 1px solid var(--line); }
  .side-stats li { display: grid; gap: 6px; align-content: start; }
  .side-stats .num { font-size: 1.75rem; }
  .has-side-brief .brief-lead, .has-side-brief .stats { display: none; }
  .tile.lead { aspect-ratio: 3.1; }
  .stage-id { top: 20px; }
  .tools { right: 16px; top: 16px; }
}

/* ---------- Điện thoại ---------- */
@media (max-width: 999px) {
  .viewer { height: calc(100svh - var(--bar) - 96px); }
  .brief { padding-top: 20px; }
}

@media (max-width: 760px) {
  .brand .hud { display: none; }
  .hero { grid-template-columns: 1fr; }
  .scan { display: none; }
  .tiles { grid-template-columns: 1fr; }
  .tile, .tile.lead { grid-column: auto; aspect-ratio: 1.5; }
  .tile.lead { aspect-ratio: 1.1; }
  .tile.lead::after { background: linear-gradient(to top, #060926 4%, #060926cc 34%, #06092600 70%); }
  .tile.lead .tile-text { top: auto; right: 0; width: auto; }
  .back span { display: none; }
}

/* Màn hình cảm ứng: không giữ viền hover sau khi chạm */
@media (hover: none) {
  .tool:hover, .toggle:hover, .pick:hover { border-color: var(--line); }
  .tool[aria-pressed="true"]:hover, .toggle[aria-pressed="true"]:hover, .pick[aria-pressed="true"]:hover { border-color: var(--blue); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .tile:hover img { transform: none; }
}

/* ---------- Bổ sung cho bảng vận hành (product.html, css/ops.css) ---------- */
:root {
  --z-label: 3;   /* nhãn bám mô hình, dưới lớp phủ HUD của sân khấu */
  --z-panel: 40;  /* bảng trượt và bảng thu gọn trên sân khấu */
  --z-toast: 80;  /* thông báo ngắn */
  --fill-blue: color-mix(in srgb, var(--blue) 24%, transparent); /* nền vùng dưới đường biểu đồ */
}
