/* ============================================================
   曹宏亮 · Hongliang Cao — personal site

   Direction: bright and high-energy. Colour is not decoration —
   it is the index. Each section owns a hue, and the seven roles
   run through the full spectrum so fifteen years read as one
   continuous band of colour from 2011 to today.
   ============================================================ */

:root {
  --paper: #ffffff;
  --wash: #f4f7fb;
  --ink: #10131a;
  --body: #47515f;
  --muted: #6f7c8c;
  --line: #e4e9f0;
  --line-2: #c9d3e0;

  /* The spectrum. `-ink` variants are darkened for text on white. */
  --c1: #ff4d3d;  --c1-ink: #d5361f;   /* coral   */
  --c2: #ff8a1f;  --c2-ink: #bd5c00;   /* orange  */
  --c3: #f5b301;  --c3-ink: #8a6a00;   /* amber   */
  --c4: #17b978;  --c4-ink: #068253;   /* green   */
  --c5: #06aec4;  --c5-ink: #04788a;   /* teal    */
  --c6: #3b7dea;  --c6-ink: #2359bd;   /* blue    */
  --c7: #8b5cf6;  --c7-ink: #6535d8;   /* violet  */

  --hue: var(--c6);
  --hue-ink: var(--c6-ink);

  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --cjk: "PingFang SC", "HarmonyOS Sans SC", "Source Han Sans SC", "Noto Sans SC",
    "Microsoft YaHei", sans-serif;
  --jp: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP",
    Meiryo, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --pad: clamp(1.25rem, 5vw, 5rem);
  --measure: 82rem;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--cjk);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, p, dd, dl, figure { margin: 0; }
:focus-visible { outline: 3px solid var(--c6); outline-offset: 3px; }

.skip-link {
  position: fixed; z-index: 200; top: 0; left: 0;
  padding: .8rem 1.2rem; background: var(--ink); color: #fff;
  font: 500 .8rem/1 var(--mono); transform: translateY(-120%);
}
.skip-link:focus { transform: none; }

/* ── Language ────────────────────────────────────────────────
   The page carries every language; the toggle picks one.
   Exactly one is on screen at a time — no stacked translations. */
body[data-lang="zh"] :is(.en, .ja) { display: none !important; }
body[data-lang="en"] :is(.zh, .ja) { display: none !important; }
body[data-lang="ja"] :is(.zh, .en) { display: none !important; }

.pair > :is(.zh, .en, .ja),
.lockup > :is(.zh, .en, .ja) { display: block; }

.zh { font-family: var(--cjk); }
.ja { font-family: var(--jp); }
.en { font-family: var(--sans); }
body[data-lang="en"] { font-family: var(--sans); }
body[data-lang="ja"] { font-family: var(--jp); }

/* CJK never takes negative tracking, and never a sub-1.1 leading —
   that is what made the previous headlines collide. */
:is(.zh, .ja) { letter-spacing: 0; }

/* ── Scroll progress ─────────────────────────────────────────── */
.progress { position: fixed; z-index: 120; inset: 0 0 auto; height: 3px; }
.progress i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--c1), var(--c2), var(--c3), var(--c4), var(--c5), var(--c6), var(--c7));
}

/* ── Masthead ────────────────────────────────────────────────── */
.masthead {
  position: sticky; z-index: 100; top: 0;
  display: flex; align-items: center; gap: 2rem;
  padding: 0 var(--pad); min-height: 4.25rem;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(14px) saturate(1.6);
  border-bottom: 1px solid var(--line);
}

.wordmark { display: flex; align-items: baseline; gap: .6rem; margin-right: auto; }
.wordmark-zh { font-size: 1rem; font-weight: 700; letter-spacing: .06em; }
.wordmark-en { color: var(--muted); font: 400 .68rem/1 var(--mono); letter-spacing: .06em; }
.wordmark::before {
  content: ""; align-self: center; width: .55rem; height: .55rem; margin-right: .15rem;
  border-radius: 50%;
  background: conic-gradient(var(--c1), var(--c2), var(--c3), var(--c4), var(--c5), var(--c6), var(--c7), var(--c1));
  animation: spin 7s linear infinite;
}

