/* Layout concept: 像一本小小的私人作品冊。窄版面、留白多、沒有強調色，畫面上最有顏色的只有作品。 */
:root {
  --bg: #f3f4f4;
  --ink: #2a2c2f;
  --muted: #666a70;
  --line: #dcdee0;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18191b; --ink: #d9dadc; --muted: #96999f; --line: #2e3033; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18191b; --ink: #d9dadc; --muted: #96999f; --line: #2e3033; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.9 var(--sans); }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-underline-offset: 4px; text-decoration-color: var(--line); }
a:hover { text-decoration-color: currentColor; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }

.page {
  max-width: 1040px; margin-inline: auto;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}

.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-block: 20px; }
.name { font: 500 19px/1 var(--serif); text-decoration: none; }
.nav { display: flex; align-items: center; gap: 4px 20px; color: var(--muted); font-size: 14px; }
.nav a, .nav button { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.nav a:hover, .nav button:hover { color: var(--ink); }

.intro {
  margin: clamp(32px, 7vw, 80px) 0 clamp(40px, 7vw, 80px); max-width: 26em;
  font: 500 clamp(17px, 2vw, 20px)/1.9 var(--serif); white-space: pre-line;
}

.series__title { margin: 0 0 28px; font: 500 16px/1.6 var(--serif); }
.series + .series { margin-top: clamp(64px, 10vw, 120px); }

/* 用 subgrid 讓同一列的圖片底部和文字頂端對齊，不受文字行數影響 */
.grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(36px, 5vw, 64px) clamp(20px, 3vw, 36px);
}
.piece { display: grid; grid-row: span 2; grid-template-rows: subgrid; row-gap: 10px; margin: 0; min-width: 0; }
.piece__open { display: block; width: 100%; align-self: end; }
.piece__open img { width: 100%; transition: opacity .25s ease; }
@media (hover: hover) { .piece__open:hover img { opacity: .82; } }
.piece__cap { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 1.6; }
.piece__zh { color: var(--muted); }
.piece__date { margin-top: 2px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.about {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px clamp(20px, 3vw, 36px);
  margin-top: clamp(64px, 10vw, 120px); padding-top: 24px; border-top: 1px solid var(--line);
}
.label { margin: 0; font-size: 14px; font-weight: 400; color: var(--muted); }
.about .label { grid-column: 1 / -1; }
/* 圖片和圖說各占一列，右欄只對齊圖片那一列，底部的兩行才會和圖片下緣切齊 */
.portrait { display: contents; }
.portrait img { grid-column: 1; grid-row: 2; width: 100%; }
.portrait figcaption { grid-column: 1; grid-row: 3; }
/* 往上抵銷行高多出來的空間，讓第一行文字的頂端和圖片切齊 */
.about__body { grid-column: 2 / -1; grid-row: 2; display: flex; flex-direction: column; min-width: 0; max-width: 36em; margin-top: -.55em; }
.about__foot { margin-top: auto; padding-top: 1.9em; margin-bottom: -12px; }
.about__body p { margin: 0 0 .2em; }
.links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; color: var(--muted); font-size: 14px; }
.about__edu { color: var(--muted); }
.about__body .about__band { margin: 0; font: italic 800 18px/1.5 "Plus Jakarta Sans", var(--sans); letter-spacing: -.01em;
  width: fit-content; cursor: default;
}
/* 滑鼠碰到時，字母一個接一個像波浪般跳起來 */
.about__band span { display: inline-block; white-space: pre; }
.about__band.is-waving span { animation: band-wave .55s ease-in-out both; animation-delay: calc(var(--i) * 38ms); }
@keyframes band-wave {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-.42em); }
  75% { transform: translateY(.06em); }
}
.about__body .links { margin: 8px 0 0; }
.links a, .links button { display: inline-flex; align-items: center; min-height: 44px; overflow-wrap: anywhere; }
.links button:hover { color: var(--ink); }

.foot { margin-top: clamp(48px, 8vw, 96px); padding-block: 24px; font-size: 13px; color: var(--muted); }

/* 檢視作品 */
.viewer {
  width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; border: 0;
  background: var(--bg); color: var(--ink);
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(16px, env(safe-area-inset-left, 0px));
}
.viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.viewer::backdrop { background: var(--bg); }
.viewer__bar { display: flex; justify-content: space-between; align-items: center; min-height: 52px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; color: var(--muted); }
.icon:hover { color: var(--ink); }
.icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.3; }
.viewer__stage {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; grid-template-rows: minmax(0, 1fr);
  align-items: center; gap: 12px; min-height: 0; touch-action: pan-y;
}
.viewer__img { grid-column: 2; grid-row: 1; justify-self: center; max-width: 100%; max-height: 100%; width: auto; height: auto; min-height: 0; object-fit: contain; animation: fade .2s ease; }
.viewer__prev { grid-column: 1; grid-row: 1; }
.viewer__next { grid-column: 3; grid-row: 1; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.viewer__cap { width: 100%; max-width: 40em; margin-inline: auto; padding-block: 16px 20px; text-align: center; font-size: 14px; line-height: 1.8; max-height: 30vh; overflow-y: auto; }
.viewer__cap p { margin: 0; }
.viewer__meta { color: var(--muted); font-size: 13px; }
.viewer__note { margin-top: 6px !important; color: var(--muted); }

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .about { grid-template-columns: minmax(0, 1fr); }
  .about__body { grid-column: auto; grid-row: auto; margin-top: 8px; }
  .about__foot { margin-bottom: 0; }
  .portrait img { grid-column: auto; grid-row: auto; max-width: 60%; }
  .portrait figcaption { grid-column: auto; grid-row: auto; }
  .viewer__stage { grid-template-columns: minmax(0, 1fr); }
  .viewer__img { grid-column: 1; }
  .viewer__prev, .viewer__next { grid-column: 1; z-index: 1; background: var(--bg); opacity: .75; }
  .viewer__prev { justify-self: start; }
  .viewer__next { justify-self: end; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
