/* ==========================================================================
   Duy Hoang — minimalist portfolio
   ========================================================================== */

:root {
  --ink: #141414;
  --ink-soft: #6b6b6b;
  --paper: #fafaf8;
  --line: #e6e4df;
  --accent: #141414;
  --overlay: #0c0c0d;
  --header-bg: rgba(250, 250, 248, 0.92);
  --menu-bg: #ffffff;
  --menu-hover: #f4f3ef;
  --tile-bg: #ecebe7;
  color-scheme: light;
  --header-h: 84px;
  --gutter: clamp(16px, 4vw, 48px);
  --font-sans: "Jost", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-script: "Pinyon Script", cursive;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Dark mode ----------
   Follows the visitor's system setting; the header toggle overrides it
   (stored as data-theme on <html>, remembered in localStorage). */
:root[data-theme="dark"] {
  --ink: #ecebe8;
  --ink-soft: #9b9994;
  --paper: #111112;
  --line: #2a2a2d;
  --header-bg: rgba(17, 17, 18, 0.88);
  --menu-bg: #1b1b1d;
  --menu-hover: #252528;
  --tile-bg: #1d1d1f;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #ecebe8;
    --ink-soft: #9b9994;
    --paper: #111112;
    --line: #2a2a2d;
    --header-bg: rgba(17, 17, 18, 0.88);
    --menu-bg: #1b1b1d;
    --menu-hover: #252528;
    --tile-bg: #1d1d1f;
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--ink);
  background: var(--paper);
  transition: background-color .3s, color .3s;
  -webkit-font-smoothing: antialiased;
}

img, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }

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

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  background: var(--header-bg);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s, background .3s;
}
.site-header.is-scrolled { border-bottom-color: var(--line); }

/* Transparent header over the home hero */
.site-header--overlay {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  color: #fff;
}

.logo {
  font-family: var(--font-script);
  font-weight: 700;              /* Pinyon Script ships one weight; this synthesizes bold */
  -webkit-text-stroke: 0.6px currentColor;  /* adds real heft to the strokes */
  font-size: clamp(30px, 4.2vw, 40px);
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  padding-top: 6px;              /* script descenders sit high; optically centre it */
}

.nav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: clamp(18px, 3vw, 40px);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.nav a,
.dropdown__toggle {
  position: relative;
  padding: 6px 0;
  letter-spacing: inherit;
  text-transform: inherit;
}

/* Hairline underline on hover / current page */
.nav > a::after,
.dropdown__toggle::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .35s var(--ease);
}
.nav > a:hover::after,
.nav > a[aria-current="page"]::after,
.dropdown__toggle:hover::after,
.dropdown.is-open .dropdown__toggle::after { transform: scaleX(1); }

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

.dropdown { position: relative; }

.dropdown__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dropdown__toggle svg { width: 9px; height: 9px; transition: transform .3s var(--ease); }
.dropdown.is-open .dropdown__toggle svg { transform: rotate(180deg); }

.dropdown__menu {
  position: absolute;
  top: calc(100% + 14px);
  right: -16px;
  min-width: 240px;
  margin: 0;
  padding: 8px 0;
  list-style: none;
  background: var(--menu-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .25);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .25s, transform .25s var(--ease), visibility .25s;
  text-transform: none;
  letter-spacing: 0;
}
/* Invisible bridge so the menu doesn't close while the pointer travels to it */
.dropdown__menu::before {
  content: "";
  position: absolute;
  inset: -16px 0 100% 0;
}
.dropdown.is-open .dropdown__menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}
@media (hover: hover) {
  .dropdown:hover .dropdown__menu { opacity: 1; visibility: visible; transform: none; }
  .dropdown:hover .dropdown__toggle svg { transform: rotate(180deg); }
}

.dropdown__menu a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 20px;
  font-size: 15px;
  transition: background .2s;
}
.dropdown__menu a:hover { background: var(--menu-hover); }
.dropdown__menu a::after { display: none; }
.dropdown__menu small {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: -5px;
  border-radius: 50%;
  transition: background .2s;
}
.theme-toggle:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.theme-toggle svg { width: 17px; height: 17px; }
/* Show the moon in light mode, the sun in dark mode */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- Home hero ---------- */

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: var(--header-h) var(--gutter);
  color: #fff;
  text-align: center;
  background: #1c1b22 url("/media/hero/hero.jpg") center / cover no-repeat;
  isolation: isolate;
}
/* Gentle scrim so the slogan stays legible on any photo */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.35) 0%, rgba(0,0,0,0) 22%),
    radial-gradient(ellipse at center, rgba(0,0,0,.28) 0%, rgba(0,0,0,.08) 60%, rgba(0,0,0,.25) 100%);
}

