/* michaelwong.com — Swiss minimal, dark-first. v3.1
   Tokens, grid, type, motion. Motion = precision instrument:
   short distances, long decelerations, no bounce. */

:root[data-theme="dark"] {
  --bg: #0a0b0d;
  --bg-raise: #0e1013;
  --fg: #eef0f2;
  --mute: #8a9097;
  --dim: #565c64;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #ff6a3d;
  --accent-glow: rgba(255, 106, 61, 0.35);
  --hover-wash: rgba(255, 255, 255, 0.025);
}
:root[data-theme="light"] {
  --bg: #f5f5f3;
  --bg-raise: #ffffff;
  --fg: #111316;
  --mute: #6b7079;
  --dim: #9ca0a7;
  --line: rgba(0, 0, 0, 0.10);
  --line-strong: rgba(0, 0, 0, 0.2);
  --accent: #c8442a;
  --accent-glow: rgba(200, 68, 42, 0.18);
  --hover-wash: rgba(0, 0, 0, 0.025);
}

* { box-sizing: border-box; }
html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-feature-settings: "ss01", "cv11", "tnum";
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  transition: background 0.35s ease, color 0.35s ease;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

/* ── Grid ───────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
  padding-left: 64px;
  padding-right: 64px;
  max-width: 1520px;
  margin: 0 auto;
}

/* ── Type utilities ─────────────────────────────────── */
.lbl {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
}
.lbl-dim { color: var(--dim); }
.lbl-fg { color: var(--fg); }
.num { font-variant-numeric: tabular-nums; }

/* ── Hairlines + coordinate ticks (signature motif) ── */
.rule-wrap { grid-column: 1 / -1; position: relative; }
.rule {
  height: 1px;
  background: var(--line);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1) var(--d, 0s);
}
body.is-loaded .rule { transform: scaleX(1); }
.rule-wrap::before, .rule-wrap::after {
  content: '+';
  position: absolute;
  top: -8px;
  font-size: 12px;
  color: var(--dim);
  opacity: 0;
  transition: opacity 0.6s ease calc(var(--d, 0s) + 0.7s);
}
.rule-wrap::before { left: -3px; }
.rule-wrap::after { right: -3px; }
body.is-loaded .rule-wrap::before, body.is-loaded .rule-wrap::after { opacity: 1; }

/* ── Entrance: masked line reveal + fade-up ─────────── */
.hl { display: block; overflow: hidden; padding-bottom: 0.14em; margin-bottom: -0.14em; }
.hl > span {
  display: block;
  transform: translateY(110%);
  transition: transform 1s cubic-bezier(0.16, 1, 0.3, 1) var(--d, 0s);
}
body.is-loaded .hl > span { transform: translateY(0); }

.rv {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease var(--d, 0s), transform 0.95s cubic-bezier(0.16, 1, 0.3, 1) var(--d, 0s);
}
body.is-loaded .rv { opacity: 1; transform: none; }

/* ── Nav ────────────────────────────────────────────── */
.nav { padding-top: 32px; padding-bottom: 32px; align-items: center; }
.nav-brand {
  grid-column: 1 / 4;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-mark {
  width: 8px; height: 8px;
  background: var(--accent);
  display: inline-block;
  flex: 0 0 auto;
}
[data-theme="dark"] .nav-mark { box-shadow: 0 0 12px var(--accent-glow); }
.nav-links { grid-column: 5 / 11; display: flex; gap: 28px; }
.nav-links a {
  font-size: 11px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--mute);
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
  transition: color 0.25s ease, border-color 0.25s ease;
}
.nav-links a:hover { color: var(--fg); }
.nav-links a.active { color: var(--fg); border-bottom-color: var(--accent); }
.theme-toggle {
  grid-column: 11 / 13; justify-self: end;
  font-size: 11px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 0;
  transition: border-color 0.25s ease, background 0.25s ease;
}
.theme-toggle:hover { border-color: var(--line-strong); background: var(--hover-wash); }

/* ── Hero ───────────────────────────────────────────── */
.hero { padding-top: 88px; padding-bottom: 96px; }
.hero-side { grid-column: 1 / 3; }
.hero-main { grid-column: 3 / 11; }
.hero-meta { grid-column: 11 / 13; text-align: right; }
.hero h1 {
  margin: 0;
  font-size: clamp(56px, 7.4vw, 116px);
  line-height: 0.96;
  letter-spacing: -0.04em;
  font-weight: 500;
  text-wrap: balance;
}
.hero h1 .soft { color: var(--mute); }
.hero h1 .mark { color: var(--accent); }
[data-theme="dark"] .hero h1 .mark { text-shadow: 0 0 28px var(--accent-glow); }
.hero p {
  margin: 40px 0 0;
  font-size: 18px;
  line-height: 1.6;
  max-width: 580px;
}
.hero-links { margin-top: 32px; display: flex; gap: 28px; }

