/* Kelly Zheng — personal site. Black, white and a little green. */

@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

html { scroll-behavior: smooth; transition: background-color .45s ease, color .45s ease; }
html.dark { background: #000000; color: #FFFFFF; }
html.light { background: #FFFFFF; color: #000000; }
body {
  margin: 0;
  font-family: "Archivo", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", "Arial Narrow", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}
.preload, .preload * { transition: none !important; }

a { color: inherit; text-decoration: none; }
a:hover { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
a:focus-visible, button:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.wrap { position: relative; max-width: 1440px; margin: 0 auto; padding: 0 clamp(20px, 3.4vw, 48px); box-sizing: border-box; }
.g12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; }
.g10 { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); column-gap: 24px; }

/* Every section is at least one full screen; the home hero is exactly one screen */
.full {
  min-height: 100vh; min-height: 100svh; box-sizing: border-box; padding: clamp(28px, 6vh, 96px) 0;
  display: flex; flex-direction: column; justify-content: center;
}
.screen1 {
  min-height: 100vh; min-height: 100svh; box-sizing: border-box; padding: clamp(16px, 3.5vh, 32px) 0 clamp(16px, 3vh, 32px);
  display: flex; flex-direction: column;
}

/* Home hero */
.hero {
  height: 100vh; height: 100svh; min-height: 360px; box-sizing: border-box; padding: clamp(16px, 3.5vh, 32px) 0 clamp(14px, 3vh, 32px);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; row-gap: clamp(16px, 3.5vh, 40px);
}
.hero-top { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; align-items: center; font-weight: 500; }
.hero-top p { margin: 0; }
.h-lamp { grid-column: 1 / span 3; }
.h-lang { grid-column: 10 / span 3; justify-self: end; }
.hero-mid {
  min-height: 0; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 4fr) auto;
  grid-template-rows: minmax(0, 1fr); column-gap: 24px; align-items: end;
}

.hero-mid .photo-btn {
  grid-column: 3; justify-self: end; align-self: end;
  height: min(100%, calc(min(27vw, 380px) * 1.25)); width: auto; aspect-ratio: 4 / 5;
}
.r-result { min-height: clamp(170px, 30vh, 300px); }
/* Name on the left, two facts on the right, each on the baseline of one line of the name:
   Kelly / what I do, Zheng / where I am and the way down. The h1 steps aside (display: contents)
   so its two lines can share rows with the facts. Everything on the right hangs from the right edge. */
.hero-foot {
  --nf: clamp(56px, min(21vw, 26vh), 304px); --nf: clamp(56px, min(21vw, 26svh), 304px);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 24px; row-gap: calc(var(--nf) * .22); align-items: last baseline;
  padding-bottom: calc(var(--nf) * .2); border-bottom: 1px solid currentColor;
}
.hero-foot .hero-name { display: contents; }
.hero-name .mh:first-child { grid-column: 1; grid-row: 1; }
.hero-name .mh:last-child { grid-column: 1; grid-row: 2; }
/* the direction: large, but in the plain width and weight, so the name stays the loudest thing */
.hero-role { grid-column: 2; grid-row: 1; justify-self: end; margin: 0; font-size: max(22px, calc(var(--nf) * .26)); font-weight: 500; line-height: 1; letter-spacing: -.025em; white-space: nowrap; }
:lang(zh) .hero-role { letter-spacing: 0; }
.hero-meta { grid-column: 2; grid-row: 2; justify-self: end; }
.hero-meta { display: flex; align-items: center; gap: 16px; }
.h-based { margin: 0; font-size: 15px; font-weight: 500; white-space: nowrap; }
.h-down { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; box-sizing: border-box; border: 1px solid currentColor; color: inherit; transition: background-color .2s ease, border-color .2s ease, color .2s ease; }
.h-down:hover, .h-down:focus-visible { background: #2DB55D; border-color: #2DB55D; color: #000; }
.h-down svg { animation: bob 2.4s ease-in-out 1.8s infinite; }
@keyframes bob { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(5px); } }
.hero-name {
  margin: 0;
  font-size: var(--nf);
  font-weight: 800; font-variation-settings: 'wdth' 62; line-height: .76; letter-spacing: -.035em;
}

/* Line heights that change with the language */
.lh-text { line-height: 1.25; }
.lh-title { line-height: .9; }
.lh-h3 { line-height: 1.05; }
.lh-body { line-height: 1.45; }
.lh-big { line-height: 1.08; }
.lh-h1 { line-height: .8; letter-spacing: -.03em; }
.lh-next { line-height: .85; }
:lang(zh) .lh-text { line-height: 1.6; }
:lang(zh) .lh-title { line-height: 1.05; }
:lang(zh) .lh-h3 { line-height: 1.3; }
:lang(zh) .lh-body { line-height: 1.7; }
:lang(zh) .lh-big { line-height: 1.35; }
:lang(zh) .lh-h1 { line-height: .95; letter-spacing: -.02em; }
:lang(zh) .lh-next { line-height: 1; }

/* Header controls */
.lang { display: flex; }
.lang button {
  font: inherit; font-size: 14px; font-weight: 700; min-width: 52px; min-height: 44px; padding: 0 12px;
  border: 1px solid currentColor; cursor: pointer; background: transparent; color: inherit;
}
.lang button + button { margin-left: -1px; }
.dark .lang button[aria-pressed="true"] { background: #FFFFFF; color: #000000; }
.light .lang button[aria-pressed="true"] { background: #000000; color: #FFFFFF; }

.lamp {
  font: inherit; color: inherit; background: none; border: 1px solid currentColor; width: 44px; height: 44px;
  padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.lamp .rays { opacity: 0; transition: opacity .3s ease; }
.lamp .bulb { fill: none; transition: fill .3s ease; }
.light .lamp .rays { opacity: 1; }
.light .lamp .bulb { fill: #2DB55D; }

.light .logo { filter: invert(1); }

/* Photo block */
.photo-btn {
  position: relative; display: block; padding: 0; border: 0; container-type: size;
  background: #2DB55D; color: #000000; cursor: pointer; overflow: hidden; font: inherit; text-align: left;
}
.photo-btn .flip { position: absolute; inset: 0; padding: clamp(10px, 6cqw, 18px); display: flex; flex-direction: column; justify-content: space-between; transition: opacity .3s ease; }
.photo-btn .eye { width: clamp(18px, 9cqw, 28px); height: auto; }
.photo-btn .see {
  font-size: clamp(14px, min(11.5cqw, 9cqh), 38px); font-weight: 800; font-variation-settings: 'wdth' 62;
  line-height: 1; letter-spacing: -0.015em; text-wrap: pretty;
}
.photo-btn .photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; clip-path: inset(100% 0 0 0); transition: clip-path .6s cubic-bezier(.2,.8,.2,1); }
.photo-btn.is-on .flip { opacity: 0; }
.photo-btn.is-on .photo { clip-path: inset(0 0 0 0); }

/* Row hover */
.row .t { transition: color .2s ease; }
.dark .row:hover .t, .dark .row:focus-visible .t { color: #2DB55D; }
.light .row:hover .t, .light .row:focus-visible .t { color: #17853F; }
.row:hover { text-decoration: none; }
.next .t { transition: color .2s ease; }
.next:hover { text-decoration: none; }
.dark .next:hover .t, .dark .next:focus-visible .t { color: #2DB55D; }
.light .next:hover .t, .light .next:focus-visible .t { color: #17853F; }

/* Side rail */
.rail { grid-column: 1 / span 2; grid-row: 1; align-self: start; position: sticky; top: 0; height: 100vh; height: 100svh; box-sizing: border-box; padding: clamp(32px, 8vh, 72px) 0; display: flex; gap: 16px; }
.rail a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding-left: 22px; color: #8C8C8C; font-weight: 500; transition: color .2s ease; }
.light .rail a { color: #6B6B6B; }
.rail a.is-active { color: inherit; font-weight: 700; }
.rail a:hover { text-decoration: none; }
.mk { position: absolute; left: 0; width: 8px; height: 8px; background: #2DB55D; transition: top .4s cubic-bezier(.2,.8,.2,1); }
.bar { position: absolute; left: 0; top: 0; width: 1px; height: 0; background: currentColor; transition: height .15s linear; }

/* Experience and education rows */
.xr { display: grid; grid-template-columns: minmax(0, 1fr) 230px 72px 140px 44px; column-gap: 24px; row-gap: 10px; align-items: baseline; }
.xt { grid-column: 1; } .xa { grid-column: 2; } .xb { grid-column: 3; } .xc { grid-column: 4; } .xab { grid-column: 2 / span 2; }
/* Experience: each row opens its own page. A bordered square, like the other controls, says so;
   it fills green on hover, and flashes green once, row by row, when the list first appears. */
.xg { grid-column: 5; align-self: center; justify-self: end; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; box-sizing: border-box; border: 1px solid currentColor; transition: background-color .2s ease, border-color .2s ease, color .2s ease; }
.xg svg { transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
.row:hover .xg, .row:focus-visible .xg { background: #2DB55D; border-color: #2DB55D; color: #000; }
.row:hover .xg svg, .row:focus-visible .xg svg { transform: translateX(3px); }
@keyframes open-hint { 35%, 60% { background-color: #2DB55D; border-color: #2DB55D; color: #000; } }
.on .xr .xg { animation: open-hint .9s ease calc(1.2s + var(--k) * .2s); }
/* phones: drop the repeated word Intern so the dates stay on one line */
@media (max-width: 760px) {
  .row.xr { grid-template-columns: minmax(0, 1fr) auto 44px; column-gap: 16px; }
  .row.xr .xt { grid-column: 1 / span 2; } .row.xr .xa { grid-column: 1; } .row.xr .xc { grid-column: 2; } .row.xr .xb { display: none; }
  .row.xr .xg { grid-column: 3; grid-row: 1 / span 2; }
  .row.xr .xa { flex-wrap: wrap; row-gap: 4px; } .row.xr .xa span { white-space: nowrap; }
}
@media (max-width: 1100px) {
  .xr { grid-template-columns: minmax(0, 1.3fr) minmax(0, .7fr) minmax(0, 1fr) 44px; }
  .xg { grid-column: 4; grid-row: 1 / span 2; }
  .xt { grid-column: 1 / span 3; } .xa { grid-column: 1; } .xb { grid-column: 2; } .xc { grid-column: 3; } .xab { grid-column: 1 / span 2; }
}

/* The path: a headline, then the route drawn across three tracks (study, research, work).
   The green line runs along a track and turns at right angles, so the path is visibly not straight. */
.pt-top { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); column-gap: 24px; align-items: end; margin-bottom: clamp(20px, 5vh, 72px); }
.pt-head { grid-column: 1 / span 5; margin: 0; font-size: clamp(44px, min(5.8vw, 10.5vh), 104px); font-weight: 800; font-variation-settings: 'wdth' 62; line-height: .9; letter-spacing: -.03em; text-wrap: balance; }
:lang(zh) .pt-head { font-size: clamp(34px, min(4.4vw, 8vh), 76px); line-height: 1.12; letter-spacing: 0; }
.pt-text { grid-column: 6 / span 5; max-width: 36em; font-size: clamp(14px, 2.3vh, 16px); }
.pt-text p { margin: 0 0 .55em; text-wrap: pretty; }
.pt-text p:last-child { margin-bottom: 0; }
.pt-key { font-weight: 700; }

.pt { --pg: #2DB55D; --muted: #8C8C8C; --gx: 18px; position: relative; display: grid; grid-template-columns: clamp(56px, 6vw, 84px) repeat(7, minmax(0, 1fr)); grid-template-rows: auto repeat(3, auto); }
.light .pt { --muted: #6B6B6B; }
.pt-list { display: contents; list-style: none; margin: 0; padding: 0; }
.pt-year { grid-row: 1; align-self: end; padding: 0 12px clamp(8px, 1.4vh, 12px) 16px; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pt-lane { grid-column: 1; padding: clamp(10px, 1.8vh, 14px) 8px 0 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.pt-track { grid-column: 1 / 8; align-self: start; height: 1px; background: currentColor; opacity: .22; }
.pt-v { position: relative; z-index: 1; justify-self: start; align-self: stretch; width: 2px; background: var(--pg); }
.pt-stop { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 4px; padding: clamp(10px, 1.8vh, 14px) 12px clamp(10px, 2.4vh, 30px) 16px; }
.pt-stop.has-h::before { content: ""; position: absolute; left: 0; top: -1px; width: 100%; height: 2px; background: var(--pg); }
.pt-node { position: absolute; left: -4px; top: -5px; width: 10px; height: 10px; background: currentColor; }
.pt-meta { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pt-t { font-size: clamp(15px, min(1.35vw, 2.6vh), 19px); font-weight: 700; font-variation-settings: 'wdth' 75; line-height: 1.12; hyphens: auto; }
.pt-s { font-size: 13px; line-height: 1.3; color: var(--muted); }
.pt-next { grid-column: 8; grid-row: 1 / 5; display: flex; flex-direction: column; gap: 6px; padding: 14px; background: #2DB55D; color: #000; }
.pt-ny { font-size: 15px; font-weight: 700; }
.pt-nt { margin-top: auto; font-size: clamp(20px, min(1.9vw, 3.4vh), 32px); font-weight: 800; font-variation-settings: 'wdth' 62; line-height: .98; letter-spacing: -.01em; }
:lang(zh) .pt-nt { line-height: 1.2; letter-spacing: 0; }
.pt-ns { font-size: 13px; line-height: 1.35; }

/* drawn in: tracks and years first, then the route travels stop to stop and lands in the green block */
.pt-track, .pt-year, .pt-lane { opacity: 0; transition: opacity .5s ease .2s; }
.on .pt-track { opacity: .22; }
.on .pt-year, .on .pt-lane { opacity: 1; }
.pt-stop.has-h::before { transform: scaleX(0); transform-origin: left; transition: transform .24s linear calc(.5s + var(--hd) * .16s); }
.pt-v { transform: scaleY(0); transform-origin: top; transition: transform .24s linear calc(.5s + var(--d) * .16s); }
.pt-v.up { transform-origin: bottom; }
.pt-stop > span { opacity: 0; transition: opacity .35s ease calc(.5s + var(--n) * .16s); }
.pt-next { clip-path: inset(0 100% 0 0); transition: clip-path .6s cubic-bezier(.7, 0, .2, 1) calc(.5s + var(--n) * .16s); }
.on .pt-stop.has-h::before, .on .pt-v { transform: none; }
.on .pt-stop > span { opacity: 1; }
.on .pt-next { clip-path: inset(0 0 0 0); }

@media (max-width: 760px) {
  .pt-top { grid-template-columns: minmax(0, 1fr); row-gap: 20px; }
  .pt-head, .pt-text { grid-column: 1; }
  .pt { display: block; }
  .pt-year, .pt-lane, .pt-track, .pt-v { display: none; }
  .pt-list { display: block; }
  /* the tracks become three indents: the route steps sideways between them as it runs down */
  .pt { --x0: 5px; }
  .pt-stop { padding: 0 0 22px calc(var(--x0) + var(--gx) * 2 + 30px); }
  .pt-node { z-index: 1; left: calc(var(--x0) + var(--l) * var(--gx) - 4px); top: 3px; }
  .pt-stop::after { content: ""; position: absolute; left: calc(var(--x0) + var(--l) * var(--gx)); top: 0; bottom: 0; width: 2px; background: var(--pg); }
  .pt-list > .pt-stop:first-child::after { top: 8px; }
  .pt-stop::before, .pt-stop.has-h::before { content: ""; position: absolute; top: auto; bottom: -1px; left: calc(var(--x0) + var(--a) * var(--gx)); width: calc(var(--w) * var(--gx) + 2px); height: 2px; background: var(--pg); transform: none; }
  .pt-meta { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: flex; gap: 8px; font-size: 13px; font-weight: 700; }
  .pt-meta span + span { color: var(--muted); font-weight: 600; }
  .pt-next { margin-left: calc(var(--x0) + var(--gx) * 2); padding: 16px; min-height: 96px; }
  .pt-stop { opacity: 0; transition: opacity .4s ease calc(.3s + var(--n) * .1s); }
  .on .pt-stop { opacity: 1; }
}

/* Skills: a tree drawn on the grid. Lines are 1px and meet at right angles;
   the chosen branch is traced in green from the root, through its leaves, to its statement. */
.tr {
  --tg: clamp(16px, 2.2vw, 32px);   /* gap between branches */
  --st: clamp(18px, 3.6vh, 40px);   /* root stem */
  --dr: clamp(16px, 3vh, 32px);     /* drop from the bracket to a branch */
  --lg: clamp(14px, 2.6vh, 26px);   /* branch head to its first leaf */
  --lp: 5px;                        /* leaf padding */
  --tail: clamp(20px, 4.4vh, 48px); /* last leaf to the statement rule */
  --hi: #2DB55D;                    /* green line */
  --hit: #2DB55D;                   /* green text */
  --muted: #8C8C8C;
  --ease: cubic-bezier(.65, 0, .35, 1);
}
.light .tr { --hit: #17853F; --muted: #6B6B6B; }

.tr-root { position: relative; margin: 0; padding-bottom: var(--st); font-size: 15px; font-weight: 700; line-height: 1.2; }
.tr-root::after { content: ""; position: absolute; left: 0; bottom: 0; width: 2px; height: var(--st); background: var(--hi); }

.tr-cols { position: relative; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: auto auto; column-gap: var(--tg); }
/* green run along the bracket, out to the chosen branch */
.tr-cols::after { content: ""; position: absolute; left: 0; top: 0; height: 2px; width: calc(var(--sel) * (100% + var(--tg)) / 4); background: var(--hi); transition: width .45s var(--ease); }
/* each branch spans the two shared rows (head, leaves), so leaves line up even when a name wraps */
.tr-col { position: relative; display: grid; grid-row: span 2; grid-template-rows: subgrid; row-gap: 0; }
.tr-col::before { content: ""; position: absolute; left: 0; top: 0; width: calc(100% + var(--tg)); height: 1px; background: currentColor; }
.tr-col:last-child::before { display: none; }
/* the drop grows to fill any spare height above a shorter head */
.tr-drop { flex: 1 0 auto; width: 1px; min-height: var(--dr); margin-bottom: 8px; background: currentColor; }

.tr-head { display: flex; flex-direction: column; align-items: flex-start; width: 100%; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.tr-num { font-size: 13px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; transition: color .25s ease; }
.tr-name { margin-top: 10px; font-size: clamp(22px, min(2.5vw, 4.6vh), 44px); font-weight: 800; font-variation-settings: 'wdth' 62; line-height: .95; letter-spacing: -.015em; text-wrap: balance; transition: color .25s ease; }
:lang(zh) .tr-name { line-height: 1.15; letter-spacing: 0; }
.tr-level { margin-top: 10px; font-size: 13px; font-weight: 600; line-height: 1.2; color: var(--muted); }
.tr-head:hover .tr-name { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .14em; }
.tr-col.is-on .tr-head:hover .tr-name { text-decoration: none; }
.tr-col.is-on .tr-num, .tr-col.is-on .tr-name { color: var(--hit); }

.tr-leaves { position: relative; container: trleaves / inline-size; list-style: none; margin: 0; padding: var(--lg) 0 var(--tail); overflow: hidden; }
.tr-leaves li { position: relative; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; padding: var(--lp) 0 var(--lp) 22px; font-size: 15px; line-height: 1.3; }
.tr-leaves li::before { content: ""; position: absolute; left: 0; top: calc(var(--lp) + .66em); width: 14px; height: 1px; background: currentColor; }
.tr-leaves li::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: currentColor; }
.tr-leaves li:first-child::after { top: calc(8px - var(--lg)); }
.tr-leaves li:last-child::after { bottom: auto; height: calc(var(--lp) + .66em + 1px); }
.tr-a { font-weight: 600; }
.tr-b { font-size: 13px; color: var(--muted); }
.tr-b:empty { display: none; }
/* in a narrow branch, the note sits under its tool instead of wrapping unevenly beside it */
@container trleaves (max-width: 229px) {
  .tr-leaves li { flex-direction: column; }
  .tr-b { margin-top: 1px; }
}

/* the chosen branch: every line in it turns green and thickens; its trunk runs on down to the statement */
.tr-col.is-on .tr-drop, .tr-col.is-on .tr-leaves li::after { width: 2px; background: var(--hi); }
.tr-col.is-on .tr-leaves li::before { height: 2px; background: var(--hi); }
.tr-col.is-on .tr-leaves li:last-child::after { height: auto; bottom: -100vh; }

.tr-panel { position: relative; padding-top: clamp(22px, 4vh, 44px); }
.tr-panel::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: currentColor; }
/* green run back along the rule, to where the statement starts */
.tr-panel::after { content: ""; position: absolute; left: 0; top: 0; height: 2px; width: calc(var(--sel) * (100% + var(--tg)) / 4 + 2px); background: var(--hi); transition: width .45s var(--ease) .2s; }
.tr-detail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: var(--tg); align-items: start; transition: opacity .2s ease, transform .2s ease; }
.tr-detail.is-out { opacity: 0; transform: translateY(8px); }
.tr-stmt { grid-column: 1 / span 2; margin: 0; font-size: clamp(26px, min(3vw, 5.4vh), 52px); font-weight: 700; font-variation-settings: 'wdth' 70; line-height: 1.02; letter-spacing: -.02em; text-indent: -.42em; text-wrap: balance; }
:lang(zh) .tr-stmt { font-size: clamp(22px, min(2.3vw, 4.2vh), 38px); line-height: 1.3; letter-spacing: 0; word-break: keep-all; overflow-wrap: anywhere; }
.tr-side { grid-column: 3 / span 2; }
.tr-desc { margin: 0; max-width: 34em; font-size: 16px; text-wrap: pretty; }
.tr-note { display: flex; flex-wrap: wrap; gap: 2px 10px; margin: 16px 0 0; font-size: 13px; line-height: 1.4; }
.tr-note[hidden] { display: none; }
.tr-note-k { font-weight: 700; }
.tr-acc { display: none; }

/* The tree draws itself in when the section first scrolls into view */
.tr-root::after, .tr-drop, .tr-leaves li::after { transform: scaleY(0); transform-origin: top; }
.tr-col::before, .tr-leaves li::before, .tr-panel::before { transform: scaleX(0); transform-origin: left; }
.tr-head, .tr-leaves li > span, .tr-detail { opacity: 0; }
.tr-cols::after, .tr-panel::after { opacity: 0; }
.tr-root::after { transition: transform .45s var(--ease) .1s; }
.tr-col::before { transition: transform .4s linear calc(.5s + var(--i) * .4s); }
.tr-drop { transition: transform .3s var(--ease) calc(.6s + var(--i) * .4s), background-color .3s ease, width 0s; }
.tr-head { transition: opacity .5s ease calc(.75s + var(--i) * .4s); }
.tr-leaves li::after { transition: transform .35s var(--ease) calc(.95s + var(--i) * .4s), background-color .3s ease, width 0s; }
.tr-leaves li::before { transition: transform .3s var(--ease) calc(1.1s + var(--i) * .4s), background-color .3s ease, height 0s; }
.tr-leaves li > span { transition: opacity .4s ease calc(1.15s + var(--i) * .4s); }
.tr-panel::before { transition: transform .8s var(--ease) 2.2s; }
.tr-detail { transition: opacity .5s ease 2.6s, transform .2s ease; }
.tr-cols::after { transition: opacity 0s linear .5s, width .45s var(--ease); }
.tr-panel::after { transition: opacity 0s linear 2.6s, width .45s var(--ease) .2s; }
.on .tr-root::after, .on .tr-drop, .on .tr-leaves li::after, .on .tr-col::before, .on .tr-leaves li::before, .on .tr-panel::before { transform: none; }
.on .tr-head, .on .tr-leaves li > span, .on .tr-detail, .on .tr-cols::after, .on .tr-panel::after { opacity: 1; }
/* once drawn, selection changes answer straight away */
.tr.is-drawn .tr-drop, .tr.is-drawn .tr-leaves li::after { transition: background-color .25s ease, width 0s; }
.tr.is-drawn .tr-leaves li::before { transition: background-color .25s ease, height 0s; }
.tr.is-drawn .tr-detail { transition: opacity .2s ease, transform .2s ease; }
.tr.is-drawn .tr-cols::after { transition: width .45s var(--ease); }
.tr.is-drawn .tr-panel::after { transition: width .45s var(--ease) .2s; }
.tr.is-drawn .tr-col.is-on .tr-leaves li::after, .tr.is-drawn .tr-col.is-on .tr-leaves li::before { transition-delay: .3s; }

/* Phones: the same tree, turned on its side as an indented list; the statement opens under its branch */
@media (min-width: 761px) { .tr-acc { display: none !important; } }
@media (max-width: 760px) {
  .tr { --st: 16px; --dr: 0px; --lg: 14px; --tail: 14px; }
  .tr-root::after { width: 1px; background: currentColor; }
  .tr-cols { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; padding-left: 24px; }
  .tr-cols::after, .tr-panel { display: none; }
  .tr-col { display: block; grid-row: auto; padding: 0 0 18px; }
  .tr-col::before, .tr-col:last-child::before { display: block; left: -24px; top: 0; bottom: 0; width: 1px; height: auto; transform-origin: top; }
  .tr-col:last-child::before { bottom: auto; height: 15px; }
  .tr-drop { position: absolute; left: -24px; top: 14px; width: 16px; height: 1px; min-height: 0; margin: 0; transform-origin: left; }
  .tr-col.is-on .tr-drop { width: 16px; height: 2px; }
  .tr-head { padding-top: 8px; }
  .tr-name { font-size: 28px; }
  .tr-acc:not([hidden]) { display: block; padding: 0 0 8px; }
  .tr-acc .tr-stmt { font-size: 26px; }
  :lang(zh) .tr-acc .tr-stmt { font-size: 22px; }
  .tr-acc .tr-side { margin-top: 16px; }
  .tr-col::before { transform: scaleY(0); }
  .tr-drop { transform: scaleX(0); }
  .on .tr-col::before, .on .tr-drop { transform: none; }
}

.textbtn { font: inherit; font-size: 15px; font-weight: 500; color: inherit; background: none; border: 0; padding: 12px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }

/* Visually hidden section labels (shown on phones) */
.lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }

/* Motion: page load */
@keyframes rise { from { transform: translateY(1.25em); } to { transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes wipe { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.mh { display: block; overflow: hidden; padding: .22em 0 .26em; margin: -.22em 0 -.26em; }
.mh > span { display: block; animation: rise 1.1s cubic-bezier(.2,.8,.2,1) both; }
.fa { animation: fadein .8s ease .8s both; }
.wipe { animation: wipe .9s cubic-bezier(.7,0,.2,1) .45s both; }
.eye { transform-origin: center; animation: blink 4.5s ease-in-out 2.2s infinite; }

/* Motion: on scroll (JS adds .on to a section when it enters view) */
.mr { display: block; overflow: hidden; padding: .14em 0; margin: -.14em 0; }
.mr > span { display: block; transform: translateY(115%); transition: transform .9s cubic-bezier(.2,.8,.2,1); }
.on .mr > span { transform: none; }
.ln { position: relative; }
.ln::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .8s cubic-bezier(.2,.8,.2,1); }
.on .ln::before { transform: scaleX(1); }
.fd { opacity: 0; transition: opacity .6s ease .45s; }
.on .fd { opacity: 1; }
.fdl { transition-delay: 1.4s; }
.ln .xa, .ln .xb, .ln .xc, .ln .xab { opacity: 0; transition: opacity .6s ease .45s; }
.on .ln .xa, .on .ln .xb, .on .ln .xc, .on .ln .xab { opacity: 1; }
.on .ln:nth-child(2)::before, .on .ln:nth-child(2) .mr > span { transition-delay: .15s; }
.on .ln:nth-child(3)::before, .on .ln:nth-child(3) .mr > span { transition-delay: .3s; }
.on .ln:nth-child(4)::before, .on .ln:nth-child(4) .mr > span { transition-delay: .45s; }
.on .pl > .mr:nth-child(2) > span { transition-delay: .12s; }
.on .pl > .mr:nth-child(3) > span { transition-delay: .24s; }
.on .pl > .mr:nth-child(4) > span { transition-delay: .36s; }
.on .pl > .mr:nth-child(5) > span { transition-delay: .48s; }
.step { position: relative; }
.step::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .5s cubic-bezier(.2,.8,.2,1); }
.step > * { opacity: 0; transition: opacity .5s ease; }
.on .step::before { transform: scaleX(1); }
.on .step > * { opacity: 1; }
.on .step:nth-child(1)::before { transition-delay: .6s; }  .on .step:nth-child(1) > * { transition-delay: .75s; }
.on .step:nth-child(2)::before { transition-delay: .72s; } .on .step:nth-child(2) > * { transition-delay: .87s; }
.on .step:nth-child(3)::before { transition-delay: .84s; } .on .step:nth-child(3) > * { transition-delay: .99s; }
.on .step:nth-child(4)::before { transition-delay: .96s; } .on .step:nth-child(4) > * { transition-delay: 1.11s; }
.on .step:nth-child(5)::before { transition-delay: 1.08s; } .on .step:nth-child(5) > * { transition-delay: 1.23s; }
.on .step:nth-child(6)::before { transition-delay: 1.2s; }  .on .step:nth-child(6) > * { transition-delay: 1.35s; }
.on .step:nth-child(7)::before { transition-delay: 1.32s; } .on .step:nth-child(7) > * { transition-delay: 1.47s; }
.stepg { clip-path: inset(0 100% 0 0); transition: clip-path .7s cubic-bezier(.7,0,.2,1) 1.55s; }
.on .stepg { clip-path: inset(0 0 0 0); }

/* Tablets: no room for the side rail, so sections carry their own labels instead */
@media (min-width: 761px) and (max-width: 1023px) {
  .rail { display: none !important; }
  main { grid-column: 1 / -1 !important; }
  .lbl { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; margin: 0 0 16px; }
}

/* Phones */
@media (max-width: 760px) {
  .hero-top { grid-template-columns: minmax(0, 1fr) auto; row-gap: 14px; }
  .h-lamp { grid-column: 1; grid-row: 1; }
  .h-lang { grid-column: 2; grid-row: 1; }
  .hero-mid { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); align-items: stretch; }
  /* phones: the way down stacks above the location, beside Zheng */
  .hero-foot { column-gap: 12px; }
  .hero-meta { flex-direction: column; align-items: flex-end; gap: 8px; }
  .h-based { font-size: 13px; }
  .hero-mid .photo-btn { grid-column: 1; grid-row: 1; justify-self: end; height: min(100%, calc((100vw - 2 * clamp(20px, 3.4vw, 48px)) * 1.25)); max-height: 100%; }
  .hero-foot { --nf: clamp(56px, min(24vw, 18vh), 304px); --nf: clamp(56px, min(24vw, 18svh), 304px); }
  .g { grid-template-columns: minmax(0, 1fr) !important; }
  .g > * { grid-column: 1 / -1 !important; grid-row: auto !important; }
  .g.r-meta { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; column-gap: 16px; }
  .g.r-meta > * { grid-column: auto !important; }
  .r-result { min-height: clamp(140px, 20vh, 200px); }
  .rail { display: none !important; }
  .lbl { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; margin: 0 0 16px; }
}

/* Respect reduced motion: show everything in its final state */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; transition: none; }
  .on .xr .xg { animation: none; }
  .h-down svg { animation: none; }
  .row .t, .next .t, .mk, .bar, .rail a, .photo-btn .photo, .photo-btn .flip, .lamp .rays, .lamp .bulb, .tr-name, .tr-num, .tr-detail { transition: none; }
  .mh > span, .fa, .wipe, .eye { animation: none; }
  .mr > span, .ln::before, .step::before { transition: none; transform: none; }
  .fd, .ln .xa, .ln .xb, .ln .xc, .ln .xab, .step > * { transition: none; opacity: 1; }
  .stepg { transition: none; clip-path: none; }
  .tr *, .tr *::before, .tr *::after, .tr-cols::after { transition: none !important; transform: none !important; }
  .pt *, .pt *::before, .pt *::after { transition: none !important; transform: none !important; }
  .pt-track { opacity: .22; } .pt-year, .pt-lane, .pt-stop, .pt-stop > span { opacity: 1; } .pt-next { clip-path: none; }
  .tr-head, .tr-leaves li > span, .tr-detail, .tr-cols::after, .tr-panel::after { opacity: 1; }
}
