:root {
  --bg: #0b0a1c;
  --surface: #15132b;
  --surface-2: #221d48;
  --ink: #e9edf3;
  --muted: #8891a1;
  --accent: #5a9bfc;
  --accent-ink: #0b0a1c;

  --font: 'Be Vietnam Pro', system-ui, sans-serif;
  --step-small: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --step-lead: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --step-head: clamp(1.75rem, 1.4rem + 1vw, 2.25rem);
  --step-display: clamp(2.75rem, 7.2vw, 7.5rem);

  --margin: clamp(20px, 4.5vw, 72px);
  --section: clamp(120px, 14vw, 200px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-body);
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ol, ul { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: transparent; transition: text-decoration-color .2s; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--accent); color: var(--accent-ink); }
code { font-size: .9em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

h2 { font-size: var(--step-head); font-weight: 600; letter-spacing: -0.04em; line-height: 0.95; }
h3 { font-size: var(--step-body); font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 28px;
  font: 600 var(--step-body)/1 var(--font);
  color: var(--accent-ink); background: var(--accent);
  border: 0; border-radius: 0; cursor: pointer;
  transition: transform .15s var(--ease-out), background-color .2s, opacity .2s;
}
.btn:hover { background: #7cb1ff; }
.btn:active { transform: scale(.97); }
.btn:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.btn--quiet { background: var(--surface-2); color: var(--ink); }
.btn--quiet:hover { background: #2e2766; }

/* ---------- Màn đầu ---------- */
.hero {
  position: relative; isolation: isolate;
  min-height: 100svh;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto 1fr auto;
  align-content: space-between;
  gap: clamp(12px, 2vh, 24px) 24px;
  padding: 28px var(--margin) 36px;
}
.hero__sky {
  /* Cố định theo khung nhìn, cao bằng khung nhìn lớn nhất: nội dung màn đầu cao thấp hay thanh địa chỉ
     điện thoại ẩn hiện đều không làm nền đổi cỡ. */
  position: fixed; inset: 0 0 auto 0; height: 100vh; height: 100lvh; z-index: -2;
  overflow: hidden; background: #120c3a;
}
/* Lớp ảnh lặp ngang: trôi bằng translate3d do GPU ghép, không vẽ lại. */
.sky-layer {
  position: absolute; top: 0; left: 0; height: 100%;
  background-repeat: repeat-x; background-position: 0 0;
  will-change: transform; opacity: 0; transition: opacity .8s ease;
}
.sky-overlay { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .8s ease; }
.hero__sky.is-ready .sky-layer, .hero__sky.is-ready .sky-overlay { opacity: 1; }
/* Mép dưới của bầu trời chìm vào nền trang; tiêu đề có lớp tối nhẹ phía sau để đọc được. */
.hero::after {
  content: ''; position: absolute; inset: auto 0 0 0; height: 28%; z-index: -1; pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--bg));
}
/* Lớp tối dưới chữ: góc trên trái (tiêu đề) và đáy (ô câu hỏi), để chữ đọc được trên nền tranh. */
.hero::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 42% at 22% 12%, rgba(8, 5, 26, .72), transparent 70%),
    linear-gradient(to top, rgba(8, 5, 26, .85) 0%, rgba(8, 5, 26, .35) 26%, transparent 42%);
}
.hero__title, .wordmark, .corner--tr a, .strip__status, .ask label { text-shadow: 0 2px 18px rgba(5, 4, 20, .95), 0 0 4px rgba(5, 4, 20, .8); }
.corner { font-size: var(--step-small); font-weight: 500; }
.corner--tr { display: flex; gap: 24px; }
.wordmark { font-weight: 600; font-size: var(--step-body); }
.hero__title {
  grid-column: 1 / -1;
  font-size: var(--step-display);
  font-weight: 600; letter-spacing: -0.045em; line-height: 0.95;
  white-space: nowrap;
}
.strip-wrap { grid-column: 1 / -1; align-self: center; min-width: 0; }
/* Hình quạt: số lá cố định, JS tính độ chồng mép để vừa khung, không cuộn ngang. */
.strip {
  --h: clamp(190px, 36vh, 340px);
  position: relative; display: flex; justify-content: center;
  padding: calc(var(--h) * .2 + 20px) 0 60px; margin-top: -24px;
}
.strip li {
  position: relative; flex: none;
  transform: translateY(var(--dy, 0)) rotate(var(--rot, 0deg));
  transform-origin: 50% 110%;
  transition: transform .5s var(--ease-out);
}
/* Không đổi thứ tự chồng khi rê hay chọn: lá chỉ được nâng thẳng lên, nên lá bên cạnh không bị che
   và vẫn bấm được. */
