/* Ding-Ze Hu — portfolio (single-page, theme-aware) */
:root {
  color-scheme: light;
  --bg: #f8f9fb;
  --bg-elevated: #ffffff;
  --text: #1a1d24;
  --text-muted: #5c6370;
  --border: #e2e5eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --hero-gradient: linear-gradient(135deg, #0f172a 0%, #1e3a5f 45%, #2563eb 100%);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --radius: 12px;
  --nav-width: 280px;
  --header-h: 64px;
  --font-sans: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1218;
  --bg-elevated: #181c24;
  --text: #eef1f6;
  --text-muted: #9ca3af;
  --border: #2d3340;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.15);
  --hero-gradient: linear-gradient(135deg, #020617 0%, #0f172a 50%, #1e3a8a 100%);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45);
}

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

html {
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 12px;
  z-index: 10000;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-weight: 600;
}

.skip-link:focus {
  left: 12px;
}

/* ——— Top bar (mobile + theme) ——— */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem 0 1.25rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.site-header__brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
}

.site-header__brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-icon--moon {
  display: none;
}

[data-theme="dark"] .theme-icon--sun {
  display: none;
}

[data-theme="dark"] .theme-icon--moon {
  display: block;
}

.nav-open-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.nav-open-btn svg {
  width: 22px;
  height: 22px;
}

/* ——— Side nav (desktop drawer / mobile overlay) ——— */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--nav-width);
  max-width: 88vw;
  height: 100vh;
  z-index: 1001;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: calc(var(--header-h) + 1rem) 1.25rem 1.5rem;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.site-nav.is-open {
  transform: translateX(0);
}

.site-nav__overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.site-nav__overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.nav-profile {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.nav-profile img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
}

.nav-profile h1 {
  margin: 0.75rem 0 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.nav-profile a {
  color: var(--text);
  text-decoration: none;
}

.nav-profile a:hover {
  color: var(--accent);
}

.social-row {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.social-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

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

.social-row svg {
  width: 20px;
  height: 20px;
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav li {
  margin: 0.2rem 0;
}

.site-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
}

.site-nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.site-nav a svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

/* Main column */
.main-wrap {
  padding-top: var(--header-h);
  min-height: 100vh;
}

@media (min-width: 1024px) {
  .site-header {
    left: var(--nav-width);
    width: auto;
    justify-content: flex-end;
    border-left: none;
    background: var(--bg);
    box-shadow: none;
    border-bottom-color: transparent;
  }

  .site-header__brand {
    display: none;
  }

  .nav-open-btn {
    display: none;
  }

  .site-nav {
    transform: translateX(0);
    box-shadow: none;
    padding-top: 1.5rem;
  }

  .site-nav__overlay {
    display: none;
  }

  .main-wrap {
    margin-left: var(--nav-width);
    padding-top: 0;
  }
}

/* ——— Hero ——— */
.hero {
  background: var(--hero-gradient);
  color: #f8fafc;
  padding: clamp(3rem, 10vw, 5.5rem) 1.5rem;
  text-align: center;
}

.hero__inner {
  max-width: 720px;
  margin: 0 auto;
}

.hero h2 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.75rem, 4.5vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.hero__tagline {
  margin: 0 0 1.25rem;
  font-size: 1.05rem;
  opacity: 0.92;
  line-height: 1.65;
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn--primary {
  background: #fff;
  color: #1e3a8a;
  border-color: #fff;
}

.btn--primary:hover {
  background: rgba(255, 255, 255, 0.92);
  color: #1e3a8a;
  text-decoration: none;
}

.btn--ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #fff;
  color: #fff;
  text-decoration: none;
}

/* ——— Sections ——— */
section {
  scroll-margin-top: calc(var(--header-h) + 12px);
}

@media (min-width: 1024px) {
  section {
    scroll-margin-top: 24px;
  }
}

.section {
  padding: clamp(2.5rem, 6vw, 4rem) 1.5rem;
}

.section--muted {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

.section__title {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section__lead {
  margin: 0 0 1.75rem;
  color: var(--text-muted);
  max-width: 65ch;
}

/* Experience */
.experience-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.35rem;
  box-shadow: var(--shadow);
}

.experience-card__header {
  margin-bottom: 1rem;
}

.experience-card__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.experience-card__meta {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.experience-card ul {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text);
}

.experience-card li {
  margin: 0.5rem 0;
}

.tech-inline {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.tech-inline strong {
  color: var(--text);
}

/* About grid */
.about-grid {
  display: grid;
  gap: 1.75rem;
  align-items: start;
}

@media (min-width: 768px) {
  .about-grid {
    grid-template-columns: 220px 1fr;
  }
}

.about-grid img {
  width: 100%;
  max-width: 220px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.about-grid p {
  margin: 0 0 1rem;
  color: var(--text);
}

.facts {
  display: grid;
  gap: 0.5rem 1.5rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 480px) {
  .facts {
    grid-template-columns: repeat(2, 1fr);
  }
}

.facts li {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.facts strong {
  color: var(--text);
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}

/* Skills */
.skill-groups {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .skill-groups {
    grid-template-columns: repeat(2, 1fr);
  }
}

.skill-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
}

.skill-card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tag {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
}

/* Education */
.edu-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.edu-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.edu-item h3 {
  margin: 0 0 0.35rem;
  font-size: 1.08rem;
}

.edu-item .inst {
  margin: 0;
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
}

.edu-item .dates {
  margin: 0.35rem 0 0.75rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.edu-item p {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  color: var(--text);
}

/* Projects */
.projects-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.project-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.project-card__body {
  padding: 1.35rem;
}

.project-card h3 {
  margin: 0 0 0.65rem;
  font-size: 1.1rem;
  line-height: 1.35;
}

.project-card p {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  color: var(--text);
}

.project-card p:last-of-type {
  margin-bottom: 0;
}

.project-card__stack {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0.75rem 0 0;
}

.project-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.project-tools span {
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.project-card__actions {
  margin-top: 1rem;
}

.project-card__img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
}

.project-card__media--fit {
  padding: 0.65rem 0.85rem 0.85rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Wide figures (e.g. thesis charts): scale down but never crop — full image visible */
.project-card__img.project-card__img--fit-full {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(380px, 50vh);
  margin-left: auto;
  margin-right: auto;
  object-fit: contain;
  object-position: center;
  border-bottom: none;
}

.btn--secondary {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

/* Footer */
.site-footer {
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.site-footer a {
  font-weight: 600;
}

.back-top {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 999;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.back-top.is-visible {
  opacity: 1;
  visibility: visible;
}

.back-top:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.back-top svg {
  width: 22px;
  height: 22px;
}
