:root {
  --serif: "Fraunces", "Times New Roman", serif;
  --text: "Newsreader", Georgia, serif;
  --home-font: "Cormorant Garamond", Garamond, "Times New Roman", serif;
  --bg: #0b0b0b;
  --fg: #f2efe9;
  --muted: rgba(242, 239, 233, 0.68);
}
body[data-view="work"] {
  --bg: #ffffff;
  --fg: #111111;
  --muted: rgba(17, 17, 17, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: clip; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--text);
  font-size: 18px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.5s ease;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

.fill { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(var(--crop, 1)); }

.view { opacity: 0; transition: opacity 0.6s ease; }
.view.is-in { opacity: 1; }

/* ---------- Title card (thumbnail tạm khi chưa có media) ---------- */
.card {
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: clamp(16px, 3vw, 28px);
  color: #fff;
  background:
    radial-gradient(110% 90% at 25% 15%, hsl(var(--h) 55% 42% / 0.9), transparent 60%),
    radial-gradient(90% 90% at 85% 95%, hsl(calc(var(--h) + 35) 60% 28% / 0.9), transparent 60%),
    hsl(var(--h) 30% 10%);
  background-size: 170% 170%;
  animation: drift 16s ease-in-out infinite alternate;
  overflow: hidden;
}
.card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.16; mix-blend-mode: overlay;
}
.card-title { position: relative; z-index: 1; font-family: var(--serif); font-weight: 300; font-size: clamp(1.5rem, 3.4vw, 2.5rem); line-height: 1.05; }
.card-meta { position: relative; z-index: 1; margin-top: 6px; font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.7; }
@keyframes drift { from { background-position: 0% 0%; } to { background-position: 100% 100%; } }

/* ---------- Topbar & socials ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 20px clamp(16px, 3vw, 32px);
  font-family: var(--serif); font-size: 1.15rem; letter-spacing: 0.04em; text-transform: uppercase;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 80%, transparent) 30%, transparent);
  pointer-events: none;
}
body[data-view="home"] .topbar { background: none; }
.topbar a { pointer-events: auto; transition: opacity 0.2s; }
.menu { display: flex; gap: clamp(16px, 3vw, 32px); }
.menu a { opacity: 0.6; }
/* Work dropdown: opens on hover / keyboard focus */
.has-sub { position: relative; pointer-events: auto; }
.submenu {
  position: absolute; top: 100%; right: -14px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  margin-top: 8px; padding: 12px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  font-size: 0.85em; letter-spacing: 0.08em; white-space: nowrap;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.submenu::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; } /* hover bridge */
.has-sub:hover .submenu, .has-sub:focus-within .submenu { opacity: 1; visibility: visible; transform: none; }
.submenu a:hover { opacity: 1; }
body[data-view="home"] .submenu { background: rgba(0, 0, 0, 0.55); }
.menu a:hover, .menu a[aria-current] { opacity: 1; }
body[data-view="home"] .brand { opacity: 0; pointer-events: none; }
body[data-view="home"] .topbar { color: #fff; }

/* Footer icons: end of every page, centered (the homepage has its own set). */
.socials {
  position: relative; z-index: 1;
  display: flex; justify-content: center; gap: 20px;
  padding: 8px 16px 48px;
}
.socials a, .pager-socials a { display: block; width: 24px; height: 24px; opacity: 0.85; transition: opacity 0.2s, transform 0.2s; }
.socials a:hover, .pager-socials a:hover { opacity: 1; transform: translateY(-2px); }
.socials svg, .pager-socials svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.socials svg .solid, .pager-socials svg .solid { fill: currentColor; stroke: none; }

/* ---------- Home ---------- */
.home { position: fixed; inset: 0; background: #000; overflow: hidden; container-type: size; }
.reel { position: absolute; inset: 0; }
.slide { position: absolute; inset: 0; opacity: 0; transition: opacity 1.4s ease; }
.slide.is-on { opacity: 1; }
.slide .card { animation: drift 16s ease-in-out infinite alternate, zoom 10s ease-out infinite alternate; }
@keyframes zoom { from { transform: scale(var(--crop, 1)); } to { transform: scale(calc(var(--crop, 1) * 1.08)); } }
.slide .fill { animation: zoom 10s ease-out infinite alternate; }
.reel::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, 0.38); }
/* Showreel keeps its original framing (letterbox included); phones held upright fill the screen. */
.reel video.fill { object-fit: contain; transform: none; }
@media (max-width: 768px) and (orientation: portrait) {
  .reel video.fill { object-fit: cover; }
}