.hero__inner { max-width: 880px; }

.hero__slogan {
  margin: 0;
  font-weight: 300;
  font-size: clamp(30px, 5.4vw, 64px);
  line-height: 1.12;
  letter-spacing: -0.01em;
  text-wrap: balance;
  text-shadow: 0 2px 30px rgba(0,0,0,.25);
  animation: rise 1.2s var(--ease) both .15s;
}

.hero__roles {
  margin: 28px 0 0;
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  opacity: .85;
  animation: rise 1.2s var(--ease) both .45s;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Inner pages ---------- */

.page {
  padding: calc(var(--header-h) + clamp(24px, 5vw, 56px)) var(--gutter) 80px;
  max-width: 1600px;
  margin: 0 auto;
}

.page__title {
  margin: 0 0 clamp(24px, 4vw, 48px);
  font-weight: 300;
  font-size: clamp(28px, 3.4vw, 40px);
  letter-spacing: -0.01em;
}

/* ---------- Masonry grid ---------- */

.masonry {
  column-count: 1;
  column-gap: 14px;
}
@media (min-width: 560px)  { .masonry { column-count: 2; } }
@media (min-width: 960px)  { .masonry { column-count: 3; column-gap: 18px; } }
@media (min-width: 1400px) { .masonry { column-count: 4; } }

.tile {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 0 14px;
  break-inside: avoid;
  overflow: hidden;
  background: var(--tile-bg);
  cursor: zoom-in;
}
@media (min-width: 960px) { .tile { margin-bottom: 18px; } }

.tile img,
.tile video {
  width: 100%;
  height: auto;
  opacity: 0;
  transform: scale(1.001);
  transition: opacity .6s var(--ease), transform .8s var(--ease);
}
.tile.is-loaded img,
.tile.is-loaded video { opacity: 1; }
.tile:hover img,
.tile:hover video { transform: scale(1.03); }

.tile__badge {
  position: absolute;
  top: 12px; right: 12px;
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  color: #fff;
  pointer-events: none;
}
.tile__badge svg { width: 11px; height: 11px; margin-left: 2px; }

.grid-status {
  color: var(--ink-soft);
  font-size: 15px;
}

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

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  background: var(--overlay);
  color: #fff;
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s, visibility .3s;
  touch-action: pan-y;
}
.lightbox[hidden] { display: none; }
.lightbox.is-open { opacity: 1; visibility: visible; }

.lightbox__stage {
  margin: 0;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 76px clamp(12px, 8vw, 110px) 64px;
}
.lightbox__stage img,
.lightbox__stage video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.6);
  animation: fade .35s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.lightbox__caption {
  position: absolute;
  left: 0; right: 0; bottom: 22px;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,.7);
  padding: 0 70px;
  pointer-events: none;
}

/* Persistent Back / Home controls, top-left */
.lightbox__top-left {
  position: absolute;
  top: 20px;
  left: var(--gutter);
  display: flex;
  gap: 10px;
  z-index: 2;
}
.lb-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fff;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  background: rgba(255,255,255,.04);
  transition: background .2s, border-color .2s;
}
.lb-btn:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.6); }
.lb-btn svg { width: 14px; height: 14px; }

.lightbox__counter {
  position: absolute;
  top: 30px;
  right: var(--gutter);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: rgba(255,255,255,.65);
  font-variant-numeric: tabular-nums;
}

.lightbox__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px; height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.2);
  transition: background .2s, border-color .2s;
  z-index: 2;
}
.lightbox__arrow:hover { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.55); }
.lightbox__arrow svg { width: 18px; height: 18px; }
.lightbox__arrow--prev { left: clamp(8px, 2vw, 32px); }
.lightbox__arrow--next { right: clamp(8px, 2vw, 32px); }