.strip.is-shuffling { pointer-events: none; }
.strip.is-shuffling .slot { animation: none; }
.slot {
  position: relative; display: block;
  height: var(--h); aspect-ratio: 240 / 412;
  padding: 0; border: 0; border-radius: 4.5% / 2.6%; background: none; cursor: pointer;
  filter: brightness(.86) drop-shadow(0 14px 18px rgba(0, 0, 0, .55));
  transition: filter .3s, transform .45s var(--ease-out);
  /* Bay lơ lửng: cùng biên độ, cùng nhịp, mỗi lá bắt đầu ở một lúc khác nhau. */
  animation: float 4.4s ease-in-out var(--float-delay, 0s) infinite alternate both;
}
.slot img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; }
/* Ánh nhũ vàng lướt qua mặt lá khi rê chuột. */
.slot::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 240, 200, .28) 48%, transparent 66%) 120% 0 / 260% 100% no-repeat;
  transition: background-position .8s var(--ease-out);
}
.slot:hover::after, .slot:focus-visible::after { background-position: -20% 0; }
.slot:hover, .slot:focus-visible { filter: brightness(1.05) drop-shadow(0 20px 22px rgba(0, 0, 0, .6)); transform: translateY(-9%); }
.slot:active { transform: translateY(-7%) scale(.98); }
.slot[aria-pressed="true"] {
  transform: translateY(-20%);
  filter: brightness(1.08) drop-shadow(0 0 16px rgba(242, 209, 107, .55)) drop-shadow(0 22px 22px rgba(0, 0, 0, .6));
}
/* Lá đang chọn: tâm ngôi sao giữa mặt sau lá ấm và đậm màu hơn khoảng 10%, không chói.
   Lớp vàng nhẹ hoà kiểu overlay chỉ quanh tâm sao (50% / 47.6% chiều cao lá). */
.slot__glow {
  position: absolute; left: 50%; top: 47.6%; width: 44%; aspect-ratio: 1;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 205, 70, .42) 0%, rgba(255, 195, 60, .2) 40%, rgba(255, 190, 60, 0) 70%);
  mix-blend-mode: overlay; opacity: 0; pointer-events: none;
  transition: opacity .4s ease;
}
.slot[aria-pressed="true"] .slot__glow { opacity: 1; }
.slot__tag {
  position: absolute; left: 0; right: 0; bottom: -2px; transform: translateY(100%);
  padding-top: 12px; font-size: var(--step-small); font-weight: 600; text-align: left; color: #ffe28a;
  text-shadow: 0 0 12px rgba(255, 205, 80, .8), 0 2px 10px rgba(5, 4, 20, .9);
}
.strip.is-full .slot:not([aria-pressed="true"]) { filter: brightness(.45) drop-shadow(0 14px 18px rgba(0, 0, 0, .55)); }
.strip__bar {
  /* Bố cục cố định: chữ hướng dẫn bên trái, nút bên phải; chữ dài hay ngắn cũng không đẩy nút đi chỗ khác. */
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 16px; padding-top: 4px;
}
.strip__bar .strip__status { padding: 0; min-height: 3em; line-height: 1.5; }
.btn--small { min-height: 40px; padding: 0 16px; font-size: var(--step-small); }
.strip__status { padding: 4px var(--margin) 0; font-size: var(--step-small); color: var(--ink); }
@keyframes float { from { translate: 0 0; } to { translate: 0 -7px; } }

