/* ==========================================================
   Media — Portfolio
   Phong cách: nền pastel mềm ở hero, màu nhấn tím-xanh duy nhất,
   phông sans hình học, thẻ trắng bo góc, nhiều khoảng trắng.
   Bảng màu và token nằm ở :root / [data-theme="dark"]
   ========================================================== */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #15141c;
  --text-soft: #5d5c6a;
  --line: #e7e7ee;
  --accent: #5a55c4;
  --accent-ink: #ffffff;
  --accent-soft: #e9e8f8;
  --accent-deep: #d5d7f3;
  --ok: #23754f;
  --danger: #c2255c;
  --mesh-1: rgba(251, 207, 232, .85);
  --mesh-2: rgba(191, 219, 254, .9);
  --mesh-3: rgba(224, 218, 255, .75);
  --mesh-4: rgba(187, 240, 207, .6);
  --mesh-5: rgba(254, 225, 188, .65);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  --header-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

[data-theme="dark"] {
  --bg: #121218;
  --surface: #1c1c26;
  --text: #f2f2f7;
  --text-soft: #adadbd;
  --line: #2c2c3a;
  --accent: #a09cff;
  --accent-ink: #14131f;
  --accent-soft: #2a2943;
  --accent-deep: #34335a;
  --ok: #7bd3a8;
  --danger: #ff8fab;
  --mesh-1: rgba(120, 60, 100, .35);
  --mesh-2: rgba(60, 90, 150, .38);
  --mesh-3: rgba(90, 80, 160, .3);
  --mesh-4: rgba(40, 110, 80, .25);
  --mesh-5: rgba(140, 100, 50, .22);
}

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

