:root {
  color-scheme: light;
  --background: #fff;
  --surface: #f3f3f3;
  --panel: #fff;
  --text: #242424;
  --muted: #595959;
  --accent: #383838;
  --line: #d8d8d8;
  --page: min(1280px, 100% - clamp(36px, 9vw, 144px));
  --typeface: "Times New Roman", Times, "Songti SC", SimSun, serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: var(--nav-offset, 88px); }
body { margin: 0; background: var(--background); color: var(--text); font: 1rem/1.5 var(--typeface); }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
h1, h2, h3, p { margin: 0; }
.wrap { width: var(--page); margin-inline: auto; }
.skip { position: fixed; left: 1rem; top: 1rem; z-index: 3; padding: .75rem 1rem; background: var(--accent); color: white; transform: translateY(-200%); }
.skip:focus { transform: none; }
.site-header { position: sticky; top: 0; z-index: 2; background: var(--background); border-bottom: 1px solid var(--line); }
.site-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; min-height: 74px; }
.brand { justify-self: start; white-space: nowrap; font-weight: 700; }
.nav-links { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: clamp(14px, 2.4vw, 34px); row-gap: 8px; font-size: .875rem; }
.site-controls { display: flex; align-items: center; gap: 14px; justify-self: end; }
.language-switch { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--muted); font-size: .875rem; }
.language-switch a { padding-block: 8px; }
.language-switch a[aria-current] { color: var(--text); font-weight: 700; }
.language-switch a:hover { text-decoration: underline; text-underline-offset: 4px; }
.theme-switch { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 30px; }
.theme-switch button { display: grid; place-items: center; padding: 0; width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font: 1.3rem/1 Arial, sans-serif; cursor: pointer; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); }
.theme-switch button:hover { color: var(--text); }
.nav-links a, .footer-links a { transition: color .2s ease; }
.nav-links a:hover, .footer-links a:hover { text-decoration: underline; text-underline-offset: 4px; }
.eyebrow { color: var(--accent); font: .875rem/1.4 var(--typeface); letter-spacing: .1em; text-transform: uppercase; }
.hero { padding-block: clamp(55px, 7vw, 98px) clamp(48px, 6vw, 84px); }
.hero > .wrap { display: flex; flex-direction: column; min-block-size: clamp(17rem, calc(6.2rem + 21vw), 25.65rem); }
.hero h1 { width: fit-content; max-width: 100%; font-size: clamp(1.75rem, 5.9vw, 5.25rem); line-height: 1; letter-spacing: -.055em; margin-block: 18px clamp(32px, 3vw, 44px); }
.hero h1:lang(zh-CN) { letter-spacing: .1em; }
.hero-word { display: inline-block; white-space: nowrap; }
.hero-word > span { display: inline-block; }
.intro { color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.23rem); max-width: 46ch; }
.hero-outro { margin-top: auto; text-align: right; font-family: DengXian, "等线", "Segoe UI", sans-serif; font-weight: 500; }
.hero-quote { max-width: none; font-size: clamp(1.23rem, 1.85vw, 1.65rem); text-wrap: balance; }
.hero-reply { max-width: none; margin-top: .3em; color: var(--text); font-size: clamp(1.48rem, 2.25vw, 2.06rem); }
@media (min-width: 700px) {
  .hero-quote { white-space: nowrap; }
}
.button { display: inline-flex; align-items: center; justify-content: center; padding: 12px 19px; min-height: 46px; border: 1px solid var(--line); background: var(--panel); font: .95rem var(--typeface); transition: color .2s ease, background .2s ease, border-color .2s ease; }
.button:hover { background: var(--accent); border-color: var(--accent); color: white; }
.button-primary { background: var(--text); border-color: var(--text); color: white; }
.button-primary:hover { background: var(--muted); border-color: var(--muted); }
.work, .details { border-top: 1px solid var(--line); padding-block: clamp(40px, 5vw, 74px) clamp(62px, 8vw, 110px); }
.section-head, .detail-heading, .site-footer { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 10px 24px; }
.section-head { margin-bottom: clamp(24px, 3.4vw, 48px); }
.section-head h2, .about h2 { font-size: clamp(1.75rem, 4vw, 3.9rem); line-height: 1; letter-spacing: -.045em; }
.meta { color: var(--muted); font: .9rem/1.5 var(--typeface); }
.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(26px, 4vw, 54px) clamp(18px, 3vw, 44px); }
.project-card { display: block; height: 100%; }
.card-image { display: grid; place-items: center; aspect-ratio: 2 / 1; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.card-image img { width: 100%; height: 100%; object-fit: contain; transition: transform .32s ease; }
.project-card:hover .card-image img { transform: scale(1.025); }
.card-caption { display: grid; align-items: baseline; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.card-caption h3 { font-size: clamp(1.2rem, 2.4vw, 1.9rem); line-height: 1.12; letter-spacing: -.035em; }
.project-card:hover h3 { text-decoration: underline; text-underline-offset: 4px; }
.card-caption .meta { grid-column: 1; }
.card-caption time { white-space: nowrap; }
.card-open { grid-row: 1; grid-column: 2; color: var(--accent); font: .9rem var(--typeface); }
.about { border-top: 1px solid var(--line); padding-block: clamp(44px, 7vw, 92px); }
.about-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.about-portrait { width: clamp(80px, 11vw, 150px); height: auto; border: 1px solid var(--line); border-radius: 4px; }
.about h3 { margin: 0 0 16px; color: var(--text); font-size: clamp(1.3rem, 2.4vw, 1.85rem); line-height: 1.15; letter-spacing: -.035em; }
.about h4 { margin: 0; font-size: 1rem; line-height: 1.4; }
.about-sections {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  grid-template-areas: "work education" "work skills";
  grid-template-rows: auto 1fr;
  align-items: start;
  column-gap: clamp(24px, 5vw, 72px);
  row-gap: clamp(26px, 4vw, 42px);
  margin-top: clamp(24px, 4vw, 48px);
}
.about-panel { border-top: 1px solid var(--line); padding-top: 18px; }
.about-education { grid-area: education; }
.about-work { grid-area: work; }
.about-skills { grid-area: skills; }
.about-education p, .experience p { margin-top: 4px; }
.experience p:not(.meta), .skill-list dd { color: var(--muted); }
.experience p:not(.meta) { margin-top: 8px; max-width: 66ch; }
.experience + .experience { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.skill-list { display: grid; gap: 12px; margin: 0; }
.skill-list dt { font-weight: 700; }
.skill-list dd { margin: 2px 0 0; }
footer { border-top: 1px solid var(--line); }
.site-footer { align-items: center; padding-block: 26px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 12px 26px; }
.project-hero { padding-block: clamp(26px, 4vw, 56px) 24px; }
.project-hero h1 { font-size: clamp(2.6rem, 6.6vw, 6.4rem); line-height: 1; letter-spacing: -.045em; overflow-wrap: anywhere; }
.project-title-row { display: flex; align-items: center; gap: clamp(10px, 2vw, 28px); margin-top: 12px; }
.project-title-row h1 { min-width: 0; }
.project-arrow { display: grid; place-items: center; flex: 0 0 auto; width: clamp(34px, 4vw, 56px); height: 52px; font-size: clamp(1.75rem, 3.6vw, 3rem); line-height: 1; color: var(--muted); }
.project-arrow:hover { color: var(--accent); }
.documentation-title { margin-block: 12px 18px; }
.breadcrumb a { text-decoration: underline; text-underline-offset: 3px; }
.store-overview { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 3fr); align-items: start; gap: clamp(16px, 2.6vw, 36px); padding-bottom: clamp(40px, 5vw, 70px); }
.store-gallery, .store-summary { min-width: 0; }
.media-stage { display: grid; aspect-ratio: 16 / 9; background: #242320; color: white; }
.media-preview { position: relative; display: grid; place-items: center; }
.media-preview img { position: absolute; width: 100%; height: 100%; object-fit: contain; }
.media-preview:has(.play-control) img { opacity: .74; }
.play-control { z-index: 1; display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: #242320e8; color: white; border: 1px solid #ffffff85; font-size: 1.4rem; }
.media-preview:hover .play-control { background: white; color: var(--text); }
.media-stage iframe { display: block; width: 100%; height: 100%; border: 0; }
.media-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(100px, 1fr); gap: 7px; overflow: auto hidden; padding: 7px 0 2px; }
.media-thumb { position: relative; display: grid; place-items: center; min-height: 54px; aspect-ratio: 2 / 1; background: #242320; color: white; outline-offset: -3px; border: 2px solid transparent; }
.media-thumb img { width: 100%; height: 100%; object-fit: contain; }
.media-thumb[aria-current] { border-color: #777063; }
.media-thumb:hover { border-color: #a49c8e; }
.media-thumb .thumbnail-play { position: absolute; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #242320e8; color: white; font-size: .8rem; }
.media-caption { display: flex; justify-content: end; padding-block: 8px 4px; }
.media-caption a[hidden] { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.media-caption a { text-decoration: underline; text-underline-offset: 3px; }
.media-position { padding: 7px 2px 4px; text-align: center; }
.store-summary { background: var(--panel); border: 1px solid var(--line); }
.store-cover { width: 100%; height: auto; }
.store-info { padding: clamp(16px, 2vw, 24px); }
.store-info > p { color: var(--muted); }
.store-facts { margin-block: 18px; border-bottom: 1px solid var(--line); }
.store-facts > div { display: grid; grid-template-columns: minmax(4rem, 26%) minmax(0, 1fr); gap: 10px; padding-block: 8px; border-top: 1px solid var(--line); }
.store-facts dt { color: var(--muted); }
.store-facts dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.store-contents { margin: 0; padding-inline-start: 1.15em; }
.store-contents li + li { margin-top: 3px; }
.store-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; list-style: none; }
.store-tags li { padding: 1px 6px; border: 1px solid var(--line); background: var(--surface); }
.store-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-heading { margin-bottom: 20px; }
.detail-heading h2 { font-size: clamp(1.6rem, 3vw, 2.7rem); line-height: 1.1; letter-spacing: -.04em; }
.pdf-page { margin: 0; }
.page-stack { display: grid; gap: 16px; }
.pdf-page img { width: 100%; height: auto; border: 1px solid var(--line); }
.pdf-page a { display: block; }
.project-essay { max-width: 880px; margin-inline: auto; font-size: clamp(1.03rem, 1.3vw, 1.18rem); line-height: 1.75; }
article.project-essay h2 { margin: 1.7em 0 .5em; font-size: clamp(1.45rem, 2.5vw, 2rem); line-height: 1.15; }
article.project-essay h3 { margin: 1.25em 0 .35em; font-size: clamp(1.125rem, 1.65vw, 1.4rem); line-height: 1.3; }
article.project-essay > :is(h2, h3):first-child { margin-top: 0; }
.project-essay p + p { margin-top: .75em; }
.project-essay ul, .project-essay ol { padding-left: 1.45em; }
.project-essay li + li { margin-top: .4em; }
.essay-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); align-items: start; gap: 14px; margin: 1.2em 0 1.5em; }
.essay-figures figure { margin: 0; }
.essay-figures img { width: 100%; height: auto; background: var(--panel); border: 1px solid var(--line); }
.essay-figures figcaption { margin-top: .45em; }
.project-nav { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px 24px; border-top: 1px solid var(--line); padding-block: 24px 42px; }
@media (max-width: 810px) {
  .store-overview { grid-template-columns: 1fr; }
  .store-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
  .store-cover { align-self: start; }
}
@media (min-width: 671px) and (max-width: 950px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  html { scroll-padding-top: var(--nav-offset, 140px); }
  .site-nav { grid-template-columns: 1fr auto; min-height: auto; padding-block: 12px; }
  .nav-links { grid-row: 2; grid-column: 1 / -1; column-gap: clamp(8px, 2vw, 22px); }
}
@media (max-width: 670px) {
  .site-controls { gap: 9px; }
  .theme-switch button { width: 30px; height: 30px; }
  .project-grid, .store-summary { grid-template-columns: 1fr; }
  .about-sections { grid-template-columns: 1fr; grid-template-areas: "education" "work" "skills"; grid-template-rows: auto; }
  .store-cover { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .portfolio-home {
    --letter-duration: 560ms;
    --letter-step: 76ms;
    --center-hold: 340ms;
    --title-settle-start: calc(var(--letter-duration) + var(--last-letter) * var(--letter-step) + var(--center-hold));
    --title-settle-duration: 800ms;
    --content-start: calc(var(--title-settle-start) + var(--title-settle-duration) + 80ms);
  }

  .opening-pending .portfolio-home :is(.hero h1, .site-header, .hero-intro, .hero-outro, main > :not(.hero), footer) {
    opacity: 0;
  }

  .opening-active .hero h1 {
    animation: hero-title-settle var(--title-settle-duration) cubic-bezier(.68, 0, .3, 1) var(--title-settle-start) both;
  }

  .opening-active .hero-word > span {
    animation: hero-letter-in var(--letter-duration) cubic-bezier(.35, .72, .24, 1) calc(var(--letter) * var(--letter-step)) both;
  }

  .opening-active .portfolio-home :is(.site-header, .hero-intro, .hero-outro, main > :not(.hero), footer) {
    animation: hero-content-in .8s ease-out calc(var(--content-start) + var(--content-delay, 0ms)) both;
  }

  .portfolio-home .hero-outro { --content-delay: 100ms; }
  .portfolio-home main > :not(.hero), .portfolio-home footer { --content-delay: 220ms; }

  @supports (animation-timeline: view()) {
    [data-scroll-text] {
      animation: scroll-text-in linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 30%;
    }
  }

  .scroll-text-fallback [data-scroll-text] {
    opacity: var(--scroll-opacity, 1);
    transform: translateY(var(--scroll-shift, 0px));
  }

  .project-card:focus-visible [data-scroll-text] {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

@keyframes hero-letter-in {
  from { opacity: 0; transform: translateY(var(--letter-rise)); filter: blur(5px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

@keyframes hero-title-settle {
  from { transform: translateY(var(--title-hold-y)); }
  to { transform: translateY(0); }
}

@keyframes hero-content-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scroll-text-in {
  from { opacity: .42; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
