/* ==========================================================================
   yiwen.tw — ink painting portfolio
   Paper white and ink black.
   ========================================================================== */

:root {
  --bg: #fbfaf7;
  --ink: #1c1c1e;
  --text: #2b2a28;
  --muted: #77726a;
  --faint: #b3ada3;
  --line: #e6e1d6;
  --serif: "EB Garamond", "Noto Serif TC", "Songti TC", "PMingLiU", Georgia, serif;
  --serif-zh: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", system-ui, -apple-system, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --wrap: 1280px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif-zh);
  font-size: 16px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--ink); }
:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 40px; }

/* template notice ------------------------------------------------------- */
.notice {
  padding: 7px 16px;
  background: var(--ink);
  color: #f3f0ea;
  font-family: var(--sans);
  font-size: .78rem;
  letter-spacing: .06em;
  text-align: center;
}
.notice span { margin-left: .6em; opacity: .7; }

/* header ------------------------------------------------------------------ */
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 34px; padding-bottom: 30px; }
.brand { display: flex; align-items: baseline; gap: 14px; white-space: nowrap; }
.brand-en { font-family: var(--serif); font-size: 1.7rem; letter-spacing: .08em; color: var(--ink); line-height: 1; }
.brand-zh { font-family: var(--serif-zh); font-size: 1rem; letter-spacing: .2em; color: var(--muted); }

.site-nav { display: flex; gap: 34px; }
.site-nav a { display: flex; flex-direction: column; align-items: center; padding-bottom: 4px; border-bottom: 1px solid transparent; color: var(--muted); line-height: 1.3; transition: color .2s, border-color .2s; }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.nav-zh { font-size: .98rem; letter-spacing: .25em; padding-left: .25em; }
.nav-en { font-family: var(--serif); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }

.nav-toggle { display: none; font-family: var(--sans); font-size: .82rem; letter-spacing: .1em; color: var(--muted); }

/* works ------------------------------------------------------------------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px 30px; margin: 6px 0 40px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.filters button { padding: 2px 0; border-bottom: 1px solid transparent; color: var(--muted); font-family: var(--serif-zh); font-size: .95rem; letter-spacing: .12em; transition: color .2s, border-color .2s; }
.filters button span { font-family: var(--serif); font-size: .86rem; letter-spacing: .04em; }
.filters button:hover { color: var(--ink); }
.filters button.is-active { color: var(--ink); border-bottom-color: var(--ink); }

.grid { --cols: 3; --gap: 44px; columns: var(--cols); column-gap: var(--gap); padding-bottom: 60px; }
/* script places works left to right into the shortest column */
.grid.is-masonry { display: flex; align-items: flex-start; gap: var(--gap); columns: auto; }
.grid.is-masonry > .col { flex: 1 1 0; min-width: 0; }
.work { margin: 0 0 52px; break-inside: avoid; }
.work[hidden] { display: none; }
.work-link { display: block; background: #f1ede4; }
.work-link img { width: 100%; transition: opacity .3s; }
.work-link:hover img { opacity: .88; }
.work figcaption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin-top: 12px; font-size: .9rem; line-height: 1.5; }
.cap-title { color: var(--ink); letter-spacing: .1em; }
.cap-en { font-family: var(--serif); font-style: italic; color: var(--muted); }
.cap-year { margin-left: auto; font-family: var(--serif); color: var(--muted); }

/* inner pages -------------------------------------------------------------- */
.page-head { padding-top: 10px; }
.page-head h1 { margin: 0; padding-bottom: 18px; border-bottom: 1px solid var(--line); font-weight: 500; font-size: 1.5rem; letter-spacing: .2em; color: var(--ink); }
.page-body { padding-top: 40px; padding-bottom: 100px; }