html {
  scroll-behavior: smooth;
  /* Giữ chỗ cho thanh cuộn để trang không lệch ngang khi chuyển trang */
  scrollbar-gutter: stable;
  scroll-padding-top: calc(var(--header-h) + 12px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: .9375rem;
  line-height: 1.65;
  overflow-x: hidden;
  position: relative;
  transition: background-color .25s, color .25s;
  /* Footer luôn nằm đáy màn hình ở mọi trang */
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

body > main {
  flex: 1 0 auto;
}

.site-footer {
  flex-shrink: 0;
}

body.no-scroll {
  overflow: hidden;
}

/* Nền pastel ở đầu trang, mờ dần vào nền chính */
body::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 460px;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 70% at 0% 0%, var(--mesh-1), transparent 70%),
    radial-gradient(60% 70% at 100% 0%, var(--mesh-2), transparent 70%),
    radial-gradient(45% 55% at 55% 30%, var(--mesh-3), transparent 75%),
    radial-gradient(50% 50% at 0% 85%, var(--mesh-4), transparent 70%),
    radial-gradient(50% 50% at 100% 90%, var(--mesh-5), transparent 70%);
  -webkit-mask-image: linear-gradient(#000 60%, transparent);
  mask-image: linear-gradient(#000 60%, transparent);
}

body.home::before {
  height: 620px;
}

img,
svg {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

h1,
h2,
h3,
h4,
p,
dl,
dd {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

code {
  font-size: .88em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: .1em .4em;
  border-radius: 5px;
}

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

.container {
  width: min(1180px, 100% - 48px);
  margin-inline: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: top .2s;
}

.skip-link:focus {
  top: 12px;
}

/* ---------- Typography ---------- */
h1,
h2,
h3 {
  font-weight: 700;
  letter-spacing: -.02em;
}

h1 {
  font-size: clamp(1.85rem, 3.5vw, 2.75rem);
  line-height: 1.15;
  text-wrap: balance;
}

h1 em {
  font-style: normal;
  color: var(--accent);
}

h2 {
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  line-height: 1.2;
  text-wrap: balance;
}

.eyebrow,
.section-no {
  font-size: .9rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 10px;
  letter-spacing: 0;
}

.lead {
  margin-top: 18px;
  max-width: 46ch;
  font-size: .9375rem;
  color: var(--text-soft);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: transparent;
  transition: background-color .25s, border-color .25s;
  border-bottom: 1px solid transparent;
}

.site-header.scrolled {
  background: var(--bg);
  border-bottom-color: var(--line);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand-symbol {
  width: 42px;
  height: 38px;
  flex: none;
}

.brand-name {
  display: grid;
  gap: 3px;
  line-height: 1;
  color: var(--text);
}

.brand-name>span {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: .13em;
}

.brand-name small {
  font-size: .57rem;
  font-weight: 500;
  letter-spacing: .62em;
  padding-left: 1px;
}

.nav ul {
  display: flex;
  gap: 6px;
}

.nav a {
  display: block;
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: .88rem;
  transition: color .2s;
}

.nav a:hover {
  color: var(--accent);
}

.nav a.active {
  color: var(--accent);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: border-color .2s, color .2s;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sun {
  display: none;
}

[data-theme="dark"] .icon-sun {
  display: block;
}

[data-theme="dark"] .icon-moon {
  display: none;
}

.menu-btn {
  display: none;
}

.menu-btn .bar {
  transform-origin: center;
  transition: transform .25s var(--ease), opacity .2s;
}

.menu-btn[aria-expanded="true"] .b1 {
  transform: translateY(5px) rotate(45deg);
}

.menu-btn[aria-expanded="true"] .b2 {
  opacity: 0;
}

.menu-btn[aria-expanded="true"] .b3 {
  transform: translateY(-5px) rotate(-45deg);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 19px;
  border-radius: 8px;
  border: 1.5px solid transparent;
  font-weight: 600;
  font-size: .875rem;
  text-decoration: none;
  transition: transform .2s var(--ease), background-color .2s, border-color .2s, color .2s;
}

.btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .2s var(--ease);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  transform: translateY(-2px);
}

.btn-primary:hover svg {
  transform: translateX(3px);
}

.btn-ghost {
  border-color: var(--line);
  background: var(--surface);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-round {
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

.btn-round:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-round svg {
  width: 18px;
  height: 18px;
}

/* Nút liên hệ nhanh dạng icon: Zalo, Email */
.btn-social {
  --brand: var(--accent);
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 35%, transparent);
  transition: transform .2s var(--ease), box-shadow .2s;
}

.btn-social svg {
  width: 26px;
  height: 26px;
}

.btn-social.btn-mail svg {
  width: 22px;
  height: 22px;
}

.btn-social:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--brand) 55%, transparent);
}

.btn-zalo {
  --brand: #0068ff;
}

.btn-mail {
  --brand: #ea4335;
}

@media (max-width: 640px) {
  .hero-cta .btn-primary {
    flex: 1 1 auto;
  }
}

/* ---------- Hero (trang chủ) ---------- */
.hero {
  padding: clamp(24px, 3vw, 40px) 0 clamp(44px, 6vw, 76px);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 48px);
  align-items: center;
}

.hero-grid>*,
.about-grid>*,
.contact-grid>* {
  min-width: 0;
}

.hero-copy .eyebrow {
  font-size: .9375rem;
}

.hero-cta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.portrait {
  position: relative;
  width: min(100%, 340px);
  aspect-ratio: 1;
  margin: 0 auto;
}

.portrait::before {
  content: "";
  position: absolute;
  width: 52%;
  height: 56%;
  left: 4%;
  top: -2%;
  background: var(--accent-deep);
  border-radius: 60% 40% 55% 45% / 55% 50% 50% 45%;
}

.portrait::after {
  content: "";
  position: absolute;
  width: 62%;
  height: 28%;
  left: 16%;
  bottom: -3%;
  background: var(--accent-deep);
  opacity: .7;
  border-radius: 50%;
}

.portrait img {
  position: absolute;
  inset: 4% 0;
  width: 100%;
  height: 92%;
  object-fit: cover;
  background: #ececec;
  border-radius: 56% 44% 48% 52% / 44% 54% 46% 56%;
  z-index: 1;
}

/* Trang chủ chỉ có hero: lấp đầy màn hình, nội dung căn giữa, footer nằm đáy */
body.home::before {
  height: 100%;
}

body.home main {
  flex: 1;
  display: flex;
  align-items: center;
}

body.home .hero {
  width: 100%;
  padding-block: clamp(32px, 6vh, 72px);
}

body.home .hero-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 96px);
}

body.home .portrait {
  width: min(100%, 420px);
  margin-inline: auto 0;
}

@media (max-width: 860px) {
  body.home .hero-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  body.home .portrait {
    width: min(100%, 280px);
    margin-inline: auto;
    order: -1;
  }
}

/* ---------- Sections & page hero ---------- */
.section {
  padding: clamp(40px, 5.5vw, 72px) 0;
}

.section.tight {
  padding-top: clamp(24px, 3vw, 40px);
}

.section-head {
  text-align: center;
  margin-bottom: clamp(20px, 2.5vw, 28px);
}

