/* ==========================================================================
   Aking Huang — personal site
   Auto light/dark via prefers-color-scheme, with a manual override
   (data-theme="light" | "dark" on <html>).
   Palette: deep navy + teal accent, carried across both themes.
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */

:root {
  --navy-900: #070D18;
  --navy-800: #0B1220;
  --navy-700: #111A2B;
  --navy-600: #16223A;
  --navy-500: #1E2C48;

  --teal-400: #2DD4BF;
  --teal-500: #14B8A6;
  --teal-600: #0D9488;
  --teal-700: #0F766E;

  --sky-400: #38BDF8;
  --sky-600: #0284C7;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  --maxw: 1080px;
  --gutter: 24px;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono",
    Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Light theme (default when the OS asks for light) */
:root,
html[data-theme="light"] {
  --bg: #F6F9FC;
  --bg-tint: #EAF1F8;
  --surface: #FFFFFF;
  --surface-2: #F1F5FA;
  --surface-3: #E6EDF6;
  --border: rgba(11, 18, 32, 0.10);
  --border-strong: rgba(11, 18, 32, 0.18);

  --text: #0B1220;
  --text-soft: #33425C;
  --text-dim: #63748F;

  --accent: #0D9488;
  --accent-soft: rgba(13, 148, 136, 0.12);
  --accent-line: rgba(13, 148, 136, 0.35);
  --accent-2: #0284C7;
  --accent-2-soft: rgba(2, 132, 199, 0.12);

  --header-bg: rgba(246, 249, 252, 0.82);
  --shadow-sm: 0 1px 2px rgba(11, 18, 32, 0.06);
  --shadow: 0 2px 4px rgba(11, 18, 32, 0.05), 0 12px 28px rgba(11, 18, 32, 0.07);
  --shadow-lg: 0 4px 8px rgba(11, 18, 32, 0.06), 0 24px 56px rgba(11, 18, 32, 0.12);
  --glow: radial-gradient(60% 60% at 50% 0%, rgba(13, 148, 136, 0.16), transparent 70%);
  color-scheme: light;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080E1A;
    --bg-tint: #0B1220;
    --surface: #0F1729;
    --surface-2: #141F35;
    --surface-3: #1B2842;
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.18);

    --text: #E9EFF8;
    --text-soft: #C2CFE2;
    --text-dim: #8A9CB8;

    --accent: #2DD4BF;
    --accent-soft: rgba(45, 212, 191, 0.14);
    --accent-line: rgba(45, 212, 191, 0.40);
    --accent-2: #38BDF8;
    --accent-2-soft: rgba(56, 189, 248, 0.14);

    --header-bg: rgba(8, 14, 26, 0.78);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 12px 28px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.35), 0 24px 56px rgba(0, 0, 0, 0.55);
    --glow: radial-gradient(60% 60% at 50% 0%, rgba(45, 212, 191, 0.18), transparent 70%);
    color-scheme: dark;
  }
}

html[data-theme="dark"] {
  --bg: #080E1A;
  --bg-tint: #0B1220;
  --surface: #0F1729;
  --surface-2: #141F35;
  --surface-3: #1B2842;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);

  --text: #E9EFF8;
  --text-soft: #C2CFE2;
  --text-dim: #8A9CB8;

  --accent: #2DD4BF;
  --accent-soft: rgba(45, 212, 191, 0.14);
  --accent-line: rgba(45, 212, 191, 0.40);
  --accent-2: #38BDF8;
  --accent-2-soft: rgba(56, 189, 248, 0.14);

  --header-bg: rgba(8, 14, 26, 0.78);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 12px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.35), 0 24px 56px rgba(0, 0, 0, 0.55);
  --glow: radial-gradient(60% 60% at 50% 0%, rgba(45, 212, 191, 0.18), transparent 70%);
  color-scheme: dark;
}

/* --- Base ---------------------------------------------------------------- */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

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

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

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
}
.skip:focus { left: 16px; top: 16px; }

/* --- Header -------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s var(--ease), background-color 0.3s var(--ease);
}
.site-header.scrolled { border-bottom-color: var(--border); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-size: 16px;
  white-space: nowrap;
}

.brand .mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: #04211E;
  background: linear-gradient(140deg, var(--teal-400), var(--sky-400));
  box-shadow: 0 2px 10px var(--accent-soft);
  flex-shrink: 0;
}

.brand .sub {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 13px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav a {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
  transition: color 0.18s var(--ease), background-color 0.18s var(--ease);
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--accent); background: var(--accent-soft); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--border-strong); color: var(--text); transform: translateY(-1px); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-moon,
.theme-toggle .icon-sun,
.theme-toggle .icon-auto { display: none; }
html[data-theme-mode="auto"] .theme-toggle .icon-auto { display: block; }
html[data-theme-mode="light"] .theme-toggle .icon-sun { display: block; }
html[data-theme-mode="dark"] .theme-toggle .icon-moon { display: block; }

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease),
    background-color 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease);
  white-space: nowrap;
  font-family: inherit;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #04211E;
  box-shadow: 0 4px 16px var(--accent-soft);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 26px var(--accent-line); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); }

/* --- Hero ---------------------------------------------------------------- */

