/* czhang.uk — design values follow the redesign-existing-projects skill.
   Fonts: Geist, Geist Mono. Surfaces: #000000, #131209, #181818, #1F1F1F, #272727, #313131.
   Spacing: 0 2 4 8 12 16 24 32 40 48 64 80 96. Easing: cubic-bezier(0.22, 1, 0.36, 1). */

@font-face {
  font-family: "Geist";
  src: url("../fonts/geist-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/geist-mono-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #000000;
  --surface-1: #131209;
  --surface-2: #181818;
  --surface-3: #1f1f1f;
  --surface-4: #272727;
  --line: #313131;

  --text: #ffffff;
  --text-muted: #9b9b9b;
  --accent: #c9a45c;

  --nav-bg: rgb(24 24 24 / 0.72);
  --nav-line: rgb(49 49 49 / 0.8);
  --shadow: rgb(19 18 9 / 0.6);
  --shadow-strong: rgb(19 18 9 / 0.8);
  --backdrop: rgb(0 0 0 / 0.8);
  --overlay: rgb(24 24 24 / 0.8);
  --grad-a: #ffffff;
  --grad-b: #9b9b9b;
  --photo-opacity: 0.32;
  --grain: 0.05;
  color-scheme: dark;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --s-1: 2px;
  --s-2: 4px;
  --s-3: 8px;
  --s-4: 12px;
  --s-5: 16px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 48px;
  --s-10: 64px;
  --s-11: 80px;
  --s-12: 96px;

  --r-md: 0.375rem;
  --r-lg: 0.5rem;
  --r-xl: 0.75rem;
  --r-2xl: 1rem;

  --z-base: 0;
  --z-nav: 10;
  --z-menu: 20;
  --z-skip: 30;

  --font: "Geist", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  transition: color 300ms var(--ease), text-decoration-color 300ms var(--ease);
}
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

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

/* Fine grain on the page background; no gradients */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-base);
  pointer-events: none;
  opacity: var(--grain);
  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='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.skip-link {
  position: absolute;
  left: var(--s-5);
  top: -80px;
  z-index: var(--z-skip);
  padding: var(--s-3) var(--s-4);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--r-lg);
  font-weight: 600;
  text-decoration: none;
  transition: top 300ms var(--ease);
}
.skip-link:focus { top: var(--s-5); color: var(--bg); }

.wrap {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--s-6);
  position: relative;
  z-index: 1;
}

/* Navigation: floats off the edge on a blurred surface */
.nav {
  position: fixed;
  top: var(--s-5);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  gap: var(--s-6);
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-6);
  background: var(--nav-bg);
  border: 1px solid var(--nav-line);
  border-radius: var(--r-2xl);
  box-shadow: 0 8px 32px var(--shadow);
}

/* The blur sits on a pseudo layer: backdrop-filter on .nav itself would trap the fixed mobile panel inside the bar */
.nav::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.nav__brand {
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.25rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav__links a {
  display: block;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 300ms var(--ease), background-color 300ms var(--ease);
}
.nav__links a:hover { color: var(--text); background: var(--surface-3); }
.nav__links a[aria-current="true"] { color: var(--text); background: var(--surface-4); }

.nav__lang {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  background: var(--text);
  color: var(--bg);
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 300ms var(--ease), transform 500ms var(--ease);
}
.nav__lang:hover { background: var(--accent); color: var(--bg); }
.nav__lang:active { transform: scale(0.98); }

.nav__toggle {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
  position: relative;
}
.nav__toggle span {
  position: absolute;
  left: 12px;
  right: 12px;
  height: 2px;
  background: currentColor;
  transition: transform 500ms var(--ease), opacity 300ms var(--ease);
}
.nav__toggle span:nth-child(1) { top: 14px; }
.nav__toggle span:nth-child(2) { top: 19px; }
.nav__toggle span:nth-child(3) { top: 24px; }
.nav__toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.nav__toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav__toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

/* Hero */
.hero {
  position: relative;
  min-height: 100dvh;
  display: flex;
  align-items: flex-end;
  padding-block: var(--s-12) var(--s-11);
  overflow: hidden;
  background: var(--surface-1);
}

.hero__photo {
  position: absolute;
  inset: 0;
  z-index: var(--z-base);
}
.hero__photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 40%;
  opacity: var(--photo-opacity);
  filter: grayscale(0.4);
}
/* Solid scrim fades the photo into the page with a mask, not a gradient fill */
.hero__photo {
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
}

