/* Ting-Chun Liu — editorial, gallery-catalogue layout.
   White ground, text and image composed on one grid, one rare red accent. */

/* Everything is sized in rem: the whole layout follows the root font size, so the
   desktop scale below reproduces the design as it looked at 80% browser zoom.
   Phones keep 100%. */
html { font-size: 80%; }
@media (max-width: 800px) { html { font-size: 100%; } }

:root {
  --bg: #fff;
  --ink: #141414;
  --mut: #6e6e6e;
  --dim: #9a9a9a;
  --line: #e6e6e6;
  --tint: #f4f4f2;
  --red: #e4032e;

  --side-w: 17.5rem;
  --pad: 2.75rem;
  --gap: 0.875rem;          /* gutter between plates */
  --col: 41.25rem;         /* information column (work text) */
  --plates-max: 51.25rem;  /* image field on work pages */
  --label: 21.25rem;       /* heading column on list pages */

  --sans: "Helvetica Neue", Helvetica, Arial, "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;

  --fs-body: 1.1562rem;
  --fs-meta: 0.875rem;
  --fs-title: clamp(2rem, 3.4vw, 3rem);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: var(--fs-body)/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
img, iframe, video, canvas { display: block; max-width: 100%; border: 0; }
h1, h2, h3, h4 { font-weight: 700; margin: 0; letter-spacing: -0.01em; }
p, figure { margin: 0; }
button { font: inherit; color: inherit; }
::selection { background: var(--ink); color: var(--bg); }

.mono { font-family: var(--mono); font-size: var(--fs-meta); letter-spacing: 0; }
.mut { color: var(--mut); }
.idx { font-family: var(--mono); font-size: var(--fs-meta); color: var(--mut); font-weight: 400; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* underlined links inside running text */
.prose a, .meta a, .cv-row a, .contact a {
  text-decoration: underline; text-decoration-thickness: 1px;
  text-underline-offset: 0.1875rem; text-decoration-color: var(--dim);
}
.prose a:hover, .meta a:hover, .cv-row a:hover, .contact a:hover { text-decoration-color: var(--ink); }

/* ---------- sidebar ---------- */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w);
  padding: 2.75rem 2.25rem 2.25rem;
  display: flex; flex-direction: column;
  background: var(--bg); z-index: 10;
}
.brand { display: block; line-height: 1.25; }
.brand-en { display: block; font-size: 1.4375rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-zh { display: block; font-size: 1.0312rem; color: var(--mut); margin-top: 2px; }
.menu-btn { display: none; }

.nav { margin-top: 4rem; display: flex; flex-direction: column; gap: 0.625rem; }
.nav a { display: flex; align-items: baseline; font-size: 1.25rem; color: var(--mut); width: fit-content; transition: color .15s; }
.nav .gap { height: 1.1em; }
.nav a:hover, .nav a.on { color: var(--ink); }

.side-foot { margin-top: auto; font-family: var(--mono); font-size: 0.8125rem; color: var(--mut); line-height: 1.9; }
.side-foot a:hover { color: var(--ink); }
.side-foot .links { display: flex; gap: 0.875rem; }
.side-foot .legal { display: flex; gap: 0.875rem; margin-top: 0.375rem; }

/* ---------- legal pages ---------- */
.legal-page { max-width: 48.75rem; font-size: 1.0938rem; line-height: 1.7; }
.legal-page h2 { font-size: 1.25rem; margin: 2.2em 0 .6em; }
.legal-page p, .legal-page ul { margin: 0 0 1em; }
.legal-page .en { color: var(--mut); }
.legal-page .todo { background: #fff3a8; padding: 0 .2em; }
.legal-page button { font-family: var(--mono); font-size: 0.8125rem; background: none; border: 1px solid var(--ink); padding: 0.375rem 0.75rem; cursor: pointer; }
.signal { width: 100%; height: 2.5rem; margin-bottom: 1.125rem; }

/* language switch */
.langs { display: flex; gap: 0.875rem; margin-top: 2.25rem; font-family: var(--mono); font-size: 0.875rem; color: var(--mut); }
.langs a { padding-bottom: 1px; border-bottom: 1px solid transparent; }
.langs a:hover { color: var(--ink); }
.langs a.on { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- main ---------- */
.main { margin-left: var(--side-w); min-height: 100vh; padding: 2.75rem var(--pad) 7.5rem 0; }
.main.full { padding: 0; }

.page-head { display: grid; grid-template-columns: var(--label) 1fr; gap: 3rem; align-items: end; margin-bottom: 3.5rem; }
.page-title { font-size: var(--fs-title); line-height: 1.1; }
.page-head .lead { color: var(--mut); max-width: 47.5rem; }

/* ---------- home ---------- */
.home-hero {
  position: relative; min-height: 100vh; overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
}
.home-hero .field { position: absolute; inset: 0; }
.home-hero .field canvas { width: 100% !important; height: 100% !important; }
.home-statement {
  position: relative; z-index: 1; align-self: stretch; margin: auto var(--pad) 4.5rem 0; padding-top: 3rem;
  max-width: 51.25rem; font-size: clamp(1.125rem, 1.75vw, 1.625rem); line-height: 1.3; font-weight: 700; letter-spacing: -0.015em;
}
.home-statement span { background: var(--bg); box-decoration-break: clone; -webkit-box-decoration-break: clone; padding: 0 .12em; }
.home-selected { padding: 6rem var(--pad) 7.5rem 0; }
.home-selected .more { display: inline-block; margin-top: 2.5rem; font-family: var(--mono); font-size: var(--fs-meta); border-bottom: 1px solid var(--ink); }

/* chat: "Ask me about my work" — a text terminal floating on the field, after the
   ASCII GPU in llms.txt. Everything is monospace; borders are drawn with characters. */
.ask {
  position: relative; z-index: 2; width: min(48rem, calc(100% - 2 * var(--pad))); margin-top: max(11vh, 4rem);
  padding: 1.25rem 1.5rem 1rem; font-family: var(--mono); font-size: 1.125rem; line-height: 1.6;
  container-type: inline-size;
  background: rgba(255, 255, 255, .78);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid var(--ink);
}
.ask-gpu {
  margin: 0 auto 0.75rem; width: max-content; max-width: 100%; overflow: hidden;
  font: min(0.875rem, calc(100cqi / 43))/1.2 var(--mono); color: rgb(22, 140, 190);
}
.ask-gpu b { font-weight: 400; }
/* fan blades: chat.js alternates "+" (f1) and "x" (f2), which reads as spinning */
.ask-gpu.f1 .d, .ask-gpu.f2 .v, .ask-gpu.f2 .h { visibility: hidden; }
.ask-gpu i { font-style: normal; }
.ask-h { font: 700 1rem/1.3 var(--mono); text-align: center; margin-bottom: 0.875rem; letter-spacing: 0; }
.ask-h::before { content: "[ "; color: var(--dim); font-weight: 400; }
.ask-h::after { content: " ]"; color: var(--dim); font-weight: 400; }
.ask-log:empty { display: none; }
.ask-log { margin-bottom: 0.875rem; max-height: 42vh; overflow-y: auto; overscroll-behavior: contain; }
.ask-log p { white-space: pre-line; overflow-wrap: anywhere; }
.ask-q { color: var(--mut); }
.ask-q::before { content: "> "; color: rgb(22, 140, 190); }
.ask-a { margin-top: 0.375rem; }
.ask-a a { border-bottom: 1px solid currentColor; color: rgb(22, 140, 190); }
.ask-a.pending::after { content: "█"; color: rgb(22, 170, 222); animation: ask-blink 1s steps(1) infinite; }
.ask-a.err { color: var(--mut); }
@keyframes ask-blink { 50% { opacity: 0; } }
.ask-links { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; margin-top: 0.75rem; }
.ask-link {
  display: inline-block; max-width: 100%; color: rgb(12, 96, 134); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; clip-path: inset(0 100% 0 0); animation: ask-type .5s steps(18, end) forwards;
}
.ask-link::before { content: "[ "; color: var(--dim); }
.ask-link::after { content: " → ]"; color: var(--dim); }
.ask-link.ext::after { content: " ↗ ]"; }
.ask-link:hover { background: rgb(22, 140, 190); color: #fff; }
.ask-link:hover::before, .ask-link:hover::after { color: #fff; }
@keyframes ask-type { from { opacity: 1; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0 0 0 0); } }
.ask-form { display: flex; align-items: baseline; gap: 0.5rem; border-top: 1px dashed var(--dim); border-bottom: 1px dashed var(--dim); padding: 0.375rem 0; }
.ask-prompt { color: rgb(22, 140, 190); }
.ask-form input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 0.25rem 0;
  font: inherit; color: var(--ink); caret-color: rgb(22, 140, 190);
}
.ask-form input::placeholder { color: var(--mut); }
.ask-form button, .ask-chips button { font: inherit; background: none; border: 0; color: var(--ink); cursor: pointer; padding: 0; }
.ask-form button::before { content: "[ "; color: var(--dim); }
.ask-form button::after { content: " ]"; color: var(--dim); }
.ask-form button:disabled { color: var(--dim); cursor: default; }
.ask-chips { display: flex; flex-direction: column; align-items: flex-start; gap: 0.125rem; margin-top: 0.75rem; }
.ask-chips button { color: var(--mut); text-align: left; }
.ask-chips button::before { content: "$ "; color: var(--dim); }
.ask-chips button:hover, .ask-form button:hover:not(:disabled) { color: rgb(22, 140, 190); }
.ask.open .ask-chips { display: none; }
.ask-note { margin-top: 0.75rem; font-size: 0.875rem; line-height: 1.5; color: var(--mut); }
.ask-note::before { content: "// "; color: var(--dim); }
.ask-note a { border-bottom: 1px solid rgba(0, 0, 0, .25); }
.ask-check:empty { display: none; }
.ask-check { margin-top: 0.625rem; display: flex; justify-content: center; }
@media (prefers-reduced-motion: reduce) { .ask-link { animation: none; opacity: 1; clip-path: none; } }

/* ---------- plates / cards ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3.5rem var(--gap); }
.card { display: block; }
.card .thumb { aspect-ratio: 3 / 2; background: var(--tint); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2,.7,.2,1), opacity .3s; }
a.card:hover .thumb img { transform: scale(1.025); }
.card .ph { padding: 1.25rem; text-align: center; color: var(--mut); font-size: 1rem; }
.card .cap { display: grid; grid-template-columns: 1fr auto; gap: 0 0.5rem; margin-top: 0.875rem; align-items: baseline; }
.card .cap .t { font-weight: 700; font-size: 1.1875rem; line-height: 1.35; }
.card .cap .zh { display: block; font-weight: 400; color: var(--mut); font-size: 1.0312rem; }
.card .cap .mono { color: var(--mut); }
a.card:hover .cap .t { text-decoration: underline; text-underline-offset: 0.25rem; text-decoration-thickness: 1px; }

/* ---------- work: information column + image field ---------- */
.work { display: grid; grid-template-columns: var(--col) minmax(0, 1fr); gap: 3.5rem; align-items: start; }
.work-info { min-width: 0; }
.work-info .idx { display: block; margin-bottom: 0.875rem; }
.work-info h1 { font-size: clamp(1.75rem, 2.6vw, 2.375rem); line-height: 1.15; }
.work-info .zh { font-size: 1.25rem; color: var(--mut); margin-top: 0.375rem; }

.meta { display: grid; grid-template-columns: 6.2em 1fr; gap: 0.375rem 0.75rem; margin: 1.75rem 0 0; font-size: 0.9688rem; line-height: 1.5; }
.meta dt { font-family: var(--mono); font-size: 0.8125rem; color: var(--mut); padding-top: 2px; }
.meta dd { margin: 0; }

.work-info .prose { margin-top: 2rem; font-size: 1.125rem; line-height: 1.75; }
.work-info .prose p + p { margin-top: .9em; }
.work-info .prose h3 { font-size: 1.125rem; margin: 1.6em 0 .5em; }
.credits { margin-top: 1.5rem; font-family: var(--mono); font-size: 0.8125rem; line-height: 1.7; color: var(--mut); white-space: pre-line; }

.plates { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.plates .cols { columns: 2; column-gap: var(--gap); }
.plates .cols figure { break-inside: avoid; margin-bottom: var(--gap); }
.plates .clip video { width: 100%; height: auto; background: #000; }
.plates img { width: 100%; height: auto; background: var(--tint); }

.embed { position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.embed iframe, .embed video { position: absolute; inset: 0; width: 100%; height: 100%; }
button.embed.lite { display: block; width: 100%; padding: 0; border: 0; cursor: pointer; }
button.embed.lite img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .3s; opacity: .92; }
button.embed.lite:hover img { opacity: 1; }
.embed .play { position: absolute; left: 1.5rem; bottom: 1.25rem; font-family: var(--mono); font-size: 0.8125rem; color: #fff; background: rgba(0,0,0,.6); padding: 0.375rem 0.625rem; }
.embed .play::before { content: "▶  Play"; }

.pager {
  grid-column: 1 / -1; margin-top: 6rem; padding-top: 1.375rem; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 2rem; font-size: 1.0312rem;
}
.pager a { display: flex; flex-direction: column; gap: 0.25rem; max-width: 45%; }
.pager a:last-child { text-align: right; margin-left: auto; }
.pager .mono { color: var(--mut); }
.pager a:hover .t { text-decoration: underline; text-underline-offset: 0.25rem; }

/* ---------- performance ---------- */
.perf { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4rem var(--gap); }
.perf-card { display: block; }
.perf-card .thumb { position: relative; aspect-ratio: 16 / 9; background: var(--tint); overflow: hidden; }
.perf-card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.perf-card:hover .thumb img { transform: scale(1.025); }
.perf-card .watch { position: absolute; left: 1rem; bottom: 0.875rem; font-family: var(--mono); font-size: 0.8125rem; color: #fff; background: rgba(0,0,0,.62); padding: 0.375rem 0.625rem; }
.perf-card:hover .watch { background: var(--red); }
.perf .cap { margin-top: 0.875rem; }
.perf h2 { font-size: 1.1875rem; line-height: 1.35; }
.perf-card:hover h2 { text-decoration: underline; text-underline-offset: 0.25rem; text-decoration-thickness: 1px; }
.perf p { font-size: 0.9688rem; color: var(--mut); margin-top: 0.25rem; }

/* ---------- about / cv ---------- */
.about-top, .cv-sec { margin-right: clamp(0rem, 18vw, 22rem); }
.about-top { display: grid; grid-template-columns: var(--label) 1fr; gap: 3rem; margin-bottom: 5.5rem; }
.bio { font-size: clamp(1.125rem, 1.55vw, 1.375rem); line-height: 1.5; max-width: 54rem; letter-spacing: -0.005em; }
.contact { margin-top: 1.75rem; font-family: var(--mono); font-size: var(--fs-meta); }
.cv-sec { display: grid; grid-template-columns: var(--label) 1fr; gap: 3rem; padding: 1.75rem 0 2rem; border-top: 1px solid var(--line); }
.cv-sec h2 { font-size: 1.0625rem; }
.cv-sec h2 .idx { display: block; margin-bottom: 0.25rem; }
.cv-row { display: grid; grid-template-columns: 7.5em 1fr; gap: 1rem; padding: 0.3125rem 0; font-size: 0.9375rem; line-height: 1.55; }
.cv-row .mono { color: var(--mut); padding-top: 2px; }

/* ---------- blog ---------- */
.year-group { display: grid; grid-template-columns: var(--label) 1fr; gap: 3rem; padding: 1.625rem 0; border-top: 1px solid var(--line); }
.year-group > .mono { font-size: 1rem; color: var(--ink); }
.year-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.625rem; }
.year-group a { display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 1.5rem; }
.year-group .t { font-size: 1.3125rem; font-weight: 700; line-height: 1.4; }
.year-group .ex { grid-column: 1; color: var(--mut); font-size: 1.0312rem; line-height: 1.6; }
.year-group .cat { grid-row: 1; grid-column: 2; color: var(--mut); }
.year-group a:hover .t { text-decoration: underline; text-underline-offset: 0.25rem; text-decoration-thickness: 1px; }

.post { display: grid; grid-template-columns: minmax(0, 21.25rem) minmax(0, 65rem); gap: 3rem; align-items: start; }
.post > *, .work > * { min-width: 0; }
.post-info { position: sticky; top: 2.75rem; }
.post-info h1 { font-size: clamp(1.625rem, 2.4vw, 2.125rem); line-height: 1.25; }
.post-info .meta { margin-top: 1.375rem; }
.post-info .back { display: inline-block; margin-top: 1.75rem; font-family: var(--mono); font-size: 0.8125rem; color: var(--mut); }
.post-info .back:hover { color: var(--ink); }

.post-body { font-size: 1.1562rem; line-height: 1.9; }
.post-body p { margin: 0 0 1.15em; }
.post-body h3, .post-body h4 { font-size: 1.3125rem; margin: 2.2em 0 .8em; }
.post-body ul, .post-body ol { padding-left: 1.3em; margin: 0 0 1.15em; }
.post-body li { margin: .25em 0; }
.post-body blockquote { margin: 1.6em 0; padding: 0 0 0 1.25rem; border-left: 2px solid var(--ink); color: #333; }
.post-body pre { background: var(--tint); padding: 1rem 1.125rem; overflow-x: auto; margin: 0 0 1.3em; font: 0.9062rem/1.65 var(--mono); tab-size: 4; }
.post-body code { font-family: var(--mono); font-size: .88em; }
.post-body hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
.post-body figure { margin: 2em 0; }
.post-body img { width: auto; max-width: 100%; height: auto; }
.post-body figcaption { font-family: var(--mono); font-size: 0.8125rem; color: var(--mut); margin-top: 0.5rem; line-height: 1.6; }
.post-body .embed { margin: 2em 0; }

/* ---------- friends ---------- */
.grid.friends { grid-template-columns: repeat(5, 1fr); gap: 2.5rem var(--gap); }
.grid.friends .thumb { aspect-ratio: 1 / 1; }
.grid.friends .cap { grid-template-columns: 1fr auto; }
.grid.friends .cap .t { font-size: 1.0312rem; }

/* ---------- analytics consent ---------- */
.consent {
  position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 30; margin-left: auto; max-width: 27.5rem;
  background: var(--ink); color: var(--bg); padding: 1rem 1.125rem; font-size: 0.8438rem; line-height: 1.55;
  display: grid; grid-template-columns: 1fr auto auto; gap: 0.5rem 0.875rem; align-items: center;
}
.consent p { grid-column: 1 / -1; }
.consent button { background: none; border: 1px solid rgba(255,255,255,.4); padding: 0.3125rem 0.75rem; cursor: pointer; font-family: var(--mono); font-size: 0.75rem; }
.consent button.ok { background: var(--bg); color: var(--ink); border-color: var(--bg); }
.consent .note { font-family: var(--mono); font-size: 0.7188rem; opacity: .65; grid-column: 1; }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  :root { --col: 31.25rem; --label: 17.5rem; --pad: 2.5rem; --plates-max: 40rem; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .grid.friends { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 800px) {
  .work, .post, .page-head, .about-top, .cv-sec, .year-group { grid-template-columns: 1fr; gap: 1.5rem; }
  .work .plates { max-width: 47.5rem; }
  .work-info, .post-info { position: static; max-height: none; overflow: visible; }
  .perf { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  :root { --pad: 1.125rem; --fs-body: 1.0938rem; }
  .side {
    position: sticky; top: 0; inset: auto; width: auto; padding: 0.875rem 1.125rem;
    border-bottom: 1px solid var(--line);
  }
  .side-head { display: flex; justify-content: space-between; align-items: center; }
  .brand-en, .brand-zh { display: inline; font-size: 1.125rem; }
  .brand-zh { margin-left: 0.5rem; font-size: 0.9375rem; }
  .menu-btn { display: block; background: none; border: 0; padding: 0.25rem 0; font-family: var(--mono); font-size: 0.8125rem; cursor: pointer; }
  .nav, .side-foot, .langs { display: none; }
  .side.open .nav { display: flex; margin-top: 1.5rem; }
  .side.open .langs { display: flex; margin-top: 1.375rem; }
  .side.open .side-foot { display: block; margin-top: 1.75rem; }
  .signal { display: none; }
  .main { margin-left: 0; padding: 1.75rem var(--pad) 5rem; }
  .main.full { padding: 0; }
  .home-hero { min-height: calc(100svh - 3.4375rem); }
  .home-statement { margin: auto var(--pad) 2rem; font-size: 1.1875rem; }
  .home-selected { padding: 4rem var(--pad) 5rem; }
  .ask { margin-top: 1.5rem; padding: 1rem 0.875rem 0.75rem; font-size: 1rem; }
  .ask-form input { font-size: 1rem; }
  .grid { grid-template-columns: 1fr; gap: 2.75rem; }
  .grid.friends { grid-template-columns: repeat(2, 1fr); }
  .plates .cols { columns: 1; }
  .page-head { margin-bottom: 2.25rem; }
  .post-body { font-size: 1.125rem; line-height: 1.85; }
  .post-body pre { margin-left: calc(var(--pad) * -1); margin-right: calc(var(--pad) * -1); max-width: none; }
  .year-group a { grid-template-columns: 1fr; }
  .year-group .cat { grid-row: auto; grid-column: 1; }
  .cv-row { grid-template-columns: 5.6em 1fr; }
  .about-top, .cv-sec { margin-right: 0; }
  .pager { flex-direction: column; }
  .pager a, .pager a:last-child { max-width: none; text-align: left; margin-left: 0; }
  .consent { left: 0.625rem; right: 0.625rem; bottom: 0.625rem; padding: 0.75rem 0.875rem; font-size: 0.7812rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
