/* Marginalia — personal page for Armand (@a4ds5t)
   Cream paper, serif display, grotesque margin labels. No page JS;
   locale routing + cookie persist live in the Worker. */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url("/fonts/newsreader-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 300 500;
  font-display: swap;
  src: url("/fonts/newsreader-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --paper: #faf6ee;
  --ink: #1e1a15;
  --ink-soft: #4a4238;
  --muted: #6b6152;
  --rule: #e5dccc;
  --accent: #3d6b57;
  --accent-soft: #e7efe9;
  --tint: rgba(255, 255, 255, 0.55);
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Simplified Chinese: keep Latin faces, fall back to system CJK (no self-hosted CJK woff2). */
:lang(zh-Hans) {
  --serif: "Newsreader", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.62;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.sheet {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(28px, 6vw, 72px) clamp(22px, 5vw, 56px) 64px;
}

/* ---- top line ---- */

.topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.topline-main {
  display: flex;
  flex: 1 1 16rem;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  min-width: 0;
}

.topline .who {
  margin: 0;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
}

.topline .sub {
  margin: 0;
  max-width: 22em;
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -0.01em;
  text-transform: none;
  text-align: right;
  color: var(--accent);
}

:lang(zh-Hans) .topline .who {
  letter-spacing: 0.06em;
  text-transform: none;
}

:lang(zh-Hans) .topline .sub,
:lang(zh-Hans) .label,
:lang(zh-Hans) .posts-note,
:lang(zh-Hans) .projects .state {
  letter-spacing: 0.04em;
  text-transform: none;
}

/* Language switcher — top right, plain text links (no pills/cards). */
.lang {
  display: flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: 0.35em;
  margin: 0;
  margin-left: auto;
  padding-top: 1px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.lang a {
  color: inherit;
  padding-bottom: 1px;
  border-bottom: 1px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.lang a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.lang a[aria-current="page"] {
  color: var(--ink-soft);
  border-bottom-color: var(--rule);
  cursor: default;
}

.lang-sep {
  opacity: 0.55;
}

.lang a[lang="zh-Hans"] {
  letter-spacing: 0;
  text-transform: none;
}

/* ---- margin grid ---- */

.row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  column-gap: 40px;
  padding: 38px 0;
  border-bottom: 1px solid var(--rule);
}

.row:last-of-type {
  border-bottom: 0;
}

.label {
  margin: 0;
  padding-top: 9px;
  position: relative;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 1px;
  background: var(--accent);
  opacity: 0.7;
}

.intro {
  padding-top: clamp(40px, 8vw, 76px);
}

.intro h1 {
  margin: 0 0 20px;
  font-weight: 400;
  font-size: clamp(2.9rem, 7.4vw, 4.9rem);
  line-height: 0.98;
  letter-spacing: -0.022em;
}

.intro p {
  margin: 0 0 16px;
  max-width: 34em;
  color: var(--ink-soft);
}

.intro p.lead {
  margin-bottom: 18px;
  font-size: clamp(1.18rem, 2.4vw, 1.42rem);
  line-height: 1.5;
  color: var(--ink);
}

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

.now-line {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 36em;
}

.now-line p {
  margin: 0;
  color: var(--ink-soft);
}

.pulse {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-top: 0.65em;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ---- projects ---- */

.projects {
  list-style: none;
  margin: 0;
  padding: 0;
}

.projects li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--rule);
}

.projects li:first-child {
  padding-top: 0;
  border-top: 0;
}

.projects .num {
  font-family: var(--sans);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.projects .name {
  font-size: 1.16rem;
  line-height: 1.35;
  letter-spacing: -0.008em;
}

.projects .name a {
  border-bottom: 1px solid var(--rule);
  transition: color 0.18s ease, border-color 0.18s ease;
}

.projects .name a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.projects .desc {
  display: block;
  margin-top: 3px;
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.55;
  letter-spacing: 0;
  color: var(--muted);
}

.projects .state {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--accent);
}

.projects .desc a {
  border-bottom: 1px solid var(--rule);
  transition: color 0.18s ease, border-color 0.18s ease;
}

.projects .desc a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.more {
  margin: 18px 0 0;
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.more a {
  padding-bottom: 1px;
  border-bottom: 1px solid var(--rule);
  transition: color 0.18s ease, border-color 0.18s ease;
}

.more a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- posts ---- */

.posts-note {
  margin: 0 0 18px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.posts {
  display: grid;
  gap: 26px;
}

.post {
  margin: 0;
  max-width: 36em;
}

.post blockquote {
  margin: 0;
  font-size: 1.06rem;
  line-height: 1.6;
  letter-spacing: -0.004em;
  color: var(--ink);
}

.post blockquote p {
  display: inline;
  margin: 0;
}

.post blockquote::before {
  content: "\201C";
  color: var(--accent);
}

.post blockquote::after {
  content: "\201D";
  color: var(--accent);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.post-meta a {
  padding-bottom: 1px;
  border-bottom: 1px solid var(--rule);
  transition: color 0.18s ease, border-color 0.18s ease;
}

.post-meta a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- social ---- */

.social {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.social a {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--tint);
  font-family: var(--sans);
  font-size: 13.5px;
  letter-spacing: 0.01em;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.social a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.social a span {
  font-size: 12px;
  color: var(--muted);
}

/* ---- foot ---- */

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ---- narrow ---- */

@media (max-width: 680px) {
  body {
    font-size: 18px;
  }

  .sheet {
    padding-bottom: 48px;
  }

  .row {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 12px;
    padding: 28px 0;
  }

  .label {
    padding-top: 0;
    font-size: 11px;
  }

  .label::before {
    display: none;
  }

  .intro {
    padding-top: 32px;
  }

  .projects li {
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 2px 12px;
  }

  .projects .state {
    grid-column: 2;
    margin-top: 4px;
  }

  .social a {
    flex: 1 1 auto;
    justify-content: center;
  }
}

@media (max-width: 400px) {
  .topline {
    font-size: 11px;
    letter-spacing: 0.1em;
  }

  .topline .sub {
    text-align: left;
    max-width: none;
  }

  .lang {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .social {
    gap: 8px;
  }

  .social a {
    padding: 8px 12px;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
