/* ===== Phong cách "Midnight & Gold": nền đêm, khung art-deco, màn mở đầu ===== */

@property --glint {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

/* ---------- Nền: cực quang + lưới mờ + vignette ---------- */
#backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 45%, #0e1d3d 0%, transparent 70%),
    linear-gradient(180deg, #060b19 0%, #040811 100%);
}
#backdrop::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(150, 205, 232, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(150, 205, 232, 0.045) 1px, transparent 1px);
  background-size: 72px 72px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, #000 20%, transparent 75%);
}
#backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.65) 100%);
}

.aurora {
  position: absolute;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  animation: drift 34s ease-in-out infinite alternate;
}
.aurora.a1 { left: -18vmax; top: -22vmax; background: radial-gradient(circle, rgba(20, 192, 208, 0.42), transparent 65%); }
.aurora.a2 { right: -20vmax; bottom: -26vmax; background: radial-gradient(circle, rgba(120, 150, 180, 0.32), transparent 65%); animation-duration: 42s; animation-direction: alternate-reverse; }
.aurora.a3 { left: 30vw; top: 40vh; width: 40vmax; height: 40vmax; background: radial-gradient(circle, rgba(52, 84, 170, 0.35), transparent 65%); animation-duration: 50s; }

@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(6vmax, 4vmax) scale(1.12); }
  100% { transform: translate(-4vmax, 7vmax) scale(0.95); }
}

#ambient {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

/* ---------- Khung viền vàng kiểu art-deco ---------- */
body.framed #stage {
  box-shadow:
    0 0 0 1px rgba(214, 238, 252, 0.75),
    0 40px 90px -20px rgba(0, 0, 0, 0.85),
    0 0 140px rgba(20, 192, 208, 0.13);
}

body.framed #frame::before,
body.framed #frame::after {
  content: "";
  position: absolute;
  pointer-events: none;
}
/* Viền trong: có tia sáng chạy vòng quanh */
body.framed #frame::before {
  inset: -10px;
  padding: 1px;
  background: conic-gradient(
    from var(--glint),
    var(--plat-soft) 0deg 290deg,
    #ffffff 318deg,
    var(--plat-soft) 346deg 360deg
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: glint 10s linear infinite;
}
body.framed #frame::after {
  inset: -18px;
  border: 1px solid var(--plat-faint);
}
@keyframes glint { to { --glint: 360deg; } }

/* Màu hoạ tiết 4 góc khung (bạch kim) */
:root {
  --corner-1: #e2f3ff;
  --corner-2: #8ea6bf;
  --corner-3: #cbe9fb;
  --corner-glow: rgba(214, 238, 252, 0.35);
}
.corner {
  position: absolute;
  width: 48px;
  height: 48px;
  pointer-events: none;
  filter: drop-shadow(0 0 6px var(--corner-glow));
  display: none;
}
body.framed .corner { display: block; }
.corner.tl { left: -25px; top: -25px; }
.corner.tr { right: -25px; top: -25px; transform: scaleX(-1); }
.corner.bl { left: -25px; bottom: -25px; transform: scaleY(-1); }
.corner.br { right: -25px; bottom: -25px; transform: scale(-1, -1); }

.frame-caption {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0;
  display: none;
  color: rgba(214, 226, 240, 0.72);
  pointer-events: none;
  transition: opacity 0.4s ease;
}
body.framed .frame-caption { display: flex; }
.frame-caption.top {
  bottom: calc(100% + 30px);
  justify-content: center;
  gap: 0.9em;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(10px, 0.95vw, 13px);
  letter-spacing: 0.42em;
  text-transform: uppercase;
}
.frame-caption i { color: var(--plat); font-style: normal; }
.frame-caption.bottom {
  top: calc(100% + 26px);
  justify-content: space-between;
  align-items: baseline;
  padding: 0 6px;
}
#caption-chapter {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(10px, 0.9vw, 12px);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--plat-bright);
}
#caption-chapter::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 12px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 10px var(--teal);
  vertical-align: 1px;
}
@media (max-height: 620px), (max-width: 720px) {
  body.framed { --scale: 0.9; }
  .frame-caption { display: none !important; }
}

/* ---------- Màn hình mở đầu ---------- */
body.intro-open #frame { opacity: 0; }
body.intro-open #toolbar,
body.intro-open #progress { opacity: 0; pointer-events: none; }

#intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow: hidden;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(8, 14, 30, 0.35), rgba(3, 6, 14, 0.85) 75%);
}
#intro[hidden] { display: none; }
#intro.closing { animation: intro-out 0.9s cubic-bezier(0.7, 0, 0.2, 1) forwards; pointer-events: none; }
@keyframes intro-out { to { opacity: 0; transform: scale(1.07); filter: blur(10px); } }

