/* Yuwen Wang — portfolio
   Visual language taken from the PDF boards: Helvetica, bold uppercase
   headings, light grey label bars, generous white space. */

:root {
  --ink: #141414;
  --muted: #5c5c5c;
  --faint: #8a8a8a;
  --line: #e2e2e2;
  --bar: #e6e6e6;
  --bg: #ffffff;
  --panel: #f5f5f4;
  --accent: #141414;
  --accent-soft: #e6e6e6;
  --max: 1240px;
  --gutter: clamp(16px, 4vw, 48px);
  --font: "Helvetica Neue", Helvetica, Arial, "PingFang SC", sans-serif;
  color-scheme: light;
}

/* Per-project accents, picked from each project's boards */
body.p-snailscout { --accent: #4f5459; --accent-soft: #e4e4e2; }
body.p-kombugas   { --accent: #a3542a; --accent-soft: #eddcd9; }
body.p-mycostrain { --accent: #3a3f45; --accent-soft: #e2e2e2; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

[id] { scroll-margin-top: 80px; }

body.lightbox-open { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

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

a { color: inherit; }

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

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 60px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 15px;
}

.site-nav { display: flex; gap: clamp(14px, 3vw, 32px); }

.site-nav a {
  text-decoration: none;
  font-size: 14px;
  color: var(--muted);
}

.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--ink); }

/* ---------- Shared type ---------- */

.label {
  display: inline-block;
  background: var(--bar);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tags li {
  font-size: 12px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}

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

.intro {
  padding-block: clamp(56px, 12vw, 140px) clamp(40px, 7vw, 80px);
}

.intro h1 {
  font-size: clamp(44px, 9vw, 112px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin: 0 0 28px;
}

.intro p {
  font-size: clamp(18px, 2.2vw, 24px);
  line-height: 1.45;
  max-width: 34em;
  margin: 0;
  color: var(--muted);
}

.intro p strong { color: var(--ink); font-weight: 600; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-top: 2px solid var(--ink);
  padding-top: 14px;
  margin-bottom: 28px;
}

.section-head h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-head span { font-size: 14px; color: var(--faint); }

.work { padding-bottom: clamp(56px, 10vw, 120px); }

.card {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 44px);
  align-items: center;
  text-decoration: none;
  padding-block: clamp(20px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
}

.card:first-of-type { padding-top: 0; }

.card-media {
  overflow: hidden;
  background: var(--panel);
  aspect-ratio: 16 / 10;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.card:hover .card-media img { transform: scale(1.03); }

.card-num {
  font-size: 13px;
  color: var(--faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.card h3 {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 8px 0 12px;
}

.card p {
  color: var(--muted);
  margin: 0 0 18px;
  max-width: 30em;
}

.card .more {
  display: inline-block;
  margin-top: 18px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid currentColor;
}

.about {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: clamp(20px, 4vw, 64px);
  padding-bottom: clamp(56px, 10vw, 120px);
}

.about .lead {
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.4;
  margin: 0 0 20px;
}

.about p { color: var(--muted); max-width: 40em; }

.about dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 24px;
  margin: 28px 0 0;
}

.about dt {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.about dd { margin: 0; }

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 28px calc(28px + env(safe-area-inset-bottom, 0px));
  font-size: 13px;
  color: var(--faint);
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---------- Project page ---------- */

.hero {
  position: relative;
  background: #222;
  height: min(78vh, 760px);
  min-height: 360px;
  overflow: hidden;
}

.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: clamp(24px, 5vw, 80px);
  padding-block: clamp(36px, 6vw, 72px);
  border-bottom: 1px solid var(--line);
}

.project-head .eyebrow {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 10px;
}

.project-head h1 {
  font-size: clamp(38px, 6vw, 76px);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}

.project-head .subtitle {
  font-size: 18px;
  color: var(--muted);
  margin: 0 0 22px;
}

.meta {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 4px 28px;
  margin: 0 0 22px;
  font-size: 14px;
}

.meta dt { color: var(--faint); }
.meta dd { margin: 0; font-weight: 600; }

.overview {
  font-size: clamp(17px, 1.6vw, 20px);
  line-height: 1.6;
  margin: 0;
}

.project-body {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: clamp(24px, 4vw, 64px);
  padding-block: clamp(32px, 5vw, 64px);
}

.toc {
  position: sticky;
  top: calc(84px + env(safe-area-inset-top, 0px));
  align-self: start;
  font-size: 13px;
}

.toc p {
  margin: 0 0 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
}

.toc a {
  display: block;
  padding: 5px 0 5px 14px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  text-decoration: none;
  color: var(--faint);
}

.toc a:hover { color: var(--ink); }

.toc a.active {
  color: var(--ink);
  border-left-color: var(--accent);
}

.chapter {
  scroll-margin-top: 80px;
  padding-bottom: clamp(48px, 7vw, 96px);
}

.chapter > .label { background: var(--accent-soft); }

.chapter h2 {
  font-size: clamp(26px, 3.4vw, 40px);
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  margin: 14px 0 18px;
}

.chapter > p,
.chapter .prose p {
  max-width: 68ch;
  margin: 0 0 16px;
}

.chapter h3 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 32px 0 10px;
}

.quote {
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.4;
  font-weight: 600;
  border-left: 3px solid var(--accent);
  padding-left: 20px;
  margin: 28px 0;
  max-width: 34em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin: 24px 0 28px;
}

.stats div { background: var(--bg); padding: 16px 18px; }

.stats strong {
  display: block;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.1;
  color: var(--accent);
}

.stats span { font-size: 13px; color: var(--muted); line-height: 1.45; display: block; margin-top: 6px; }

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 20px 0 28px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.steps li {
  counter-increment: step;
  background: var(--panel);
  padding: 14px 16px 16px;
  font-size: 14px;
  line-height: 1.5;
}

.steps li::before {
  content: counter(step, decimal-leading-zero);
  display: block;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.steps strong { display: block; }

.formula {
  font-family: "Times New Roman", Times, serif;
  font-size: 26px;
  font-style: italic;
  margin: 16px 0;
}

.figure {
  margin: 28px 0;
}

/* Tall panels would be huge at full width; keep them to a readable column */
.figure.portrait { max-width: 560px; }

.figure button {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: zoom-in;
  position: relative;
}

.figure button::after {
  content: "Click to enlarge";
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-size: 12px;
  background: rgba(20, 20, 20, 0.75);
  color: #fff;
  padding: 3px 8px;
  opacity: 0;
  transition: opacity 0.2s;
}

.figure button:hover::after,
.figure button:focus-visible::after { opacity: 1; }

.figure img { width: 100%; }

.figure figcaption {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.fig-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 28px 0;
  align-items: start;
}

.fig-row .figure { margin: 0; }

.next-project {
  display: block;
  text-decoration: none;
  border-top: 2px solid var(--ink);
  padding-block: 28px 64px;
}

.next-project span {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.next-project strong {
  display: block;
  font-size: clamp(30px, 5vw, 60px);
  line-height: 1.05;
  margin-top: 6px;
}

.next-project:hover strong { text-decoration: underline; text-underline-offset: 6px; }

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

.lightbox {
  border: 0;
  padding: 0;
  margin: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  background: rgba(12, 12, 12, 0.96);
  color: #fff;
}

.lightbox::backdrop { background: rgba(0, 0, 0, 0.6); }

.lightbox .stage {
  position: absolute;
  inset: 56px 0 44px;
  overflow: auto;
  display: grid;
  place-items: center;
}

.lightbox img {
  max-width: 96vw;
  max-height: calc(100vh - 110px);
  max-height: calc(100dvh - 110px);
  cursor: zoom-in;
}

.lightbox.zoomed .stage { place-items: start; }

.lightbox.zoomed img {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}

.lightbox .bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: env(safe-area-inset-top, 0px) 16px 0;
  font-size: 14px;
}

.lightbox .caption {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  height: 44px;
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #bbb;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.lightbox button {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
}

.lightbox button:hover { border-color: #fff; }

.lightbox .controls { display: flex; gap: 8px; }

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

@media (max-width: 900px) {
  .card,
  .about,
  .project-head { grid-template-columns: 1fr; }

  .project-body { grid-template-columns: 1fr; }

  .toc { display: none; }

  .hero { height: 52vh; min-height: 280px; }
}

@media (max-width: 600px) {
  .fig-row { grid-template-columns: 1fr; }

  .lightbox .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card-media img { transition: none; }
}
