/* Personal site of Zhenzhao Tu.
   One column, system monospace, no chrome. */

:root {
  color-scheme: light dark;
  --bg: #fbfbf8;
  --fg: #171717;
  --muted: #5c5c57;
  --rule: #dcdad3;
  --link: #0b4fbf;
  --visited: #6b2d8b;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --fg: #ece8e1;
    --muted: #a49e94;
    --rule: #3c3934;
    --link: #8cb4ff;
    --visited: #d4a3f5;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: 48rem;
  padding: 2.5rem 1.5rem 4rem;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.9375rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

@media (max-width: 40rem) {
  body {
    padding: 1.5rem 1.15rem 3rem;
    font-size: 1.0625rem;
  }
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 1;
}

h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.25;
}

h1 {
  margin: 0 0 0.2em;
  font-size: 2rem;
}

h2 {
  margin: 2em 0 0.5em;
  font-size: 1.125rem;
}

h3 {
  margin: 1.6em 0 0.4em;
  font-size: 1.05rem;
}

@media (max-width: 40rem) {
  h1 {
    font-size: 1.85rem;
  }
}

p,
ul,
ol {
  margin: 0 0 1em;
}

.affiliation,
.date,
.meta {
  color: var(--muted);
}

.affiliation {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: normal;
  margin: 0.15em 0 1.75em;
}

.affiliation a {
  color: inherit;
}

.status-wrap {
  position: relative;
  display: inline-block;
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.9rem;
  cursor: pointer;
  outline-offset: 3px;
}

.status-trigger:hover,
.status-trigger:focus-visible {
  color: var(--fg);
}

.status-cursor {
  display: inline-block;
  color: var(--fg);
  animation: status-cursor-blink 1s steps(1, end) infinite;
}

@keyframes status-cursor-blink {
  50% {
    opacity: 0;
  }
}

.status-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 30;
  width: clamp(17.5rem, 85vw, 22rem);
  padding: 0.7rem 0.85rem;
  background: var(--bg);
  border-left: 2px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--fg);
  opacity: 0;
  transform: translateY(4px) scale(0.99);
  transition: opacity 160ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}

.status-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.status-cmd {
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.status-active-label {
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.status-meta {
  color: var(--muted);
  font-size: 0.8em;
  margin-bottom: 0.5rem;
}

.status-body {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
}

.status-body p {
  margin: 0 0 0.5rem;
}

.status-contact {
  margin-top: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
  .status-cursor {
    animation: none;
  }
  .status-panel {
    transition: none !important;
  }
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:visited {
  color: var(--visited);
}

a:hover {
  text-decoration-thickness: 2px;
}

a:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

/* --- homepage introduction --- */

.flow-region,
.intro {
  position: relative;
  margin: 0 0 2.4rem;
}

.flow-source p,
.intro-source p {
  margin: 0 0 1em;
}

.flow-source p:last-child,
.intro-source p:last-child {
  margin-bottom: 0;
}

#portrait-wrap {
  display: block;
  width: 10.75rem;
  border: 0;
  background: none;
  user-select: none;
  position: relative;
  padding-bottom: 0.5rem;
}

#portrait-wrap img,
.portrait-image img {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  background: none;
  box-shadow: none;
  pointer-events: none;
  -webkit-user-drag: none;
}

.portrait-status {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  margin-top: 6px;
  padding: 0 0 0 0.35rem;
  width: 100%;
  border: 0;
  background: none;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.2;
  color: var(--muted);
  cursor: pointer;
  outline-offset: 3px;
  user-select: none;
  white-space: nowrap;
}

.portrait-status:hover,
.portrait-status:focus-visible {
  color: var(--fg);
}

.status-prefix {
  color: var(--muted);
}

.status-short {
  color: var(--muted);
}

.status-pulse {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.portrait-status[data-activity="active"] .status-pulse {
  animation: pulse-active 2.4s ease-in-out infinite;
}

@keyframes pulse-active {
  0%, 100% {
    transform: scale(0.72);
    opacity: 0.45;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

.portrait-status[data-activity="quiet"] .status-pulse {
  animation: pulse-quiet 4.2s ease-in-out infinite;
}

@keyframes pulse-quiet {
  0%, 100% {
    transform: scale(0.78);
    opacity: 0.30;
  }
  50% {
    transform: scale(0.95);
    opacity: 0.62;
  }
}

.status-panel {
  position: absolute;
  z-index: 50;
  width: min(88vw, 24rem);
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border-left: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--fg);
  opacity: 0;
  transform: translateY(5px) scale(0.985);
  transition: opacity 170ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 170ms cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
  box-shadow: none;
}

.status-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.status-short-header {
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.status-meta {
  color: var(--muted);
  font-size: 0.8em;
  margin-bottom: 0.45rem;
}

.status-message {
  margin-bottom: 0.45rem;
}

.status-contact {
  margin: 0.45rem 0 0;
}

@media (prefers-reduced-motion: reduce) {
  .status-pulse {
    animation: none !important;
  }
  .status-panel {
    transition: none !important;
    transform: none !important;
  }
}

.intro:not(.is-enhanced) #portrait-wrap {
  float: right;
  shape-outside: url("/assets/images/me.webp");
  shape-margin: 0.7rem;
  margin: 0.15rem 0 0.9rem 1rem;
}

@media (max-width: 40rem) {
  #portrait-wrap {
    width: 8.75rem;
  }

  .intro:not(.is-enhanced) #portrait-wrap {
    shape-margin: 0.45rem;
    margin: 0.1rem 0 0.7rem 0.7rem;
  }
}

.flow-region.is-enhanced .flow-source,
.intro.is-enhanced .flow-source {
  display: none;
}

.flow-region.is-enhanced .flow-image,
.intro.is-enhanced #portrait-wrap {
  position: absolute;
  z-index: 2;
  margin: 0;
  float: none;
  cursor: grab;
  touch-action: none;
}

.flow-region.is-enhanced .flow-image.is-dragging,
.intro.is-enhanced #portrait-wrap.is-dragging {
  cursor: grabbing;
}

