/* Animate the ink independently of the words' scroll-driven position. */
.signature-ink { display: block; animation: name-appear 1.05s cubic-bezier(.19,.85,.2,1) .06s backwards; }
.family-name .signature-ink { animation-delay: .18s; }
.signature :is(.given-name, .family-name) { clip-path: inset(-.2em -.14em -.2em -.14em); }
.signature { animation: signature-appear 1.04s cubic-bezier(.18,.8,.22,1) .09s backwards; transform-origin: 50% 75%; }
.hero .role, .hero .bio {
  animation: opening-line .85s cubic-bezier(.2,.78,.23,1) backwards;
}
.hero .role { animation-delay: .19s; }
.hero .bio { animation-delay: .29s; }
[data-hold-opening] .hero :is(.signature, .signature-ink, .role, .bio) { animation-play-state: paused; }
[data-history-return] .hero :is(.signature, .signature-ink, .role, .bio) { animation: none; }
/* The masthead and its controls stay interactive while the content crossfades. */
:root { view-transition-name: none; }
main { view-transition-name: root; background-color: var(--page); }
::view-transition { pointer-events: none; clip-path: inset(var(--head) 0 0); }
::view-transition-group(root) { animation-duration: .38s; animation-timing-function: ease-in-out; }
::view-transition-old(root) { animation: switch-out .34s ease-in-out both; }
::view-transition-new(root) { animation: switch-in .38s ease-in-out both; }
:root:active-view-transition-type(language)::view-transition-new(root) {
  animation: switch-language-in .38s cubic-bezier(.22,.7,.3,1) both;
}
@keyframes switch-out { to { opacity: 0; } }
@keyframes switch-in { from { opacity: 0; } }
@keyframes switch-language-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
.theme-icon { transition: transform var(--theme-duration) ease-in-out; }
:root[data-theme-changing] :where(body, main, .site-footer, .design-viewer,
  main section, .chapter-heading-surface, .card-title, main h1, main p, main a, main strong, main mark,
  main dt, .name-zh, .role, .project-tabs button, .page-intro),
:root[data-theme-changing] #portfolio::before,
:root[data-theme-changing] :is(#portfolio, #projects)::after,
:root[data-theme-changing] .menu-panel::before,
:root[data-theme-changing] .resume-timeline > li::before,
:root[data-theme-changing] .resume-timeline > li::after {
  transition-property: background-color, color, border-color, text-decoration-color;
  transition-duration: var(--theme-duration);
  transition-timing-function: ease-in-out;
}
:root[data-theme-changing] :is(.brand img, .org-mark, .client-mark img, .tool-groups .mark-single-ink) {
  transition: filter var(--theme-duration) ease-in-out, transform .3s var(--ease);
}
:is(.button, .control, .project-tabs button, .project-links a, .menu-more summary, .menu-preferences button) {
  transition: scale .18s var(--ease), color .2s ease, background-color .2s ease;
}
:is(.button, .control, .project-tabs button, .project-links a, .menu-more summary, .menu-preferences button):active { scale: .96; }
@keyframes name-appear {
  from { opacity: .12; transform: translateY(107%); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes signature-appear {
  from { opacity: .08; transform: translateY(20px) scale(.96); }
  to { opacity: 1; transform: none; }
}
@keyframes opening-line {
  from { opacity: .04; transform: translateY(28px); }
  to { opacity: 1; transform: none; }
}

/* Keep the sticky containers untransformed. Only the top of the dark panel stretches. */
@media screen and (min-width: 900px) and (min-height: 540px) {
  main { --hero-run: clamp(190px, 45svh, 490px); --paper-lip: clamp(28px, 6svh, 76px); }
  #about.hero {
    display: block;
    min-height: 0;
    padding: 0;
  }
  #about.hero::after { content: ""; display: block; height: var(--hero-run); }
  .hero-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: var(--head);
    min-height: calc(100svh - var(--head));
    padding: clamp(18px, 3svh, 44px) var(--side) calc(var(--paper-lip) + 18px);
  }
  #portfolio:where(:not(.detail-lead)) {
    --cover-height: 85svh;
    position: relative;
    z-index: 1;
    margin-top: calc(-1 * (var(--hero-run) + var(--paper-lip)));
    padding-bottom: clamp(96px, 16svh, 190px);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    background: transparent;
  }
  /* The moving cover and the solid fill below it interpolate the same color. */
  #portfolio:not(.detail-lead)::after {
    content: ""; position: absolute; inset: var(--cover-height) 0 0; z-index: -1;
    background-color: var(--stage); pointer-events: none;
  }
  #portfolio::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    z-index: -1;
    height: calc(var(--cover-height) + 1px);
    border-radius: inherit;
    background: var(--stage);
    pointer-events: none;
  }
  #projects {
    position: relative;
    z-index: 2;
    margin-top: calc(-1 * clamp(58px, 10svh, 115px));
    border-radius: clamp(34px, 4vw, 78px) clamp(34px, 4vw, 78px) 0 0;
    background: var(--page);
  }
}
@keyframes profile-recede {
  from { transform: none; opacity: 1; }
  to { transform: translateY(-76px) scale(.88); opacity: .10; }
}
@keyframes name-part {
  from { transform: none; }
  to { transform: translateX(var(--part)); }
}
@keyframes open-cover {
  from { transform: scaleX(.84); }
  to { transform: scaleX(1); }
}
@keyframes title-handoff {
  0% { transform: translateY(100px) scale(.90); opacity: .10; }
  23%, 76% { transform: none; opacity: 1; }
  100% { transform: translate3d(0, -68px, 0) scale(.96); opacity: .18; }
}
@keyframes photograph-pass {
  from { transform: translateY(38px) scale(.965); opacity: .32; }
  32%, 76% { transform: none; opacity: 1; }
  to { transform: translateY(-40px) scale(.97); opacity: .7; }
}