.intro-orbit {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(94vmin, 780px);
  height: min(94vmin, 780px);
  transform: translate(-50%, -50%);
  overflow: visible;
}
.ring { transform-origin: 300px 300px; animation: spin 70s linear infinite; }
.ring circle { fill: none; stroke-width: 1; }
.r1 circle { stroke: rgba(150, 205, 232, 0.3); stroke-dasharray: 2 9; }
.r2 { animation-duration: 46s; animation-direction: reverse; }
.r2 circle { stroke: rgba(110, 215, 228, 0.2); }
.r3 { animation-duration: 30s; }
.r3 circle { stroke: rgba(150, 205, 232, 0.22); stroke-dasharray: 1 5; }
.ring .moon { fill: var(--plat-bright); stroke: none; filter: drop-shadow(0 0 6px #e2f3ff); }
.ring .moon.teal { fill: #6fdbe6; filter: drop-shadow(0 0 6px #6fdbe6); }
@keyframes spin { to { transform: rotate(360deg); } }

.intro-content { position: relative; max-width: 860px; }
.intro-content > * {
  opacity: 0;
  animation: rise 1s cubic-bezier(0.2, 0.7, 0.1, 1) forwards;
}
.intro-content > :nth-child(1) { animation-delay: 0.2s; }
.intro-content > :nth-child(2) { animation-delay: 0.35s; }
.intro-content > :nth-child(3) { animation-delay: 0.5s; }
.intro-content > :nth-child(4) { animation-delay: 0.75s; }
.intro-content > :nth-child(5) { animation-delay: 0.9s; }
.intro-content > :nth-child(6) { animation-delay: 1.05s; }
.intro-content > :nth-child(7) { animation-delay: 1.3s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

.intro-eyebrow {
  margin: 0 0 18px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: #a9b8d0;
}
.intro-eyebrow i { color: var(--plat); font-style: normal; margin: 0 0.5em; }

.ornament { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 18px; }
.ornament span { width: 96px; height: 1px; background: linear-gradient(90deg, transparent, var(--plat)); }
.ornament span:last-child { transform: scaleX(-1); }
.ornament i { width: 8px; height: 8px; border: 1px solid var(--plat); transform: rotate(45deg); box-shadow: 0 0 10px rgba(150, 205, 232, 0.6); }

.intro-title {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(34px, 6.2vw, 88px);
  line-height: 1.04;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.intro-title .chrome {
  padding: 0 0.06em 0.08em;
  /* Kim loại bạch kim: sáng ở trên, tối ở giữa, có ánh xanh ngọc lướt qua */
  background:
    linear-gradient(100deg, transparent 35%, rgba(120, 235, 245, 0.9) 48%, transparent 60%) 0 0 / 260% 100%,
    linear-gradient(180deg, #ffffff 0%, #e4edf6 38%, #8a9cb2 52%, #d6e2ee 68%, #ffffff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: sheen 6s ease-in-out infinite;
  filter: drop-shadow(0 0 22px rgba(20, 192, 208, 0.28)) drop-shadow(0 2px 0 rgba(0, 0, 0, 0.35));
}
.intro-title .amp {
  font-weight: 300;
  font-size: 0.62em;
  line-height: 1.15;
  color: #8fdfe8;
  text-shadow: 0 0 18px rgba(20, 192, 208, 0.55);
}
@keyframes sheen {
  0% { background-position: 130% 0, 0 0; }
  60%, 100% { background-position: -30% 0, 0 0; }
}

.intro-sub {
  margin: 26px auto 0;
  max-width: 620px;
  font-size: clamp(15px, 1.45vw, 19px);
  font-weight: 300;
  line-height: 1.6;
  color: #c9d3e3;
}
.intro-meta {
  margin: 14px 0 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(214, 226, 240, 0.75);
}
.intro-meta i { font-style: normal; color: var(--plat); font-size: 11px; margin: 0 0.9em; vertical-align: 2px; }

.intro-actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 34px; }
.btn-primary, .btn-ghost {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: 999px;
  font: 600 15px/1 var(--sans);
  letter-spacing: 0.02em;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
}
.btn-primary {
  border: 1px solid rgba(240, 248, 255, 0.85);
  background: linear-gradient(135deg, #f2f7fc 0%, #9db2c8 48%, #e2f3ff 100%);
  color: #07131f;
  box-shadow: 0 12px 34px -10px rgba(150, 205, 232, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.65);
}
.btn-primary svg { width: 16px; height: 16px; fill: currentColor; }
.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.7) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: btn-shine 3.6s ease-in-out 2s infinite;
}
@keyframes btn-shine { 0%, 60% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 18px 44px -10px rgba(150, 205, 232, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.65); }
.btn-ghost {
  border: 1px solid rgba(150, 205, 232, 0.38);
  background: rgba(10, 16, 32, 0.4);
  color: #dbe7f3;
}
.btn-ghost:hover { background: rgba(150, 205, 232, 0.1); transform: translateY(-2px); }
.btn-primary:focus-visible, .btn-ghost:focus-visible { outline: 2px solid var(--plat-bright); outline-offset: 3px; }

.intro-hint { margin: 30px 0 0; font-size: 12.5px; color: #7f8ea8; line-height: 2.2; }
.intro-hint i { font-style: normal; margin: 0 0.35em; color: rgba(150, 205, 232, 0.5); }
.intro-hint kbd {
  display: inline-block;
  min-width: 24px;
  padding: 2px 7px;
  border: 1px solid rgba(150, 205, 232, 0.32);
  border-radius: 6px;
  font: 500 11.5px/1.5 var(--sans);
  color: #dbe7f3;
  background: rgba(150, 205, 232, 0.06);
}

@media (prefers-reduced-motion: reduce) {
  .aurora, .ring, .intro-title .chrome, .btn-primary::after, body.framed #frame::before { animation: none; }
  .intro-content > * { animation: none; opacity: 1; }
  #intro.closing { animation-duration: 0.01s; }
}