.home-title {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 16px; text-align: center; color: #fff;
  pointer-events: none;
}
.home-name { display: block; pointer-events: auto; }
.home-name h1 {
  font-family: var(--home-font); font-weight: 500; text-transform: uppercase;
  font-size: clamp(1.8rem, 5.6vw, 4.5rem); line-height: 1;
  letter-spacing: 0.08em; padding-left: 0.08em; /* optically center letter-spaced text */
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.35);
}
@media (max-width: 768px) {
  /* Phones: the name needs clear contrast against the letter-spaced DIRECTOR line. */
  .home-name h1 { font-size: clamp(1.9rem, 10.5vw, 2.75rem); }
}
.home-role {
  margin-top: 6px; line-height: 1.2;
  font-family: var(--home-font); font-weight: 600;
  font-size: clamp(1.05rem, 1.9vw, 1.5rem); letter-spacing: 0.36em; text-transform: uppercase;
  padding-left: 0.36em;
}
.home-tagline {
  margin-top: 0; line-height: 1.25;
  font-family: var(--home-font); font-style: italic; font-weight: 500;
  font-size: clamp(1.05rem, 1.7vw, 1.4rem); opacity: 0.9;
}
.home-socials {
  position: absolute; left: 50%; bottom: clamp(20px, 4vh, 40px); transform: translateX(-50%);
  display: flex; gap: 20px; pointer-events: auto;
}
/* Sit the icons just under the picture's bottom edge in the reel's final shots
   (letterbox starts at 949/1080 = 87.87% of the frame). --reel-h is the rendered video height. */
@supports (top: 1cqh) {
  .home-socials {
    --reel-h: min(100cqh, 100cqw * 1080 / 2048);
    --gap: max(14px, var(--reel-h) * 0.035); /* the letterbox is thick on desktop: sit a bit lower */
    bottom: auto;
    top: calc((100cqh - var(--reel-h)) / 2 + var(--reel-h) * 0.8787 + var(--gap));
  }
  @media (max-width: 768px) and (orientation: portrait) {
    .home-socials {
      --reel-h: max(100cqh, 100cqw * 1080 / 2048);
      --gap: max(10px, var(--reel-h) * 0.02);
    }
  }
}
.home-socials a { display: block; width: 22px; height: 22px; opacity: 0.85; transition: opacity 0.2s, transform 0.2s; }
.home-socials a:hover { opacity: 1; transform: translateY(-2px); }
.home-socials svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.home-socials svg .solid { fill: currentColor; stroke: none; }
body[data-view="home"] .socials { display: none; }

/* ---------- Work ---------- */
.work { padding: 110px 0 120px; }
.work-head {
  width: min(56vw, 640px); margin: 0 auto 64px;
  font-family: var(--serif); font-weight: 300; text-transform: uppercase;
  font-size: clamp(3rem, 9vw, 7rem); line-height: 0.9; letter-spacing: -0.02em;
}
.work-head span {
  display: block; margin-top: 12px;
  font-family: var(--text); font-size: 0.85rem; letter-spacing: 0.18em; color: var(--muted);
}
.work-list { width: min(56vw, 640px); margin-inline: auto; }
.work-filters {
  width: min(56vw, 640px); margin: -36px auto 56px;
  display: flex; flex-wrap: wrap; gap: 6px 22px;
  font-family: var(--serif); font-size: 0.85rem; letter-spacing: 0.16em; text-transform: uppercase;
}
.work-filters a { color: var(--muted); padding-bottom: 3px; border-bottom: 1px solid transparent; transition: color 0.2s; }
.work-filters a:hover { color: var(--fg); }
.work-filters a[aria-current] { color: var(--fg); border-color: currentColor; }

/* Other credits: CV-style list under the directed work */
.other-credits { width: min(56vw, 640px); margin: 96px auto 0; }
.work-filters + .other-credits { margin-top: 0; }
.other-credits h2 {
  font-family: var(--serif); font-weight: 400; font-size: 0.85rem; letter-spacing: 0.16em; text-transform: uppercase;
  margin-bottom: 14px;
}
.other-credits li { border-top: 1px solid rgba(17, 17, 17, 0.14); }
.other-credits li:last-child { border-bottom: 1px solid rgba(17, 17, 17, 0.14); }
.other-credits a {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 2px 24px; padding: 14px 0;
  transition: padding 0.25s;
}
.other-credits a:hover { padding-left: 8px; }
.oc-title { font-family: var(--serif); font-size: 1.15rem; line-height: 1.3; }
.oc-role { color: var(--fg); font-size: 0.95rem; text-align: right; }
.oc-meta { grid-column: 1 / -1; color: var(--muted); font-size: 0.85rem; }
.work-group {
  display: flex; gap: 14px; align-items: baseline;
  padding: 56px 0 14px;
  font-family: var(--serif); font-size: 0.85rem; letter-spacing: 0.16em; text-transform: uppercase;
}
.work-group:first-child { padding-top: 0; }
.work-group span { color: var(--muted); }
.work-item { position: relative; }
.work-thumb {
  position: relative; z-index: 1; display: block;
  aspect-ratio: 16 / 9; overflow: hidden; background: #111;
}
.marquee {
  position: absolute; top: 50%; left: 50%; z-index: 0;
  width: 100vw; transform: translate(-50%, -50%);
  pointer-events: none; opacity: 0; transition: opacity 0.35s ease;
}
.work-item:hover .marquee, .work-item.is-active .marquee { opacity: 1; }
.mq-row { display: flex; width: max-content; animation: marquee 50s linear infinite; }
.mq-rev { animation-direction: reverse; }
.mq-row span {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(64px, 11vw, 150px); line-height: 1;
  white-space: nowrap; padding-right: 0.25em;
  color: transparent; -webkit-text-stroke: 1.4px var(--fg);
}
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Project & About (nền tối) ---------- */
.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.backdrop .fill { filter: brightness(0.42) blur(3px); transform: scale(calc(var(--crop, 1) * 1.06)); }
.backdrop .card { animation-duration: 30s; }