.hero__inner { max-width: 680px; margin-left: 0; }

.eyebrow {
  margin: 0 0 var(--s-6);
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.25rem;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.hero h1 {
  margin: 0;
  font-size: 3rem;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.04em;
  text-wrap: balance;
  background: linear-gradient(to right, var(--grad-a), var(--grad-b));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero__slogan {
  margin: var(--s-6) 0 0;
  font-size: 1.25rem;
  line-height: 1.75rem;
  color: var(--text-muted);
  text-wrap: pretty;
  max-width: 680px;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-6);
  margin-top: var(--s-9);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 0;
  border-radius: var(--r-lg);
  background: var(--text);
  color: var(--bg);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 300ms var(--ease), transform 500ms var(--ease);
}
.btn:hover { background: var(--accent); color: var(--bg); transform: translateY(-2px); }
.btn:active { transform: scale(0.98); }

.link-quiet {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: color 300ms var(--ease);
}
.link-quiet:hover { color: var(--text); }
.link-quiet:active { transform: translateY(1px); }

/* Sections: label column on the left, content on the right */
.section {
  padding-block: var(--s-12);
  position: relative;
  z-index: 1;
}

.section__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-8);
}

.section__label {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.25rem;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.section h2 {
  margin: var(--s-3) 0 0;
  font-size: 1.875rem;
  line-height: 2.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.prose { max-width: 65ch; }
.prose p { margin: 0 0 var(--s-5); color: var(--text-muted); text-wrap: pretty; }
.prose p:first-child { color: var(--text); font-size: 1.125rem; line-height: 1.75rem; }
.prose p:last-child { margin-bottom: 0; }
.prose--spaced { margin-top: var(--s-7); }
.prose--tight { margin-top: var(--s-6); }
.prose a, .entry a, .note a { color: var(--accent); font-weight: 500; }
.prose a:hover, .entry a:hover, .note a:hover { color: var(--text); text-decoration-color: var(--text); }

/* Link rows: plain list, no borders, outcome beside each link */
.rows { margin: var(--s-8) 0 0; padding: 0; list-style: none; display: grid; gap: var(--s-3); }
.rows a {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--s-5);
  padding: var(--s-5) var(--s-6);
  border-radius: var(--r-xl);
  background: var(--surface-2);
  text-decoration: none;
  transition: background-color 300ms var(--ease), transform 500ms var(--ease);
}
.rows a:hover { background: var(--surface-3); transform: translateX(4px); color: var(--text); }
.rows a:active { transform: translateX(4px) scale(0.99); }
.rows strong { display: block; font-weight: 600; }
.rows small { display: block; margin-top: var(--s-1); font-size: 0.875rem; line-height: 1.25rem; color: var(--text-muted); }
.rows i { font-size: 1.25rem; color: var(--text-muted); transition: color 300ms var(--ease); }
.rows a:hover i { color: var(--accent); }

/* Affiliations: two lists of unequal weight */
.lists { display: grid; gap: var(--s-8); margin-top: var(--s-8); }
.list h3 {
  margin: 0 0 var(--s-5);
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.list ul { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--s-3); }
.list a {
  display: inline-block;
  color: var(--accent);
  font-size: 1.125rem;
  line-height: 1.75rem;
  font-weight: 500;
  transition: color 300ms var(--ease), transform 500ms var(--ease);
}
.list a:hover { color: var(--text); transform: translateX(4px); }

/* Elsewhere: short entries */
.entries { margin: 0; display: grid; gap: var(--s-7); }
.entry h3 { margin: 0 0 var(--s-2); font-size: 1.125rem; line-height: 1.75rem; font-weight: 600; }
.entry p { margin: 0; color: var(--text-muted); max-width: 65ch; text-wrap: pretty; }

/* Contact block */
.contact {
  padding: var(--s-9) var(--s-6);
  border-radius: var(--r-2xl);
  background: var(--surface-2);
}
.contact h2 { margin-top: 0; }
.contact p { margin: var(--s-4) 0 0; color: var(--text-muted); max-width: 65ch; text-wrap: pretty; }
.contact__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-6); margin-top: var(--s-7); }