/* underline-draw link */
.uline {
  font-size: 11px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--fg);
  padding-bottom: 5px;
  position: relative;
}
.uline::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
.uline:hover::after { transform: scaleX(1); transform-origin: left; }
.uline.always::after { transform: scaleX(1); }
.uline.always:hover::after { transform: scaleX(0); transform-origin: right; }
.uline.quiet { color: var(--mute); }
.uline.quiet:hover { color: var(--fg); }
.uline .arr { display: inline-block; transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1); }
.uline:hover .arr { transform: translateX(4px); }

/* hero meta block */
.meta-k { margin-top: 24px; }
.meta-k:first-child { margin-top: 0; }

/* crosshair mark (signature) */
.crosshair {
  display: inline-block;
  margin-bottom: 14px;
}
.crosshair line, .crosshair circle {
  stroke: var(--dim);
  stroke-width: 1;
  fill: none;
}
.crosshair circle {
  stroke-dasharray: 44;
  stroke-dashoffset: 44;
  transition: stroke-dashoffset 1.4s cubic-bezier(0.16, 1, 0.3, 1) 0.5s;
}
.crosshair line {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  transition: stroke-dashoffset 1s cubic-bezier(0.16, 1, 0.3, 1) 0.9s;
}
body.is-loaded .crosshair line, body.is-loaded .crosshair circle { stroke-dashoffset: 0; }

/* ── Sections ───────────────────────────────────────── */
.sec { padding-top: 72px; padding-bottom: 72px; }
.sec-head { grid-column: 1 / 4; }
.sec-head h2 {
  margin: 8px 0 0;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.sec-head .sec-note {
  margin-top: 14px;
  font-size: 14px;
  color: var(--mute);
  line-height: 1.6;
  max-width: 280px;
}
.sec-body { grid-column: 5 / 13; }
.sec-head .uline { display: inline-block; margin-top: 18px; }

/* ── Rows (experience / channels) ───────────────────── */
.row {
  border-bottom: 1px solid var(--line);
  padding: 26px 12px;
  margin: 0 -12px;
  display: grid;
  grid-template-columns: 160px 1fr 200px;
  gap: 24px;
  align-items: baseline;
  transition: background 0.3s ease;
  position: relative;
}
.row:first-child, .row.row-top { border-top: 1px solid var(--line); }
.row:hover { background: var(--hover-wash); }
.row-when { font-size: 11px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mute); }
.row-title {
  font-size: 21px; font-weight: 500; letter-spacing: -0.01em;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.row:hover .row-title { transform: translateX(4px); }
.row-sub { margin-top: 8px; font-size: 14px; line-height: 1.6; color: var(--mute); max-width: 480px; }
.row-org { font-size: 14px; font-weight: 600; text-align: right; }
.row-org a:hover { color: var(--accent); }

/* ── Project table ──────────────────────────────────── */
.ptable-head, .prow {
  display: grid;
  grid-template-columns: 40px 200px 1fr 110px 70px;
  gap: 16px;
}
.ptable-head {
  padding: 14px 12px;
  margin: 0 -12px;
  border-bottom: 1px solid var(--line);
}
.prow {
  padding: 24px 12px;
  margin: 0 -12px;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
  transition: background 0.3s ease;
  cursor: pointer;
}
.prow:hover { background: var(--hover-wash); }
.prow-num { font-size: 11px; font-weight: 500; letter-spacing: 0.14em; color: var(--dim); transition: color 0.3s ease; }
.prow:hover .prow-num { color: var(--accent); }
.prow-name {
  font-size: 21px; font-weight: 500; letter-spacing: -0.01em;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.prow:hover .prow-name { transform: translateX(4px); }
.prow-tag { margin-top: 6px; }
.prow-blurb { font-size: 14px; line-height: 1.6; max-width: 460px; }
.prow-status { font-size: 12px; display: flex; align-items: center; gap: 8px; }
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}
[data-theme="dark"] .status-dot { box-shadow: 0 0 10px var(--accent-glow); }
.status-dot.off { background: var(--dim); box-shadow: none; }
.prow-year { text-align: right; }

/* ── Placeholder stripes (screenshot slots) ─────────── */
.pv-stripes {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, var(--line) 0 1px, transparent 1px 8px);
}

