:root {
  --page: #0d0d0f;
  --ink: rgb(244, 243, 240);
  --dark: #0d0d0f;
  --light: #e8e7e3;
  --muted: rgba(244, 243, 240, 0.6);
  --line: rgba(244, 243, 240, 0.16);
  --accent: #e4b93f;
  --pad: clamp(16px, 3vw, 48px);
  --ring-card: clamp(34px, 4.6vw, 84px);
  --hero-ink: #f4f3f0;  /* JS đổi theo từng cảnh của hero */
  --hero-hud: #f4f3f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--dark); }
body {
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { display: block; width: 100%; height: 100%; object-fit: cover; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
body.is-locked { overflow: hidden; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.anchor { display: block; height: 0; }

main { position: relative; z-index: 1; }

/* ---------- Lớp nền và cảnh 3D ---------- */
#stage {
  position: fixed;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.glow {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(38% 34% at 24% 44%, rgba(226, 224, 228, 0.62), transparent 72%),
    radial-gradient(30% 40% at 40% 62%, rgba(92, 150, 158, 0.34), transparent 74%);
}

/* Vệt theo con trỏ */
.cursor-trail {
  position: fixed;
  inset: 0;
  z-index: 60;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: difference;
}

/* ---------- Nav: ở hero chỉ có logo, qua hero thành thanh tối ---------- */
.nav {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: clamp(20px, 3vw, 44px);
  padding: 6px 16px;
  border-radius: 6px;
  transform: translateX(-50%);
  color: var(--hero-hud);
  font-size: 13px;
  transition: background-color 0.3s;
}
.nav.is-past-hero, .nav.is-menu-open { background: #09090b; color: #fff; }
.logo { font-weight: 800; letter-spacing: -0.02em; font-size: 17px; }
.nav-side {
  min-width: 52px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.nav.is-past-hero .nav-side, .nav.is-menu-open .nav-side { opacity: 1; visibility: visible; }
/* Nằm ngoài .nav để logo vẫn căn giữa màn hình */
.home-link {
  position: fixed;
  top: 24px;
  left: var(--pad);
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  min-height: 28px;
  color: #fff;
  mix-blend-mode: difference;
  font-size: 13px;
}

/* ---------- Menu toàn màn hình ---------- */
.menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 72px var(--pad) 32px;
  background: var(--light);
  color: #141416;
  clip-path: inset(0 0 100% 0);
  visibility: hidden;
  transition: clip-path 0.6s cubic-bezier(0.76, 0, 0.24, 1), visibility 0s 0.6s;
}
.menu.is-open {
  clip-path: inset(0);
  visibility: visible;
  transition: clip-path 0.6s cubic-bezier(0.76, 0, 0.24, 1), visibility 0s;
}
.menu nav { position: relative; display: grid; gap: clamp(8px, 2.2vh, 24px); text-align: center; }
.menu nav a {
  display: block;
  font-weight: 600;
  font-size: clamp(34px, 7.4vh, 72px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  transition: color 0.25s;
}
.menu nav a small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  color: #66666c;
}
.menu-word { position: relative; display: inline-block; }
.menu-flank, .menu-tile {
  position: absolute;
  top: 50%;
  opacity: 0;
  transition: opacity 0.25s, transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.menu-flank {
  right: calc(100% + 18px);
  width: 66px;
  height: 46px;
  transform: translateY(-50%) translateX(14px) rotate(-14deg) scale(0.8);
}
.menu-tile {
  left: calc(100% + 18px);
  display: grid;
  place-items: center;
  width: 66px;
  height: 46px;
  background: #1c1c20;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  transform: translateY(-50%) translateX(-14px) scale(0.8);
}
.menu nav a:hover, .menu nav a:focus-visible { color: #c29a1a; }
.menu nav a:hover .menu-flank, .menu nav a:focus-visible .menu-flank { opacity: 1; transform: translateY(-50%) rotate(-14deg); }
.menu nav a:hover .menu-tile, .menu nav a:focus-visible .menu-tile { opacity: 1; transform: translateY(-50%); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: #180d13;
  color: var(--hero-ink);
}
.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-title {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  top: clamp(52px, 8vh, 84px);
  display: flex;
  justify-content: space-between;
  font-size: clamp(48px, 7.2vw, 170px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}
.hero-title span { display: block; }
.hero-note, .hero-tags, .hero-burger, .hero-rule, .hero-strip { color: var(--hero-hud); }
.hero-note, .hero-tags { position: absolute; top: 27%; font-size: 10px; line-height: 1.55; }
.hero-note { left: var(--pad); }
.hero-tags { right: var(--pad); text-align: right; }
.hero-burger {
  position: absolute;
  right: var(--pad);
  top: 46%;
  display: grid;
  gap: 5px;
  width: 44px;
  height: 44px;
  place-content: center end;
}
.hero-burger i { display: block; width: 26px; height: 1px; background: currentColor; }
.hero-rule {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  top: 62%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid currentColor;
  font-size: 10px;
}
.hero-links { display: flex; gap: 18px; }
.hero-links a { padding: 6px 0; }
.hero-strip {
  position: absolute;
  left: 50%;
  bottom: 26px;
  width: min(300px, 46vw);
  transform: translateX(-50%);
}
.hero-wave { --played: 0; display: flex; align-items: flex-end; gap: 2px; height: 20px; margin-bottom: 4px; }
.hero-wave i { flex: 1; background: currentColor; opacity: 0.55; transform-origin: bottom; transform: scaleY(calc(0.35 + var(--played) * 0.65)); }
.hero-thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.hero-thumbs button {
  aspect-ratio: 16 / 9;
  min-height: 24px;
  background: rgba(255, 255, 255, 0.14) center / cover no-repeat;
  opacity: 0.6;
  transition: opacity 0.3s;
}
.hero-thumbs button[aria-current], .hero-thumbs button:hover { opacity: 1; }
.hero-next {
  position: absolute;
  right: var(--pad);
  bottom: 26px;
  width: clamp(84px, 9vw, 150px);
  padding: 4px;
  background: rgba(255, 255, 255, 0.9);
  color: #141416;
}
.hero-next img { height: auto; aspect-ratio: 16 / 9; }
/* Không có WebGL thì không có cảnh để chọn */
.hero-canvas[hidden] ~ .hero-strip, .hero-canvas[hidden] ~ .hero-next { display: none; }
.hero-next figcaption { padding: 3px 1px 0; font-size: 9px; }

/* ---------- Băng chữ chấm bi và khối hộp ---------- */
.reel {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.reel-track, .service-row {
  display: flex;
  width: max-content;
  white-space: pre;
  font-family: 'Doto', 'Be Vietnam Pro', monospace;
  font-weight: 900;
  will-change: transform;
}
.reel-track { position: relative; font-size: clamp(64px, 11vw, 200px); }
.reel-note {
  position: absolute;
  max-width: 220px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.reel-note--a { top: 18%; right: 10%; }
.reel-note--b { left: 12%; top: 24%; }
.reel-note--c { right: 22%; bottom: 14%; }

/* Vòng chữ xoay quanh thẻ ảnh */
.orbit { position: absolute; inset: 0; perspective: 1000px; }
.orbit-ring { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.orbit-ring span {
  position: absolute;
  white-space: nowrap;
  font-size: clamp(10px, 1vw, 15px);
  color: rgba(244, 243, 240, 0.72);
  backface-visibility: hidden;
}
.orbit-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(96px, 11vw, 170px);
  aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%);
}
.orbit-card img { position: absolute; inset: 0; }
.orbit-letters span {
  position: absolute;
  font-family: 'Doto', 'Be Vietnam Pro', monospace;
  font-size: clamp(64px, 9vw, 160px);
  font-weight: 900;
  line-height: 1;
}

/* ---------- Vòng ảnh các lĩnh vực ---------- */
.sectors {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.sectors-ring { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.sectors-ring img {
  position: absolute;
  left: calc(var(--ring-card) / -2);
  top: calc(var(--ring-card) / -2);
  width: var(--ring-card);
  height: var(--ring-card);
  border-radius: 4px;
  will-change: transform, opacity;
}
.sectors-head { position: relative; text-align: center; }
.sectors-head h2 {
  font-size: clamp(30px, 4.6vw, 76px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.sectors-head p { margin-top: 10px; font-size: 13px; color: var(--muted); }
.sectors-list {
  position: absolute;
  inset: auto var(--pad) 26px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Dự án bay theo chiều sâu ---------- */
.archive {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: grid;
  place-items: center;
  perspective: 1200px;
}
.archive-head { position: relative; max-width: 520px; padding: 0 var(--pad); text-align: center; }
.archive-head small { font-size: 12px; color: var(--muted); }
.archive-head h2 {
  margin-top: 12px;
  font-size: clamp(24px, 3vw, 46px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.025em;
}
.archive-stage {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  pointer-events: none;
}
.fly {
  --fly-w: clamp(220px, 34vw, 560px);
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--fly-w);
  margin-left: calc(var(--fly-w) / -2);
  margin-top: calc(var(--fly-w) * -0.36);
  will-change: transform, opacity;
}
.fly img { height: auto; aspect-ratio: 3 / 2; }
.fly figcaption, .projects figcaption { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---------- Giới thiệu năng lực: màn hình mô phỏng và các thẻ lệch nhau ---------- */
.studio { position: relative; padding: clamp(40px, 8vh, 96px) var(--pad) clamp(96px, 16vh, 200px); }
.studio-monitor { width: min(62vw, 860px); margin: 0 auto clamp(72px, 14vh, 160px); perspective: 1400px; }
.studio-screen {
  aspect-ratio: 16 / 10;
  padding: 8px;
  background: #050506;
  border-radius: 6px;
  transform-origin: 50% 100%;
}
.studio-neck { display: block; width: 9%; height: clamp(28px, 6vw, 72px); margin: 0 auto; background: linear-gradient(90deg, #17171a, #33333a, #17171a); }
.studio-foot { display: block; width: 26%; height: 6px; margin: 0 auto; border-radius: 3px 3px 0 0; background: #2a2a2f; }
.studio-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: clamp(40px, 7vw, 96px) 16px; }
.studio-item--years { grid-column: 1 / span 6; }
.studio-item--flow { grid-column: 8 / span 5; margin-top: 4vh; }
.studio-item--code { grid-column: 2 / span 5; }
.studio-item--color { grid-column: 8 / span 4; margin-top: 10vh; }
.studio-item h3 { margin-top: 14px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.studio-item > p { margin-top: 4px; max-width: 34em; font-size: 12px; line-height: 1.6; color: var(--muted); }
.studio-card { position: relative; overflow: hidden; background: #17171a; }
.studio-card--years {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 4 / 3;
  background:
    radial-gradient(60% 46% at 28% 26%, #e9e2c8 0%, transparent 70%),
    radial-gradient(70% 60% at 82% 72%, #8d8a4a 0%, transparent 72%),
    radial-gradient(90% 38% at 50% 52%, #0a0d0e 10%, transparent 78%),
    linear-gradient(120deg, #2e4a55, #171a1c 55%, #6d7a68);
}
.studio-card--years small { font-size: 11px; }
.studio-years { font-family: 'Doto', 'Be Vietnam Pro', monospace; font-size: clamp(34px, 5vw, 84px); font-weight: 900; line-height: 1; }
.studio-card--flow { display: grid; place-items: center; gap: 14px; aspect-ratio: 16 / 9; padding: 16px; }
.studio-card--flow b { padding: 3px 8px; background: #fff; color: #111; font-size: 13px; font-weight: 800; }
.studio-nodes { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(16px, 3vw, 44px); width: 100%; }
.studio-nodes::before { content: ''; position: absolute; left: 10%; right: 10%; top: 50%; height: 1px; background: rgba(244, 243, 240, 0.4); }
.studio-nodes img { position: relative; height: auto; aspect-ratio: 4 / 3; }
.studio-card--code { display: grid; grid-template-columns: 1.5fr 1fr; aspect-ratio: 16 / 9; }
.studio-card--code pre { padding: clamp(12px, 2vw, 24px); overflow: hidden; font: 500 clamp(10px, 1vw, 14px) / 1.7 ui-monospace, Menlo, monospace; color: #d9d9dc; }
.studio-card--code i { background: linear-gradient(160deg, #f4f4f2, #cfd8e6); }
.studio-card--color { display: grid; grid-template-columns: auto 1fr; gap: 10px; aspect-ratio: 5 / 4; padding: 12px; }
.studio-swatches { display: grid; grid-auto-rows: 1fr; gap: 8px; width: clamp(22px, 3vw, 40px); }
.studio-swatches i:nth-child(1) { background: #3a3a40; }
.studio-swatches i:nth-child(2) { background: #6a6a72; }
.studio-swatches i:nth-child(3) { background: #9c9ca4; }
.studio-swatches i:nth-child(4) { background: #d6d6da; }
.studio-spectrum { background: linear-gradient(90deg, #1fb6e8, #6a5cf0 38%, #f0454e 72%), linear-gradient(0deg, #e8d23a, transparent); background-blend-mode: overlay; }

/* ---------- Dịch vụ và chuyển cảnh ô vuông ---------- */
.service {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--dark);
}
.service-layer, .gallery-layer, .pixel-wipe { position: absolute; inset: 0; width: 100%; height: 100%; }
.service-layer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 76px;
}
.service-row i {
  display: inline-block;
  width: 0.62em;
  height: 0.62em;
  margin: 0 0.1em;
  border: 0.12em solid currentColor;
  border-radius: 50%;
}
.service-row--dim { font-size: clamp(16px, 2vw, 30px); color: rgba(244, 243, 240, 0.28); }
.service-row--big {
  position: absolute;
  left: 0;
  top: 50%;
  margin-top: -0.62em;
  font-size: clamp(64px, 10vw, 190px);
}
.service-info {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  bottom: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.service-info h2 { font-size: clamp(24px, 3vw, 44px); font-weight: 700; letter-spacing: -0.02em; }
.service-info ul { font-size: 13px; line-height: 1.7; text-align: right; color: var(--muted); }
.gallery-layer {
  visibility: hidden;
  display: grid;
  grid-template: 1fr 1fr / 1fr 1fr;
  gap: 2px;
  background: #000;
}
.gallery-layer img { min-height: 0; }
.pixel-wipe { pointer-events: none; }

/* ---------- Ảnh nổi bật ---------- */
.feature {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--dark);
}
.feature::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3); /* giữ chữ đọc được trên ảnh sáng */
}
.feature-text {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: 100%;
  padding: 0 var(--pad);
  transform: translate(-50%, -50%);
  text-align: center;
  text-shadow: 0 1px 24px rgba(0, 0, 0, 0.55);
}
.feature-text small { font-size: 13px; }
.feature-text h2 {
  margin-top: 8px;
  font-size: clamp(32px, 6vw, 110px);
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* ---------- Danh sách dự án ---------- */
.projects {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(32px, 6vw, 96px) 16px;
  padding: clamp(96px, 16vh, 200px) var(--pad);
  background: var(--dark);
}
.projects figure:nth-child(1) { grid-column: 2 / span 4; }
.projects figure:nth-child(2) { grid-column: 7 / span 5; margin-top: 18vh; }
.projects figure:nth-child(3) { grid-column: 1 / span 6; }
.projects figure:nth-child(4) { grid-column: 8 / span 4; margin-top: 12vh; }
.projects img { height: auto; }

/* ---------- Footer ---------- */
.footer {
  position: relative;
  z-index: 1;
  overflow: hidden;
  padding-top: clamp(64px, 12vh, 140px);
  background: var(--dark);
}
.footer-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 var(--pad);
}
.footer-top h2 {
  max-width: 14em;
  font-size: clamp(28px, 4vw, 64px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.03em;
}
.footer-top a { font-size: clamp(15px, 1.5vw, 20px); border-bottom: 1px solid currentColor; overflow-wrap: anywhere; }
.footer-bottom {
  display: flex;
  justify-content: space-between;
  margin-top: clamp(40px, 8vh, 80px);
  padding: 0 var(--pad) 20px;
  font-size: 12px;
  color: var(--muted);
}
.footer-band { padding: 16px var(--pad) 10px; background: var(--light); }
.footer-mark {
  font-size: calc((100vw - 2 * var(--pad)) / 7.9); /* chữ rộng khoảng 7,7em, vừa khít một dòng */
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.05em;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .home-link span { display: none; }
  .hero-title { flex-direction: column; font-size: 19vw; }
  .hero-title span:last-child { align-self: flex-end; }
  .hero-note, .hero-tags { top: auto; bottom: 21.5%; }
  .hero-burger { top: 44%; }
  .hero-rule { top: auto; bottom: 16%; }
  .hero-rule > span { display: none; }
  .hero-strip { left: var(--pad); width: 58vw; transform: none; }
  .reel-note { max-width: 170px; font-size: 12px; }
  .reel-note--a { top: 13%; right: var(--pad); }
  .reel-note--b { left: var(--pad); top: 24%; }
  .reel-note--c { right: var(--pad); bottom: 12%; }
  .sectors-list { display: grid; grid-template-columns: 1fr 1fr; text-align: center; }
  .service-info { flex-direction: column; align-items: flex-start; }
  .service-info ul { text-align: left; }
  .menu-flank, .menu-tile { display: none; }
  .studio-grid { grid-template-columns: 1fr; row-gap: 88px; } /* chừa chỗ cho parallax, tránh thẻ chạm nhau */
  .studio-item:nth-child(n) { grid-column: auto; margin-top: 0; }
  .projects { grid-template-columns: 1fr; }
  .projects figure:nth-child(n) { grid-column: auto; margin-top: 0; }
}

/* ---------- Giảm chuyển động: bỏ pin và 3D, nội dung xếp thẳng ---------- */
.reduced #stage, .reduced .hero-canvas, .reduced .hero-strip, .reduced .hero-next, .reduced .orbit, .reduced .cursor-trail, .reduced .sectors-ring, .reduced .pixel-wipe, .reduced .glow { display: none; }
.reduced .reel, .reduced .sectors, .reduced .archive, .reduced .service { height: auto; min-height: 60vh; padding: 96px var(--pad); overflow: hidden; }
.reduced .reel { flex-direction: column; align-items: flex-start; gap: 16px; }
.reduced .reel-note { position: static; }
.reduced .sectors-list { position: static; margin-top: 32px; }
.reduced .archive { display: block; perspective: none; }
.reduced .archive-stage {
  position: static;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  margin-top: 48px;
}
.reduced .fly { position: static; width: auto; margin: 0; }
.reduced .service-layer, .reduced .gallery-layer { position: static; visibility: visible; }
.reduced .service-row--big { display: none; }
.reduced .service-info { position: static; margin-top: 32px; }
.reduced .gallery-layer { height: 80vh; margin-top: 48px; }
.reduced .studio-screen { transform: none; }
.reduced .menu { transition: none; }
.reduced .nav { background: #09090b; }
.reduced .nav-side { opacity: 1; visibility: visible; }