.project, .about { position: relative; min-height: 100svh; }
.project-inner, .about-inner, .pager { position: relative; z-index: 1; }

.project-inner {
  width: min(900px, 100% - 32px); margin-inline: auto;
  padding: 100px 0 40px; text-align: center;
}
.player { position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.project-title { font-family: var(--serif); font-weight: 400; font-size: clamp(1.9rem, 4vw, 2.6rem); margin-top: 36px; line-height: 1.1; }
.project-sub { margin-top: 6px; font-style: italic; color: var(--muted); }
.notes { margin-top: 36px; display: grid; gap: 6px; color: var(--muted); font-size: 0.95rem; }
.notes li::before { content: "✦"; margin-right: 10px; font-size: 0.7em; vertical-align: 0.15em; color: var(--fg); }
.credits {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 20px 24px;
  margin-top: 40px;
}
.credits > div { flex: 1 1 150px; max-width: 280px; }
.credits dt { font-family: var(--serif); font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase; }
.credits dd { color: var(--muted); font-size: 0.95rem; }

/* PREV · icons · NEXT on one row, so the social icons stay on screen with the pager. */
.pager {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 32px clamp(16px, 3vw, 32px) 32px;
}
.pager-link.prev { justify-self: start; }
.pager-link.next { justify-self: end; }
.pager-socials { display: flex; gap: 20px; }
body[data-view="project"] .socials { display: none; }
@media (max-width: 768px) {
  .pager { grid-template-columns: 1fr 1fr; row-gap: 24px; padding-bottom: 40px; }
  .pager-socials { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
}
.pager-link {
  font-family: var(--serif); font-weight: 400; text-transform: uppercase;
  font-size: clamp(2.6rem, 9vw, 8.5rem); line-height: 1;
  color: transparent; -webkit-text-stroke: 1.3px var(--fg);
  transition: color 0.35s ease;
}
.pager-link:hover { color: var(--fg); }

.about-inner { width: min(1080px, 100% - 32px); margin-inline: auto; padding: 130px 0 120px; }
.about-head {
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(2.4rem, 6.5vw, 5rem); line-height: 1.02; letter-spacing: -0.01em;
  margin-bottom: 64px;
}
.about-head em { font-style: italic; }
.about-body { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: clamp(28px, 5vw, 64px); align-items: start; }
.about-portrait { position: sticky; top: 90px; aspect-ratio: 4 / 5; overflow: hidden; }
.about-portrait img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(0.15); }
.about-text p { font-size: 1.15rem; margin-bottom: 1.2em; }
.about-text em { font-style: italic; }
.about-text blockquote {
  margin: 48px 0; padding-left: 24px; border-left: 1px solid var(--muted);
  font-family: var(--serif); font-style: italic; font-weight: 300;
  font-size: clamp(1.25rem, 2.4vw, 1.6rem); line-height: 1.4;
}
.about-contact { font-family: var(--serif); font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 40px; }
.about-contact a {
  display: inline-block; margin-top: 6px;
  font-size: clamp(1.3rem, 3vw, 1.8rem); letter-spacing: 0; text-transform: none;
  border-bottom: 1px solid currentColor; overflow-wrap: anywhere;
}
.about-cta {
  font-family: var(--serif); font-size: 1rem; letter-spacing: 0.12em; text-transform: uppercase;
  border-bottom: 1px solid currentColor; padding-bottom: 4px;
}

/* ---------- Custom cursor ---------- */
.cursor {
  position: fixed; left: 0; top: 0; z-index: 999;
  width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  background: #fff; mix-blend-mode: difference; pointer-events: none;
  opacity: 0; transition: opacity 0.2s, width 0.25s, height 0.25s, margin 0.25s;
}
.cursor.is-on { opacity: 1; }
.cursor.is-link { width: 46px; height: 46px; margin: -23px 0 0 -23px; }
html.has-cursor, html.has-cursor * { cursor: none; }

/* ---------- Responsive & a11y ---------- */
@media (max-width: 760px) {
  body { font-size: 17px; }
  .work { padding-top: 84px; }
  .work-list, .work-head, .work-filters, .other-credits { width: 80vw; }
  .other-credits a { grid-template-columns: 1fr; }
  .oc-role { text-align: left; }
  .about-body { grid-template-columns: 1fr; }
  .about-portrait { position: static; max-width: 320px; }
  .topbar { font-size: 1rem; }
  .project-inner { padding-top: 80px; }
  .about-inner { padding-top: 100px; }
}
a:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }

/* The showreel and the Work marquee are the point of the site, so they keep running.
   Reduced-motion users only lose the decorative extras. */
@media (prefers-reduced-motion: reduce) {
  .card, .slide .card, .slide .fill { animation: none; }
  .card::after { display: none; }
}