.ask { grid-column: 1 / -1; display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.ask__field { flex: 1; max-width: 640px; display: grid; gap: 8px; }
.ask label { font-size: var(--step-small); font-weight: 500; color: #c9c6e6; }
.ask input {
  height: 52px; padding: 0 16px;
  font: 400 var(--step-body) var(--font); color: var(--ink);
  background: rgba(20, 16, 50, .88); border: 0; border-bottom: 2px solid rgba(156, 140, 240, .55); border-radius: 0;
  transition: border-color .2s, background-color .2s;
}
.ask input::placeholder { color: #a9a6c8; }
.ask input:focus { outline: none; border-bottom-color: var(--accent); background: #1a1736; }
/* Đủ ba lá: khung câu hỏi phát sáng nhẹ để kéo ánh nhìn xuống. Tắt khi đã gõ vào ô. */
.ask label, .ask input { transition: color .4s ease, border-color .4s ease, box-shadow .6s ease, background-color .2s; }
.ask.is-calling label { color: #ffe3a0; }
.ask.is-calling input:not(:focus) {
  border-bottom-color: #ffd98a;
  animation: ask-glow 2.6s ease-in-out infinite alternate;
}
/* Đủ ba lá: nút Lật ba lá chuyển vàng gold cùng tông khung câu hỏi, quầng sáng nhẹ và một vệt sáng
   lướt chậm qua mặt nút. */
.ask.is-calling .btn:not(:disabled) {
  position: relative; overflow: hidden; isolation: isolate;
  background: #f5c84c; color: #2a1a05;
  box-shadow: 0 0 0 1px rgba(255, 228, 150, .7), 0 0 22px rgba(255, 200, 80, .4);
  animation: btn-glow 2.6s ease-in-out infinite alternate;
}
.ask.is-calling .btn:not(:disabled):hover { background: #ffd666; }
.ask.is-calling .btn:focus-visible { outline-color: #fff0b8; }
.ask.is-calling .btn:not(:disabled)::after {
  content: ''; position: absolute; inset: -20% auto -20% 0; width: 45%; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 0%, rgba(255, 252, 230, .75) 50%, transparent 100%);
  transform: translateX(-160%) skewX(-12deg);
  animation: btn-sheen 3.4s ease-in-out .6s infinite;
}
@keyframes btn-sheen {
  0% { transform: translateX(-160%) skewX(-12deg); }
  45%, 100% { transform: translateX(360%) skewX(-12deg); }
}
@keyframes btn-glow {
  from { box-shadow: 0 0 0 1px rgba(255, 228, 150, .55), 0 0 14px rgba(255, 200, 80, .28); }
  to { box-shadow: 0 0 0 1px rgba(255, 236, 170, .85), 0 0 30px rgba(255, 205, 90, .5); }
}
@keyframes ask-glow {
  from { box-shadow: 0 0 0 1px rgba(255, 217, 138, .3), 0 0 14px rgba(255, 205, 90, .16); }
  to { box-shadow: 0 0 0 1px rgba(255, 217, 138, .6), 0 0 28px rgba(255, 205, 90, .34); }
}
.noscript { grid-column: 1 / -1; color: var(--muted); }

/* Phần dưới màn đầu có nền đặc, che nền trời cố định. */
main, .foot { position: relative; background: var(--bg); }

/* ---------- Lời giải ---------- */
.reading { padding: clamp(56px, 7vw, 104px) var(--margin) 0; }
.reading__question {
  max-width: 24ch; font-size: var(--step-head);
  font-weight: 600; letter-spacing: -0.03em; line-height: 1.1;
}
.reading__topic { margin-top: 16px; color: var(--muted); font-size: var(--step-small); }
.reading__cards {
  margin-top: clamp(48px, 6vw, 88px);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(24px, 4vw, 64px);
}
.read-card { display: grid; align-content: start; gap: 16px; }
.read-card__label { font-size: var(--step-small); color: var(--muted); font-weight: 500; }
.read-card h3 { font-size: var(--step-lead); letter-spacing: -0.02em; line-height: 1.15; }
.read-card__keys { color: var(--muted); font-size: var(--step-small); }
.read-card__text { max-width: 42ch; }

.flip { width: clamp(160px, 16vw, 220px); aspect-ratio: 240 / 412; perspective: 900px; margin-bottom: 8px; }
.flip__inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 1s var(--ease-out); }
.flip.is-open .flip__inner { transform: rotateY(180deg); }
.flip__face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 4.5% / 2.6%; overflow: hidden; filter: drop-shadow(0 16px 20px rgba(0, 0, 0, .5)); }
.flip__face img { width: 100%; height: 100%; object-fit: cover; }
.flip__face--front { transform: rotateY(180deg); }
.flip__face--front.is-rev img { transform: rotate(180deg); }

.reading__summary { margin-top: clamp(56px, 7vw, 104px); max-width: 680px; display: grid; gap: 16px; }
.reading__summary h3 { font-size: var(--step-lead); letter-spacing: -0.02em; }
#reading-summary { display: grid; gap: 12px; }
.care { padding: 20px 24px; background: var(--surface-2); }
.reading__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }

/* ---------- Một lượt xem ---------- */
.how { padding-top: var(--section); }
.how__top { display: flex; justify-content: space-between; align-items: end; padding-inline: var(--margin); }
.how h2 { letter-spacing: -0.03em; }
.how__nav { display: flex; gap: 8px; }
.square {
  width: 48px; height: 48px; border: 0; border-radius: 0; cursor: pointer;
  background: var(--surface-2); color: var(--ink); font: 500 var(--step-body) var(--font);
  transition: background-color .2s, transform .15s var(--ease-out);
}
.square:hover { background: var(--accent); color: var(--accent-ink); }
.square:active { transform: scale(.94); }
.how__bar { margin: 24px var(--margin) 0; height: 6px; background: var(--surface); }
.how__bar span { display: block; height: 100%; width: 20%; background: var(--ink); transition: width .2s linear; }
.how__row {
  display: flex; gap: 32px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 40px var(--margin) 8px; scroll-padding-inline: var(--margin); scrollbar-width: none;
}
.how__row::-webkit-scrollbar { display: none; }
.how__row li { flex: none; width: 280px; scroll-snap-align: start; display: flex; flex-direction: column; }
.how__row p { margin-top: 8px; }
.how__row img { margin-top: var(--gap); width: 160px; aspect-ratio: 4 / 5; object-fit: cover; object-position: top; }

/* ---------- Bộ bài ---------- */
.sheet { padding: var(--section) var(--margin) 0; }
.sheet__title { font-size: var(--step-display); letter-spacing: -0.045em; }
.sheet__intro {
  margin-top: 32px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px;
  font-size: var(--step-small); max-width: 1100px;
}
.sheet__intro p { font-size: var(--step-small); }
.sheet__caption { color: var(--ink); font-weight: 500; min-height: 3em; }
.sheet__runs { margin-top: 40px; display: grid; gap: 28px; }
.run h3 { font-size: var(--step-small); font-weight: 500; color: var(--muted); margin-bottom: 10px; }
.run ul { display: flex; flex-wrap: wrap; gap: 8px; }
.frame {
  display: block; padding: 0; border: 0; background: none; cursor: pointer;
  transition: opacity .25s, transform .3s var(--ease-out);
}
.frame img { height: 120px; width: auto; }
.sheet__runs:hover .frame, .sheet__runs:focus-within .frame { opacity: .35; }
.sheet__runs .frame:hover, .sheet__runs .frame:focus-visible, .sheet__runs .frame.is-active { opacity: 1; transform: translateY(-4px); }

/* ---------- Hỏi đáp ---------- */
.faq {
  padding: var(--section) var(--margin) 0;
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px;
}
.faq h2 { grid-column: 1 / 4; letter-spacing: -0.03em; }
.faq__text { grid-column: 5 / 13; columns: 2; column-gap: 56px; }
.faq__text p { break-inside: avoid; margin-bottom: 20px; line-height: 1.55; }
.faq__text strong { font-weight: 500; }

/* ---------- Chân trang ---------- */
.foot {
  padding: 30svh var(--margin) 30px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline; gap: 24px;
  font-size: var(--step-small); color: var(--muted);
}
.foot__links { display: flex; gap: 24px; }
.foot__meta { text-align: right; }

/* ---------- Xuất hiện ---------- */
.js [data-reveal] .reveal-item { opacity: 0; transform: translateY(24px); }
.js [data-reveal].is-in .reveal-item {
  opacity: 1; transform: none;
  transition: opacity .7s var(--ease-out), transform .7s var(--ease-out);
  transition-delay: calc(var(--d, 0) * 80ms);
}
.reading .reveal-item { animation: rise .7s var(--ease-out) both; animation-delay: calc(var(--d, 0) * 80ms); }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }

/* ---------- Điện thoại ---------- */
@media (max-width: 760px) {
  .hero { padding: 20px 20px 28px; grid-template-rows: auto auto 1fr auto; }
  .corner--tr { gap: 16px; }
  .corner--tr a:nth-child(2) { display: none; }
  .hero__title { white-space: normal; font-size: clamp(2.5rem, 12vw, 3.5rem); }
  .strip { --h: clamp(170px, 30vh, 250px); }
  .strip__bar { gap: 12px; }
  .ask { flex-direction: column; align-items: stretch; }
  .reading { padding-inline: 20px; }
  .reading__cards { grid-template-columns: 1fr; gap: 56px; }
  .flip { width: 46vw; }
  .how__top, .how__bar { margin-inline: 20px; padding-inline: 0; }
  .how__nav { display: none; }
  .how__row { padding-inline: 20px; scroll-padding-inline: 20px; gap: 16px; }
  .how__row li { width: 72vw; }
  .how__row img { margin-top: calc(var(--gap) * .4); }
  .sheet, .faq { padding-inline: 20px; }
  .sheet__intro { grid-template-columns: 1fr; }
  .run ul { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -20px; padding-inline: 20px; }
  .frame img { height: 104px; }
  .faq { display: block; }
  .faq h2 { margin-bottom: 24px; }
  .faq__text { columns: 1; }
  .faq__text p { margin-bottom: 18px; }
  .foot { padding: 20svh 20px 24px; grid-template-columns: 1fr; gap: 8px; }
  .foot__meta { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .js [data-reveal] .reveal-item { opacity: 1; transform: none; }
}
