/* ============================================
   Fangfei Ye — portfolio
   dark / mono / atmospheric
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500&display=swap');

:root {
  --bg: #0a0a0a;
  --fg: #c8c8c8;
  --fg-strong: #ececec;
  --muted: #5a5a5a;
  --muted-2: #3a3a3a;
  --line: #1c1c1c;
  --hover: #141414;
  --placeholder: #161616;
  --font: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;
  --fs: 12px;
  --fs-sm: 11px;
  --fs-lg: 13px;
  --lh: 1.55;
  --pad: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

a:hover { color: var(--fg-strong); border-bottom-color: var(--muted-2); }

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

::selection { background: var(--fg); color: var(--bg); }

/* ---------- Header ---------- */
header.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px var(--pad);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  z-index: 100;
  font-size: var(--fs);
}

header.site-header .left {
  display: flex;
  gap: 14px;
  align-items: baseline;
}

header.site-header .clock {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

header.site-header .brand {
  color: var(--muted);
}

header.site-header nav {
  display: flex;
  gap: 18px;
}

header.site-header nav a {
  color: var(--muted);
}

header.site-header nav a:hover,
header.site-header nav a.active {
  color: var(--fg-strong);
  border-bottom-color: var(--fg-strong);
}

header.site-header .right {
  display: flex;
  align-items: baseline;
  gap: 22px;
}

/* ---------- Language toggle ---------- */
.lang-toggle {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--muted);
  user-select: none;
}

.lang-toggle button {
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 0 0 1px 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.lang-toggle button:hover { color: var(--fg-strong); }

.lang-toggle button.active {
  color: var(--fg-strong);
  border-bottom-color: var(--fg-strong);
}

.lang-toggle .sep { color: var(--muted-2); }

/* ---------- Sub header (poetic title) ---------- */
.poetic {
  position: fixed;
  top: 44px;
  left: 0; right: 0;
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--muted);
  letter-spacing: 0.04em;
  pointer-events: none;
  padding: 4px 0 6px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

/* ---------- Layout ---------- */
main {
  padding: 88px var(--pad) 80px;
  min-height: 100vh;
  max-width: 1280px;
  margin: 0 auto;
}

.section-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 24px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  margin-top: 28px;
  color: var(--muted);
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.section-label .label { color: var(--fg-strong); }
.section-label .count { color: var(--muted); }

main > .section-label:first-child { margin-top: 0; }

/* ---------- Works grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 36px 20px;
}

@media (max-width: 1100px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px)  { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .grid { grid-template-columns: 1fr; } }

.work-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.work-card a.thumb {
  display: block;
  aspect-ratio: 4 / 5;
  background: var(--placeholder);
  position: relative;
  overflow: hidden;
  border-bottom: none;
  transition: opacity 0.2s ease;
}

.work-card a.thumb::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  font-size: var(--fs-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.work-card a.thumb:hover { opacity: 0.6; }

/* When a real <img> is dropped in, hide the placeholder label and cover the box */
.work-card a.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.work-card a.thumb:has(img)::after { display: none; }

.work-card .caption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--fs-sm);
}

.work-card .caption .date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.work-card .caption .title {
  color: var(--fg-strong);
}

/* ---------- Work detail ---------- */
.work-detail {
  max-width: 1080px;
  margin: 0 auto;
}

.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 28px;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.detail-top .clock-line { font-variant-numeric: tabular-nums; }

/* Image gallery — adapts to 1, 2, 3+ images */
.gallery {
  display: grid;
  gap: 16px;
  align-items: start;
  justify-content: center;
  margin-bottom: 28px;
}

.gallery.count-1 { grid-template-columns: minmax(0, 880px); }
.gallery.count-2 { grid-template-columns: 1fr 1fr; }
.gallery.count-3 { grid-template-columns: 1fr 1fr 1fr; }

.gallery .panel {
  background: var(--placeholder);
  position: relative;
  overflow: hidden;
  aspect-ratio: auto;
}

.gallery .panel.placeholder {
  aspect-ratio: 3 / 4;
}

.gallery .panel::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  font-size: var(--fs-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery .panel img,
.gallery .panel video {
  width: 100%;
  height: auto;
  display: block;
}

.gallery .panel:has(img)::after,
.gallery .panel:has(video)::after { display: none; }

.gallery .panel:has(img),
.gallery .panel:has(video) { background: transparent; }

@media (max-width: 760px) {
  .gallery.count-2,
  .gallery.count-3 { grid-template-columns: 1fr; }
}

.about .portrait img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.about .portrait:has(img)::after { display: none; }

.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-top: 8px;
}

