/* ==========================================================================
   Nguyễn Tấn Phát — Portfolio
   Màu: nền ngà, chữ gần đen, một màu nhấn xanh dương.
   ========================================================================== */

:root {
  --paper: #f7f5ef;
  --paper-deep: #efece3;
  --surface: #fdfcf8;
  --ink: #15171c;
  --ink-soft: #4a505c;      /* 7.4:1 trên --paper */
  --line: #d9d4c7;
  --accent: #1c4fd0;        /* 6.6:1 trên --paper */
  --accent-ink: #ffffff;
  --accent-soft: #e3e9f9;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  --step--1: clamp(0.84rem, 0.82rem + 0.1vw, 0.9rem);
  --step-0: clamp(1rem, 0.97rem + 0.15vw, 1.08rem);
  --step-1: clamp(1.2rem, 1.12rem + 0.4vw, 1.4rem);
  --step-2: clamp(1.45rem, 1.3rem + 0.8vw, 1.95rem);
  --step-3: clamp(1.9rem, 1.6rem + 1.5vw, 2.8rem);
  --step-hero: clamp(2.7rem, 1.6rem + 5.4vw, 6.2rem);

  --wrap: 1180px;
  --gutter: clamp(1.1rem, 4vw, 2.5rem);
  --section: clamp(4rem, 9vw, 7.5rem);
  --header-h: 64px;
  --radius: 6px;
}

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

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

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; letter-spacing: -0.015em; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0; padding: 0; }

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

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

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

.skip-link {
  position: absolute;
  left: 1rem; top: -100px;
  z-index: 100;
  padding: 0.7rem 1rem;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
}
.skip-link:focus { top: 0.75rem; }

main:focus { outline: none; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.75rem 1.4rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--ink); border-color: var(--ink); }
.btn-ghost { color: var(--ink); background: transparent; }
.btn-ghost:hover { background: var(--ink); color: #fff; }
.project-links { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 1.25rem; }
.project-links .btn { min-height: 42px; padding: 0.55rem 0.9rem; font-size: var(--step--1); }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  border-radius: 4px;
}

.site-nav ul { display: flex; gap: 0.25rem; list-style: none; }
.site-nav a {
  display: block;
  padding: 0.5rem 0.8rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius);
}
.site-nav a:hover { background: var(--paper-deep); }
.site-nav a[aria-current="true"] { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.site-nav .nav-cta { background: var(--ink); color: #fff; }
.site-nav .nav-cta:hover { background: var(--accent); }
.site-nav .nav-cta[aria-current="true"] { color: #fff; box-shadow: none; border-radius: var(--radius); }

.nav-toggle {
  display: none;
  width: 44px; height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  position: relative;
}
.nav-toggle-bar,
.nav-toggle-bar::before,
.nav-toggle-bar::after {
  position: absolute;
  left: 50%;
  width: 20px; height: 2px;
  margin-left: -10px;
  background: var(--ink);
  content: "";
}
.nav-toggle-bar { top: 50%; margin-top: -1px; }
.nav-toggle-bar::before { top: -6px; }
.nav-toggle-bar::after { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::before { top: 0; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::after { top: 0; transform: rotate(-45deg); }

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .site-nav {
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 0.5rem var(--gutter) 1rem;
    display: none;
  }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; }
  .site-nav a { padding: 0.8rem 0.5rem; font-size: 1.05rem; }
  .site-nav a[aria-current="true"] { box-shadow: inset 3px 0 0 var(--accent); }
  .site-nav .nav-cta { margin-top: 0.5rem; text-align: center; }
}

/* ---------- Hero ---------- */

.hero { padding-block: clamp(2.5rem, 6vw, 5rem) var(--section); }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.9fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: end;
}
.hero-name {
  font-size: var(--step-hero);
  line-height: 0.98;
  letter-spacing: -0.035em;
  font-weight: 800;
  max-width: 9ch;
}
.hero-roles {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0;
  margin: 1.6rem 0 1.5rem;
  font-weight: 600;
  font-size: var(--step-0);
}
.hero-roles li { padding-right: 0.8rem; margin-right: 0.8rem; border-right: 2px solid var(--accent); line-height: 1.3; }
.hero-roles li:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.hero-intro { max-width: 60ch; color: var(--ink-soft); font-size: var(--step-1); line-height: 1.6; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }

.hero-portrait { margin: 0; }
.hero-portrait img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: center top;
  border-radius: var(--radius);
  background: var(--paper-deep);
}

.facts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: clamp(3rem, 7vw, 5rem) 0 0;
  border-top: 2px solid var(--ink);
}
.facts > div { padding: 1.1rem 1rem 0 0; }
.facts > div + div { padding-left: 1rem; border-left: 1px solid var(--line); }
.facts dt { font-size: var(--step-2); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.facts dd { margin: 0.35rem 0 0; color: var(--ink-soft); font-size: var(--step--1); line-height: 1.45; }

/* ---------- Sections ---------- */

.section { padding-block: var(--section); border-top: 1px solid var(--line); }
.section-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 1rem 3rem; margin-bottom: clamp(2rem, 5vw, 3.5rem); align-items: start; }
.section-head h2 { font-size: var(--step-3); letter-spacing: -0.03em; }
.lead { color: var(--ink-soft); font-size: var(--step-1); line-height: 1.55; max-width: 62ch; }

