:root {
  --paper: #0f0e0d;
  --paper-2: #1c1a17;
  --ink: #efebe3;
  --ink-2: #c4beb2;
  --muted: #8d877c;
  --line: #2d2a25;
  --on-acc: #141413;
  --acc: #f4a711;
  /* Shape rule: images 12px, large blocks 16px, everything you can click is a pill */
  --r-sm: 12px;
  --r: 12px;
  --r-lg: 16px;
  --gutter: clamp(16px, 3.4vw, 48px);
  --max: 1240px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --display: "Geist", "Noto Sans TC", system-ui, -apple-system, "PingFang TC", sans-serif;
  --sans: "Geist", "Noto Sans TC", system-ui, -apple-system, "PingFang TC", sans-serif;
  --tc: "Noto Sans TC", "Geist", system-ui, -apple-system, "PingFang TC", sans-serif;
  --serif: var(--display);
  --mono: "Geist Mono", "Noto Sans TC", ui-monospace, monospace;
  --acc-text: var(--acc);
  color-scheme: dark;
}

/* Light theme: same brand orange, the résumé's paper colour. Follows the system
   setting unless the visitor picks one with the header button. */
:root[data-theme="light"] {
  --paper: #efebe3; --paper-2: #e3ded3; --ink: #141413; --ink-2: #3f3c36; --muted: #6d685f; --line: #d4cec1;
  --acc-text: #9a5f00;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --paper: #efebe3; --paper-2: #e3ded3; --ink: #141413; --ink-2: #3f3c36; --muted: #6d685f; --line: #d4cec1;
    --acc-text: #9a5f00;
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.15; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--acc); }

.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; z-index: 100; }
.skip:focus { left: 8px; }

.display {
  font-family: var(--display); font-weight: 600; letter-spacing: -.055em; line-height: .92;
}
.label {
  font: 400 11px/1.2 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0;
}

.kick { margin: 0 0 clamp(20px, 3vw, 40px); font: 500 12px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.kick b { color: var(--acc-text); font-weight: 500; }
.cta .kick, .cta .kick b { color: var(--on-acc); }

/* Paper texture (same recipe as the résumé site) */
body { position: relative; }
body::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><filter id='p' x='0' y='0'><feTurbulence type='fractalNoise' baseFrequency='.035 .06' numOctaves='5' seed='3' stitchTiles='stitch'/><feDiffuseLighting lighting-color='%23fff' surfaceScale='1.6'><feDistantLight azimuth='45' elevation='58'/></feDiffuseLighting></filter><rect width='600' height='600' filter='url(%23p)'/></svg>");
  background-size: 600px 600px; mix-blend-mode: soft-light; opacity: .5;
}
body::after {
  content: ""; position: fixed; inset: -100px; z-index: 150; pointer-events: none; opacity: .09; mix-blend-mode: screen; filter: invert(1);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain .8s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-37px, 21px); } 40% { transform: translate(24px, -43px); }
  60% { transform: translate(-12px, 38px); } 80% { transform: translate(41px, 9px); } 100% { transform: translate(0, 0); }
}

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  max-width: 1600px; margin: 0 auto; padding: 14px clamp(20px, 6vw, 120px);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
}
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%; background: var(--acc); transform-origin: left; transform: scaleX(var(--p, 0)); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 700 17px/1 var(--sans); letter-spacing: -.02em; justify-self: start; }
.brand img { width: 34px; height: 34px; transition: transform .5s var(--ease); }
.brand:hover img { transform: rotate(-12deg) scale(1.06); }
.nav { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 9%, transparent); }
.nav a {
  font: 500 11.2px/1 var(--sans); text-decoration: none; padding: 8px 13px; border-radius: 999px;
  transition: background .2s, color .2s;
}
.nav a:hover { background: var(--acc); color: var(--on-acc); }
.nav a[aria-current] { background: var(--ink); color: var(--paper); }
.nav a[aria-current]:hover { background: var(--ink); color: var(--paper); }
.status { justify-self: end; font: 500 13px/1 var(--sans); color: var(--ink); text-decoration: none; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); transition: background .2s, color .2s, border-color .2s; }
.status:hover { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }

