/* =========================================================================
   Tâm Nguyễn — Personal card
   Mobile-first. Màu nhấn được ghi đè từ config.js (theme.accent).
   ========================================================================= */

:root {
  --bg: #101318;
  --surface: #161a21;
  --surface-2: #1d222b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f1ec;
  --muted: #b1b5bd;
  --faint: #868c97;
  --accent: #d6a85d;
  --accent-ink: #17130b;
  --accent-soft: rgba(214, 168, 93, 0.12);
  --accent-line: rgba(214, 168, 93, 0.38);

  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 22px;
  --gutter: 20px;
  --max: 1040px;
  --header-h: 60px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

@supports (color: color-mix(in srgb, red, blue)) {
  :root {
    --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
    --accent-line: color-mix(in srgb, var(--accent) 38%, transparent);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 12px);
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(120% 60% at 50% -10%, rgba(214, 168, 93, 0.07), transparent 60%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}
main:focus { outline: none; }

.container {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left));
}

.nowrap { white-space: nowrap; }
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.muted { color: var(--faint); }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- Icons ---------- */
.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-icon] { display: inline-flex; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(16, 19, 24, 0.82);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}
.site-header.is-scrolled { border-bottom-color: var(--line); }

.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.monogram {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent-line);
  border-radius: 9px;
}
.monogram svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 3.6;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.brand-name { font-size: 0.975rem; }

.lang-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
}
.lang-switch button {
  min-width: 44px;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ---------- Hero / Profile ---------- */
.hero {
  display: grid;
  gap: 28px;
  padding-top: 24px;
  padding-bottom: 8px;
  text-align: center;
}

.hero-media { display: flex; justify-content: center; }

.avatar-frame {
  position: relative;
  width: min(68vw, 300px);
  aspect-ratio: 4 / 5;
}
.avatar-frame img {
  /* viền ảnh mờ dần, tan vào nền thay vì cắt khung sắc */
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.92) saturate(0.92);
  --fade-x: linear-gradient(to right, transparent 0%, #000 22%, #000 78%, transparent 100%);
  --fade-y: linear-gradient(to bottom, transparent 0%, #000 12%, #000 62%, transparent 100%);
  -webkit-mask-image: var(--fade-x), var(--fade-y);
  -webkit-mask-composite: source-in;
  mask-image: var(--fade-x), var(--fade-y);
  mask-composite: intersect;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.meter {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}
.meter i {
  display: block;
  width: 3px;
  height: 100%;
  border-radius: 1px;
  background: currentColor;
  transform-origin: bottom;
  transform: scaleY(0.4);
  animation: meter 1.8s var(--ease) infinite alternate;
}
.meter i:nth-child(1) { animation-delay: -0.2s; }
.meter i:nth-child(2) { animation-delay: -0.9s; }
.meter i:nth-child(3) { animation-delay: -0.5s; }
.meter i:nth-child(4) { animation-delay: -1.3s; }
.meter i:nth-child(5) { animation-delay: -0.7s; }
@keyframes meter {
  0% { transform: scaleY(0.3); }
  60% { transform: scaleY(0.85); }
  100% { transform: scaleY(0.5); }
}

.hero h1 {
  margin-top: 12px;
  font-size: clamp(2.25rem, 9vw, 3.5rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.02em;
}
.tagline {
  margin-top: 8px;
  color: var(--text);
  opacity: 0.86;
  font-size: 1.0625rem;
  font-weight: 500;
}
.lead {
  margin: 16px auto 0;
  max-width: 44ch;
  color: var(--muted);
  font-size: 1rem;
}

.hero-actions {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease),
    border-color 0.2s var(--ease), color 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}
.btn-ghost .icon { color: var(--accent); }
.btn-ghost:hover { border-color: var(--accent-line); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent-line); }

/* ---------- Sections ---------- */
main { counter-reset: section; }
.section { padding-top: 56px; }

.section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
/* Số kênh 01, 02… như trên bàn mixer; tự đánh lại khi một mục bị ẩn */
.section:not([hidden]) .section-title { counter-increment: section; }
.section-title::before {
  content: counter(section, decimal-leading-zero);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  align-self: center;
  background: var(--line);
}

/* ---------- Contact ---------- */
.contact-list {
  display: grid;
  gap: 10px;
}
.contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 68px;
  padding: 12px 16px 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.contact-item:hover {
  border-color: var(--accent-line);
  background: var(--surface-2);
}
.contact-item:active { transform: scale(0.995); }
.contact-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.contact-icon .zalo-mark {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.contact-text {
  display: grid;
  min-width: 0;
  flex: 1;
  line-height: 1.35;
}
.contact-label { font-weight: 600; }
.contact-value {
  color: var(--muted);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}
.contact-arrow { color: var(--faint); transition: color 0.2s var(--ease), transform 0.2s var(--ease); }
.contact-item:hover .contact-arrow { color: var(--accent); transform: translate(2px, -2px); }

/* ---------- About ---------- */
.about-text {
  color: var(--text);
  opacity: 0.9;
  font-size: 1.0625rem;
  line-height: 1.75;
  max-width: 62ch;
}

.work-photo { margin: 28px 0 0; }
.work-photo img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}
.work-photo figcaption {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  color: var(--faint);
  font-size: 0.875rem;
}
.work-photo figcaption::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--accent);
}