.nav { display: flex; gap: clamp(1rem, 2.6vw, 2.2rem); }
.nav a {
  position: relative; padding: .4rem 0;
  color: var(--body); font-size: .84rem; font-weight: 500;
  transition: color 160ms ease;
}
.nav a .en { font: 500 .78rem/1 var(--sans); }
.nav a span + span { margin-left: .4em; }
.nav a::after {
  content: ""; position: absolute; inset: auto 0 0; height: 3px;
  background: var(--c6); transform: scaleX(0); transform-origin: right;
  transition: transform 200ms ease;
}
.nav a:nth-child(2)::after { background: var(--c7); }
.nav a:nth-child(3)::after { background: var(--c4); }
.nav a:nth-child(4)::after { background: var(--c1); }
.nav a:hover { color: var(--ink); }
.nav a:hover::after { transform: scaleX(1); transform-origin: left; }

.lang { display: flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.lang button {
  padding: .34rem .7rem; min-width: 2.5rem;
  background: none; border: 0;
  color: var(--body); font: 500 .72rem/1.2 var(--mono);
  cursor: pointer; transition: color 150ms ease, background 150ms ease;
}
.lang button:hover { background: var(--wash); color: var(--ink); }
.lang button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ── Hero ────────────────────────────────────────────────────── */
.hero {
  position: relative;
  padding: clamp(2.5rem, 6vh, 4.5rem) var(--pad) clamp(3.5rem, 7vh, 5.5rem);
}
.hero > * { position: relative; max-width: var(--measure); }

.hero-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
  color: var(--c1-ink); font: 500 .76rem/1.4 var(--mono); letter-spacing: .06em;
}
.hero-meta :is(.zh, .en, .ja) { display: inline; }
.hero-meta :is(.zh, .ja) { letter-spacing: .08em; }
.hero-meta .sep {
  flex: 0 0 3rem; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--c1), var(--c3));
}
.hero-meta .place { color: var(--muted); }

.lockup { margin: clamp(1.5rem, 3.5vw, 2.5rem) 0 0; font-weight: 700; }
.lockup :is(.zh, .ja) {
  font-size: clamp(2.15rem, 6.2vw, 5rem);
  line-height: 1.16;
  letter-spacing: .01em;
}
.lockup .en {
  font-size: clamp(2.05rem, 5.9vw, 4.85rem);
  line-height: 1.06;
  letter-spacing: -.035em;
}

/* The one word the whole page is about, spelled out in the full
   spectrum. Everything else in the hero stays ink black. */
.lockup em { font-style: normal; }
.lockup em i { font-style: normal; }
.lockup em i:nth-child(1) { color: var(--c1); }
.lockup em i:nth-child(2) { color: var(--c2); }
.lockup em i:nth-child(3) { color: var(--c4); }
.lockup em i:nth-child(4) { color: var(--c6); }
.lockup em i:nth-child(5) { color: var(--c7); }

.portrait {
  position: absolute; top: 0; right: var(--pad); z-index: 1;
  width: clamp(9rem, 15vw, 14rem); margin: 0;
}
.portrait::before {
  content: ""; position: absolute; inset: .9rem -.9rem -.9rem .9rem;
  background: linear-gradient(150deg, var(--c3), var(--c1));
  border-radius: 4px;
}
.portrait img {
  position: relative; display: block; width: 100%; height: auto;
  border-radius: 4px;
}

.hero-body {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  margin-top: clamp(2.25rem, 4.5vw, 3.25rem);
  padding-top: clamp(1.75rem, 3.5vw, 2.5rem);
  border-top: 2px solid var(--line);
}
.lede { max-width: 40rem; color: var(--body); font-size: 1.05rem; line-height: 1.85; }
.lede .en { line-height: 1.7; }

.readout { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; align-self: start; }
.readout > div {
  padding: 1rem 1.1rem;
  background: var(--wash); border-top: 4px solid var(--hue); border-radius: 3px;
}
.readout > div:nth-child(1) { --hue: var(--c1); }
.readout > div:nth-child(2) { --hue: var(--c3); }
.readout > div:nth-child(3) { --hue: var(--c4); }
.readout > div:nth-child(4) { --hue: var(--c6); }
.readout dt { color: var(--muted); font: 500 .62rem/1 var(--mono); letter-spacing: .1em; }
.readout dd { margin-top: .7rem; font: 700 1.4rem/1.1 var(--sans); }
.readout dd small { display: block; margin-top: .45rem; color: var(--body); font: 400 .72rem/1.3 var(--mono); }
.readout dd :is(.zh, .en, .ja) { display: inline; }