.hero {
  position: relative;
  padding: 92px 0 72px;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -140px -20% auto;
  height: 620px;
  background: var(--glow);
  pointer-events: none;
  z-index: 0;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(70% 55% at 50% 12%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(70% 55% at 50% 12%, #000 0%, transparent 78%);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}

.hero .wrap { position: relative; z-index: 1; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 500;
  margin-bottom: 26px;
}
.eyebrow .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  flex-shrink: 0;
  animation: pulse 2.6s var(--ease) infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--accent-soft); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

.hero h1 {
  font-size: clamp(2.1rem, 5.6vw, 3.45rem);
  line-height: 1.16;
  letter-spacing: -0.028em;
  margin: 0 0 20px;
  font-weight: 700;
  max-width: 17ch;
}

.hero h1 .accent {
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero p.lede {
  font-size: clamp(1rem, 1.9vw, 1.15rem);
  color: var(--text-soft);
  max-width: 60ch;
  margin: 0 0 34px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 40px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.chips li {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 5px 11px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.chips li:hover { color: var(--accent); border-color: var(--accent-line); }

/* --- Stat strip ---------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 56px;
}
.stat {
  background: var(--surface);
  padding: 20px 22px;
}
.stat .num {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: var(--font-mono);
  color: var(--accent);
  line-height: 1.3;
}
.stat .lbl {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* --- Sections ------------------------------------------------------------ */

section { scroll-margin-top: 88px; }

.section { padding: 78px 0; }
.section.tinted { background: var(--bg-tint); border-block: 1px solid var(--border); }

.section-head { margin-bottom: 40px; max-width: 62ch; }

.section-head .kicker {
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  display: block;
  margin-bottom: 12px;
}

.section-head h2 {
  font-size: clamp(1.5rem, 3.3vw, 2.05rem);
  letter-spacing: -0.022em;
  margin: 0 0 12px;
  font-weight: 680;
  line-height: 1.25;
}

.section-head p {
  color: var(--text-dim);
  margin: 0;
  font-size: 15.5px;
}

/* --- Project grid -------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: transform 0.22s var(--ease), border-color 0.22s var(--ease),
    box-shadow 0.22s var(--ease);
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity 0.22s var(--ease);
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-line);
  box-shadow: var(--shadow);
}
.card:hover::before { opacity: 1; }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.card-icon svg { width: 20px; height: 20px; }

.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.tag.live { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.tag.wip { background: var(--accent-2-soft); border-color: rgba(56, 189, 248, 0.32); color: var(--accent-2); }

.card h3 {
  font-size: 1.03rem;
  margin: 0 0 9px;
  font-weight: 640;
  letter-spacing: -0.012em;
}

.card p {
  font-size: 14.3px;
  color: var(--text-dim);
  margin: 0 0 18px;
  flex-grow: 1;
  line-height: 1.68;
}

.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.stack li {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--surface-2);
  padding: 3px 8px;
  border-radius: 5px;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  margin-top: auto;
  align-self: flex-start;
}
.card-link svg { width: 14px; height: 14px; transition: transform 0.2s var(--ease); }
.card-link:hover svg { transform: translateX(3px); }

/* --- Notes --------------------------------------------------------------- */

.notes { display: grid; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.note {
  background: var(--surface);
  padding: 20px 24px;
  display: flex;
  align-items: baseline;
  gap: 20px;
  transition: background-color 0.18s var(--ease);
}
.note:hover { background: var(--surface-2); }

.note .date {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 88px;
}
.note .title { font-weight: 560; font-size: 15px; }
.note .title span { color: var(--text-dim); font-weight: 400; }

/* --- About --------------------------------------------------------------- */

.about-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 48px;
  align-items: start;
}

.prose p { margin: 0 0 18px; color: var(--text-soft); font-size: 15.5px; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--text); font-weight: 620; }

.facts { display: grid; gap: 12px; }

.fact {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.fact .k {
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 7px;
}
.fact .v { font-size: 14.5px; font-weight: 550; line-height: 1.6; }

/* --- Contact ------------------------------------------------------------- */

.contact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.contact-card::before {
  content: "";
  position: absolute;
  inset: auto -30% -70% -30%;
  height: 320px;
  background: radial-gradient(50% 50% at 50% 50%, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.contact-card > * { position: relative; }
.contact-card h2 {
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  font-weight: 680;
}
.contact-card p { color: var(--text-dim); margin: 0 auto 28px; max-width: 46ch; font-size: 15.5px; }

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 22px;
}

.contact-meta {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: center;
}
.contact-meta a:hover { color: var(--accent); }

.copy-btn {
  position: relative;
}
.copy-btn .copied {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  font-family: var(--font-mono);
}
.copy-btn.done .copied { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Footer -------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 30px 0;
  margin-top: 20px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--text-dim);
}
.footer-inner a:hover { color: var(--accent); }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }

/* --- Reveal animation ---------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.reveal.in { opacity: 1; transform: none; }

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

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 880px) {
  .about-grid { grid-template-columns: 1fr; gap: 32px; }
  .hero { padding: 68px 0 56px; }
  .section { padding: 60px 0; }
}

@media (max-width: 720px) {
  :root { --gutter: 18px; }
  .nav { display: none; }
  .brand .sub { display: none; }
  .contact-card { padding: 32px 22px; }
  .note { flex-direction: column; gap: 4px; }
  .note .date { min-width: 0; }
  .hero h1 { max-width: none; }
  .stats { margin-top: 40px; }
}

@media (max-width: 420px) {
  .hero-actions .btn { width: 100%; justify-content: center; }
  .contact-actions .btn { width: 100%; justify-content: center; }
}