/* These keyframes follow the same scroll position in either direction.
   The middle of every track is a reading interval at full contrast. */
@keyframes read-row {
  0% { opacity: .18; transform: translateY(var(--rise, 36px)); }
  23%, 80% { opacity: 1; transform: none; }
  100% { opacity: .40; transform: translateY(-24px); }
}
@keyframes artwork-reveal {
  0% { opacity: .18; }
  23%, 80% { opacity: 1; }
  100% { opacity: .40; }
}
@keyframes chapter-heading {
  0% { opacity: .14; transform: translateX(var(--heading-shift, .1em)); }
  23%, 73% { opacity: 1; transform: none; }
  98%, 100% { opacity: .08; transform: translateX(var(--heading-shift, .1em)); }
}
@keyframes chapter-paper {
  0% { transform: var(--paper-opening, translateY(34px) scaleX(.86)); }
  27%, 74% { transform: none; }
  100% { transform: translateY(-28px) scaleX(.94); }
}
@keyframes archive-paper {
  from { scale: .84 1; }
  to { scale: 1; }
}
@keyframes gallery-image {
  0% { opacity: .3; transform: translateY(38px) scale(.965); }
  27%, 76% { opacity: 1; transform: none; }
  100% { opacity: .48; transform: translateY(-36px) scale(.97); }
}
@keyframes gallery-copy {
  0%, 8% { opacity: .14; transform: translateY(43px); }
  34%, 86% { opacity: 1; transform: none; }
  100% { opacity: .52; transform: translateY(-18px); }
}
@keyframes gallery-caption {
  0% { opacity: .16; transform: translateY(38px); }
  21%, 83% { opacity: 1; transform: none; }
  100% { opacity: .35; transform: translateY(-20px); }
}
@keyframes closing-paper {
  0% { transform: translateY(38px) scaleX(.82); }
  40%, 100% { transform: none; }
}
@keyframes heading-enter {
  0% { opacity: .12; transform: translateX(var(--heading-shift, .1em)); }
  29%, 100% { opacity: 1; transform: none; }
}
@keyframes closing-link {
  0% { opacity: .2; transform: translateY(30px); }
  18%, 100% { opacity: 1; transform: none; }
}
@keyframes footer-enter {
  from { opacity: .35; transform: translateY(12px); }
  80%, to { opacity: 1; transform: none; }
}

:root { --flow-progress: .5; --flow-ease: cubic-bezier(.42,0,.3,1); }
:where([data-flow="item"], [data-flow="milestone"] > *, .chapter-heading-surface .title, .gallery-title,
  .gallery-case > .case-visual, .gallery-case > .case-heading, .gallery-case > .case-copy,
  .story-shot > a, .site-footer > *) {
  animation: var(--sequence, read-row) 1s var(--flow-ease) both var(--flow-play, paused);
  animation-timeline: var(--flow-clock, auto);
  animation-delay: calc(-1s * var(--flow-progress));
  animation-range: var(--flow-range, normal);
}
.card-title .title { display: inline-block; --sequence: chapter-heading; }
[data-heading-side="right"] { --heading-shift: -.1em; }
.gallery-case > .case-visual { --sequence: gallery-image; }
.gallery-case > .case-heading, .gallery-case > .case-copy { --sequence: gallery-copy; }
.gallery-title { --sequence: gallery-caption; }
.story-shot > a { --sequence: photograph-pass; }
.design-pieces > [data-flow="item"] { --sequence: artwork-reveal; }
.site-footer > * { --sequence: footer-enter; --flow-range: entry; }
#contact .title { --sequence: heading-enter; }
#contact .contact-item { --sequence: closing-link; }