.prose { max-width: 42rem; }
.prose h2 { margin: 2.6rem 0 1rem; font-weight: 500; font-size: 1.15rem; letter-spacing: .18em; color: var(--ink); }
.prose h2:first-child { margin-top: 0; }
.prose h2 span, .cv h2 span { margin-left: .5em; font-family: var(--serif); font-style: italic; font-weight: 400; font-size: .92rem; letter-spacing: .03em; color: var(--muted); }
.prose p { margin: 0 0 1.1em; }
.prose a { border-bottom: 1px solid var(--faint); }
.prose a:hover { border-bottom-color: var(--ink); }

.cv { max-width: 52rem; }
.cv-group + .cv-group { margin-top: 3rem; }
.cv h2 { margin: 0 0 1rem; font-weight: 500; font-size: 1.15rem; letter-spacing: .18em; color: var(--ink); }
.cv ul { margin: 0; padding: 0; list-style: none; }
.cv li { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 0 20px; padding: 12px 0; border-top: 1px solid var(--line); }
.cv li:last-child { border-bottom: 1px solid var(--line); }
.cv-year { font-family: var(--serif); color: var(--muted); }
.cv-title { display: block; color: var(--ink); letter-spacing: .06em; }
.cv-title em { margin-left: .4em; font-family: var(--serif); color: var(--muted); letter-spacing: .02em; }
.cv-where { display: block; font-size: .9rem; color: var(--muted); }

.contact-lines { margin-top: 2rem; font-family: var(--serif); font-size: 1.15rem; letter-spacing: .04em; }

/* footer ------------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--line); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 30px; padding-top: 24px; padding-bottom: 34px; font-family: var(--sans); font-size: .78rem; letter-spacing: .04em; color: var(--muted); }
.footer-inner p { margin: 0; }
.footer-inner span { margin-left: .4em; }

/* lightbox ------------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 56px 72px 28px;
  background: rgba(251, 250, 247, .985);
}
.lightbox[hidden] { display: none; }
.lb-stage { display: flex; align-items: center; justify-content: center; min-height: 0; }
.lb-stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }
.lb-caption { padding-top: 18px; text-align: center; line-height: 1.6; }
.lb-title { font-size: 1.15rem; letter-spacing: .14em; color: var(--ink); }
.lb-title em { margin-left: .5em; font-family: var(--serif); letter-spacing: .02em; color: var(--muted); }
.lb-meta { margin-top: 4px; font-family: var(--serif); font-size: .95rem; color: var(--muted); }
.lb-count { margin-top: 6px; font-family: var(--sans); font-size: .72rem; letter-spacing: .12em; color: var(--faint); }
.lb-btn { position: absolute; display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; font-family: var(--serif); font-size: 2rem; line-height: 1; color: var(--muted); transition: color .2s; }
.lb-btn:hover { color: var(--ink); }
.lb-close { top: 10px; right: 14px; font-size: 1.8rem; }
.lb-prev { left: 10px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 10px; top: 50%; transform: translateY(-50%); }
body.lb-open { overflow: hidden; }

/* responsive ------------------------------------------------------------------ */
@media (max-width: 1000px) {
  .grid { --cols: 2; --gap: 32px; }
}

@media (max-width: 760px) {
  .wrap { padding-left: 20px; padding-right: 20px; }
  .header-inner { position: relative; padding-top: 22px; padding-bottom: 20px; }
  .brand-en { font-size: 1.4rem; }
  .nav-toggle { display: block; }
  .js .site-nav { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; display: none; flex-direction: column; gap: 0; padding: 4px 20px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .js .site-nav.open { display: flex; }
  .site-nav a { flex-direction: row; justify-content: space-between; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .site-nav a[aria-current="page"] { border-bottom-color: var(--line); }
  .no-js .site-nav { flex-wrap: wrap; gap: 14px; }
  .no-js .header-inner { flex-wrap: wrap; }
  .filters { gap: 6px 20px; margin-bottom: 28px; }
  .lightbox { padding: 52px 14px 20px; }
  .lb-prev, .lb-next { display: none; }
}

@media (max-width: 520px) {
  .grid { --cols: 1; }
  .work { margin-bottom: 40px; }
  .brand { gap: 10px; }
  .brand-zh { font-size: .9rem; letter-spacing: .12em; }
}

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