.page-hero {
  padding: clamp(24px, 4vw, 48px) 0 clamp(8px, 2vw, 20px);
  text-align: center;
}

.page-hero h1 {
  max-width: 20ch;
  margin-inline: auto;
}

.page-hero .lead {
  margin-inline: auto;
}

/* ---------- Giới thiệu ---------- */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px clamp(24px, 4vw, 56px);
  align-items: start;
}

.about-body p {
  color: var(--text-soft);
  margin-bottom: 16px;
}

@media (max-width: 860px) {
  .about-body p {
    text-align: justify;
    text-align-last: left;
  }
}

.about-body strong {
  color: var(--text);
}

.facts {
  margin-top: 24px;
  border-top: 1px solid var(--line);
}

.facts li {
  display: flex;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: .93rem;
}

.facts span {
  flex: 0 0 90px;
  color: var(--text-soft);
}

.skills {
  background: var(--surface);
  border-radius: var(--radius);
  padding: clamp(20px, 2.5vw, 28px);
}

.skills h3 {
  font-size: .95rem;
  margin-bottom: 18px;
}

.skill {
  margin-bottom: 18px;
}

.skill-row {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: 8px;
}

.skill-row span:last-child {
  color: var(--text-soft);
  font-weight: 500;
}

.bar {
  height: 6px;
  background: var(--accent-soft);
  border-radius: 99px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: var(--w);
  background: var(--accent);
  border-radius: 99px;
  transform-origin: left;
}

.js .skills:not(.visible) .bar i {
  transform: scaleX(0);
}

.skills.visible .bar i {
  transition: transform .7s var(--ease) .05s;
}

.skills h3:nth-of-type(2) {
  margin-top: 28px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tags li {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent);
}

.skills .tags {
  margin-top: 0;
}

/* ---------- Dự án: thanh công cụ ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  font-size: .86rem;
  transition: background-color .2s, color .2s, border-color .2s;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.search {
  position: relative;
  flex: 1 1 240px;
  max-width: 340px;
}

.search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--text-soft);
  stroke-width: 2;
  stroke-linecap: round;
}

.search input {
  width: 100%;
  padding: 11px 16px 11px 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  transition: border-color .2s;
}

.search input::placeholder {
  color: var(--text-soft);
  opacity: .85;
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.result-count {
  font-size: .85rem;
  color: var(--text-soft);
  margin-bottom: 20px;
  min-height: 1.5em;
}

/* ---------- Lưới dự án: 5 → 3 → 2 → 1 cột ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 24px 20px;
}

.project-grid.is-featured {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .25s var(--ease);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.card:hover {
  transform: translateY(-3px);
}

.card-art {
  aspect-ratio: 11 / 6;
  overflow: hidden;
}

.card-art svg {
  width: 100%;
  height: 100%;
  transition: transform .45s var(--ease);
}

.card:hover .card-art svg {
  transform: scale(1.04);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 16px 16px 14px;
}

.card h3 {
  font-size: 1rem;
  line-height: 1.35;
  height: 2.7em;
  overflow: hidden;
  letter-spacing: -.01em;
}

.card p {
  color: var(--text-soft);
  font-size: .84rem;
  line-height: 1.55;
  min-height: 4.65em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .stack {
  margin-top: auto;
  min-height: 0;
  color: var(--accent);
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.5;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.card-open {
  all: unset;
  cursor: pointer;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.card-open::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.card-open:focus-visible {
  outline: none;
}

.card:has(.card-open:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.card:hover .card-open {
  color: var(--accent);
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.meta {
  display: grid;
  gap: 4px;
  font-size: .74rem;
  color: var(--text-soft);
  min-width: 0;
}

.meta li {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.meta li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta svg {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.go {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  transition: transform .2s var(--ease);
}

.go svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card:hover .go {
  transform: translateX(3px);
}

.project-grid.is-featured .card h3 {
  font-size: 1.1rem;
}

.project-grid.is-featured .card p {
  font-size: .9rem;
}

.section-cta {
  text-align: center;
  margin-top: 30px;
}

.sample-note {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: .86rem;
  color: var(--text-soft);
  max-width: 70ch;
}

@media (max-width: 860px) {
  .sample-note {
    text-align: justify;
    text-align-last: left;
  }
}

.empty {
  text-align: center;
  padding: 56px 20px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-soft);
  display: grid;
  gap: 6px;
  justify-items: center;
}

.empty[hidden] {
  display: none;
}

.empty svg {
  width: 44px;
  height: 44px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  margin-bottom: 8px;
}

.empty strong {
  color: var(--text);
}

.empty .btn {
  margin-top: 14px;
  padding: 10px 20px;
}

/* ---------- Liên hệ ---------- */
.contact-grid {
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
}