.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: clamp(2.25rem, 4.5vw, 3rem); }
.btn {
  display: inline-flex; align-items: center; padding: .9rem 1.5rem; border-radius: 999px;
  background: var(--ink); color: #fff;
  font: 600 .9rem/1 var(--sans);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.btn :is(.zh, .ja) { display: inline; }
.btn:hover { background: var(--c1); transform: translateY(-2px); box-shadow: 0 10px 22px -10px var(--c1); }
.btn.ghost { background: none; color: var(--ink); border: 2px solid var(--line-2); font-family: var(--mono); font-weight: 500; }
.btn.ghost:hover { background: none; border-color: var(--c6); color: var(--c6-ink); box-shadow: none; }

/* ── Bands ───────────────────────────────────────────────────── */
.band { padding: clamp(3.25rem, 5.5vw, 5rem) var(--pad); }
.band > * { max-width: var(--measure); }

#about { --hue: var(--c6); --hue-ink: var(--c6-ink); }
#work { --hue: var(--c7); --hue-ink: var(--c7-ink); }
#contact { --hue: var(--c1); --hue-ink: var(--c1-ink); }

.rubric {
  display: flex; align-items: center; gap: .8rem; margin-bottom: clamp(2rem, 4vw, 3rem);
  color: var(--hue-ink); font: 600 .78rem/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
}
.rubric > span:first-child {
  padding: .32rem .5rem; border-radius: 3px;
  background: var(--hue); color: #fff;
}
.rubric :is(.zh, .ja) { letter-spacing: .18em; }
.rubric :is(.zh, .en, .ja) { display: inline; }
.rubric::after { content: ""; flex: 1; height: 2px; border-radius: 2px; background: var(--hue); opacity: .25; }

.band-title { margin-bottom: 1.1rem; font-weight: 700; }
.band-lede {
  max-width: 44rem; margin-bottom: clamp(2rem, 4vw, 3rem);
  color: var(--body); font-size: 1rem; line-height: 1.8;
}
.band-title + .thinking, .band-title + .record { margin-top: clamp(2rem, 4vw, 3rem); }
.band-title :is(.zh, .ja) { font-size: clamp(1.8rem, 3.6vw, 2.8rem); line-height: 1.35; }
.band-title .en { font-size: clamp(1.8rem, 3.6vw, 2.8rem); line-height: 1.15; letter-spacing: -.025em; }

/* ── About ───────────────────────────────────────────────────── */
.band-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: clamp(2.5rem, 6vw, 5.5rem); }
.band-grid h2 { font-weight: 700; }
.band-grid h2 :is(.zh, .ja) { font-size: clamp(1.85rem, 3.5vw, 2.7rem); line-height: 1.42; }
.band-grid h2 .en { font-size: clamp(1.8rem, 3.4vw, 2.6rem); line-height: 1.2; letter-spacing: -.025em; }

.prose { display: grid; gap: 1.5rem; max-width: 42rem; }
.prose p { color: var(--body); font-size: 1.02rem; line-height: 1.9; }
.prose .en { line-height: 1.75; }

.traits {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
  margin: clamp(3rem, 6vw, 4.5rem) 0 0; padding: 0; list-style: none;
}
.traits li {
  padding: 1.5rem 1.4rem 1.7rem; border-radius: 6px;
  background: var(--wash); border-bottom: 5px solid var(--hue);
}
.traits li:nth-child(1) { --hue: var(--c4); --hue-ink: var(--c4-ink); }
.traits li:nth-child(2) { --hue: var(--c6); --hue-ink: var(--c6-ink); }
.traits li:nth-child(3) { --hue: var(--c7); --hue-ink: var(--c7-ink); }
.traits h3 { margin-bottom: .8rem; color: var(--hue-ink); font-size: 1.1rem; font-weight: 700; }
.traits p { color: var(--body); font-size: .9rem; line-height: 1.75; }

