/* Ziwei Che — personal site
   Concept: the catalogue entry. A museum catalogue and a court record are the
   same object: dated, annotated, and set against a wide ruled margin. One
   hairline runs the length of the page and inks in as the record is read. */

:root {
  --ground: #e7e8e3;
  --panel: #f3f4f0;
  --ink: #1b2420;
  --muted: #4e5852;
  --rule: #c9cbc3;
  --red: #9e2b1e;

  --display: "Bodoni Moda", "Didot", "Bodoni MT", Georgia, serif;
  --text: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --pad: 34px;
  --gutter: 150px;
  --gap: 40px;
  --maxw: 1000px;
  --navh: 58px;
}

@media (max-width: 860px) {
  :root { --pad: 20px; --gutter: 0px; --gap: 26px; }
}

* { box-sizing: border-box; }

html {
  color-scheme: light;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--text);
  font-size: 16.5px;
  line-height: 1.6;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--pad);
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

/* ─────────── masthead ─────────── */

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--navh);
  background: var(--ground);
  background: color-mix(in srgb, var(--ground) 90%, transparent);
  backdrop-filter: blur(8px) saturate(140%);
  border-bottom: 1px solid var(--rule);
}
.masthead .shell {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.masthead-name {
  font-family: var(--display);
  font-size: 1.02rem;
  font-weight: 500;
  letter-spacing: .015em;
}
.masthead-nav { display: flex; gap: 26px; }
.masthead-nav a {
  font-size: .875rem;
  color: var(--muted);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}
.masthead-nav a:hover { color: var(--ink); border-bottom-color: var(--red); }
.masthead-nav a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--red); }
@media (max-width: 700px) { .masthead-nav { display: none; } }

/* ─────────── hero ─────────── */

.hero { padding-block: 96px 64px; }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  gap: 56px;
  align-items: end;
}

h1 {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: clamp(3.6rem, 11vw, 7.2rem);
  line-height: .88;
  letter-spacing: -.025em;
  margin: 0 0 20px;
  text-wrap: balance;
}

.credential {
  font-size: .95rem;
  color: var(--muted);
  margin: 0 0 26px;
  max-width: 30em;
}

.hero-rule {
  border: 0;
  border-top: 1px solid var(--ink);
  margin: 0 0 24px;
}

.standfirst {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.24rem, 2.6vw, 1.6rem);
  line-height: 1.42;
  margin: 0 0 34px;
  max-width: 21em;
}

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 26px; }

.action {
  display: inline-block;
  padding: 12px 22px;
  background: var(--ink);
  color: var(--ground);
  font-size: .9rem;
  font-weight: 500;
  letter-spacing: .01em;
  text-decoration: none;
  transition: background .18s ease;
}
.action:hover { background: var(--red); }

.link {
  font-size: .92rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2px;
  transition: color .18s ease, border-color .18s ease;
}
.link:hover { color: var(--ink); border-bottom-color: var(--red); }

/* the portrait as a catalogue plate */
.plate {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border: 1px solid var(--ink);
  outline: 1px solid var(--rule);
  outline-offset: 11px;
  will-change: transform;
}

@media (max-width: 860px) {
  .hero { padding-block: 52px 44px; }
  .hero-grid { grid-template-columns: 1fr; gap: 38px; align-items: start; }
  .plate { max-width: 216px; order: -1; outline-offset: 8px; }
}

/* ─────────── the ruled margin ─────────── */

.record {
  position: relative;
  border-top: 1px solid var(--rule);
}
/* the margin rule, and the ink that fills it while reading */
.record::before,
.record::after {
  content: "";
  position: absolute;
  top: 0;
  left: calc(var(--pad) + var(--gutter));
  width: 1px;
}
.record::before { bottom: 0; background: var(--rule); }
.record::after { height: var(--fill, 0px); background: var(--red); }

@media (min-width: 1001px) {
  /* once the shell stops growing, the rule tracks the centred column */
  .record::before,
  .record::after { left: calc(50% - (var(--maxw) / 2) + var(--pad) + var(--gutter)); }
}