.contact-intro>p:first-child {
  color: var(--text-soft);
  max-width: 44ch;
}

.contact-list {
  margin-top: 24px;
  border-top: 1px solid var(--line);
}

.contact-list li {
  display: flex;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: .93rem;
}

.contact-list span {
  flex: 0 0 100px;
  color: var(--text-soft);
}



.form {
  background: var(--surface);
  border-radius: var(--radius);
  padding: clamp(20px, 2.5vw, 28px);
  display: grid;
  gap: 14px;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: .86rem;
  margin-bottom: 8px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field.invalid input,
.field.invalid textarea {
  border-color: var(--danger);
}

.error {
  margin-top: 6px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--danger);
}

.error:empty {
  display: none;
}

.form .btn {
  justify-self: start;
}

.form-status {
  font-size: .9rem;
  font-weight: 500;
}

.form-status:empty {
  display: none;
}

.form-status.ok {
  color: var(--ok);
  padding: 12px 14px;
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border-radius: 8px;
}

.form-status.warn {
  color: var(--danger);
  padding: 12px 14px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border-radius: 8px;
}

/* ---------- Footer & nút lên đầu ---------- */
.site-footer {
  padding: 28px 0;
  border-top: 1px solid var(--line);
  font-size: .88rem;
  color: var(--text-soft);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
}

.footer-inner ul {
  display: flex;
  gap: 20px;
}

.footer-inner a {
  text-decoration: none;
}

.footer-inner a:hover {
  color: var(--accent);
}

.to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity .25s, transform .25s, visibility .25s;
}

.to-top.show {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.to-top:hover {
  transform: translateY(-3px);
}

.to-top svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 19, 30, .5);
  animation: fade .2s both;
}

.modal-dialog {
  position: relative;
  width: min(680px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 24px 60px -20px rgba(20, 19, 30, .45);
  animation: pop .25s var(--ease) both;
}

.modal-dialog:focus {
  outline: none;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(.98);
  }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: var(--surface);
  transition: color .2s;
}

.modal-close:hover {
  color: var(--accent);
}

.modal-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.modal-art {
  aspect-ratio: 16 / 7;
  overflow: hidden;
}

.modal-art svg {
  width: 100%;
  height: 100%;
}

.modal-body {
  padding: clamp(20px, 3vw, 28px);
}

.modal-meta {
  font-size: .85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}

.modal-body h3 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  line-height: 1.2;
}

.modal-body>p {
  margin-top: 12px;
  color: var(--text-soft);
}

.modal-points {
  margin: 20px 0;
  display: grid;
  gap: 10px;
}

.modal-points li {
  position: relative;
  padding-left: 28px;
  font-size: .93rem;
}

.modal-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .5em;
  width: 14px;
  height: 8px;
  border-left: 2.5px solid var(--accent);
  border-bottom: 2.5px solid var(--accent);
  transform: rotate(-45deg) translateY(-3px);
}

.modal-body h4 {
  font-size: .85rem;
  margin: 8px 0;
}