/* ── Work record ─────────────────────────────────────────────── */
.record { margin: 0; padding: 0; list-style: none; }
.record li {
  position: relative;
  display: grid; grid-template-columns: 10.5rem minmax(0, 1fr);
  gap: clamp(1.25rem, 3vw, 2.5rem);
  padding: 2rem 0 2rem 1.75rem;
  border-bottom: 1px solid var(--line);
  transition: background 200ms ease;
}
/* Fifteen years, running through the spectrum from today back to 2011. */
.record li:nth-child(1) { --hue: var(--c1); --hue-ink: var(--c1-ink); }
.record li:nth-child(2) { --hue: var(--c2); --hue-ink: var(--c2-ink); }
.record li:nth-child(3) { --hue: var(--c3); --hue-ink: var(--c3-ink); }
.record li:nth-child(4) { --hue: var(--c4); --hue-ink: var(--c4-ink); }
.record li:nth-child(5) { --hue: var(--c5); --hue-ink: var(--c5-ink); }
.record li:nth-child(6) { --hue: var(--c6); --hue-ink: var(--c6-ink); }
.record li:nth-child(7) { --hue: var(--c7); --hue-ink: var(--c7-ink); }

.record li::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0;
  width: 4px; border-radius: 2px; background: var(--hue);
}
.record li:hover { background: var(--wash); }

.years { color: var(--muted); font: 500 .84rem/1.5 var(--mono); padding-top: .2rem; }
.years :is(.zh, .en, .ja) { display: inline; }

.org { margin-bottom: .5rem; color: var(--hue-ink); font: 600 .74rem/1.4 var(--mono); letter-spacing: .1em; }
.org span { margin-left: .6rem; color: var(--muted); font-family: var(--cjk); font-weight: 400; letter-spacing: .04em; }
.entry h3 { margin-bottom: .7rem; font-size: clamp(1.2rem, 2vw, 1.55rem); font-weight: 700; }
.entry h3 .en { letter-spacing: -.015em; }
.entry > .pair { max-width: 46rem; color: var(--body); font-size: .97rem; line-height: 1.8; }
.entry .note {
  margin-top: .85rem; padding: .55rem .9rem; border-radius: 4px;
  background: var(--wash); border-left: 4px solid var(--hue);
  color: var(--body); font-size: .88rem; line-height: 1.7;
}
.tags { margin-top: .9rem; color: var(--muted); font: 400 .72rem/1.6 var(--mono); }

/* The two roles worth stopping on. The flag marks them; the wider rail
   and the larger heading follow, so there is one source of truth. */
.flag {
  margin-left: .7rem; padding: .2rem .45rem; border-radius: 3px;
  background: var(--hue); color: #fff;
  font-weight: 600; font-size: .64rem; letter-spacing: .12em;
}
.record li:has(.flag)::before { width: 8px; }
.record li:has(.flag) .entry h3 { font-size: clamp(1.35rem, 2.4vw, 1.85rem); }
.record li:has(.flag) > .years { color: var(--ink); font-weight: 600; }

.education {
  margin-top: 1.75rem; padding-left: 1.75rem;
  color: var(--body); font: 400 .86rem/1.7 var(--mono);
}
.education :is(.zh, .ja) { letter-spacing: .02em; }
.education b { color: var(--c7-ink); font-weight: 600; margin-right: .7rem; }

/* ── Now — the one saturated field on the page ───────────────── */
#now {
  --hue: #fff; --hue-ink: #fff;
  color: #fff; background: #5b3df5;
}
#now .rubric > span:first-child { background: #fff; color: #5b3df5; }
#now .rubric::after { opacity: .38; }
.thinking { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(1.5rem, 3.5vw, 2.5rem); }
.thinking article { padding-top: 1.25rem; border-top: 5px solid var(--dot); }
.thinking article:nth-child(1) { --dot: var(--c3); }
.thinking article:nth-child(2) { --dot: var(--c4); }
.thinking article:nth-child(3) { --dot: var(--c1); }
.thinking h3 { margin-bottom: .9rem; font-size: 1.18rem; font-weight: 700; line-height: 1.5; }
.thinking h3 .en { line-height: 1.3; letter-spacing: -.015em; }
.thinking p { color: rgba(255, 255, 255, .84); font-size: .93rem; line-height: 1.8; }