.note {
  margin-top: var(--s-5);
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--text-muted);
}

/* Footer */
.footer {
  padding-block: var(--s-10) var(--s-9);
  position: relative;
  z-index: 1;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.25rem;
}
.footer__inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-5); }
.footer a { color: var(--text); }
.footer a:hover { color: var(--accent); }
.footer nav { display: flex; gap: var(--s-6); }

/* Standalone pages (404, privacy) */
.page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  padding-block: var(--s-12);
  position: relative;
  z-index: 1;
}
.page h1 {
  margin: 0 0 var(--s-6);
  font-size: 3rem;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.04em;
  text-wrap: balance;
}
.page p { margin: 0 0 var(--s-5); color: var(--text-muted); max-width: 65ch; text-wrap: pretty; }
.page h2 { margin: var(--s-8) 0 var(--s-3); font-size: 1.25rem; line-height: 1.75rem; font-weight: 600; }

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 700ms var(--ease), transform 700ms var(--ease);
}
.reveal.is-in { opacity: 1; transform: none; }

/* Larger screens */
@media (min-width: 768px) {
  .nav { width: max-content; max-width: calc(100% - 32px); }
  .nav__links a, .nav__lang, .nav__brand { white-space: nowrap; }
  .hero h1 { font-size: 3.75rem; }
  .section h2 { font-size: 2.25rem; line-height: 2.5rem; }
  .section__grid { grid-template-columns: 5fr 7fr; gap: var(--s-10); }
  .lists { grid-template-columns: 3fr 2fr; }
  .contact { padding: var(--s-10); }
}

@media (min-width: 1024px) {
  .hero h1 { font-size: 6rem; line-height: 1; }
  .section__head { position: sticky; top: 96px; align-self: start; }
}

/* Mobile navigation: full height panel, links arrive one after another */
@media (max-width: 767px) {
  .nav {
    left: var(--s-5);
    right: var(--s-5);
    transform: none;
    justify-content: space-between;
  }
  .nav__toggle { display: block; }
  .nav__panel {
    position: fixed;
    inset: 0;
    z-index: var(--z-menu);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--s-6);
    padding: var(--s-10) var(--s-6);
    background: var(--bg);
    visibility: hidden;
    opacity: 0;
    transition: opacity 300ms var(--ease), visibility 0s linear 300ms;
  }
  .nav__panel[data-open="true"] { visibility: visible; opacity: 1; transition-delay: 0s; }
  .nav__links { flex-direction: column; align-items: flex-start; gap: var(--s-3); }
  .nav__links a { font-size: 1.875rem; line-height: 2.25rem; font-weight: 600; color: var(--text); padding: var(--s-3) 0; background: none; }
  .nav__links li, .nav__lang, .theme { opacity: 0; transform: translateY(16px); transition: opacity 300ms var(--ease), transform 500ms var(--ease); }
  .nav__panel[data-open="true"] .nav__links li,
  .nav__panel[data-open="true"] .nav__lang,
  .nav__panel[data-open="true"] .theme { opacity: 1; transform: none; }
  .nav__panel[data-open="true"] .nav__links li:nth-child(1) { transition-delay: 60ms; }
  .nav__panel[data-open="true"] .nav__links li:nth-child(2) { transition-delay: 120ms; }
  .nav__panel[data-open="true"] .nav__links li:nth-child(3) { transition-delay: 180ms; }
  .nav__panel[data-open="true"] .nav__links li:nth-child(4) { transition-delay: 240ms; }
  .nav__panel[data-open="true"] .nav__lang { transition-delay: 300ms; align-self: flex-start; }
  .nav__panel[data-open="true"] .theme { transition-delay: 360ms; align-self: flex-start; }
  .nav__toggle { position: relative; z-index: calc(var(--z-menu) + 1); }
  .nav__brand { position: relative; z-index: calc(var(--z-menu) + 1); }
}

@media (min-width: 768px) {
  .nav__panel { display: flex; align-items: center; gap: var(--s-6); }
}

/* Opening sequence: pure CSS, so nothing flashes before a script runs */
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; translate: 0 -16px; } to { opacity: 1; translate: 0 0; } }
@keyframes settle { from { opacity: 0; transform: scale(1.06); } to { opacity: 1; transform: none; } }