/* ---------- Xuất hiện nhanh, không chặn nội dung ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}

.js .reveal.visible {
  opacity: 1;
  transform: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 1199px) {
  .project-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 28px 24px;
  }
}

@media (max-width: 899px) {

  .project-grid,
  .project-grid.is-featured {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 559px) {

  .project-grid,
  .project-grid.is-featured {
    grid-template-columns: minmax(0, 1fr);
  }

  .card h3 {
    height: auto;
    max-height: 2.7em;
  }

  .card p {
    min-height: 0;
  }
}

@media (max-width: 860px) {
  body.home::before {
    height: 600px;
  }

  .hero-grid,
  .about-grid,
  .contact-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .portrait {
    margin-inline: auto;
    width: min(100%, 280px);
  }

  .menu-btn {
    display: grid;
  }

  .nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 8px 24px 16px;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .18s, transform .18s, visibility .18s;
  }

  .nav.open {
    visibility: visible;
    opacity: 1;
    transform: none;
  }

  .nav ul {
    flex-direction: column;
    gap: 0;
  }

  .nav a {
    padding: 14px 4px;
    font-size: 1rem;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(1180px, 100% - 32px);
  }

  .search {
    max-width: none;
    flex-basis: 100%;
  }

  .hero-cta .btn-primary {
    flex: 1;
  }

  .form .btn {
    justify-self: stretch;
  }

  .modal {
    padding: 8px;
    align-items: end;
  }

  .modal-dialog {
    max-height: calc(100dvh - 16px);
  }

  .modal-art {
    aspect-ratio: 16 / 9;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
  }
}

/* Keep form text readable and prevent automatic input zoom on phones. */
@media (max-width: 640px) {

  .field input,
  .field textarea,
  .search input {
    font-size: 1rem;
  }

  .icon-btn,
  .btn-round {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Hero identity: full name first, profession second. */
.hero-copy h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.2;
  letter-spacing: -.035em;
}

.hero-role {
  margin-top: 12px;
  font-size: clamp(1rem, 1.6vw, 1.3rem);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: -.02em;
}

.hero-copy .lead {
  max-width: 53ch;
  margin-top: 22px;
}

@media (max-width: 860px) {
  .hero-copy .lead {
    text-align: justify;
    text-align-last: left;
  }
}

@media (max-width: 480px) {
  .brand-symbol {
    width: 34px;
    height: 31px;
  }

  .brand-name>span {
    font-size: 1.05rem;
  }

  .brand-name small {
    font-size: .48rem;
  }
}

/* Language switch matches the existing header controls. */
.lang-btn {
  flex: none;
  min-width: 42px;
  min-height: 42px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font: 600 .75rem var(--font);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease;
}

.lang-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 480px) {
  .header-inner {
    gap: 8px;
  }

  .header-actions {
    gap: 5px;
  }

  .lang-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .logo {
    gap: 7px;
  }
}

/* Thu gọn menu trên mobile */
@media (max-width: 860px) {
  .site-header {
    --header-h: 64px;
  }

  .site-header .nav {
    left: auto;
    right: 16px;
    top: calc(100% + 8px);

    width: min(210px, calc(100vw - 32px));
    padding: 8px;

    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgb(0 0 0 / 12%);

    max-height: calc(100dvh - 88px);
    overflow-y: auto;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px);

    transition:
      opacity 0.2s ease,
      transform 0.2s ease,
      visibility 0.2s;
  }

  .site-header .nav.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  .site-header .nav ul {
    flex-direction: column;
    gap: 4px;
  }

  .site-header .nav a {
    padding: 10px 14px;
    min-height: 44px;
    display: flex;
    align-items: center;

    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    border-radius: 8px;
  }

  .site-header .nav a.active {
    background: var(--accent-soft);
    color: var(--accent);
  }

  .site-header .nav a:hover {
    background: var(--accent-soft);
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-header .nav {
    transition: none;
  }
}

/* ==========================================================
   Chuyển trang mượt (View Transitions giữa các trang)
   Header đứng yên, nội dung mờ dần + trượt nhẹ.
   ========================================================== */
@view-transition {
  navigation: auto;
}

.site-header {
  view-transition-name: site-header;
}

::view-transition-group(site-header) {
  animation: none;
}

::view-transition-old(site-header) {
  display: none;
}

::view-transition-new(site-header) {
  animation: none;
}

::view-transition-old(root) {
  animation: page-out .2s cubic-bezier(.4, 0, 1, 1) both;
}

::view-transition-new(root) {
  animation: page-in .38s var(--ease) both;
}

@keyframes page-out {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

/* Trình duyệt chưa hỗ trợ View Transitions: nội dung hiện dần khi tải trang */
@supports not (view-transition-name: none) {
  body > main {
    animation: page-in .45s var(--ease) both;
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  body > main {
    animation: none;
  }
}

/* ---------- Dự án thật: ảnh chụp trang web + nút "Xem web" ---------- */
.card-art img,
.modal-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  transition: transform .45s var(--ease);
}

.card:hover .card-art img {
  transform: scale(1.04);
}

.live-link {
  position: relative;
  z-index: 2;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform .2s var(--ease), box-shadow .2s;
}

.live-link svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.live-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent);
}

.modal-actions {
  margin-top: 22px;
}

.modal-actions .btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Ít dự án: lưới 2 cột rộng rãi thay vì 5 cột trống */
.project-grid:not(.is-featured) {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 28px 24px;
}

.project-grid:not(.is-featured) .card h3 {
  font-size: 1.15rem;
  height: auto;
}

.project-grid:not(.is-featured) .card p {
  font-size: .9rem;
  min-height: 0;
}