/* ---------- Skills ---------- */

.skills {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 0;
  border-top: 1px solid var(--ink);
}
.skills li { padding: 1.4rem 1.4rem 1.6rem 0; border-bottom: 1px solid var(--line); }
.skills h3 { font-size: var(--step-1); margin-bottom: 0.45rem; }
.skills p { color: var(--ink-soft); font-size: 0.97rem; }

/* ---------- Projects ---------- */

.project-index ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  counter-reset: proj;
}
.project-index a {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  background: var(--surface);
}
.project-index a:hover { border-color: var(--ink); }

.case { padding-block: clamp(3.5rem, 7vw, 5.5rem); }
.case + .case { border-top: 1px solid var(--line); }

.case-head { margin-bottom: 2rem; }
.case-client {
  display: inline-block;
  margin-bottom: 0.8rem;
  padding: 0.2rem 0.65rem;
  background: var(--ink);
  color: var(--paper);
  font-size: var(--step--1);
  font-weight: 600;
  border-radius: 3px;
}
.case-head h3 { font-size: var(--step-2); max-width: 26ch; letter-spacing: -0.025em; }

/* “Slate” — thông tin sản xuất như bảng ghi hình */
.slate {
  display: flex;
  flex-wrap: wrap;
  margin: 1.4rem 0 0;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.slate > div { flex: 1 1 200px; padding: 0.7rem 1rem; border-right: 1px solid var(--line); }
.slate > div:last-child { border-right: 0; }
.slate dt { font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; }
.slate dd { margin: 0.1rem 0 0; font-weight: 600; line-height: 1.4; }

.case-body {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 2rem clamp(2rem, 5vw, 4rem);
  align-items: start;
}
.case-text { max-width: 66ch; }
.subproject { margin-top: 1.6rem; padding-left: 1rem; border-left: 3px solid var(--accent); }
.subproject h4 { font-size: 1.08rem; margin-bottom: 0.35rem; }
.subproject p { color: var(--ink-soft); }

.scope { list-style: none; border-top: 1px solid var(--ink); }
.scope li { padding: 0.7rem 0 0.7rem 1.4rem; border-bottom: 1px solid var(--line); position: relative; line-height: 1.45; }
.scope li::before { content: ""; position: absolute; left: 0; top: 1.15rem; width: 8px; height: 2px; background: var(--accent); }

/* ---------- Video ---------- */

.videos { display: grid; gap: 1rem; }
.case-body > .videos { grid-column: 2; grid-row: 1; }
.video {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
}
.video.is-vertical { aspect-ratio: 9 / 16; max-width: 360px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-play {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  padding: 0; border: 0;
  background: var(--ink);
  cursor: pointer;
  color: #fff;
  font: inherit;
}
.video-play img { width: 100%; height: 100%; object-fit: cover; opacity: 0.78; transition: opacity 0.2s; }
.video-play:hover img { opacity: 0.6; }
.video-label {
  position: absolute; left: 0.75rem; bottom: 0.75rem; right: 0.75rem;
  display: flex; align-items: center; gap: 0.6rem;
  font-weight: 600; font-size: 0.95rem; text-align: left;
  text-shadow: 0 1px 3px rgb(0 0 0 / 0.6);
}
.play-icon {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  position: relative;
}
.play-icon::after {
  content: ""; position: absolute; left: 17px; top: 13px;
  border-style: solid; border-width: 9px 0 9px 14px;
  border-color: transparent transparent transparent #fff;
}
.video-play:focus-visible { outline-offset: -4px; outline-color: #fff; }

/* ---------- Gallery ---------- */

.gallery {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 0.75rem;
  margin-top: 2.25rem;
}
.gallery:empty { display: none; }
.gallery li { position: relative; }
.gallery li.is-wide { grid-column: span 2; }
.gallery li.is-tall { grid-row: span 2; }
.shot {
  display: block;
  width: 100%; height: 100%;
  padding: 0; border: 0;
  background: var(--paper-deep);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
}
.shot img {
  width: 100%; height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform 0.35s ease;
}
.gallery li.is-tall .shot img { aspect-ratio: auto; min-height: 100%; }
.shot:hover img { transform: scale(1.025); }
.shot:focus-visible { outline-offset: 2px; }
.gallery-more { display: flex; margin: 1.25rem auto 0; }
.gallery-group-title {
  grid-column: 1 / -1;
  margin: 0.7rem 0 -0.25rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--step-0);
  font-weight: 750;
  letter-spacing: -0.01em;
  list-style: none;
}
.gallery-group-title:first-child { margin-top: 0; }

/* ---------- Process ---------- */

.section-process { background: var(--ink); color: var(--paper); border-top: 0; }
.section-process .lead { color: #c9ccd3; }
.section-process :focus-visible { outline-color: #8fb0ff; }
.process {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  counter-reset: step;
  border-top: 1px solid #3a3f4a;
}
.process li { counter-increment: step; padding: 1.4rem 1.2rem 0 0; }
.process li + li { padding-left: 1.2rem; border-left: 1px solid #3a3f4a; }
.process li::before {
  content: counter(step, decimal-leading-zero);
  display: block;
  margin-bottom: 1rem;
  font-size: var(--step-2);
  font-weight: 800;
  color: #8fb0ff;
  font-variant-numeric: tabular-nums;
}
.process h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.process p { color: #c9ccd3; font-size: 0.95rem; }

/* ---------- Resume ---------- */

.resume { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 2.5rem clamp(2rem, 6vw, 5rem); }
.resume h3 { font-size: var(--step-1); padding-bottom: 0.6rem; border-bottom: 1px solid var(--ink); margin-bottom: 1rem; }
.resume h3:not(:first-child) { margin-top: 2.2rem; }
.timeline { list-style: none; }
.timeline li {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 0 1.2rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line);
}
.timeline p { margin: 0; }
.tl-time { grid-row: span 2; color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.tl-role { font-weight: 700; }
.tl-org { color: var(--ink-soft); }
.resume-block p { margin: 0; }
.resume-block.plain { list-style: none; }
.resume-block.plain li { padding: 0.25rem 0; font-weight: 600; }
.tools { color: var(--ink-soft); }

/* ---------- Contact ---------- */

.section-contact { background: var(--paper-deep); }
.contact-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem clamp(2rem, 6vw, 5rem); align-items: start; }
.contact-grid h2 { font-size: var(--step-3); margin-bottom: 1rem; letter-spacing: -0.03em; }
.contact-place { margin-top: 1rem; font-weight: 600; }
.contact-actions { display: grid; gap: 0.75rem; }
.contact-link {
  display: grid;
  gap: 0.15rem;
  padding: 1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.contact-link:hover { background: var(--ink); color: #fff; }
.contact-kind { font-size: 0.85rem; font-weight: 600; opacity: 0.8; }
.contact-value { font-size: var(--step-1); font-weight: 700; overflow-wrap: anywhere; }
.contact-cv[hidden] { display: none; }

/* ---------- Footer ---------- */

.site-footer { padding-block: 2rem; border-top: 1px solid var(--line); font-size: 0.92rem; color: var(--ink-soft); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem 2rem; }
.site-footer p { margin: 0; }

/* ---------- Lightbox ---------- */

.lightbox {
  width: 100vw; height: 100vh;
  max-width: 100vw; max-height: 100vh;
  margin: 0; padding: clamp(3.5rem, 6vw, 4.5rem) clamp(0.5rem, 5vw, 5rem);
  border: 0;
  background: rgb(12 13 16 / 0.96);
  color: #fff;
}
.lightbox::backdrop { background: rgb(12 13 16 / 0.8); }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox-figure { margin: 0; display: grid; gap: 0.75rem; justify-items: center; max-height: 100%; }
.lightbox-img { max-width: 100%; max-height: calc(100vh - 10rem); width: auto; height: auto; object-fit: contain; border-radius: 4px; }
.lightbox-caption { max-width: 70ch; text-align: center; font-size: 0.95rem; color: #d7d9de; }
.lightbox-count { position: absolute; top: 1.1rem; left: 1.25rem; margin: 0; font-size: 0.9rem; color: #d7d9de; font-variant-numeric: tabular-nums; }
.lightbox-btn {
  position: absolute;
  width: 48px; height: 48px;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 50%;
  background: rgb(0 0 0 / 0.4);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-btn:hover { background: var(--accent); border-color: var(--accent); }
.lightbox-btn:focus-visible { outline-color: #8fb0ff; }
.lightbox-close { top: 0.75rem; right: 0.75rem; }
.lightbox-prev { left: 0.75rem; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 0.75rem; top: 50%; transform: translateY(-50%); }
.lightbox.is-single .lightbox-prev,
.lightbox.is-single .lightbox-next { display: none; }

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 1.2rem; }
  .facts > div:nth-child(4) { padding-left: 0; border-left: 0; }
  .process { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
  .process li, .process li + li { padding: 1.4rem 1.2rem 1.4rem 0; border-left: 0; border-bottom: 1px solid #3a3f4a; }
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .hero-grid, .section-head, .case-body, .resume, .contact-grid { grid-template-columns: minmax(0, 1fr); }
  .hero-portrait { order: -1; max-width: 220px; }
  .case-body > .videos { grid-column: auto; grid-row: auto; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts > div, .facts > div + div { padding-left: 0; border-left: 0; }
  .facts > div:nth-child(even) { padding-left: 1rem; border-left: 1px solid var(--line); }
  .process { grid-template-columns: minmax(0, 1fr); }
  .timeline li { grid-template-columns: minmax(0, 1fr); }
  .tl-time { grid-row: auto; font-size: 0.88rem; }
  .gallery { gap: 0.5rem; }
  .gallery li.is-wide { grid-column: span 2; }
  .hero-actions .btn { flex: 1 1 auto; }
  .hero-portrait { max-width: 160px; }
  .hero-roles { flex-direction: column; gap: 0.3rem; }
  .hero-roles li, .hero-roles li:last-child { border-right: 0; margin-right: 0; padding: 0 0 0 0.7rem; border-left: 2px solid var(--accent); }
  .slate > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .slate > div:last-child { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
