:root {
  color-scheme: light;
  --paper: #f7f5f0;
  --ink: #21211e;
  --muted: #615e56;
  --oxide: #842d25;
  --rule: #cdc8bc;
  --serif: "Baskervville", "Baskerville", "Palatino Linotype", "Times New Roman", "Songti SC", "Noto Serif CJK SC", "SimSun", serif;
  --sans: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", "Consolas", "SFMono-Regular", monospace;
  --sheet-width: 80rem;
  --page-gutter: clamp(1.25rem, 5.55vw, 5rem);
  --mast-inset: env(safe-area-inset-top, 0px);
  --column-gap: clamp(1rem, 2.1vw, 2rem);
  --space-caption: .5rem;
  --space-flow: clamp(1rem, 1.7vw, 1.5rem);
  --space-group: clamp(2rem, 3.35vw, 3rem);
  --reading-width: 64ch;
  --mast-height: 4.5rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-synthesis: weight;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
:root[lang="zh-CN"] { --reading-width: 34em; }
* { box-sizing: border-box; }
body, h1, h2, h3, h4, p, figure { margin: 0; }
body {
  min-width: 0;
  padding-block: var(--mast-inset) env(safe-area-inset-bottom, 0px);
}
h1, h2, h3, h4 { font-weight: 500; }
button, input, summary, a { color: inherit; }
button, input { font: inherit; }
button, summary { cursor: pointer; }
a { text-decoration: none; }
button { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:root[lang="zh-CN"] [data-copy="en"],
:root[lang="en"] [data-copy="zh"] { display: none !important; }
:focus-visible { outline: 2px solid var(--oxide); outline-offset: 4px; }
/* A deep link focuses its section. Mark the heading so the cue is visible
   even when the section extends beyond the viewport. */
:is(section, article, footer)[tabindex="-1"]:focus-visible { outline: none; }
:is(section, article, footer)[tabindex="-1"]:focus-visible > :is(h1, h2, h3),
:is(section, article)[tabindex="-1"]:focus-visible > :is(header, .research-intro, .background-opening, .archive-entry-content, .project-copy, .software-story) > :is(h1, h2, h3),
.hardware-case:focus-visible .hardware-copy h2 {
  text-decoration-line: underline;
  text-decoration-color: var(--oxide);
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}
::selection { color: var(--ink); background: #e6cec3; }

.sheet {
  --page-inset: max(var(--page-gutter), env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  width: min(var(--sheet-width), calc(100% - var(--page-inset) * 2));
  margin-inline: auto;
}
:root.home-page {
  --sheet-width: clamp(80rem, calc(80rem + (100vw - 90rem) * .4), 86rem);
  --chapter-height: max(0px, calc(100dvh - var(--mast-inset) - var(--mast-height)));
  --chapter-padding: clamp(1.5rem, min(4vw, 6svh), 5rem);
  scroll-padding-block-start: calc(var(--mast-inset) + var(--mast-height));
}

/* Short chapters fill the viewport. Longer chapters grow with their content. */
.home-page main > section,
.home-page .contact {
  min-block-size: var(--chapter-height);
  scroll-snap-align: start;
}
.home-page main > section:not(.profile-cover),
.home-page .contact {
  align-content: center;
  padding-block: var(--chapter-padding);
}
.home-page .software {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.link-group {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-caption) var(--space-flow);
}
.text-link {
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: #938a7c;
  text-underline-offset: .22em;
}
.text-link:hover, .text-link:focus-visible { color: var(--oxide); text-decoration-color: currentColor; }
.outward::after {
  content: "";
  display: inline-block;
  width: .65em;
  height: .65em;
  margin-inline-start: .25em;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4'%3E%3Cpath d='M2 14 13 3M4 3h9v9'/%3E%3C/svg%3E") center / contain no-repeat;
}

@media (max-width: 760px) {
  :root {
    --page-gutter: clamp(1.25rem, 5.5vw, 1.5rem);
    --space-flow: clamp(.75rem, 3.3vw, 1rem);
    --space-group: clamp(1.5rem, 5vw, 2rem);
  }
}
@media (max-width: 300px) {
  :root { --page-gutter: 1rem; }
}
@media (prefers-reduced-motion: no-preference) and (pointer: coarse) {
  .home-page { scroll-snap-type: y proximity; }
}
@media (prefers-reduced-motion: reduce) {
  :root { scroll-behavior: auto; }
}