.stack {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin: clamp(2.75rem, 5.5vw, 4rem) 0 0; padding: 0; list-style: none;
}
.stack li {
  padding: .5rem .8rem; border-radius: 999px;
  background: rgba(255, 255, 255, .14); color: #fff;
  font: 500 .72rem/1 var(--mono);
  transition: background 150ms ease, transform 150ms ease;
}
.stack li:hover { background: #fff; color: #5b3df5; transform: translateY(-2px); }

/* ── Contact ─────────────────────────────────────────────────── */
.contact-title { font-weight: 700; }
.contact-title :is(.zh, .ja) { font-size: clamp(2.5rem, 6.6vw, 5.2rem); line-height: 1.18; }
.contact-title .en { font-size: clamp(2.4rem, 6.2vw, 5rem); line-height: 1.04; letter-spacing: -.035em; }

.contact-lede { max-width: 40rem; margin-top: 1.5rem; color: var(--body); font-size: 1.02rem; line-height: 1.85; }

.contact-link {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1.25rem;
  margin-top: 1rem; padding: 1.3rem 1.4rem; border-radius: 8px;
  background: var(--wash);
  transition: background 200ms ease, color 200ms ease, transform 200ms ease;
}
.contact-link:first-of-type { margin-top: clamp(2.25rem, 4.5vw, 3rem); }
.contact-where { font: 700 clamp(1.4rem, 3vw, 2.1rem)/1 var(--sans); letter-spacing: -.02em; }
.contact-handle { color: var(--muted); font: 400 .84rem/1 var(--mono); }
.contact-arrow { font-size: 1.5rem; }
.contact-link:hover { background: var(--c1); color: #fff; transform: translateX(6px); }
.contact-link:nth-of-type(2):hover { background: var(--c7); }
.contact-link:nth-of-type(3):hover { background: var(--c6); }
.contact-link:hover .contact-handle { color: rgba(255, 255, 255, .8); }

.mail { cursor: pointer; }
.mail .contact-handle :is(.zh, .en, .ja) { display: inline; }
.mail.is-revealed .contact-handle { font-family: var(--mono); }
.mail[data-copied]::after {
  content: "已复制 / copied";
  position: absolute; margin-left: 0;
  padding: .25rem .5rem; border-radius: 3px;
  background: var(--ink); color: #fff; font: 500 .68rem/1 var(--mono);
  transform: translate(-50%, -2.4rem); left: 50%;
}
.mail { position: relative; }

/* ── Colophon ────────────────────────────────────────────────── */
.colophon {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1.5rem;
  padding: 1.75rem var(--pad); border-top: 1px solid var(--line);
  color: var(--muted); font: 400 .76rem/1.5 var(--mono);
}
.colophon p:nth-child(2) { margin-right: auto; }
.to-top {
  padding: 0; background: none; border: 0; cursor: pointer;
  color: inherit; font: inherit; transition: color 150ms ease;
}
.to-top :is(.zh, .en, .ja) { display: inline; }
.to-top:hover { color: var(--c1-ink); }

/* ── Projects (optional section) ─────────────────────────────── */
.project-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 1rem; }
.project-list li { padding: 1.6rem; border-radius: 8px; background: var(--wash); border-bottom: 5px solid var(--c4); }
.project-list h3 { margin: .5rem 0 .7rem; font-size: clamp(1.2rem, 2.1vw, 1.6rem); font-weight: 700; }
.project-list p:not(.org):not(.tags) { max-width: 46rem; color: var(--body); font-size: .97rem; line-height: 1.8; }

/* ── Motion ──────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(1turn); } }

.reveal { opacity: 0; transform: translateY(14px); }
.reveal.in { opacity: 1; transform: none; transition: opacity 620ms ease, transform 620ms cubic-bezier(.22,.61,.36,1); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1000px) {
  .hero-body { grid-template-columns: 1fr; }
  .readout { max-width: 32rem; }
  .band-grid { grid-template-columns: 1fr; }
  .thinking { grid-template-columns: 1fr; gap: 2rem; }
  .traits { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .masthead { gap: 1rem; }
  .nav { display: none; }
  .wordmark-en { display: none; }
  /* Hand-placed line breaks are tuned for wide columns; let narrow
     screens wrap the headings themselves. */
  .band-grid h2 br { display: none; }
  /* Narrow screens have no room for the headline and the photo side by
     side, so the photo leaves the overlay and takes its own row. */
  .portrait {
    position: relative; top: auto; right: auto;
    width: 8.5rem; margin: 1.25rem 0 0 auto;
  }
  .record li { grid-template-columns: 1fr; gap: .8rem; padding-left: 1.25rem; }
  .years { padding-top: 0; }
  .readout { grid-template-columns: 1fr; }
  .education { padding-left: 1.25rem; }
  .contact-link { grid-template-columns: 1fr auto; }
  .contact-handle { display: none; }
  .colophon { gap: .6rem 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
