/* apps.phucnt.org — trang giới thiệu ứng dụng.
   Nền trang (hero, footer) theo chế độ sáng/tối của máy; mỗi ứng dụng giữ thế giới màu riêng của nó. */

:root {
  --bg: #f4f1ea;
  --ink: #17181d;
  --muted: #5a5d66;
  --line: #d9d4c7;
  --wash: #ebe6da;
  --display: "Bricolage Grotesque", "Be Vietnam Pro", system-ui, sans-serif;
  --body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pad: clamp(20px, 5vw, 56px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1014;
    --ink: #ece8de;
    --muted: #a3a49e;
    --line: #2a2b32;
    --wash: #191a20;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, video, svg { display: block; max-width: 100%; }
img, video { height: auto; }
a { color: inherit; }
h1, h2, p, ul, dl, dd, figure { margin: 0; }
ul { padding: 0; list-style: none; }

.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 var(--pad); }
.nowrap { white-space: nowrap; }

:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; border-radius: 6px; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 10;
  padding: 10px 14px; border-radius: 8px;
  background: var(--ink); color: var(--bg); text-decoration: none; font-weight: 600;
}
.skip:focus { top: 12px; }

/* ───────────── hero ───────────── */

.hero { padding: 28px 0 clamp(40px, 7vw, 88px); }

.topbar { display: flex; align-items: center; justify-content: space-between; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: -0.01em;
  text-decoration: none;
}
.brand-dim { color: var(--muted); font-weight: 500; }

.hero-title {
  margin-top: clamp(48px, 9vw, 120px);
  max-width: 15ch;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.5rem, 7.4vw, 5.6rem);
  line-height: 1.07;
  letter-spacing: -0.028em;
  text-wrap: balance;
}

.hero-lede {
  margin-top: clamp(18px, 2.4vw, 28px);
  max-width: 44ch;
  font-size: clamp(1.06rem, 1.5vw, 1.28rem);
  line-height: 1.55;
  color: var(--muted);
  text-wrap: pretty;
}

/* mục lục: ba ứng dụng, mỗi dòng một cửa vào */
.index { margin-top: clamp(40px, 6vw, 80px); border-top: 1px solid var(--line); }

