/* Preserve the 1440px composition as the display grows. This stylesheet is
   loaded after page styles; narrow layouts retain their own reading sizes. */
:root {
  --screen-unit: clamp(1px, .0694444444vw, 3px);
  --page-width: calc(1440 * var(--screen-unit));
}

/* On a panoramic display, height determines the useful reading canvas. */
@media (min-width: 1441px) and (min-aspect-ratio: 21/9) {
  :root { --screen-unit: clamp(1px, .1111111111svh, 3px); }
}

.page-width,
.biography,
.contact-layout,
.research-main,
.site-header .header-inner,
.social-footer .footer-content,
.archive-header,
.wheel-section,
.archive,
.sports-main {
  max-width: var(--page-width);
  margin-inline: auto;
}

.paper-detail-main { max-width: min(var(--page-width), calc(1600 * var(--screen-unit))); }
.home-introduction { max-width: var(--page-width); margin-inline: auto; }

@media (min-width: 1441px) {
  :root {
    --header-h: calc(64 * var(--screen-unit));
    --nav-gutter: calc(31.68 * var(--screen-unit));
    --nav-radius: calc(30 * var(--screen-unit));
    --gutter: calc(48.96 * var(--screen-unit));
    --page-top: calc(86.4 * var(--screen-unit));
    --page-bottom: calc(100.8 * var(--screen-unit));
    --section-gap: calc(72 * var(--screen-unit));
    --intro-gap: calc(80.64 * var(--screen-unit));
    --fs-display: calc(74.88 * var(--screen-unit));
    --fs-article: calc(40.32 * var(--screen-unit));
    --fs-title: calc(27.36 * var(--screen-unit));
    --fs-heading: calc(21.6 * var(--screen-unit));
    --fs-lede: calc(20.88 * var(--screen-unit));
    --fs-reading: calc(17 * var(--screen-unit));
    --fs-body: calc(16 * var(--screen-unit));
    --fs-small: calc(14 * var(--screen-unit));
    --fs-caption: calc(13 * var(--screen-unit));
    --fs-lab-caption: calc(15.12 * var(--screen-unit));
    --lab-gap: calc(20.16 * var(--screen-unit));
    --work-type-label: calc(16 * var(--screen-unit));
    --work-type-title: calc(24 * var(--screen-unit));
    --work-type-project: calc(13 * var(--screen-unit));
    --work-type-body: calc(15 * var(--screen-unit));
    --work-type-caption: calc(12 * var(--screen-unit));
    --header-height: calc(var(--header-h) + 68 * var(--screen-unit));
  }

  /* The home page uses a quieter gutter than the secondary pages. */
  body:has(.hero-plate) { --gutter: calc(31.68 * var(--screen-unit)); }
  .header-inner { gap: calc(16 * var(--screen-unit)); padding-inline: calc(14 * var(--screen-unit)); }
  .site-nav, .header-actions { gap: calc(8 * var(--screen-unit)); }
  .site-nav a, .language-toggle { font-size: calc(14 * var(--screen-unit)); padding: calc(7 * var(--screen-unit)) calc(15 * var(--screen-unit)); }
  .language-toggle { min-width: calc(46 * var(--screen-unit)); padding-inline: calc(11 * var(--screen-unit)); }
  .language-menu { width: calc(178 * var(--screen-unit)); padding: calc(6 * var(--screen-unit)); }
  .language-menu .language-option { font-size: calc(14 * var(--screen-unit)); min-height: calc(44 * var(--screen-unit)); padding: calc(10 * var(--screen-unit)) calc(12 * var(--screen-unit)); }

  .home-introduction { --intro-size: calc(36 * var(--screen-unit)); column-gap: calc(32 * var(--screen-unit)); padding-inline: calc(66.96 * var(--screen-unit)); padding-block: calc(93.6 * var(--screen-unit)); }
  .work { padding-block: calc(90 * var(--screen-unit)) calc(110 * var(--screen-unit)); }
  .home-introduction + .work { padding-top: 0; }
  .work-head { padding-bottom: calc(36 * var(--screen-unit)); }
  .work-head h2 { font-size: calc(129.6 * var(--screen-unit)); }
  .work-browser { grid-template-columns: minmax(0, .36fr) minmax(0, 1fr); gap: calc(23.04 * var(--screen-unit)); }
  .work-index { top: calc(var(--header-h) + 16 * var(--screen-unit)); max-height: calc(100dvh - var(--header-h) - 36 * var(--screen-unit)); }
  .work-browser:not(.is-overview) .work-preview { height: calc(100dvh - var(--header-h) - 36 * var(--screen-unit)); }
  .work-toolbar { gap: calc(20 * var(--screen-unit)); padding-bottom: calc(22 * var(--screen-unit)); }
  .work-sub { min-height: calc(28 * var(--screen-unit)); margin-bottom: calc(12 * var(--screen-unit)); }
  .work-count, .work-status, .project-category { font-size: calc(12 * var(--screen-unit)); }
  .search-box { min-height: calc(52 * var(--screen-unit)); }
  .search-box input, .search-category { font-size: calc(16 * var(--screen-unit)); }
  .search-categories { max-height: min(calc(560 * var(--screen-unit)), 60dvh); }
  .is-list .project-card-open { grid-template-columns: calc(64 * var(--screen-unit)) minmax(0, 1fr); gap: calc(16 * var(--screen-unit)); min-height: calc(90 * var(--screen-unit)); padding: calc(13 * var(--screen-unit)) calc(12 * var(--screen-unit)); }
  .is-list .project-image-wrap { width: calc(64 * var(--screen-unit)); height: calc(64 * var(--screen-unit)); }
  .is-list .project-info h3 { font-size: calc(16 * var(--screen-unit)); }
  .is-list .project-category { font-size: calc(12 * var(--screen-unit)); }
  .project-grid { gap: calc(40 * var(--screen-unit)) calc(22 * var(--screen-unit)); }
  .project-grid.is-list { gap: calc(6 * var(--screen-unit)); }
  .project-image-wrap { height: calc(446.4 * var(--screen-unit)); }
  .project-info h3 { font-size: calc(19 * var(--screen-unit)); }
  .view-button { width: calc(32 * var(--screen-unit)); height: calc(32 * var(--screen-unit)); }
  .view-button svg { width: calc(17 * var(--screen-unit)); height: calc(17 * var(--screen-unit)); }
  .preview-heading { margin-top: calc(20 * var(--screen-unit)); }
  .preview-heading h3 { font-size: calc(38.16 * var(--screen-unit)); }
  .preview-category, .preview-gallery-footer { font-size: calc(13 * var(--screen-unit)); }
  .preview-description { font-size: calc(14 * var(--screen-unit)); max-width: min(64ch, calc(100% - 64 * var(--screen-unit))); }
  .preview-stage { margin-top: calc(40 * var(--screen-unit)); }
  .preview-media { gap: calc(22 * var(--screen-unit)); }
  .preview-gallery-footer { padding-top: calc(25 * var(--screen-unit)); }

  .profile-about { padding-block: calc(100.8 * var(--screen-unit)); }
  .profile-rail { top: calc(var(--header-h) + 40 * var(--screen-unit)); }
  .profile-rail h2 { font-size: calc(97.92 * var(--screen-unit)); }
  .profile-body { max-width: calc(850 * var(--screen-unit)); font-size: calc(18 * var(--screen-unit)); }
  .profile-rail .resume-links { margin-top: calc(28 * var(--screen-unit)); gap: calc(12 * var(--screen-unit)); }
  .profile-rail .resume-link { font-size: calc(15 * var(--screen-unit)); padding: calc(14 * var(--screen-unit)) calc(19 * var(--screen-unit)); gap: calc(24 * var(--screen-unit)); }
  .profile-rail .file-format { font-size: calc(12 * var(--screen-unit)); }
  .profile-section-title { font-size: calc(28.8 * var(--screen-unit)); margin-bottom: calc(18 * var(--screen-unit)); }
  .profile-title { font-size: calc(43.2 * var(--screen-unit)); }
  .profile-chapter + .profile-chapter { margin-top: calc(52 * var(--screen-unit)); }
  .profile-experience { grid-template-columns: calc(155 * var(--screen-unit)) minmax(0, 1fr); gap: calc(22 * var(--screen-unit)); padding-block: calc(20 * var(--screen-unit)); }
  .profile-date { font-size: calc(13 * var(--screen-unit)); }
  .profile-role, .profile-subtitle, .profile-school, .profile-conversation { font-size: calc(20 * var(--screen-unit)); }
  .profile-brands { margin-top: calc(32 * var(--screen-unit)); }

  .about-intro, .bio-group { column-gap: calc(72 * var(--screen-unit)); }
  .bio-resume { margin-top: calc(40 * var(--screen-unit)); gap: calc(16 * var(--screen-unit)); }
  .bio-identity h2 { margin-bottom: calc(28 * var(--screen-unit)); }
  .bio-prose > p + p { margin-top: calc(22 * var(--screen-unit)); }
  .bio-experience { margin-top: calc(36 * var(--screen-unit)); }
  .bio-experience li { grid-template-columns: calc(160 * var(--screen-unit)) minmax(0, 1fr); gap: calc(12 * var(--screen-unit)) calc(32 * var(--screen-unit)); padding-block: calc(28 * var(--screen-unit)); }
  .bio-tools > div, .bio-honor-groups > div { padding-block: calc(26 * var(--screen-unit)); column-gap: calc(40 * var(--screen-unit)); }
  .bio-honor-list li { grid-template-columns: calc(92 * var(--screen-unit)) minmax(0, 1fr); column-gap: calc(24 * var(--screen-unit)); }

  .contact-details { --contact-row-space: calc(34.56 * var(--screen-unit)); }
  .direct-row, .contact-map-section { column-gap: calc(63.36 * var(--screen-unit)); }
  .direct-value { font-size: calc(25.92 * var(--screen-unit)); }
  .contact-map-section { padding-block: calc(51.84 * var(--screen-unit)) calc(57.6 * var(--screen-unit)); row-gap: calc(31.68 * var(--screen-unit)); }
  .map-view-switch button, .clock-date { font-size: calc(16 * var(--screen-unit)); }
  .map-view-switch { gap: calc(24 * var(--screen-unit)); }
  .contact-clocks { gap: calc(28.8 * var(--screen-unit)); padding-left: calc(83.52 * var(--screen-unit)); }
  .clock-line { font-size: calc(30.96 * var(--screen-unit)); }
  .clock-zone { margin-top: calc(12 * var(--screen-unit)); }
  .map-place-list { gap: 2px calc(25.92 * var(--screen-unit)); }
  .profile-list { column-gap: calc(34.56 * var(--screen-unit)); }
  .contact { padding-block: calc(100 * var(--screen-unit)) calc(80 * var(--screen-unit)); }
  .contact h2 { font-size: calc(77.76 * var(--screen-unit)); }
  .contact-note { font-size: calc(16 * var(--screen-unit)); }
  .contact-label { font-size: calc(13 * var(--screen-unit)); }
  .contact-value { font-size: calc(44.64 * var(--screen-unit)); }
  .contact-email .contact-value { font-size: calc(36 * var(--screen-unit)); }
  .contact-row { padding-block: calc(22 * var(--screen-unit)); }

  .theme-nav { height: calc(68 * var(--screen-unit)); gap: calc(43.2 * var(--screen-unit)); }
  .theme-button { height: calc(56 * var(--screen-unit)); }
  .wheel-section { height: calc(100svh - var(--header-height)); min-height: min(calc(590 * var(--screen-unit)), calc(100svh - var(--header-height))); max-height: calc(950 * var(--screen-unit)); padding-bottom: calc(62 * var(--screen-unit)); }
  .archive { --thumbnail-height: calc(187.2 * var(--screen-unit)); --thumbnail-gap: calc(14 * var(--screen-unit)); }
  .row-discipline, .row-title, .row-year, .row-medium { padding-right: calc(20 * var(--screen-unit)); }
  html:lang(zh) .archive-columns { font-size: calc(15 * var(--screen-unit)); }
  .project-viewer[open] { grid-template-rows: calc(64 * var(--screen-unit)) minmax(0, 1fr) calc(64 * var(--screen-unit)); }
  .viewer-scroll { padding: calc(48 * var(--screen-unit)) var(--gutter) calc(60 * var(--screen-unit)); }
  .viewer-heading { max-width: calc(850 * var(--screen-unit)); }
  .viewer-heading h2 { font-size: calc(31.68 * var(--screen-unit)); }
  .viewer-figure.is-portrait img, .viewer-figure.is-portrait video { max-height: calc(100dvh - 160 * var(--screen-unit)); }
  .viewer-figure > .media-crop { --crop-fit-height: calc(100dvh - 160 * var(--screen-unit)); }
  .viewer-media { gap: calc(50 * var(--screen-unit)); }

  .lab-main { padding-top: calc(88 * var(--screen-unit)); }
  .lab-intro { row-gap: calc(50 * var(--screen-unit)); padding-bottom: calc(128 * var(--screen-unit)); }
  .lab-intro h1 { font-size: calc(42 * var(--screen-unit)); line-height: 1.048; }
  .lab-intro p { font-size: calc(20 * var(--screen-unit)); line-height: 1.2; }
  html[lang="zh-CN"] .lab-intro p { line-height: 1.4; }
  .paper-columns { grid-template-columns: calc(238 * var(--screen-unit)) minmax(0, 1fr); column-gap: calc(66.24 * var(--screen-unit)); }
  .paper-search .search-box input { font-size: calc(16 * var(--screen-unit)); }
  .paper-entry { grid-template-columns: minmax(0, 1fr) calc(142 * var(--screen-unit)); gap: calc(43.2 * var(--screen-unit)); padding-block: calc(48.96 * var(--screen-unit)); }
  .paper-layout { grid-template-columns: calc(320 * var(--screen-unit)) minmax(0, 1fr); gap: calc(72 * var(--screen-unit)); }
  .paper-rail-dl div { grid-template-columns: calc(88 * var(--screen-unit)) minmax(0, 1fr); }
  /* SVG coordinates already scale with the figure; keep their internal type
     in viewBox units so chart labels do not grow a second time. */
  .chart-label, .chart-tick, .chart-value, .chart-axis-label { font-size: 13px; }

  html.sports-root {
    --header-h: calc(64 * var(--screen-unit));
    --sports-gutter: calc(28.8 * var(--screen-unit));
    --sports-body-size: calc(24.48 * var(--screen-unit));
    --sports-label-size: calc(17.28 * var(--screen-unit));
    --sports-side-label: calc(15.84 * var(--screen-unit));
  }
  .sports-records-column, .sports-sidebar { padding-block: calc(51.84 * var(--screen-unit)) calc(28.8 * var(--screen-unit)); }

  .social-footer .footer-meta { font-size: calc(12 * var(--screen-unit)); }
  .social-footer .footer-content { padding-block: calc(18 * var(--screen-unit)) calc(26 * var(--screen-unit)); }
  .social-footer .footer-social { column-gap: calc(34.56 * var(--screen-unit)); }
  .social-logo { width: calc(26 * var(--screen-unit)); height: calc(26 * var(--screen-unit)); }
  .social-logo--xiaohongshu { width: calc(44 * var(--screen-unit)); }
}

@media (max-width: 560px) {
  .work-head h2, html:not([lang='zh-CN']) .work-head h2 { font-size: clamp(40px, 11vw, 60px); }
}

/* Short viewports must offer scrolling instead of pushing controls offscreen. */
@media (min-width: 701px) and (max-height: 700px) {
  .wheel-section { height: calc(100svh - var(--header-height)); min-height: 280px; padding-bottom: 48px; }
  .works-wheel { min-height: 0; }
}

@media (max-height: 500px) {
  .hero-plate { min-height: 100svh; }
  .hero-work { top: calc(50% + var(--header-h) / 2); height: calc(100% - var(--header-h) - 32px); }
}