/* ── Work page entries ──────────────────────────────── */
.work-entry { padding-top: 64px; padding-bottom: 72px; border-top: 1px solid var(--line); }
.we-side { grid-column: 1 / 3; }
.we-main { grid-column: 3 / 11; }
.we-meta { grid-column: 11 / 13; text-align: right; }
.we-name {
  margin: 0;
  font-size: clamp(40px, 4.6vw, 72px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
}
.we-name .mark { color: var(--accent); }
.we-blurb { margin: 20px 0 0; font-size: 17px; line-height: 1.6; color: var(--mute); max-width: 560px; }
.we-shot {
  grid-column: 3 / 13;
  margin-top: 40px;
  aspect-ratio: 21 / 9;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.we-shot .pv-stripes { opacity: 0.7; }
.we-shot-cap {
  position: absolute; left: 16px; bottom: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px; color: var(--mute); letter-spacing: 0.04em;
}

/* ── Stats / count-ups ──────────────────────────────── */
.stats { padding-top: 28px; padding-bottom: 28px; }
.stat { grid-column: span 3; }
.stat-n {
  font-size: clamp(40px, 3.6vw, 60px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.stat-n .suffix { color: var(--accent); }
.stat .lbl { margin-top: 10px; display: block; }

/* ── CV highlight list ──────────────────────────────── */
.hl-list { margin: 18px 0 0; padding: 0; list-style: none; }
.hl-list li { display: flex; gap: 14px; padding: 7px 0; font-size: 14px; line-height: 1.6; }
.hl-list li::before { content: '—'; color: var(--accent); flex: 0 0 auto; }

/* ── Footer ─────────────────────────────────────────── */
.footer-cta { padding-top: 72px; padding-bottom: 64px; align-items: end; }
.footer-cta .fc-main { grid-column: 1 / 7; }
.footer-cta .fc-main .big {
  font-size: clamp(40px, 4.4vw, 64px);
  line-height: 0.95;
  letter-spacing: -0.035em;
  font-weight: 500;
}
.footer-cta .fc-main .big .mark { color: var(--accent); }
.footer-cta .fc-sub { margin-top: 16px; font-size: 15px; color: var(--mute); }
.footer-cta .fc-links { grid-column: 8 / 13; display: flex; justify-content: flex-end; gap: 28px; }
.footer-meta {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  padding-top: 24px;
  margin-top: 48px;
  border-top: 1px solid var(--line);
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid { padding-left: 40px; padding-right: 40px; gap: 20px; }
  .hero-side { display: none; }
  .hero-main { grid-column: 1 / 11; }
  .sec-head { grid-column: 1 / -1; margin-bottom: 8px; }
  .sec-head .sec-note { max-width: 480px; }
  .sec-body { grid-column: 1 / -1; }
  .we-side { display: none; }
  .we-main { grid-column: 1 / 11; }
  .we-shot { grid-column: 1 / -1; }
  .stat { grid-column: span 6; margin-bottom: 24px; }
}
@media (max-width: 720px) {
  .grid { padding-left: 20px; padding-right: 20px; gap: 16px; }

  /* Nav: keep links reachable — brand + toggle on top, link row beneath */
  .nav { padding-top: 20px; padding-bottom: 0; row-gap: 0; }
  .nav-brand { grid-column: 1 / 9; }
  .theme-toggle { grid-column: 9 / 13; padding: 10px 14px; }
  .nav-links {
    grid-column: 1 / -1;
    gap: 24px;
    margin-top: 16px;
    padding-bottom: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-links a { padding: 10px 0 8px; flex: 0 0 auto; }

  .hero { padding-top: 48px; padding-bottom: 56px; }
  .hero-main { grid-column: 1 / -1; }
  .hero-meta { display: none; }
  .hero h1 { font-size: clamp(38px, 11.5vw, 56px); }
  .hero p { font-size: 16px; margin-top: 28px; }
  .hero-links { flex-wrap: wrap; gap: 20px 28px; }
  .uline { padding-top: 6px; padding-bottom: 8px; }

  .sec { padding-top: 48px; padding-bottom: 48px; }
  .row { grid-template-columns: 1fr; gap: 8px; padding: 20px 12px; }
  .row-org { text-align: left; }
  .ptable-head { display: none; }
  .prow { grid-template-columns: 1fr; gap: 10px; }
  .prow-year, .prow-num { display: none; }

  .we-name { font-size: clamp(32px, 9.5vw, 44px); }
  .we-main { grid-column: 1 / -1; }
  .we-meta { display: none; }
  .we-shot { aspect-ratio: 16 / 10; margin-top: 28px; }

  .stat-n { font-size: clamp(34px, 9vw, 44px); }

  .footer-cta { padding-top: 56px; padding-bottom: 48px; }
  .footer-cta .fc-main { grid-column: 1 / -1; }
  .footer-cta .fc-links { grid-column: 1 / -1; justify-content: flex-start; margin-top: 24px; flex-wrap: wrap; }
  .footer-meta { flex-direction: column; gap: 8px; }
}

/* ── Reduced motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .hl > span, .rv, .rule, .crosshair line, .crosshair circle {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
    stroke-dashoffset: 0 !important;
  }
}