@media (max-width: 640px) {
  .lightbox__stage { padding: 72px 8px 70px; }
  .lightbox__arrow { top: auto; bottom: 14px; transform: none; width: 44px; height: 44px; }
  .lightbox__caption { bottom: 28px; }
  .lb-btn { padding: 0 13px; }
}

body.lightbox-open { overflow: hidden; }

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

.contact {
  min-height: calc(100vh - var(--header-h) - 160px);
  display: grid;
  align-content: center;
  max-width: 640px;
}
.contact p {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.contact__soon {
  display: inline-block;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink);
}

/* ---------- Hamburger menu (phones & small tablets) ---------- */

.menu-toggle { display: none; }

/* Desktop: the theme toggle is icon-only; the label stays for screen readers */
.theme-toggle__label {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.theme-toggle__switch { display: none; }

@media (max-width: 720px) {
  :root { --header-h: 68px; --gutter: 20px; }
  .logo { font-size: 30px; }

  .menu-toggle {
    position: relative;
    display: block;
    width: 40px;
    height: 40px;
    margin-right: -9px;
  }
  .menu-toggle span {
    position: absolute;
    left: 9px;
    width: 22px;
    height: 1.5px;
    background: currentColor;
    transition: transform .3s var(--ease), top .3s var(--ease);
  }
  .menu-toggle span:first-child { top: 15px; }
  .menu-toggle span:last-child  { top: 23px; }
  .menu-open .menu-toggle span:first-child { top: 19px; transform: rotate(45deg); }
  .menu-open .menu-toggle span:last-child  { top: 19px; transform: rotate(-45deg); }

  /* When open, the header turns solid (also over the home photo) */
  .site-header.menu-open {
    background: var(--paper);
    color: var(--ink);
    border-bottom-color: var(--line);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px var(--gutter) 40px;
    background: var(--paper);
    color: var(--ink);
    font-size: 15px;
    letter-spacing: 0.18em;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity .25s, transform .3s var(--ease), visibility .25s;
  }
  .menu-open .nav { opacity: 1; visibility: visible; transform: none; }

  .nav > * { border-bottom: 1px solid var(--line); }

  .nav > a,
  .dropdown__toggle,
  .theme-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 22px 0;
  }
  .nav > a::after,
  .dropdown__toggle::after { display: none; }
  .nav > a[aria-current="page"] { font-weight: 500; }
  .nav > a[aria-current="page"]::before {
    content: "";
    width: 5px; height: 5px;
    margin-right: 12px;
    border-radius: 50%;
    background: currentColor;
  }

  /* Projects expands in place */
  .dropdown__toggle { justify-content: space-between; }
  .dropdown__toggle svg { width: 11px; height: 11px; }
  .dropdown__menu,
  .dropdown:hover .dropdown__menu {
    position: static;
    display: none;
    min-width: 0;
    padding: 0 0 14px;
    background: transparent;
    border: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
  }
  .dropdown__menu::before { display: none; }
  .dropdown.is-open .dropdown__menu { display: block; }
  .dropdown:not(.is-open):hover .dropdown__toggle svg { transform: none; }
  .dropdown__menu a { padding: 10px 0 10px 18px; font-size: 16px; }
  .dropdown__menu a:hover { background: transparent; }

  /* Dark mode row with a switch */
  .theme-toggle {
    height: auto;
    margin: 0;
    gap: 14px;
    border-radius: 0;
    text-transform: uppercase;
    letter-spacing: inherit;
  }
  .theme-toggle:hover { background: none; }
  .theme-toggle__label {
    position: static;
    width: auto; height: auto;
    overflow: visible;
    clip: auto;
  }
  .theme-toggle__switch {
    display: block;
    position: relative;
    width: 42px;
    height: 24px;
    margin-left: auto;
    border: 1px solid var(--ink-soft);
    border-radius: 999px;
    transition: background .25s, border-color .25s;
  }
  .theme-toggle__switch::after {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--ink-soft);
    transition: transform .25s var(--ease), background .25s;
  }
  .theme-toggle[aria-pressed="true"] .theme-toggle__switch { background: var(--ink); border-color: var(--ink); }
  .theme-toggle[aria-pressed="true"] .theme-toggle__switch::after { transform: translateX(18px); background: var(--paper); }

  body.menu-open { overflow: hidden; }
}

@media (max-width: 420px) {
  .hero__roles { font-size: 10.5px; letter-spacing: 0.2em; }
}

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