/* Micro-motion */
.hero-title .ln { display: block; overflow-x: visible; overflow-y: clip; padding-bottom: .06em; margin-bottom: -.06em; }
.hero-title .ln > span { display: block; animation: rise 1.1s var(--ease) both; animation-delay: calc(.12s + var(--i) * .12s); }
@keyframes rise { from { transform: translateY(105%); } }
.hero-card { animation: card-in 1.2s var(--ease) .2s both; }
@keyframes card-in { from { clip-path: inset(12% 10% 12% 10% round 16px); } to { clip-path: inset(0 round 16px); } }
.hero-portrait { transform: translate(calc(var(--mx, 0) * -16px), calc(var(--my, 0) * -12px)) scale(1.08); transition: transform .5s var(--ease); will-change: transform; }
.hero-row, .hero-stats { animation: fade-up .9s var(--ease) .55s both; }
.hero-stats { animation-delay: .7s; }
@keyframes fade-up { from { opacity: 0; transform: translateY(18px); } }
.js .reveal { opacity: 0; transform: translateY(40px); transition: opacity .9s var(--ease), transform .9s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }

/* Hero pointer effects */
.hero-title .ch { display: inline-block; transition: transform .45s var(--ease), color .3s; }
.hero-title .stop { color: var(--acc); }
.hero-card {
  --rx: 0deg; --ry: 0deg; --mx: 0; --my: 0; --gx: 50%; --gy: 50%;
  transform: perspective(1400px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .6s var(--ease); will-change: transform;
}
.hero-card.tilting { transition: transform .12s linear; }
.hero-card::after {
  content: ""; position: absolute; inset: 0; z-index: 2; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at var(--gx) var(--gy), rgba(255, 255, 255, .28), transparent 45%);
  opacity: 0; transition: opacity .4s;
}
.hero-card.tilting::after { opacity: 1; }
.sr-filter { position: absolute; width: 0; height: 0; }
.hero-card.warping .hero-portrait { filter: url(#warp); }
.hero-noise {
  position: absolute; inset: -60px; z-index: 2; pointer-events: none; opacity: 0; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  transition: opacity .35s;
}
.hero-card.warping .hero-noise { opacity: .55; animation: grain .5s steps(5) infinite; }
.hero-badge {
  position: absolute; z-index: 3; right: 20px; top: 20px; width: 99px; height: 99px; border-radius: 50%;
  background: var(--paper); fill: var(--ink); font: 600 9px/1 var(--sans);
  animation: spin 22s linear infinite; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .35);
}
.hero-badge-mark { position: absolute; z-index: 4; right: 49px; top: 49px; width: 41px; height: 41px; transition: transform .5s var(--ease); }
.hero-card:hover .hero-badge { animation-duration: 8s; }
.hero-card:hover .hero-badge-mark { transform: rotate(-20deg) scale(1.1); }
.hero-badge-mark img { display: block; width: 100%; height: 100%; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Hero */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: clamp(24px, 3vw, 48px);
  padding-top: clamp(24px, 4vw, 56px); padding-bottom: clamp(56px, 8vw, 112px);
}
.hero-copy { display: flex; flex-direction: column; justify-content: space-between; gap: 40px; padding-top: clamp(16px, 4vw, 64px); }
.hero-copy { container-type: inline-size; }
/* "Portfolio" is ~3.55em wide, so 26.5% of the column keeps it inside with a little room */
.hero-title { font-size: clamp(56px, 10vw, 170px); font-size: min(24cqi, 200px); margin-left: -.04em; white-space: nowrap; }
.hero-row { display: grid; gap: 22px; justify-items: start; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-actions a { will-change: transform; }
.hero-lede { margin: 0; font: 400 clamp(16px, 1.3vw, 19px)/1.5 var(--sans); max-width: 30em; color: var(--ink-2); }
.hero-stats { list-style: none; margin: 0; padding: 8px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.hero-stats li { display: grid; gap: 10px; }
.hero-stats b { font: 600 clamp(56px, 6vw, 96px)/.9 var(--display); letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.hero-stats sup { font-size: .42em; vertical-align: top; position: relative; top: .2em; margin-left: .04em; color: var(--acc); }
.hero-stats li > span { font-size: 14px; line-height: 1.45; color: var(--ink-2); max-width: 17em; }

.hero-card {
  position: relative; align-self: stretch; min-height: clamp(420px, 44vw, 680px);
  background: var(--acc); border-radius: var(--r-lg); overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
  box-shadow: 0 40px 80px -48px rgba(140, 80, 0, .35);
}
.hero-portrait { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 58% 30%; }
.signature {
  position: absolute; z-index: 2; top: 9%; left: 9%; color: #fff; pointer-events: none;
  font: 400 clamp(64px, 8vw, 132px)/1 var(--script); transform: rotate(-8deg);
  text-shadow: 0 2px 20px rgba(0, 0, 0, .06);
}

/* Section heads */
.section-head { display: grid; gap: 20px; margin-bottom: clamp(28px, 4vw, 48px); }
/* the rule that separates the first screen from the work */
.work .section-head { border-top: 1px solid var(--line); padding-top: clamp(32px, 4vw, 64px); }
.section-title { font-size: clamp(52px, 7.5vw, 120px); }

/* Work grid */
.work { padding-bottom: clamp(96px, 12vw, 180px); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: 400 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; padding: 11px 16px; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--ink); border: 1.5px solid color-mix(in srgb, var(--ink) 75%, transparent);
  transition: background .2s, border-color .2s, color .2s, transform .15s;
}
.chip sup { font-size: 10px; color: var(--muted); margin-left: 3px; vertical-align: 5px; }
.chip:hover { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip[aria-pressed="true"] sup { color: var(--acc); }

.grid {
  container-type: inline-size;
  list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: dense;
  grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(36px, 4vw, 56px) clamp(14px, 1.6vw, 24px);
}
.card { grid-column: span 4; }
.card.s5 { grid-column: span 5; }
.card.s7 { grid-column: span 7; }
.grid.filtered .card { grid-column: span 4; }
.card[hidden] { display: none; }
.card a { display: block; text-decoration: none; }
.card-media { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--r); background: var(--paper-2); }
/* the wide card lands at about 16:10, the narrow one a little taller than square */
.card.s5 .card-media, .card.s7 .card-media { aspect-ratio: auto; height: 36cqi; }
.grid.filtered .card .card-media { aspect-ratio: 4 / 3; height: auto; }
.card-media img, .card-media video { width: 100%; height: 100%; object-fit: cover; transition: transform 1s var(--ease); }
/* Title and categories rise in over the image on hover; always shown on touch screens */
.card-info {
  position: absolute; inset: auto 0 0 0; z-index: 1; padding: 64px 20px 18px; color: #fff;
  background: linear-gradient(to top, rgba(15, 12, 8, .72), rgba(15, 12, 8, .35) 55%, transparent);
  pointer-events: none;
}
.card-info h3 { font: 600 18px/1.3 var(--sans); letter-spacing: -.015em; }
.card-info p { margin: 6px 0 0; font: 400 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: rgba(255, 255, 255, .78); }
@media (hover: hover) {
  .card-info { opacity: 0; transition: opacity .4s var(--ease); }
  .card-info h3, .card-info p { transform: translateY(14px); transition: transform .5s var(--ease); }
  .card-info p { transition-delay: .04s; }
  .card a:hover .card-info, .card a:focus-visible .card-info { opacity: 1; }
  .card a:hover .card-info h3, .card a:hover .card-info p,
  .card a:focus-visible .card-info h3, .card a:focus-visible .card-info p { transform: none; }
  .card a:hover .card-media img, .card a:hover .card-media video { transform: scale(1.035); }
}
.js .card { opacity: 0; transform: translateY(28px); }
.js .card.in { opacity: 1; transform: none; transition: opacity .8s var(--ease), transform .8s var(--ease); transition-delay: calc(var(--d, 0) * 70ms); }

/* Project page */
.project-head { padding-top: clamp(24px, 4vw, 48px); padding-bottom: clamp(32px, 4vw, 56px); }
.back { display: inline-flex; font: 500 14px/1 var(--sans); text-decoration: none; color: var(--ink-2); padding: 10px 16px; border-radius: 999px; background: var(--paper-2); margin-bottom: clamp(32px, 5vw, 64px); transition: background .2s; }
.back:hover { background: var(--acc); color: var(--on-acc); }
.project-head { container-type: inline-size; }
/* one line for every title: the longest (小瓦掃地機器人募資頁) is ~9.8em wide */
.project-title { font: 600 min(9.4cqi, 108px)/1.1 var(--display); letter-spacing: -.045em; white-space: nowrap; }
.project-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: clamp(32px, 5vw, 64px); }
.project-top .back { margin-bottom: 0; }
.project-tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.project-tags a {
  display: inline-block; padding: 9px 14px; border-radius: 999px; text-decoration: none;
  font: 400 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  border: 1.5px solid color-mix(in srgb, var(--ink) 75%, transparent); transition: background .2s, border-color .2s, color .2s;
}
.project-tags a:hover { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.project-rule { margin-top: clamp(32px, 4vw, 56px); padding-top: 18px; border-top: 1px solid var(--ink); min-height: 1px; }
.project-link { font: 500 15px/1.4 var(--sans); text-decoration: underline; text-decoration-color: var(--acc); text-decoration-thickness: 3px; text-underline-offset: 5px; }
.project-link:hover { color: var(--acc-text); }

.desc { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(28px, 5vw, 96px); padding-bottom: clamp(48px, 6vw, 88px); }
.desc-col .label { margin-bottom: 16px; }
.desc-col p { margin: 0 0 1em; color: var(--ink-2); font-family: var(--tc); line-height: 1.85; }
.desc-col[lang="en"] p { font-family: var(--sans); line-height: 1.65; font-size: 16px; }
.desc-col b, .desc-col strong { color: var(--ink); font-weight: 600; }

.gallery { display: grid; gap: clamp(12px, 1.4vw, 20px); }
.shot { margin: 0; border-radius: var(--r); overflow: hidden; background: var(--paper-2); cursor: zoom-in; }
.shot img, .shot video { width: 100%; }

.pager { display: grid; grid-template-columns: 1fr 1.7fr; gap: clamp(12px, 1.4vw, 20px); padding-top: clamp(80px, 10vw, 140px); padding-bottom: clamp(24px, 3vw, 40px); }
.pager a {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; min-height: 220px;
  padding: 28px; border-radius: var(--r); text-decoration: none; overflow: hidden;
  background: var(--paper-2); transition: background .25s;
}
.pager a:hover { background: color-mix(in srgb, var(--paper-2) 70%, var(--ink) 12%); }
.pager b { font: 600 clamp(24px, 2.6vw, 38px)/1.15 var(--display); letter-spacing: -.035em; position: relative; z-index: 1; }
.pager a.pager-next { background: var(--ink); color: var(--paper); padding-right: 46%; }
.pager-next .label { color: var(--acc); }
.pager-thumb { position: absolute; inset: 10px 10px 10px auto; width: calc(44% - 10px); border-radius: var(--r-sm); overflow: hidden; }
.pager-thumb img, .pager-thumb video { width: 100%; height: 100%; object-fit: cover; transition: transform .9s var(--ease); }
.pager-next:hover .pager-thumb img, .pager-next:hover .pager-thumb video { transform: scale(1.05); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(15, 15, 14, .96);
  display: grid; grid-template-columns: 64px 1fr 64px; align-items: center;
  animation: fade .2s ease;
}
.lightbox[hidden] { display: none; }
.lb-stage { height: 100dvh; display: grid; place-items: center; padding: 56px 0; overflow: auto; }
.lb-stage img, .lb-stage video { max-height: calc(100dvh - 112px); width: auto; max-width: 100%; object-fit: contain; border-radius: 8px; }
.lightbox button {
  background: none; border: 0; color: #fff; font: 400 26px/1 var(--sans); cursor: pointer;
  width: 52px; height: 52px; border-radius: 50%; justify-self: center;
}
.lightbox button:hover { background: rgba(255, 255, 255, .12); }
.lb-close { position: absolute; top: 10px; right: 10px; font-size: 34px !important; }
.lb-count { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; margin: 0; color: #aaa; font: 500 13px/1 var(--sans); }
@keyframes fade { from { opacity: 0; } }

/* Footer */
.site-footer { padding-bottom: 8px; }
.cta {
  position: relative; background: var(--acc); color: var(--on-acc); --ink: var(--on-acc); border-radius: var(--r-lg);
  padding: clamp(40px, 6vw, 88px) clamp(24px, 5vw, 80px) clamp(48px, 6vw, 88px);
}
.cta-title { font-size: clamp(64px, 12vw, 200px); margin: 0 0 clamp(28px, 4vw, 48px) -.04em; }
.cta-mail { font: 600 clamp(18px, 2.2vw, 30px)/1.2 var(--sans); letter-spacing: -.02em; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; word-break: break-all; }
.footer-bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  padding: 28px 4px 24px; font: 400 11px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.footer-bottom a { text-decoration: none; }
.footer-bottom a:hover { color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; font: 600 15px/1 var(--sans); text-decoration: none; white-space: nowrap;
  padding: 15px 24px; border-radius: 999px; background: var(--ink); color: var(--paper); border: 1px solid transparent;
  transition: background .2s, color .2s, border-color .2s, transform .15s var(--ease);
}
.btn:hover { background: var(--acc); color: var(--on-acc); }
.btn:active { transform: scale(.98); }
.btn--acc { background: var(--acc); color: var(--on-acc); }
.btn--acc:hover { background: var(--ink); color: var(--paper); }
.btn--ghost { background: transparent; color: var(--ink); border-color: color-mix(in srgb, var(--ink) 35%, transparent); }
.btn--ghost:hover { border-color: var(--acc); }
.hero-404 { min-height: 60vh; padding-top: 10vh; display: grid; align-content: start; gap: 24px; }
.hero-404 .hero-lede { text-align: left; justify-self: start; }

/* Fit the two-column hero inside one screen (header is ~64px) */
@media (min-width: 901px) {
  .hero { padding-top: clamp(16px, 2vw, 28px); padding-bottom: clamp(40px, 5vw, 72px); }
  .hero-copy { gap: clamp(18px, 3vh, 36px); padding-top: clamp(8px, 2vh, 24px); }
  .hero-title { font-size: min(24cqi, 200px, 17vh); }
  .hero-stats b { font-size: min(clamp(56px, 6vw, 96px), 9vh); }
  /* square photo: shows head to waist; never taller than about two thirds of the screen */
  .hero { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: center; }
  .hero-card { min-height: 0; max-height: none; align-self: center; width: min(100%, 64svh); justify-self: end; height: auto; aspect-ratio: 1; }
  .hero-copy { justify-content: center; }
  .hero-portrait { object-position: 58% 14%; transform-origin: 60% 0%; }
}

/* Responsive */
@media (max-width: 1100px) {
  .nav { justify-self: end; }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero-copy { padding-top: 8px; }
  .hero { gap: 20px; padding-top: 16px; }
  .hero-copy { gap: 24px; }
  /* Phone: photo first, sized so photo + title fit the first screen */
  .hero-card { order: -1; min-height: 0; aspect-ratio: auto; height: auto; aspect-ratio: 1; max-height: 48svh; }
  .hero-portrait { object-position: 58% 12%; }
  .hero-badge { width: 78px; height: 78px; right: 14px; top: 14px; }
  .hero-badge-mark { width: 32px; height: 32px; right: 37px; top: 37px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card, .card.s5, .card.s7, .grid.filtered .card { grid-column: span 1; }
  .card.s5 .card-media, .card.s7 .card-media { aspect-ratio: 4 / 3; height: auto; }
}
@media (max-width: 720px) {
  .desc { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  .pager a { min-height: 140px; }
  .pager a.pager-next { padding-right: 28px; padding-top: 216px; }
  .pager-thumb { inset: 10px 10px auto 10px; width: auto; height: 186px; }
  .lightbox { grid-template-columns: 1fr; }
  .lb-prev, .lb-next { position: absolute; bottom: 4px; }
  .lb-prev { left: 12px; } .lb-next { right: 12px; }
  .brand span { display: none; }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
  .hero-stats b { font-size: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .js .card, .js .reveal { opacity: 1; transform: none; }
}

/* Paper texture and grain work the other way round on a light page */
:root[data-theme="light"] body::before { mix-blend-mode: multiply; opacity: .24; }
:root[data-theme="light"] body::after { mix-blend-mode: multiply; filter: none; opacity: .07; }
:root[data-theme="light"] .hero-badge { box-shadow: 0 10px 30px -14px rgba(60, 40, 0, .3); }
:root[data-theme="light"] .hero-card { box-shadow: 0 40px 80px -48px rgba(140, 80, 0, .45); }
:root[data-theme="light"] .lightbox { background: rgba(239, 235, 227, .97); }
:root[data-theme="light"] .lightbox button { color: var(--ink); }
:root[data-theme="light"] .lightbox button:hover { background: rgba(20, 20, 19, .08); }
:root[data-theme="light"] .lb-count { color: var(--muted); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) body::before { mix-blend-mode: multiply; opacity: .24; }
  :root:not([data-theme]) body::after { mix-blend-mode: multiply; filter: none; opacity: .07; }
}

/* the header's right-hand group */
.head-end { justify-self: end; display: flex; align-items: center; gap: 8px; }
.head-end .status { justify-self: auto; }

/* Reading progress and hero photo drift come from the scroll position itself (no scroll listener) */
@supports (animation-timeline: scroll()) {
  .progress { animation: progress linear both; animation-timeline: scroll(root); }
  @keyframes progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  .hero-portrait { animation: drift linear both; animation-timeline: scroll(root); animation-range: 0 120vh; }
  @keyframes drift { to { translate: 0 9.6vh; } }
}
@supports not (animation-timeline: scroll()) { .progress { display: none; } }
@media (max-width: 1100px) {
  .site-header__inner { grid-template-columns: auto 1fr auto; }
}

/* Note shown after clicking an email link (address copied) */
.copy-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 300; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  font: 500 14px/1.3 var(--sans); background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 999px;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .45); transition: opacity .25s, transform .35s cubic-bezier(.2, .7, .2, 1);
}
.copy-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Light / dark: round button, sun in dark mode, moon in light mode (PulsoIcon glyphs) */
.theme-btn {
  position: relative; display: grid; place-items: center; width: 40px; height: 40px; min-width: 0; padding: 0;
  border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s;
}
.theme-btn:hover { border-color: var(--ink); }
.theme-btn:active { transform: scale(.94); }
.theme-btn svg { grid-area: 1 / 1; transition: opacity .35s, transform .5s cubic-bezier(.2, .9, .25, 1.2); }
.theme-btn .i-moon { opacity: 0; transform: rotate(-90deg) scale(.5); }
:root[data-theme="light"] .theme-btn .i-sun { opacity: 0; transform: rotate(90deg) scale(.5); }
:root[data-theme="light"] .theme-btn .i-moon { opacity: 1; transform: none; }
.theme-btn .rays, .theme-btn .i-moon path { transform-box: view-box; transform-origin: 12px 12px; transition: transform .6s cubic-bezier(.2, .9, .25, 1.1); }
.theme-btn:hover .rays, .theme-btn:focus-visible .rays { transform: rotate(90deg); }
.theme-btn:hover .i-moon path, .theme-btn:focus-visible .i-moon path { animation: moon-swing .7s ease-in-out; }
@keyframes moon-swing { 25% { transform: rotate(-20deg); } 60% { transform: rotate(12deg); } 100% { transform: none; } }

/* Work / About switch: a pill slides between the two (ui.js); without JS the current one is filled */
.nav { position: relative; }
.nav a { position: relative; z-index: 1; }
.nav .nav-pill {
  position: absolute; z-index: 0; left: 3px; top: 3px; bottom: 3px; border-radius: 999px; background: var(--ink);
  transition: transform .42s cubic-bezier(.3, 1.25, .5, 1), width .42s cubic-bezier(.3, 1.25, .5, 1);
}
.nav.still .nav-pill { transition: none; }
.nav.ready a[aria-current], .nav.ready a[aria-current]:hover { background: transparent; color: inherit; }
.nav.ready a { transition: color .3s; }
.nav.ready a.on, .nav.ready a.on:hover { color: var(--paper); background: transparent; }
.nav.ready a:not(.on):hover { background: transparent; color: var(--acc-text); }

/* Email: same round button as the theme switch (PulsoIcon mail; the flap folds on hover) */
.round-btn {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0 !important; border-radius: 50%;
  border: 1px solid var(--line); color: var(--ink); background: transparent; text-decoration: none;
  transition: border-color .2s, background .2s, color .2s, transform .15s;
}
.round-btn:hover { background: var(--acc); border-color: var(--acc); color: #141413; }
.round-btn:active { transform: scale(.94); }
.round-btn .flap, .round-btn .env { transform-box: view-box; transition: transform .45s cubic-bezier(.2, .9, .25, 1.2); }
.round-btn .flap { transform-origin: 12px 7px; }
.round-btn .env { transform-origin: 12px 12px; }
.round-btn:hover .flap, .round-btn:focus-visible .flap { transform: scaleY(-.6) translateY(-1px); }
.round-btn:hover .env, .round-btn:focus-visible .env { transform: scale(.96); }
