/* Bảng màu lấy từ avatar: nền vàng mật ong, tóc nâu đen, hoodie trắng kem, da nâu ấm */
:root {
  --bg: #0d0b08;
  --bg-2: #14110c;
  --surface: #1a160f;
  --surface-2: #241d13;
  --line: rgba(255, 236, 200, .09);
  --line-strong: rgba(255, 236, 200, .18);
  --text: #f4ede2;
  --muted: #a59b88;
  --glow: #8a6420;
  --accent: #eab54a;
  --on-accent: #1a1206;
  --accent-2: #e58f5e;
  --cream: #fff3d6;
  --radius: 18px;
  --wrap: 1080px;
  --font-body: "Be Vietnam Pro", system-ui, sans-serif;
  --font-name: "Bricolage Grotesque", "Be Vietnam Pro", sans-serif;
  --font-display: "Bricolage Grotesque", "Be Vietnam Pro", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { height: 100%; }

body {
  margin: 0;
  /* Cả trang nằm gọn trong một khung màn hình, không cuộn trang */
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(900px 600px at 88% -8%, rgba(150, 104, 28, .36), transparent 62%),
    radial-gradient(700px 500px at -10% 38%, rgba(150, 104, 28, .15), transparent 65%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Lớp nhiễu hạt cho cảm giác u ám */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--accent); color: var(--on-accent); }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; border-radius: 6px; }

.mono { font-family: var(--font-mono); }

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px max(20px, calc((100vw - var(--wrap)) / 2));
  background: rgba(13, 11, 8, .72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.logo { font-family: var(--font-display); font-weight: 800; font-size: 1.12rem; letter-spacing: -.03em; }
.logo span { color: var(--accent); }
.nav nav { display: flex; gap: clamp(12px, 3vw, 28px); font-size: .88rem; color: var(--muted); }
.nav nav a { transition: color .2s; }
.nav nav a:hover, .nav nav a.active { color: var(--text); }
.nav nav a.active { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 8px; }

/* ---------- Layout ---------- */
.stage {
  flex: 1;
  min-height: 0;
  width: min(var(--wrap), 100% - 40px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  gap: clamp(28px, 6vw, 72px);
}
/* Khung nội dung: phần duy nhất cuộn, mỗi mục chiếm trọn một khung */
.panel {
  min-height: 0;
  padding: 0 6px;
  overflow-y: auto;
  scroll-behavior: smooth;
  scroll-snap-type: y proximity;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(transparent, #000 32px, #000 calc(100% - 32px), transparent);
  mask-image: linear-gradient(transparent, #000 32px, #000 calc(100% - 32px), transparent);
}
.panel::-webkit-scrollbar { display: none; }
.pane {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 0;
  scroll-snap-align: start;
}
.section-head { display: flex; align-items: baseline; gap: 18px; margin-bottom: 36px; }
.section-head h2 { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.9rem, 4.6vw, 2.9rem); line-height: 1.15; letter-spacing: -.04em; }
/* Số thứ tự dạng chữ rỗng viền vàng, cùng cỡ với tiêu đề */
.num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.9rem, 4.6vw, 2.9rem);
  line-height: 1.15;
  letter-spacing: -.02em;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--accent);
}

/* ---------- Hero ---------- */
.hero h1 {
  font-family: var(--font-name);
  font-weight: 800;
  font-size: clamp(2.7rem, 7.6vw, 5.4rem);
  line-height: 1.08;
  letter-spacing: -.045em;
  text-wrap: balance;
  /* chừa chỗ cho dấu tiếng Việt khỏi bị cắt bởi nền chữ */
  padding: .1em .04em .08em 0;
  background: linear-gradient(175deg, var(--cream) 35%, var(--accent) 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 28px rgba(234, 181, 74, .16));
}
.hero-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: .82rem; font-weight: 500;
}
.chip svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.chip-ghost { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); font-weight: 400; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulse 2.4s ease-in-out infinite; }
/* Tagline kiểu dòng lệnh: dấu nhắc vàng + con trỏ nhấp nháy */
.tagline {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(1.05rem, 1.9vw, 1.3rem);
  letter-spacing: -.01em;
  color: var(--text);
}
.tagline::before { content: "> "; color: var(--accent); }
.tagline::after {
  content: "";
  display: inline-block;
  width: .55em; height: 1.05em;
  margin-left: .25em;
  vertical-align: -.16em;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 22px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, .02);
  color: var(--text);
  font: 500 .9rem var(--font-body);
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.btn:hover { border-color: var(--text); transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { background: #f6c96c; border-color: #f6c96c; }
.btn:disabled { opacity: .55; cursor: progress; transform: none; }

.hero-avatar { position: relative; align-self: center; justify-self: center; width: min(100%, 380px, 62dvh); }
.avatar {
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 0 10px rgba(234, 181, 74, .1), 0 40px 120px -20px rgba(234, 181, 74, .38);
}
/* Phóng nhẹ để cắt viền trắng quanh ảnh gốc */
.avatar img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.13); }
.spark { position: absolute; fill: var(--cream); filter: drop-shadow(0 0 10px rgba(234, 181, 74, .75)); animation: twinkle 3.6s ease-in-out infinite; }
.spark-1 { width: 34px; top: 4%; left: -2%; }
.spark-2 { width: 18px; top: 20%; left: -9%; animation-delay: -1.2s; }
.spark-3 { width: 24px; bottom: 8%; right: -3%; animation-delay: -2.3s; }

