/* ============================================================
   Preflight AI — Design Tokens & Base System
   Đồng bộ theo vutuow.io.vn: nền ấm gần đen, accent xanh lá, font
   Geist/Geist Mono, nút bo pill, bán kính card 10px, easing riêng
   (giá trị lấy trực tiếp từ CSS custom properties + computed style
   của trang đó, không suy đoán).
   ============================================================ */

@font-face {
  font-family: "Geist";
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/geist@1.7.2/dist/fonts/geist-sans/Geist-Variable.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/geist@1.7.2/dist/fonts/geist-mono/GeistMono-Variable.woff2") format("woff2");
}

:root {
  /* ---- surfaces (warm near-black — vutuow.io.vn --bg/--surface/--line) ---- */
  --bg: #131210;
  --bg-alt: #17160f;
  --surface: #1d1c19;
  --surface-2: #242219;
  --surface-3: #2a2820;
  --border: #2a2820;
  --border-strong: #3a372c;

  /* ---- text ---- */
  --text-primary: #e8e6df;
  --text-secondary: #9f9e96;
  --text-tertiary: #726f66;
  --text-on-brand: #131210;

  /* ---- brand: signal green — vutuow.io.vn --accent #16a75a ---- */
  --brand: #16a75a;
  --brand-strong: #1fc16a;
  --brand-soft: rgba(22, 167, 90, 0.14);
  --brand-border: rgba(22, 167, 90, 0.35);

  /* ---- secondary accent (logo gradient, highlights) ---- */
  --accent-gold: #d4a24e;
  --accent-coral: #ff6b4a;

  /* ---- semantic risk / score triad — low aligned to brand green (đồng bộ ý nghĩa "tốt = xanh") ---- */
  --risk-low: #16a75a;
  --risk-low-soft: rgba(22, 167, 90, 0.14);
  --risk-medium: #f5a623;
  --risk-medium-soft: rgba(245, 166, 35, 0.14);
  --risk-high: #ff5470;
  --risk-high-soft: rgba(255, 84, 112, 0.14);

  /* ---- type: Geist / Geist Mono — đồng bộ theo vutuow.io.vn ---- */
  --font-display: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", "SFMono-Regular", Consolas, monospace;

  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.75rem;
  --fs-2xl: 2.25rem;
  --fs-3xl: 3rem;

  /* ---- spacing (4/8pt rhythm) ---- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  /* ---- radius / elevation — 10px card radius khớp vutuow.io.vn ---- */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 0 1px var(--brand-border), 0 0 32px rgba(22, 167, 90, 0.18);

  /* ---- motion — easing/duration lấy từ vutuow.io.vn (--ease, --dur-fast, --dur-med) ---- */
  --ease-out: cubic-bezier(0.22, 0.9, 0.32, 1);
  --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 400ms;

  --container-max: 1024px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================ reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }
h1, h2, h3, h4, h5 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 var(--space-3); font-weight: 600; }
h1 { font-size: var(--fs-3xl); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-2xl); letter-spacing: -0.01em; }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--space-4); color: var(--text-secondary); }
small, .text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.mono, .tabular { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

::selection { background: var(--brand-soft); color: var(--text-primary); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================ layout */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-5);
}
@media (max-width: 640px) {
  .container { padding: 0 var(--space-4); }
}

.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); } .gap-5 { gap: var(--space-5); }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

section { padding: var(--space-8) 0; }
@media (max-width: 640px) { section { padding: var(--space-7) 0; } }

/* ============================================================ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 46px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--brand); color: var(--text-on-brand); }
.btn-primary:hover { background: var(--brand-strong); box-shadow: var(--shadow-glow); }

.btn-secondary { background: var(--surface-2); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--brand-border); color: var(--brand-strong); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--surface-2); }

.btn-block { width: 100%; }

/* <summary> can be styled with .btn to act as a real disclosure button — strip the native marker. */
summary.btn { list-style: none; }
summary.btn::-webkit-details-marker { display: none; }
summary.btn::marker { content: ""; }
.btn-sm { min-height: 36px; padding: 0 var(--space-4); font-size: var(--fs-xs); }

/* ============================================================ cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  transition: border-color var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.card-interactive { cursor: pointer; }
.card-interactive:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

/* ============================================================ badges / pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}
.badge-low { background: var(--risk-low-soft); color: var(--risk-low); }
.badge-medium { background: var(--risk-medium-soft); color: var(--risk-medium); }
.badge-high { background: var(--risk-high-soft); color: var(--risk-high); }
.badge-neutral { background: var(--surface-3); color: var(--text-secondary); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: normal;
  text-align: center;
  max-width: 100%;
}

/* ============================================================ score visuals */
.score-hero { text-align: center; }
.score-hero .value { font-family: var(--font-display); font-size: clamp(3.5rem, 10vw, 5.5rem); font-weight: 700; line-height: 1; }
.score-hero .band { margin-top: var(--space-2); }