.nav { animation: drop 900ms var(--ease) 1000ms both; }
.hero__photo { animation: settle 1800ms var(--ease) both; }
.hero__inner > * { animation: rise 900ms var(--ease) both; }
.hero__inner > :nth-child(1) { animation-delay: 200ms; }
.hero__inner > :nth-child(2) { animation-delay: 350ms; }
.hero__inner > :nth-child(3) { animation-delay: 550ms; }
.hero__inner > :nth-child(4) { animation-delay: 750ms; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 1ms !important; transition-delay: 0s !important; }
  .reveal { transform: none; }
  /* Keep the opening as a plain fade: no movement or zoom */
  @keyframes rise { from { opacity: 0; } to { opacity: 1; } }
  @keyframes drop { from { opacity: 0; } to { opacity: 1; } }
  @keyframes settle { from { opacity: 0; } to { opacity: 1; } }
  .nav, .hero__photo, .hero__inner > * { animation-duration: 900ms; }
}

.link-quiet--spaced { margin-top: var(--s-4); color: var(--accent); text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.link-quiet--spaced:hover { color: var(--text); }

/* Photo popup */
.lightbox {
  width: min(92vw, 720px);
  padding: var(--s-3);
  border: 0;
  border-radius: var(--r-2xl);
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 24px 64px var(--shadow-strong);
}
.lightbox::backdrop { background: var(--backdrop); backdrop-filter: blur(4px); }
.lightbox[open] { animation: lightbox-in 500ms var(--ease); }
.lightbox img { width: 100%; height: auto; border-radius: var(--r-xl); }
.lightbox p { margin: var(--s-3) var(--s-3) var(--s-2); font-size: 0.875rem; line-height: 1.25rem; color: var(--text-muted); }
.lightbox form { position: absolute; top: var(--s-5); right: var(--s-5); margin: 0; }
.lightbox__close {
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--r-lg);
  background: var(--overlay); color: var(--text); font-size: 1.25rem; cursor: pointer;
  transition: background-color 300ms var(--ease), transform 500ms var(--ease);
}
.lightbox__close:hover { background: var(--surface-4); }
.lightbox__close:active { transform: scale(0.98); }
@keyframes lightbox-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* Chinese edition: own accent (muted vermilion); Geist has no Han glyphs, so fall back to the system CJK sans */
:lang(zh) { --accent: #d4694f; --font: "Geist", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", ui-sans-serif, sans-serif; }
:lang(zh) h1, :lang(zh) h2 { letter-spacing: 0; }
:lang(zh) body, body:lang(zh) { line-height: 1.75rem; }
:lang(zh) .eyebrow, :lang(zh) .section__label { letter-spacing: 0.02em; }
:lang(zh) .list h3 { letter-spacing: 0; }

/* Light theme: dark stays the default. Values mirror the dark surfaces, with darker accents for contrast on white. */
html[data-theme="light"] {
  --bg: #ffffff;
  --surface-1: #f4f2ea;
  --surface-2: #f3f3f3;
  --surface-3: #eaeaea;
  --surface-4: #e0e0e0;
  --line: #cfcfcf;
  --text: #000000;
  --text-muted: #5c5c5c;
  --accent: #8a6a1f;
  --nav-bg: rgb(255 255 255 / 0.72);
  --nav-line: rgb(0 0 0 / 0.12);
  --shadow: rgb(60 50 20 / 0.16);
  --shadow-strong: rgb(60 50 20 / 0.28);
  --backdrop: rgb(255 255 255 / 0.7);
  --overlay: rgb(255 255 255 / 0.85);
  --grad-a: #000000;
  --grad-b: #666666;
  --photo-opacity: 0.4;
  --grain: 0.04;
  color-scheme: light;
}
html[data-theme="light"]:lang(zh) { --accent: #b8442b; }

/* Theme toggle: icon only, cycles dark, light, system */
.theme {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface-3);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  transition: background-color 300ms var(--ease), color 300ms var(--ease), transform 500ms var(--ease);
}
.theme:hover { background: var(--surface-4); color: var(--accent); }
.theme:active { transform: scale(0.98); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