.flow-region.is-dragging,
.intro.is-dragging {
  user-select: none;
}

.flow-layer,
.intro-flow {
  position: relative;
  z-index: 1;
}

.flow-image img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.flow-line {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  user-select: text;
}

.flow-line a {
  color: var(--link);
}

.flow-line a:visited {
  color: var(--visited);
}

/* --- lower page --- */

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem 3rem;
  margin: 0 0 2.4rem;
}

.columns section h2,
.now h2,
.keep h2 {
  margin-top: 0;
}

.columns ul {
  margin: 0;
}

@media (max-width: 40rem) {
  .columns {
    grid-template-columns: 1fr;
    gap: 1.8rem;
  }
}

.now,
.keep {
  margin: 0 0 2.1rem;
}

.masthead {
  margin: 0 0 2rem;
  font-size: 1rem;
}

ul.loose {
  list-style: none;
  padding: 0;
}

ul.loose li {
  margin: 0.4em 0;
}

ul.papers {
  padding-left: 1.2em;
}

ul.papers li {
  margin: 0.7em 0;
}

.back {
  margin: 0 0 1.4em;
}

figure {
  margin: 1.6rem 0;
}

figure img {
  display: block;
  width: 100%;
  height: auto;
}

figcaption {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}

figure.photo {
  margin: 2rem 0;
}

figure.photo img {
  width: 100%;
  border: 0;
  box-shadow: none;
}

figure.photo figcaption {
  text-align: center;
}

.archive-year {
  margin: 1.6em 0 0.4em;
  font-size: 1.125rem;
  font-weight: 600;
}

.more {
  margin-top: 0.8em;
}

.eq {
  overflow-x: auto;
  max-width: 100%;
  margin: 1.1em 0;
  padding: 0.2em 0;
}

math {
  font-size: 1.05em;
}

dl dt {
  margin-top: 0.9em;
}

dl dd {
  margin: 0.15em 0 0 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.2em 0;
}

footer {
  margin-top: 3rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}

footer p {
  margin: 0.25em 0;
}

@media print {
  :root {
    --bg: #fff;
    --fg: #000;
    --muted: #333;
    --rule: #ccc;
    --link: #000;
    --visited: #000;
  }

  body {
    max-width: none;
    padding: 0;
    font-size: 11pt;
    line-height: 1.45;
  }

  .skip,
  #portrait-wrap,
  .flow-image,
  .flow-layer,
  .intro-flow {
    display: none !important;
  }

  .intro.is-enhanced .flow-source,
  .flow-region.is-enhanced .flow-source {
    display: block !important;
  }

  .intro,
  .flow-region {
    height: auto !important;
  }

  a:focus {
    outline: none;
  }

  a[href^="http"]::after,
  a[href^="mailto:"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #333;
  }

  footer {
    border-top-color: #000;
  }

  .columns {
    display: block;
  }
}