/* ---------- Expertise ---------- */
.expertise-grid {
  display: grid;
  gap: 10px;
}
.expertise-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.expertise-card .icon { margin-top: 2px; color: var(--accent); }
.expertise-title {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
}
.expertise-caption {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

/* ---------- Projects ---------- */
.project-grid { display: grid; gap: 14px; }
.project-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.project-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--surface-2);
}
.project-body { display: grid; gap: 6px; padding: 16px; }
.project-name { font-size: 1.0625rem; font-weight: 600; }
.project-role {
  color: var(--accent);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.project-desc { color: var(--muted); font-size: 0.9375rem; }
.project-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9375rem;
}

/* ---------- Resources (mục phụ) ---------- */
.resources { padding-top: 48px; }
.resources-trigger {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 12px 16px 12px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.resources-trigger:hover { border-color: var(--accent-line); background: var(--surface); }
.resources-trigger .contact-icon { background: var(--surface-2); color: var(--muted); }
.resources-trigger:hover .contact-icon { color: var(--accent); }

/* ---------- Dialog ---------- */
.dialog {
  width: min(100% - 32px, 480px);
  max-height: min(86vh, 640px);
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
}
.dialog::backdrop {
  background: rgba(6, 8, 11, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.dialog[open] { animation: dialog-in 0.24s var(--ease); }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dialog-head h2 { font-size: 1.125rem; font-weight: 600; }
.dialog-note {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 0.875rem;
}
.resource-list { display: grid; gap: 10px; }
.resource-list .contact-item { background: var(--surface-2); }
.resource-list .is-main { border-color: var(--accent-line); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 64px;
  padding: 28px 0 calc(28px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--muted);
}
.footer-inner { display: grid; gap: 4px; text-align: center; }

/* ---------- Quick action bar (mobile) ---------- */
.quickbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  padding: 10px max(16px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
  background: rgba(16, 19, 24, 0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  transform: translateY(110%);
  visibility: hidden;
  transition: transform 0.3s var(--ease), visibility 0s linear 0.3s;
}
.quickbar .btn { min-height: 48px; }
.quickbar.is-visible {
  transform: none;
  visibility: visible;
  transition: transform 0.3s var(--ease), visibility 0s;
}
body.has-quickbar .site-footer { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 70;
  max-width: min(92vw, 420px);
  padding: 12px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9375rem;
  text-align: center;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast:empty { display: none; }

.noscript { padding: 16px; text-align: center; }

/* ---------- Reveal on scroll ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.js .reveal.is-visible { opacity: 1; transform: none; }

/* ========================= Breakpoints ========================= */

@media (min-width: 400px) {
  .expertise-grid { grid-template-columns: 1fr 1fr; }
  .expertise-card { flex-direction: column; gap: 10px; }
}

@media (min-width: 560px) {
  .contact-list { grid-template-columns: 1fr 1fr; }
  .hero-actions {
    grid-template-columns: auto auto;
    justify-content: center;
  }
  .project-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 768px) {
  :root { --gutter: 32px; --header-h: 68px; }
  .quickbar { display: none; }
  body.has-quickbar .site-footer { padding-bottom: 28px; }
  .toast { bottom: 32px; }
  .section { padding-top: 72px; }
  .section-title { font-size: 1.375rem; }
}

@media (min-width: 880px) {
  .hero {
    grid-template-columns: minmax(260px, 340px) 1fr;
    align-items: center;
    gap: 64px;
    padding-top: 56px;
    text-align: left;
  }
  .avatar-frame { width: 100%; }
  .lead { margin-left: 0; }
  .hero-actions { justify-content: start; }
  .contact-list { grid-template-columns: repeat(3, 1fr); }
  .split {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 56px;
  }
  .project-grid { grid-template-columns: repeat(3, 1fr); }
  .resources-trigger { max-width: 520px; }
  .footer-inner {
    grid-template-columns: 1fr auto;
    text-align: left;
  }
}

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

@media (forced-colors: active) {
  .btn, .contact-item, .lang-switch button { border: 1px solid ButtonText; }
}