.row {
  --tone: var(--wash);
  --tone-ink: var(--ink);
  --tone-dim: var(--muted);
  position: relative;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto 40px;
  align-items: center;
  gap: clamp(16px, 2.4vw, 32px);
  padding: 22px clamp(0px, 1.4vw, 20px);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  isolation: isolate;
  transition: color 0.25s var(--ease);
}
.row::before {
  content: "";
  position: absolute; inset: -1px 0; z-index: -1;
  background: var(--tone);
  border-radius: 18px;
  opacity: 0;
  transform: scaleY(0.82);
  transition: opacity 0.25s var(--ease), transform 0.3s var(--ease);
}
.row--atlas { --tone: #0a1018; --tone-ink: #eef2f7; --tone-dim: #aab6c7; }
.row--math  { --tone: #6c3bd2; --tone-ink: #ffffff; --tone-dim: #e3d8fb; }
.row--book  { --tone: #1b0f2e; --tone-ink: #f6ecd9; --tone-dim: #c2b5d6; }

.row-icon { width: 72px; height: 72px; border-radius: 22.5%; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 8px 22px rgba(0, 0, 0, 0.14); }
.row-icon--atlas { display: grid; place-items: center; background: #0a1018; border: 1px solid #243247; }
.row-icon--atlas svg { width: 64%; height: 64%; }

.row-main { display: grid; gap: 4px; min-width: 0; }
.row-name {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.35rem, 3vw, 2.3rem); line-height: 1.14; letter-spacing: -0.02em;
}
.row-desc { color: var(--muted); font-size: clamp(0.94rem, 1.2vw, 1.06rem); line-height: 1.45; transition: color 0.25s var(--ease); }
.row-plat {
  font-size: 0.86rem; font-weight: 500; letter-spacing: 0.02em; white-space: nowrap;
  color: var(--muted); transition: color 0.25s var(--ease);
}
.row-arrow {
  justify-self: end;
  font-family: var(--display); font-size: 1.5rem; line-height: 1;
  transition: transform 0.3s var(--ease);
}

@media (hover: hover) {
  .row:hover { color: var(--tone-ink); }
  .row:hover::before { opacity: 1; transform: none; }
  .row:hover .row-desc, .row:hover .row-plat { color: var(--tone-dim); }
  .row:hover .row-arrow { transform: translateY(5px); }
}
.row:active::before { opacity: 1; transform: none; }
.row:active { color: var(--tone-ink); }
.row:active .row-desc, .row:active .row-plat { color: var(--tone-dim); }

@media (max-width: 640px) {
  .row { grid-template-columns: 56px minmax(0, 1fr); gap: 14px; padding: 18px 0; }
  .row-icon { width: 56px; height: 56px; }
  .row-plat { grid-column: 2; margin-top: -8px; }
  .row-arrow { display: none; }
  .row::before { inset: -1px calc(var(--pad) * -0.5); }
}

/* ───────────── phần chung của ba ứng dụng ───────────── */

.app {
  --a-bg: #fff; --a-ink: #111; --a-dim: #555; --a-line: #ddd; --a-accent: #111; --a-on-accent: #fff;
  background: var(--a-bg);
  color: var(--a-ink);
  padding: clamp(64px, 9vw, 128px) 0;
  overflow: hidden;
}

.kicker {
  font-size: 0.84rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--a-accent);
}

.app h2 {
  margin-top: 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.1rem, 4.8vw, 3.7rem);
  line-height: 1.1;
  letter-spacing: -0.026em;
  text-wrap: balance;
}

.lede {
  margin-top: clamp(18px, 2vw, 26px);
  max-width: 34em;
  font-size: clamp(1.08rem, 1.45vw, 1.24rem);
  line-height: 1.58;
  text-wrap: pretty;
}

.app-id { display: flex; align-items: center; gap: 20px; }
.app-id img { flex: none; width: 84px; height: 84px; border-radius: 22.5%; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 14px 34px rgba(0, 0, 0, 0.22); }
.app-id h2 { margin-top: 6px; font-size: clamp(1.9rem, 3.6vw, 2.9rem); }

.points { margin-top: 26px; display: grid; gap: 14px; max-width: 34em; }
.points li { position: relative; padding-left: 26px; color: var(--a-dim); line-height: 1.55; }
.points li::before {
  content: ""; position: absolute; left: 2px; top: 0.62em;
  width: 10px; height: 10px; border-radius: 3px; background: var(--a-accent);
}

.actions { margin-top: 32px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px 22px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 0 26px;
  border-radius: 999px;
  background: var(--a-accent); color: var(--a-on-accent);
  font-weight: 600; font-size: 1.02rem; text-decoration: none;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.btn span { transition: transform 0.2s var(--ease); }
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22); }
.btn:hover span { transform: translate(2px, -2px); }
.btn:active { transform: none; }
.btn-note { font-size: 0.92rem; color: var(--a-dim); }
.link { font-weight: 500; text-underline-offset: 4px; text-decoration-thickness: 1px; color: var(--a-dim); }
.link:hover { color: var(--a-ink); }

/* hai cột: chữ + ảnh điện thoại */
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(32px, 5vw, 80px); align-items: center; }
.split--flip .app-text { order: 2; }

