/* ============================================================
   fellow99.github.io — personal homepage
   Aesthetic: "engineering index" — monospace labels, hairline
   borders, a single indigo accent, token-driven dual theme.
   No frameworks, no external requests, offline-safe.
   ============================================================ */

/* ---------- Design tokens: light (default) ---------- */
:root {
  color-scheme: light;
  --bg:        #f5f6fa;
  --bg-soft:   #eceef6;
  --surface:   #ffffff;
  --surface-2: #f8f9fc;
  --text:      #14161c;
  --muted:     #565d6e;
  --faint:     #868da0;
  --hairline:  #e3e6ef;
  --accent:      #4b5cf6;
  --accent-ink:  #ffffff;
  --accent-soft: #eceefe;
  --accent-line: rgba(75, 92, 246, 0.42);
  --glow:        rgba(75, 92, 246, 0.16);
  --grid:        rgba(20, 24, 50, 0.045);
  --header-bg:   rgba(245, 246, 250, 0.82);

  --shadow-sm: 0 1px 2px rgba(16, 20, 40, 0.06);
  --shadow-md: 0 10px 30px -16px rgba(16, 20, 40, 0.28);
  --shadow-lg: 0 28px 64px -30px rgba(16, 20, 40, 0.36);

  --radius:    16px;
  --radius-sm: 11px;
  --radius-lg: 20px;
  --header-h:  62px;
  --container: 1160px;
  --ease:      cubic-bezier(0.22, 0.61, 0.36, 1);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "JetBrains Mono", "Fira Code", "Courier New", monospace;
}