@keyframes twinkle { 0%, 100% { opacity: .35; transform: scale(.8) rotate(0deg); } 50% { opacity: 1; transform: scale(1.1) rotate(12deg); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.bio { margin-top: 18px; max-width: 54ch; white-space: pre-line; color: #ddd3c2; }
#bio-input { margin-top: 14px; }
.empty { color: var(--muted); font-family: var(--font-mono); font-size: .88rem; }

/* ---------- Sở thích ---------- */
.hobbies { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.hobby {
  display: flex; gap: 18px; align-items: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .25s, transform .25s;
}
.hobby:hover { border-color: rgba(234, 181, 74, .5); transform: translateY(-3px); }
.hobby svg {
  flex: none; width: 46px; height: 46px; padding: 11px;
  border-radius: 13px;
  background: rgba(234, 181, 74, .12);
  stroke: var(--accent); stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round;
  transition: stroke .25s, background .25s;
}
.hobby:hover svg { stroke: var(--accent-2); background: rgba(229, 143, 94, .12); }
.hobby h3 { font-size: 1.04rem; font-weight: 600; line-height: 23px; }

/* ---------- Dự án ---------- */
.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.project {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .25s, transform .25s;
}
a.project:hover { border-color: rgba(234, 181, 74, .55); transform: translateY(-4px); }
.cover {
  position: relative;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, var(--glow), #1d160b 72%);
  display: grid; place-items: center;
  overflow: hidden;
}
.cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
a.project:hover .cover img { transform: scale(1.04); }
.cover-letter { font-family: var(--font-display); font-weight: 800; font-size: 4rem; color: rgba(255, 255, 255, .16); }
.project-body { display: flex; flex-direction: column; gap: 8px; padding: 22px; flex: 1; }
.project-body h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; line-height: 1.25; letter-spacing: -.025em; }
.project-body p { color: var(--muted); font-size: .93rem; white-space: pre-line; }
.project-link { margin-top: auto; padding-top: 10px; font-family: var(--font-mono); font-size: .8rem; color: var(--accent); overflow-wrap: anywhere; }
.projects .empty { grid-column: 1 / -1; padding: 44px 24px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* ---------- Liên hệ ---------- */
.contact-lead { color: var(--muted); max-width: 52ch; margin-bottom: 28px; }
.contacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.contact { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.contact-link {
  display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: center;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .25s, background .25s, transform .25s;
}
.contact-link[href]:hover { border-color: var(--accent); background: var(--surface-2); transform: translateY(-3px); }
.contact-link svg { grid-row: span 2; width: 26px; height: 26px; stroke: var(--accent); stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.contact-name { font-weight: 600; }
.contact-value { color: var(--muted); font-size: .84rem; font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Footer ---------- */
.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding: 24px 0 88px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: .82rem;
}

/* ---------- Chế độ chỉnh sửa ---------- */
.field {
  width: 100%;
  padding: 11px 14px;
  background: rgba(0, 0, 0, .35);
  border: 1px dashed rgba(229, 143, 94, .5);
  border-radius: 12px;
  color: var(--text);
  font: 300 .95rem/1.6 var(--font-body);
}
.field:focus { outline: none; border-style: solid; border-color: var(--accent-2); }
textarea.field { resize: vertical; }
#tagline-input { max-width: 460px; }

.project.is-editing { border: 1px dashed rgba(229, 143, 94, .5); }
.project.is-editing .project-body { gap: 10px; }
.cover-pick {
  position: absolute; right: 12px; bottom: 12px;
  padding: 7px 14px; border-radius: 999px;
  background: rgba(13, 11, 8, .8); border: 1px solid var(--line-strong);
  font-size: .8rem; cursor: pointer;
}
.cover-pick:hover { border-color: var(--accent-2); }
.cover-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.project-actions { display: flex; justify-content: space-between; gap: 8px; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--muted); font: inherit; font-size: .84rem; cursor: pointer; }
.link-btn:hover { color: var(--text); }
.link-btn.danger:hover { color: #e8604f; }
.project-add {
  min-height: 220px;
  display: grid; place-items: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  background: none; color: var(--muted);
  font: 500 .95rem var(--font-body); cursor: pointer;
  transition: color .2s, border-color .2s;
}
.project-add:hover { color: var(--accent-2); border-color: var(--accent-2); }

.editbar {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  display: flex; gap: 8px;
  padding: 8px;
  background: rgba(26, 22, 15, .92);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .55);
}
.editbar .btn { padding: 9px 18px; font-size: .86rem; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 70;
  transform: translate(-50%, 20px);
  padding: 10px 20px; border-radius: 999px;
  background: var(--text); color: var(--bg);
  font-size: .88rem; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #d9483b; color: #fff; }

/* ---------- Hiệu ứng xuất hiện ---------- */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: auto 1fr; gap: 4px; }
  .hero-avatar { justify-self: start; width: min(30vw, 120px); margin-top: 18px; }
  .spark { display: none; }
  .pane { justify-content: flex-start; padding: 32px 0; }
  .hobbies, .projects, .contacts { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .nav { padding-block: 13px; }
  .logo { font-size: .82rem; }
  .nav nav { font-size: .78rem; gap: 11px; }
  .nav nav a:first-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .panel { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}