.score-bar {
  position: relative;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.score-bar > span {
  position: absolute; inset: 0 auto 0 0; width: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--brand), var(--brand-strong));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 900ms var(--ease-out);
}
.score-bar.risk-low > span { background: linear-gradient(90deg, #29b56f, var(--risk-low)); }
.score-bar.risk-medium > span { background: linear-gradient(90deg, #c97e12, var(--risk-medium)); }
.score-bar.risk-high > span { background: linear-gradient(90deg, #c62c48, var(--risk-high)); }
.score-bar.is-filled > span { transform: scaleX(var(--fill, 0)); }

.score-row { display: grid; grid-template-columns: 140px 1fr 48px; align-items: center; gap: var(--space-3); }
.score-row + .score-row { margin-top: var(--space-3); }
.score-row .label { font-size: var(--fs-sm); color: var(--text-secondary); }
.score-row .num { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }

/* ============================================================ forms */
label { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--space-2); color: var(--text-primary); }
.field { margin-bottom: var(--space-5); }
.field .hint { font-size: var(--fs-xs); color: var(--text-tertiary); margin-top: var(--space-1); }
.field .error { font-size: var(--fs-xs); color: var(--risk-high); margin-top: var(--space-1); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=url], input[type=search], input[type=tel], input:not([type]),
textarea, select {
  width: 100%;
  min-height: 46px;
  padding: 0 var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
textarea { min-height: 110px; padding: var(--space-3) var(--space-4); resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }

select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239f9e96' stroke-width='1.6' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right var(--space-4) center; padding-right: var(--space-7); }

/* Themed scrollbar for dark dropdown/panel content (native scrollbars default to a
   jarring light-OS style otherwise). */
.themed-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.themed-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.themed-scroll::-webkit-scrollbar-track { background: transparent; }
.themed-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.themed-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* Multi-select dropdown (checkbox list) — used for Placement so users can pick
   several placements per creative, grouped by platform and on-theme (native
   <select multiple>/<datalist> can't be styled consistently across browsers). */
.multiselect { position: relative; }
.multiselect-trigger {
  width: 100%;
  min-height: 46px;
  padding: 0 var(--space-7) 0 var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  text-align: left;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239f9e96' stroke-width='1.6' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.multiselect-trigger .placeholder { color: var(--text-tertiary); }
.multiselect-trigger:focus-visible,
.multiselect-trigger.is-open { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.multiselect-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 50;
  overflow: hidden;
  display: none;
}
.multiselect-panel.is-open { display: block; }
.multiselect-panel > input[type=text] {
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  min-height: 42px;
}
.multiselect-panel > input[type=text]:focus { box-shadow: none; }
.multiselect-options { max-height: 260px; overflow-y: auto; padding: var(--space-2) 0; }
.multiselect-group[hidden] { display: none; }
.multiselect-group-label {
  padding: var(--space-3) var(--space-4) var(--space-1);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}
.multiselect-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-primary);
  transition: background var(--dur-fast) var(--ease-out);
}
.multiselect-option:hover { background: var(--brand-soft); }
.multiselect-option[hidden] { display: none; }
.multiselect-option input[type=checkbox] { accent-color: var(--brand); width: 16px; height: 16px; flex: none; }

.file-drop {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
  color: var(--text-secondary);
  transition: border-color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
  cursor: pointer;
}
.file-drop:hover, .file-drop.is-dragover { border-color: var(--brand); background: var(--brand-soft); }
.file-drop input { display: none; }

/* ============================================================ nav */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10, 13, 18, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}
.navbar.is-scrolled { border-color: var(--border); background: rgba(10, 13, 18, 0.92); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) 0; }
.brand { display: flex; align-items: center; gap: var(--space-2); font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--accent-gold));
  display: flex; align-items: center; justify-content: center;
  color: var(--text-on-brand); font-weight: 800; font-size: 15px;
}
.nav-links { display: flex; align-items: center; gap: var(--space-6); }
.nav-links a:not(.btn) { color: var(--text-secondary); font-size: var(--fs-sm); font-weight: 500; transition: color var(--dur-fast) var(--ease-out); }
.nav-links a:not(.btn):hover { color: var(--text-primary); }
.nav-toggle { display: none; }

@media (max-width: 860px) {
  .nav-toggle {
    display: flex; flex-direction: column; gap: 5px; background: none; border: none; padding: 8px; cursor: pointer;
  }
  .nav-toggle span { width: 22px; height: 2px; background: var(--text-primary); border-radius: 2px; }
  .nav-links {
    position: fixed; inset: 64px 0 0 0; background: var(--bg-alt);
    flex-direction: column; align-items: stretch; padding: var(--space-6) var(--space-5);
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
  }
  .nav-links.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
}

/* ============================================================ scroll-reveal + counters (see main.js) */
[data-reveal] { opacity: 0; transform: translateY(16px); transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out); }
[data-reveal].is-visible { opacity: 1; transform: translateY(0); }
[data-reveal][data-reveal-delay="1"] { transition-delay: 80ms; }
[data-reveal][data-reveal-delay="2"] { transition-delay: 160ms; }
[data-reveal][data-reveal-delay="3"] { transition-delay: 240ms; }

.stagger > * { opacity: 0; transform: translateY(10px); transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); }
.stagger.is-visible > *:nth-child(1) { transition-delay: 0ms; }
.stagger.is-visible > *:nth-child(2) { transition-delay: 40ms; }
.stagger.is-visible > *:nth-child(3) { transition-delay: 80ms; }
.stagger.is-visible > *:nth-child(4) { transition-delay: 120ms; }
.stagger.is-visible > *:nth-child(5) { transition-delay: 160ms; }
.stagger.is-visible > * { opacity: 1; transform: translateY(0); }

/* ============================================================ misc */
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-brand { color: var(--brand); }
.text-low { color: var(--risk-low); }
.text-medium { color: var(--risk-medium); }
.text-high { color: var(--risk-high); }
.divider { border: none; border-top: 1px solid var(--border); margin: var(--space-5) 0; }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--brand); color: var(--text-on-brand);
  padding: var(--space-2) var(--space-4); z-index: 1000; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--surface-3); border-top-color: var(--brand);
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.flash {
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
  font-size: var(--fs-sm);
  border: 1px solid;
}
.flash-error { background: var(--risk-high-soft); border-color: rgba(255, 84, 112, 0.35); color: var(--risk-high); }
.flash-success { background: var(--risk-low-soft); border-color: rgba(61, 220, 132, 0.35); color: var(--risk-low); }
