/* ==========================================================================
   Juwen Lie — Portfolio
   Clean, professional single-page layout. Zero dependencies, system fonts.
   ========================================================================== */

:root {
  --font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;

  --bg: #ffffff;
  --bg-alt: #f6f8fb;
  --surface: #ffffff;
  --surface-hover: #fbfcfe;
  --border: #e4e8ef;
  --border-strong: #cfd6e2;
  --text: #0f172a;
  --text-muted: #556070;
  --text-subtle: #7b8596;
  --accent: #1f5eff;
  --accent-hover: #1749cc;
  --accent-soft: #edf2ff;
  --accent-contrast: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.82);
  --media-bg: #eef1f6;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 20px -6px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 24px 60px -18px rgba(15, 23, 42, 0.28);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --container: 1160px;
  --header-height: 64px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #0b0f17;
  --bg-alt: #0f1520;
  --surface: #121925;
  --surface-hover: #161f2d;
  --border: #212b3b;
  --border-strong: #2e3a4e;
  --text: #e7ecf3;
  --text-muted: #9aa5b6;
  --text-subtle: #737f92;
  --accent: #6d9eff;
  --accent-hover: #8fb4ff;
  --accent-soft: rgba(109, 158, 255, 0.12);
  --accent-contrast: #0b0f17;
  --header-bg: rgba(11, 15, 23, 0.8);
  --media-bg: #0e141e;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, 0.75);
}

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

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

img {
  display: block;
  max-width: 100%;
}

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

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

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

button {
  font: inherit;
  color: inherit;
}

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

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -48px;
  left: 16px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

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

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

/* --------------------------------------------------------------------------
   Scroll progress + header
   -------------------------------------------------------------------------- */

.scroll-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 120;
  pointer-events: none;
}

.scroll-progress-bar {
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}

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

.site-header.scrolled {
  border-bottom-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 100%;
}

.nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.nav-logo:hover {
  color: var(--text);
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.nav-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.nav-menu a:hover {
  color: var(--text);
  background: var(--bg-alt);
}

.nav-menu a.active {
  color: var(--text);
  background: var(--bg-alt);
}

.nav-menu a.nav-cta {
  margin-left: 6px;
  color: var(--accent-contrast);
  background: var(--accent);
}

.nav-menu a.nav-cta:hover,
.nav-menu a.nav-cta.active {
  color: var(--accent-contrast);
  background: var(--accent-hover);
}

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

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.icon-button:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.icon-moon {
  display: none;
}

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

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

.nav-toggle {
  display: none;
}

.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle-icon {
  position: relative;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle-icon::before {
  top: -5px;
}

.nav-toggle-icon::after {
  top: 5px;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon {
  background: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon::before {
  transform: translateY(5px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon::after {
  transform: translateY(-5px) rotate(-45deg);
}

@media (max-width: 900px) {
  .nav-toggle {
    display: inline-grid;
  }

  .nav-menu {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 12px 16px 18px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  }

  .nav-menu.open {
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .nav-menu a {
    padding: 12px 14px;
    font-size: 1rem;
  }

  .nav-menu a.nav-cta {
    margin: 8px 0 0;
    text-align: center;
  }
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 60%, transparent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--accent-contrast);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--text-subtle);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-alt);
  color: var(--text);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

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

.hero {
  position: relative;
  padding: 96px 0 88px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 80% at 70% 30%, #000 10%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 80% at 70% 30%, #000 10%, transparent 75%);
  opacity: 0.55;
  pointer-events: none;
}

.hero-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  align-items: center;
  gap: 56px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.eyebrow-icon {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.hero h1 {
  font-size: clamp(2.6rem, 6vw, 4.25rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.02;
}

.hero-role {
  margin-top: 14px;
  color: var(--text);
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  font-weight: 600;
}

.hero-role-sep {
  color: var(--text-subtle);
  margin: 0 4px;
}

.hero-lead {
  max-width: 560px;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 32px;
}

.hero-social {
  display: flex;
  gap: 8px;
  margin-top: 28px;
  list-style: none;
}

.hero-social a {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.hero-social a:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.hero-social svg {
  width: 18px;
  height: 18px;
}

.hero-card {
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.hero-card-title {
  margin-bottom: 18px;
  color: var(--text-subtle);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--border);
}

.stat {
  padding: 18px 16px;
  background: var(--surface);
}

.stat dt {
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat dt small {
  color: var(--text-subtle);
  font-size: 0.85rem;
  font-weight: 600;
}

.stat dd {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

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

.section {
  padding: 96px 0;
}

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

.section-header {
  max-width: 680px;
  margin-bottom: 44px;
}

.section-kicker {
  margin-bottom: 10px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.section-title {
  font-size: clamp(1.75rem, 3.4vw, 2.35rem);
  font-weight: 750;
  letter-spacing: -0.025em;
}

.section-intro {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 1.04rem;
}

/* Reveal on scroll — only after app.js confirms it is running, so content
   never stays hidden if the script fails to load. */
html.reveal-ready .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

html.reveal-ready .reveal.visible {
  opacity: 1;
  transform: none;
}

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

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

.about-text {
  color: var(--text-muted);
  font-size: 1.06rem;
  line-height: 1.75;
}

.about-text + .about-text {
  margin-top: 14px;
}

.facts {
  display: grid;
  gap: 0;
  margin: 28px 0 0;
  border-top: 1px solid var(--border);
}

.facts > div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.facts dt {
  color: var(--text-subtle);
  font-size: 0.85rem;
  font-weight: 600;
}

.facts dd {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
}

.about-figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.about-figure img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.about-figure figcaption {
  padding: 12px 16px;
  color: var(--text-subtle);
  font-size: 0.84rem;
}

/* --------------------------------------------------------------------------
   Experience timeline
   -------------------------------------------------------------------------- */

.timeline {
  position: relative;
  display: grid;
  gap: 24px;
  list-style: none;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 7px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-left: 40px;
}

.timeline-marker {
  position: absolute;
  top: 28px;
  left: 0;
  width: 16px;
  height: 16px;
  border: 3px solid var(--bg-alt);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.timeline-card {
  padding: 26px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.timeline-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.timeline-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.timeline-company {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.94rem;
}

.timeline-period {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.timeline-details {
  display: grid;
  gap: 8px;
  list-style: none;
}

.timeline-details li {
  position: relative;
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 0.97rem;
  line-height: 1.6;
}

.timeline-details li::before {
  content: "";
  position: absolute;
  top: 0.68em;
  left: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
}

.timeline-more {
  margin-top: 8px;
}

.timeline-more > .timeline-details {
  margin-top: 8px;
}

.timeline-more summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.timeline-more summary::-webkit-details-marker {
  display: none;
}

.timeline-more summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s ease;
}

.timeline-more[open] summary::after {
  transform: translateY(2px) rotate(-135deg);
}

.timeline-more .more-open,
.timeline-more[open] .more-closed {
  display: none;
}

.timeline-more[open] .more-open {
  display: inline;
}

.timeline-card .chip-list {
  margin-top: 18px;
}

/* --------------------------------------------------------------------------
   Chips (skills, experience)
   -------------------------------------------------------------------------- */

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.chip-list li {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 500;
}

.section-alt .chip-list li {
  background: var(--surface);
}

/* --------------------------------------------------------------------------
   Projects
   -------------------------------------------------------------------------- */

.project-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.project-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.project-toolbar > * {
  min-width: 0;
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.filter-tab:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.filter-tab.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.filter-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text-subtle);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

.filter-tab.active .filter-count {
  background: color-mix(in srgb, var(--bg) 20%, transparent);
  color: var(--bg);
}

.project-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 260px;
}

.project-search svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
  pointer-events: none;
}

.project-search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.project-search input::placeholder {
  color: var(--text-subtle);
}

.project-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.project-status {
  min-height: 1.4em;
  margin-bottom: 20px;
  color: var(--text-subtle);
  font-size: 0.86rem;
}

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

.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s ease;
}

.project-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.project-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.project-card.hidden {
  display: none;
}

.project-card.filter-enter {
  animation: card-in 0.35s var(--ease);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.project-card-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--media-bg);
  border-bottom: 1px solid var(--border);
  transition: transform 0.5s var(--ease);
}

.project-card:hover .project-card-image {
  transform: scale(1.025);
}

/* Thumbnails are shown in the details dialog instead of on the card. */
.project-card .project-thumbnails {
  display: none;
}

.project-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 20px 22px 20px;
  background: var(--surface);
}

.project-category {
  align-self: flex-start;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.project-title {
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.3;
}

/* Every card shows the same amount of text: exactly three lines. */
.project-description {
  display: -webkit-box;
  min-height: calc(1.55em * 3);
  margin-top: 8px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.project-description strong {
  color: var(--text);
  font-weight: 600;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.tag {
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 500;
  white-space: nowrap;
}

/* Cards show one row of up to three tags; the dialog shows them all. */
.project-card .project-tags {
  flex-wrap: nowrap;
  overflow: hidden;
}

.project-card .project-tags .tag {
  flex-shrink: 0;
}

.project-card .project-tags .tag:nth-child(n + 4) {
  display: none;
}

.project-card .is-clipped,
.project-card .project-tags .tag.tag-more.is-clipped {
  display: none;
}

.project-card .project-tags .tag.tag-more {
  display: inline-block;
  flex-shrink: 0;
  overflow: visible;
  background: transparent;
  color: var(--text-subtle);
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 18px;
}

/* Cards show one row of up to three links; the dialog lists every link. */
.project-card .project-links {
  flex-wrap: nowrap;
}

.project-card .project-links {
  overflow: hidden;
}

.project-card .project-links .project-link {
  flex-shrink: 0;
  white-space: nowrap;
}

.project-card .project-links .project-link:nth-of-type(n + 4) {
  display: none;
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.project-link::after {
  content: "↗";
  color: var(--text-subtle);
  font-size: 0.8em;
}

.project-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.project-more {
  flex-shrink: 0;
  margin-left: auto;
  padding: 6px 4px 6px 8px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.project-more::after {
  content: " →";
  display: inline-block;
  transition: transform 0.15s ease;
}

.project-card:hover .project-more::after {
  transform: translateX(3px);
}

.project-show-all {
  display: flex;
  justify-content: center;
  margin-top: 32px;
}

.project-show-all[hidden] {
  display: none;
}

.project-status:empty {
  margin-bottom: 8px;
}

.project-empty {
  padding: 48px 0;
  color: var(--text-muted);
  text-align: center;
}

/* --------------------------------------------------------------------------
   Project dialog
   -------------------------------------------------------------------------- */

.project-dialog {
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.project-dialog::backdrop {
  background: rgba(8, 12, 20, 0.6);
  backdrop-filter: blur(4px);
}

.project-dialog[open] {
  animation: dialog-in 0.25s var(--ease);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

.dialog-inner {
  position: relative;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(6px);
}

.dialog-media {
  background: var(--media-bg);
  border-bottom: 1px solid var(--border);
}

.dialog-image {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  margin: 0 auto;
}

.dialog-thumbs {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
}

.dialog-thumbs:empty {
  display: none;
}

.dialog-thumb {
  width: 72px;
  height: 50px;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.dialog-thumb[aria-current="true"] {
  border-color: var(--accent);
}

.dialog-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dialog-body {
  padding: 26px 30px 30px;
}

.dialog-title {
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.dialog-description {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
}

.dialog-description strong {
  color: var(--text);
}

.dialog-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.dialog-links:empty {
  display: none;
}

.dialog-links .project-link:first-child {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.dialog-links .project-link:first-child::after {
  color: inherit;
}

body.dialog-open {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Skills
   -------------------------------------------------------------------------- */

.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.skill-group {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.skill-group:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.skill-title {
  margin-bottom: 16px;
  font-size: 1rem;
  font-weight: 700;
}

.skill-group .chip-list li {
  background: var(--bg-alt);
}

/* --------------------------------------------------------------------------
   Education
   -------------------------------------------------------------------------- */

.education-card {
  padding: 28px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.education-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.education-school {
  font-size: 1.2rem;
  font-weight: 700;
}

.education-degree {
  margin-top: 4px;
  color: var(--text-muted);
}

.education-details {
  display: grid;
  gap: 10px;
  list-style: none;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.education-details li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  color: var(--text-muted);
  font-size: 0.96rem;
}

.education-details strong {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
}

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

.section-contact {
  padding-top: 24px;
}

.contact-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 48px;
  align-items: center;
  padding: 48px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    radial-gradient(120% 140% at 0% 0%, var(--accent-soft) 0%, transparent 55%),
    var(--surface);
  box-shadow: var(--shadow-md);
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.contact-email {
  margin-top: 16px;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

.btn.copied {
  border-color: #16a34a;
  color: #16a34a;
}

.connect-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.connect-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  text-align: center;
  transition: transform 0.2s var(--ease), border-color 0.2s ease, color 0.2s ease;
}

.connect-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  color: var(--accent);
}

.connect-qr {
  width: 100%;
  max-width: 88px;
  aspect-ratio: 1;
  padding: 4px;
  border-radius: 6px;
  background: #ffffff;
}

/* --------------------------------------------------------------------------
   Footer + back to top
   -------------------------------------------------------------------------- */

.site-footer {
  padding: 28px 0;
  border-top: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: 0.88rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.footer-top {
  color: var(--text-muted);
  font-weight: 500;
}

.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.15s ease;
}

.back-to-top.show {
  opacity: 1;
  transform: none;
}

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

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

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

@media (max-width: 960px) {
  .hero-grid,
  .about-grid,
  .contact-panel {
    grid-template-columns: 1fr;
  }

  .hero-grid {
    gap: 40px;
  }

  .contact-panel {
    gap: 32px;
    padding: 32px;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0 18px;
  }

  .logo-text {
    display: none;
  }

  .hero {
    padding: 56px 0 56px;
  }

  .section {
    padding: 64px 0;
  }

  .section-contact {
    padding-top: 8px;
  }

  .hero-cta .btn {
    flex: 1 1 auto;
  }

  .hero-card {
    padding: 20px;
  }

  .stat dt {
    font-size: 1.2rem;
  }

  .timeline-item {
    padding-left: 28px;
  }

  .timeline-card,
  .education-card {
    padding: 20px;
  }

  .timeline-header,
  .education-header {
    flex-direction: column;
    gap: 8px;
  }

  .facts > div,
  .education-details li {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .project-toolbar {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
  }

  .project-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -18px;
    padding: 2px 18px 6px;
    scrollbar-width: none;
  }

  .project-filters::-webkit-scrollbar {
    display: none;
  }

  .filter-tab {
    flex-shrink: 0;
  }

  .project-search {
    flex-basis: auto;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .contact-panel {
    padding: 24px;
    border-radius: var(--radius-lg);
  }

  .connect-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dialog-body {
    padding: 20px;
  }

  .dialog-image {
    max-height: 45vh;
  }

  .back-to-top {
    right: 16px;
    bottom: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  html.reveal-ready .reveal {
    opacity: 1;
    transform: none;
  }
}

@media print {
  .site-header,
  .scroll-progress,
  .back-to-top,
  .project-toolbar,
  .project-show-all,
  .project-more {
    display: none !important;
  }

  .project-card.hidden {
    display: flex !important;
  }

  html.reveal-ready .reveal {
    opacity: 1;
    transform: none;
  }

  .project-description {
    display: block;
    -webkit-line-clamp: unset;
  }
}