@media (min-width: 900px) {
  .given-name { --part: clamp(-178px, -12vw, -72px); }
  .family-name { --part: clamp(72px, 12vw, 178px); }
  .profile-chapter, #contact.profile-chapter {
    --chapter-paper: var(--page);
    position: relative;
    isolation: isolate;
    width: 100%;
    max-width: none;
    padding-block: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .section.profile-chapter { border-top: 0; }
  :is(#education, #skills, #activities).profile-chapter { --chapter-paper: var(--band); }
  .profile-chapter > .chapter-heading-surface {
    border-radius: var(--chapter-radius);
    background: var(--chapter-paper);
    --sequence: chapter-paper;
  }
  #contact.profile-chapter {
    --chapter-paper: var(--contact-surface); --ink: #faf9fc; --body: #e1dee8;
    --muted: #c0bacb; --link: #d7caff;
    color: var(--ink);
    min-height: var(--chapter-stage);
  }
  #contact > .chapter-heading-surface { --sequence: closing-paper; }
  .detail-page #contact.detail-lead { background: var(--chapter-paper); }
  #contact .contact-item:first-child a { color: var(--ink); }
  #projects.section.gallery:where(:not(.detail-lead)) {
    --archive-lip: clamp(90px, 22svh, 224px);
    position: relative;
    isolation: isolate;
    background: transparent;
  }
  #projects:not(.detail-lead)::after {
    content: ""; position: absolute; inset: var(--archive-lip) 0 0; z-index: -1;
    background-color: var(--page); pointer-events: none;
  }
  .profile-chapter > .chapter-heading-surface, #projects > .chapter-heading-surface, .work-story .story-copy {
    animation: var(--sequence, title-handoff) 1s var(--flow-ease) both var(--flow-play, paused);
    animation-timeline: var(--flow-clock, auto);
    animation-delay: calc(-1s * var(--flow-progress));
    animation-range: var(--flow-range, normal);
  }
  #projects > .chapter-heading-surface {
    background: var(--page);
    border-radius: var(--chapter-radius) var(--chapter-radius) 0 0;
    /* The paper opens over Featured work on entry, then recedes with the other chapter headings. */
    --paper-opening: none;
    animation-name: chapter-paper, archive-paper;
    animation-delay: calc(-1s * var(--flow-progress)), calc(-1s * var(--archive-entry-progress, 0));
    animation-range: normal, entry;
  }
}
@media (max-width: 899px) {
  [data-flow="item"] { --rise: 27px; }
}
@supports (animation-timeline: view(block)) and (animation-timeline: scroll(root block)) and (animation-range: entry 0% cover 40%) {
  :root { --flow-play: running; --flow-clock: --portfolio-flow; --flow-progress: 0; }
  [data-flow] { view-timeline: --portfolio-flow block; view-timeline-inset: var(--head) 0px; }
  @media (min-width: 900px) {
    .signature :is(.given-name, .family-name) {
      animation: name-part 1s linear both;
      animation-timeline: scroll(root block);
      animation-range: 0px clamp(280px, 58svh, 625px);
    }
  }
  @media (min-width: 900px) and (min-height: 540px) {
    .hero-inner {
      animation: profile-recede 1s linear both;
      animation-timeline: scroll(root block);
      animation-range: 0px clamp(300px, 67svh, 745px);
    }
    #portfolio::before {
      animation: open-cover 1s linear both;
      animation-timeline: scroll(root block);
      animation-range: 0px clamp(240px, 54svh, 610px);
    }
  }
}
@media (min-width: 900px) {
  [data-timelines="fallback"] .signature :is(.given-name, .family-name) {
    transform: translateX(calc(var(--part) * var(--opening-progress, 0)));
  }
}
@media (min-width: 900px) and (min-height: 540px) {
  [data-timelines="fallback"] #portfolio::before { transform: scaleX(calc(.84 + .16 * var(--opening-progress, 0))); }
  [data-timelines="fallback"] .hero-inner {
    transform: translateY(calc(-76px * var(--opening-progress, 0))) scale(calc(1 - .12 * var(--opening-progress, 0)));
    opacity: calc(1 - .9 * var(--opening-progress, 0));
  }
}
main :is(.story-copy, .hero-inner, [data-flow="item"]):has(:focus-visible),
main .gallery-case:has(:focus-visible) > *, main :is(.story-shot a, [data-flow="item"], .site-footer a):focus-visible {
  animation: none; opacity: 1; transform: none;
}
@media screen and (min-width: 900px) and (min-height: 540px) {
  /* A longer introduction must scroll past before the featured panel can cover it. */
  #about .hero-inner:has(.hero-statement[data-cms-populated]) {
    position: relative; animation: none; transform: none; opacity: 1;
  }
}