/* ---------- Design tokens: dark ---------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #08090d;
  --bg-soft:   #0d0f16;
  --surface:   #101319;
  --surface-2: #151922;
  --text:      #eceef4;
  --muted:     #9aa1b2;
  --faint:     #6b7286;
  --hairline:  #20242f;
  --accent:      #8290ff;
  --accent-ink:  #0a0b10;
  --accent-soft: #161a29;
  --accent-line: rgba(130, 144, 255, 0.48);
  --glow:        rgba(130, 144, 255, 0.20);
  --grid:        rgba(255, 255, 255, 0.035);
  --header-bg:   rgba(8, 9, 13, 0.78);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 12px 32px -16px rgba(0, 0, 0, 0.72);
  --shadow-lg: 0 32px 72px -32px rgba(0, 0, 0, 0.9);
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -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.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
img, svg { display: block; }

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

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

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

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 24px;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  border-bottom: 1px solid var(--hairline);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 3px 7px;
  line-height: 1;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: 6px;
}

.nav a {
  color: var(--muted);
  font-size: 14px;
  padding: 7px 11px;
  border-radius: 8px;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.is-active { color: var(--accent); background: var(--accent-soft); }

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 4px 6px;
  background: var(--surface);
}
.lang {
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.lang:hover { color: var(--text); text-decoration: none; }
.lang.is-active { color: var(--accent-ink); background: var(--accent); }
.lang-sep { color: var(--faint); }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.theme-toggle:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.theme-toggle .icon { width: 17px; height: 17px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(64px, 11vw, 132px) 0 clamp(48px, 7vw, 84px);
}

.hero::before {
  content: "";
  position: absolute;
  inset: -50% 0 auto;
  height: 150%;
  background: radial-gradient(58% 56% at 50% 34%, var(--glow), transparent 70%);
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(72% 62% at 50% 22%, #000, transparent 74%);
  mask-image: radial-gradient(72% 62% at 50% 22%, #000, transparent 74%);
  pointer-events: none;
}

.hero-inner { position: relative; z-index: 1; max-width: 860px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin-bottom: 14px;
}

.hero-title {
  font-size: clamp(44px, 8vw, 76px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 750;
}

.hero-role {
  margin-top: 14px;
  font-size: clamp(17px, 2.4vw, 21px);
  font-weight: 550;
  color: var(--text);
}

.hero-lede {
  margin-top: 18px;
  max-width: 66ch;
  font-size: 17px;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 560;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease),
              border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn .icon { width: 15px; height: 15px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { box-shadow: var(--shadow-md); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--hairline);
}
.btn-ghost:hover { border-color: var(--accent-line); }

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 34px;
  margin-top: 42px;
  padding-top: 26px;
  border-top: 1px solid var(--hairline);
}
.stat-strip li { display: flex; flex-direction: column; gap: 2px; }
.stat-num {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.stat-label { font-size: 13px; color: var(--muted); }

/* ---------- Section shell ---------- */
.section {
  padding: clamp(56px, 8vw, 96px) 0;
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.section-head { max-width: 720px; margin-bottom: 40px; }
.section-title {
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.12;
  letter-spacing: -0.025em;
  font-weight: 720;
}
.section-lede { margin-top: 12px; font-size: 16px; color: var(--muted); }

/* ---------- Projects ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease),
              box-shadow 0.3s var(--ease), background-color 0.3s var(--ease);
}
.project-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  border-color: var(--accent-line);
  box-shadow: var(--shadow-lg);
}
.project-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(120% 90% at 50% -30%, var(--glow), transparent 62%);
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  pointer-events: none;
}
.project-card:hover::after { opacity: 1; }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.card-index {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.card-icon {
  width: 40px;
  height: 40px;
  padding: 9px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid var(--hairline);
  color: var(--accent);
}

.card-title {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.015em;
}
.card-desc { font-size: 14.5px; color: var(--muted); }

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.card-tags li {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 3px 9px;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 10px;
  font-size: 14px;
  font-weight: 560;
  color: var(--accent);
}
.card-link .icon {
  width: 14px;
  height: 14px;
  transition: transform 0.25s var(--ease);
}
.project-card:hover .card-link .icon { transform: translate(2px, -2px); }

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 48px;
  align-items: start;
}
.about-copy p { margin-top: 16px; color: var(--muted); max-width: 60ch; }
.about-copy .section-title { margin-top: 0; }
.about-contact { font-size: 15px; }
.about-contact a { font-weight: 560; }

.fact-list { display: flex; flex-direction: column; gap: 14px; }
.fact-list li {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}
.fact-mark {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 3px 7px;
  height: fit-content;
}
.fact-text { font-size: 14.5px; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--hairline);
  background: var(--bg-soft);
  padding: 30px 0;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}
.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
}
.footer-note { font-size: 13.5px; color: var(--muted); }
.footer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  font-size: 13.5px;
  color: var(--muted);
}
.footer-dot { color: var(--faint); }

/* ---------- Reveal on scroll (JS-gated) ---------- */
html.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
html.js .reveal.is-visible { opacity: 1; transform: none; }

/* Gentle stagger for the hero copy column */
.hero-inner .reveal:nth-child(1) { transition-delay: 0ms; }
.hero-inner .reveal:nth-child(2) { transition-delay: 70ms; }
.hero-inner .reveal:nth-child(3) { transition-delay: 140ms; }
.hero-inner .reveal:nth-child(4) { transition-delay: 210ms; }
.hero-inner .reveal:nth-child(5) { transition-delay: 280ms; }
.hero-inner .reveal:nth-child(6) { transition-delay: 350ms; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .about-grid { grid-template-columns: 1fr; gap: 32px; }
}

/* Mobile / portrait: header becomes two rows and the section nav stays
   reachable (horizontal scroll) instead of being hidden. */
@media (max-width: 760px) {
  :root { --header-h: 104px; }

  .site-header { height: auto; }

  .header-inner {
    flex-wrap: wrap;
    align-items: center;
    row-gap: 4px;
    height: auto;
    padding: 9px 18px 7px;
  }

  .brand { order: 1; }
  .brand-name { font-size: 15px; }
  .controls { order: 2; margin-left: auto; }

  .nav {
    order: 3;
    width: 100%;
    margin: 4px 0 0;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 14px;
    white-space: nowrap;
  }

  .container { padding-inline: 18px; }
  .theme-toggle { width: 42px; height: 42px; }
  .lang { display: inline-flex; align-items: center; min-height: 36px; padding: 0 11px; }
}

@media (max-width: 620px) {
  .project-grid { grid-template-columns: 1fr; }

  .hero { padding-top: 44px; }
  .hero-title { font-size: clamp(38px, 11vw, 54px); }
  .hero-lede { font-size: 16px; }

  .header-inner { gap: 10px; }
  .section { padding: 52px 0; }
  .section-head { margin-bottom: 30px; }

  .footer-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .footer-meta { margin-left: 0; }
}

@media (max-width: 440px) {
  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; justify-content: center; }

  .stat-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .stat-num { font-size: 20px; }
  .stat-label { font-size: 12px; }

  .project-card { padding: 20px; }
}

/* Very narrow phones (≤380px): tighten gutters so brand + controls stay on one row. */
@media (max-width: 380px) {
  .container, .header-inner { padding-inline: 14px; }
  .lang { padding: 6px 9px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0ms !important;
  }
  html.js .reveal { opacity: 1; transform: none; }
  .project-card:hover, .btn:hover, .theme-toggle:hover { transform: none; }
}