section {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  column-gap: var(--gap);
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 64px var(--pad);
  border-top: 1px solid var(--rule);
}
section:first-of-type { border-top: 0; }

.sec-title {
  grid-column: 1;
  grid-row: 1 / -1;
  position: sticky;
  top: calc(var(--navh) + 30px);
  align-self: start;
  text-align: right;
  padding-right: 22px;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.32rem;
  line-height: 1.1;
  margin: 0;
}
.sec-body { grid-column: 2; max-width: 39em; }

@media (max-width: 860px) {
  section { grid-template-columns: 1fr; padding: 46px var(--pad) 46px calc(var(--pad) + var(--gap)); }
  .sec-title {
    grid-column: 1;
    grid-row: auto;
    position: static;
    text-align: left;
    margin-bottom: 22px;
  }
  .sec-body { grid-column: 1; }
}

/* ─────────── entries ─────────── */

.entry { position: relative; padding-bottom: 34px; }
.entry:last-child { padding-bottom: 0; }

/* the mark sits on the margin rule and inks in as the entry is passed */
.mark {
  position: absolute;
  top: .58em;
  left: calc((var(--gap) + 4.5px) * -1);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ground);
  border: 1px solid var(--rule);
  transition: background .3s ease, border-color .3s ease;
}
.entry.read .mark { background: var(--red); border-color: var(--red); }

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px 24px;
  flex-wrap: wrap;
}
.entry-org {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.2rem;
  line-height: 1.25;
  margin: 0;
}
.entry-date {
  margin-left: auto;
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.entry-role {
  font-size: .93rem;
  color: var(--muted);
  margin: 5px 0 10px;
}
.entry ul { margin: 0; padding-left: 1.05em; }
.entry li { margin-bottom: 6px; }
.entry li::marker { color: var(--rule); }
.entry li:last-child { margin-bottom: 0; }

/* ─────────── prose ─────────── */

.prose p {
  margin: 0 0 1.15em;
  max-width: 36em;
  text-wrap: pretty;
}
.prose p:last-child { margin-bottom: 0; }
.prose em { font-family: var(--display); font-size: 1.06em; }

/* ─────────── writing ─────────── */

.work {
  display: block;
  position: relative;
  padding-bottom: 30px;
  text-decoration: none;
}
.work:last-child { padding-bottom: 0; }
.work-title {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.42rem;
  line-height: 1.3;
  margin: 0 0 9px;
  max-width: 24em;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: text-decoration-color .18s ease, color .18s ease;
}
.work:hover .work-title { color: var(--red); text-decoration-color: var(--red); }
.work-cite { font-size: .87rem; color: var(--muted); margin: 0; }

/* ─────────── closing facts ─────────── */

.facts { display: grid; gap: 22px; }
.fact { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 8px 24px; }
.fact dt { color: var(--muted); font-size: .88rem; }
.fact dd { margin: 0; }
@media (max-width: 560px) {
  .fact { grid-template-columns: 1fr; gap: 2px; }
}

@media (max-width: 860px) {
  /* Stacked, the date reads better under the name than floating off to the right. */
  .entry-head { display: block; }
  .entry-date { display: block; margin: 4px 0 0; }
}

/* ─────────── colophon ─────────── */

.colophon {
  border-top: 1px solid var(--rule);
  padding: 30px var(--pad) 72px;
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  font-size: .84rem;
  color: var(--muted);
}
.colophon a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.colophon a:hover { color: var(--ink); border-bottom-color: var(--red); }

/* ─────────── accessibility & print ─────────── */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .plate { transform: none !important; }
}

@media print {
  .masthead, .actions, .colophon { display: none; }
  body { background: #fff; font-size: 10.5pt; }
  .record::before, .record::after { display: none; }
  section { padding: 14px 0; break-inside: avoid; }
  .entry, .work { break-inside: avoid; }
  .mark { display: none; }
  h1 { font-size: 30pt; }
}

section { scroll-margin-top: calc(var(--navh) + 8px); }