.detail-meta .title-line {
  color: var(--fg-strong);
  font-size: var(--fs);
  margin-bottom: 6px;
}

.detail-meta .description {
  color: var(--fg);
  margin-top: 14px;
  max-width: 520px;
  line-height: 1.7;
}

.detail-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--muted);
}

.detail-nav a:hover { color: var(--fg-strong); border-bottom-color: var(--muted-2); }

/* ---------- About ---------- */
.about {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 48px;
  max-width: 920px;
  margin: 0 auto;
}

@media (max-width: 700px) { .about { grid-template-columns: 1fr; } }

.about .portrait {
  aspect-ratio: 4 / 5;
  background: var(--placeholder);
  position: relative;
}

.about .portrait::after {
  content: 'PORTRAIT';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  font-size: var(--fs-sm);
  letter-spacing: 0.08em;
}

.about .bio { font-size: var(--fs-lg); line-height: 1.7; color: var(--fg); }
.about .bio p + p { margin-top: 1em; }
.about .bio h2 {
  font-size: var(--fs-sm);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ---------- CV ---------- */
.cv {
  max-width: 720px;
  margin: 0 auto;
  font-size: var(--fs);
}

.cv > section {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 24px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.cv > section:first-of-type { border-top: none; }

.cv > section h2 {
  font-size: var(--fs-sm);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.cv > section ul { list-style: none; }

.cv > section li {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 16px;
  padding: 4px 0;
  color: var(--fg);
}

.cv > section li .y { color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 600px) { .cv > section { grid-template-columns: 1fr; } }

/* ---------- Contact ---------- */
.contact {
  max-width: 540px;
  margin: 0 auto;
  font-size: var(--fs-lg);
  color: var(--fg);
}

.contact dl {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 14px 16px;
}

.contact dt {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--fs-sm);
  align-self: center;
}

.contact dd a:hover { color: var(--fg-strong); }

/* ---------- Footer ---------- */
footer.site-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  padding: 10px var(--pad);
  font-size: var(--fs-sm);
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--bg);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- Utility ---------- */
.muted { color: var(--muted); }
.upper { text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- Gallery tweaks for video-led project pages ---------- */
.gallery.feature-first {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.gallery.feature-first .panel:first-child {
  grid-column: 1 / -1;
  max-width: 920px;
  justify-self: center;
}
.gallery.feature-first .panel:first-child video {
  width: 100%;
}
@media (max-width: 760px) {
  .gallery.feature-first { grid-template-columns: 1fr; }
}

/* ---------- Detail image fit mode ----------
   Tall vertical works fit inside the viewport on the work detail page. */
.gallery .panel {
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery .panel img,
.gallery .panel video {
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - 220px);
  object-fit: contain;
  margin: 0 auto;
}
.gallery .panel video {
  width: 100%;
  max-height: calc(100vh - 190px);
}
.gallery.count-1 .panel img,
.gallery.count-1 .panel video {
  max-height: calc(100vh - 190px);
}
@media (max-width: 760px) {
  .gallery .panel img,
  .gallery .panel video,
  .gallery.count-1 .panel img,
  .gallery.count-1 .panel video {
    max-height: none;
    width: 100%;
  }
}

/* ---------- Clickable brand + work footer navigation ---------- */
header.site-header .brand {
  color: var(--muted);
  border-bottom: none;
}
header.site-header .brand:hover {
  color: var(--fg-strong);
  border-bottom-color: transparent;
}
.work-footer-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: baseline;
}
.work-footer-nav a {
  color: var(--muted);
  border-bottom: none;
  white-space: nowrap;
}
.work-footer-nav a:hover { color: var(--fg-strong); }
.work-footer-nav .footer-index { justify-self: center; }
.work-footer-nav .footer-next { justify-self: end; }
.work-footer-nav .footer-prev { justify-self: start; }
@media (max-width: 640px) {
  .work-footer-nav { grid-template-columns: 1fr 1fr; }
  .work-footer-nav .footer-index { display: none; }
}

/* Hide fixed work nav when the in-page prev/next is visible at the bottom */
.work-footer-nav {
  transition: opacity 0.18s ease, transform 0.18s ease;
}
body.footer-nav-hidden .work-footer-nav {
  opacity: 0;
  pointer-events: none;
  transform: translateY(100%);
}