.phones { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(12px, 1.6vw, 22px); align-items: start; }
.phones img { width: 100%; border-radius: clamp(16px, 2vw, 26px); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14), 0 24px 54px rgba(0, 0, 0, 0.22); }
.phones img:nth-child(2) { margin-top: clamp(24px, 4vw, 56px); }
.phones img:nth-child(3) { margin-top: clamp(8px, 1.4vw, 20px); }
.phones-extra { display: none; }
.phones--device img { border: 1px solid rgba(255, 255, 255, 0.16); background: #000; }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; gap: 44px; }
  .split--flip .app-text { order: 0; }
  .phones {
    display: flex; gap: 14px; align-items: flex-start;
    margin: 0 calc(var(--pad) * -1); padding: 6px var(--pad) 34px;
    overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .phones::-webkit-scrollbar { display: none; }
  .phones img, .phones img:nth-child(2), .phones img:nth-child(3) { flex: none; width: min(62vw, 270px); margin-top: 0; scroll-snap-align: center; }
  .phones-extra { display: block; }
}

/* ───────────── Atlas Nhạc Việt: xanh đêm + vàng ───────────── */

.app--atlas {
  --a-bg: #0a1018; --a-ink: #eef2f7; --a-dim: #aab6c7; --a-line: #243247;
  --a-accent: #f0c26a; --a-on-accent: #0a1018;
  background:
    radial-gradient(900px 520px at 88% -8%, rgba(57, 135, 229, 0.13), transparent 70%),
    radial-gradient(760px 520px at -6% 46%, rgba(213, 81, 129, 0.09), transparent 70%),
    #0a1018;
}

.atlas-top { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: clamp(32px, 5vw, 80px); align-items: end; }
.app--atlas .lede { color: var(--a-dim); }

.figures { display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 18px 20px; padding-bottom: 24px; border-bottom: 1px solid var(--a-line); }
.figures div { display: flex; flex-direction: column-reverse; }
.figures dd { font-family: var(--display); font-weight: 700; font-size: clamp(1.7rem, 2.8vw, 2.5rem); line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.figures dt { margin-top: 2px; font-size: 0.88rem; color: var(--a-dim); }

.views { margin-top: 22px; display: grid; gap: 12px; }
.views li { display: grid; grid-template-columns: 6.6em minmax(0, 1fr); gap: 14px; align-items: baseline; }
.views b { font-family: var(--display); font-weight: 700; font-size: 1.08rem; color: var(--a-accent); }
.views span { color: var(--a-dim); font-size: 0.98rem; line-height: 1.5; }

.screen { margin-top: clamp(40px, 5vw, 72px); }
.screen video, .screen img {
  width: 100%;
  border-radius: clamp(10px, 1.4vw, 18px);
  border: 1px solid var(--a-line);
  background: #0a1018;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);
}
.screen video { aspect-ratio: 16 / 9; object-fit: cover; }
.screen figcaption { margin-top: 14px; font-size: 0.94rem; color: var(--a-dim); }

.screen-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(18px, 2.6vw, 36px); }
.screen-pair .screen { margin-top: clamp(28px, 3.6vw, 48px); }

.fineprint { margin-top: clamp(32px, 4vw, 52px); max-width: 46em; font-size: 0.94rem; color: var(--a-dim); padding-left: 16px; border-left: 2px solid var(--a-accent); }

@media (max-width: 900px) {
  .atlas-top { grid-template-columns: 1fr; align-items: start; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .screen-pair { grid-template-columns: 1fr; }
  .views li { grid-template-columns: 1fr; gap: 2px; }
}

/* ───────────── Open Math: kem + tím ───────────── */

.app--math {
  --a-bg: #fbf5e8; --a-ink: #26174f; --a-dim: #554a78; --a-line: #e7dcc6;
  --a-accent: #6532cc; --a-on-accent: #ffffff;
  background:
    radial-gradient(700px 460px at 96% 12%, rgba(118, 199, 82, 0.2), transparent 70%),
    #fbf5e8;
}

/* ───────────── Open Book: tím than + ánh đèn vàng ───────────── */

.app--book {
  --a-bg: #170d27; --a-ink: #f6ecd9; --a-dim: #c0b3d3; --a-line: #33264a;
  --a-accent: #ffcf7a; --a-on-accent: #1d102f;
  background:
    radial-gradient(640px 520px at 22% 40%, rgba(255, 207, 122, 0.16), transparent 70%),
    #170d27;
}
.app--book .lede { color: var(--a-ink); }

/* ───────────── footer ───────────── */

.foot { padding: 40px 0 56px; font-size: 0.92rem; }
.foot-in { display: grid; gap: 6px; }
.foot-dim { color: var(--muted); }

/* ───────────── chuyển động ───────────── */

.js .reveal { opacity: 0; transform: translateY(22px); transition: opacity 0.7s var(--ease), transform 0.8s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }
.js .phones .reveal:nth-child(2) { transition-delay: 0.09s; }
.js .phones .reveal:nth-child(3) { transition-delay: 0.18s; }
.js .screen-pair .reveal:nth-child(2) { transition-delay: 0.1s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .row, .row::before, .row-arrow, .btn, .btn span { transition: none; }
}
