:root {
  --bg: #0a0a0a;
  --bg-alt: #111111;
  --text: #f0f0f0;
  --muted: #888888;
  --accent: #4d9fff;
  --border: rgba(255, 255, 255, 0.08);
  --card: #141414;
  --focus-ring: rgba(77, 159, 255, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  font-family: -apple-system, "SF Pro Display", "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 300;
  padding: 0.8rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 0.9rem;
  text-decoration: none;
  transition: top 0.3s ease;
}

.skip-link:focus-visible {
  top: 1rem;
}

/* Loader */
.loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.loader-text {
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 3px;
  text-transform: uppercase;
  animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Scroll Progress */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  width: 0%;
  z-index: 200;
  transition: width 0.1s ease;
}

/* Focus Visible — Global */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Navbar */
.navbar {
  position: fixed;
  top: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 3rem;
  background: rgba(10, 10, 10, 0);
  z-index: 100;
  transition: background 0.4s ease, padding 0.4s ease;
}

.navbar.scrolled {
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 3rem;
}

.nav-logo {
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--text);
  letter-spacing: 1px;
  touch-action: manipulation;
}

.nav-links {
  display: flex;
  gap: 2.5rem;
  list-style: none;
}

.nav-link {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
  transition: color 0.3s ease;
  position: relative;
  padding: 0.3rem 0;
  touch-action: manipulation;
}

.nav-link::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

/* Mobile Menu Toggle */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  touch-action: manipulation;
}

.menu-toggle span {
  width: 24px;
  height: 2px;
  background: var(--text);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.menu-toggle.open span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}
.menu-toggle.open span:nth-child(2) {
  opacity: 0;
}
.menu-toggle.open span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Hero */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at 50% 40%,
    rgba(77, 159, 255, 0.08) 0%,
    transparent 60%
  );
}

.hero-content {
  text-align: center;
  z-index: 1;
  padding: 0 1.5rem;
}

.hero-greeting {
  font-size: 0.95rem;
  color: var(--muted);
  letter-spacing: 2px;
  margin-bottom: 0.8rem;
  opacity: 0;
  animation: fadeIn 0.8s ease 0.3s forwards;
}

.hero-name {
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1.1;
  margin-bottom: 0.5rem;
  text-wrap: balance;
  opacity: 0;
  transform: translateY(30px);
  animation: fadeUp 0.8s ease 0.5s forwards;
}

.hero-typed {
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  color: var(--accent);
  font-weight: 400;
  min-height: 2rem;
  opacity: 0;
  animation: fadeIn 0.8s ease 0.8s forwards;
}

.cursor {
  animation: blink 0.8s infinite;
  color: var(--accent);
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

@keyframes fadeIn {
  to { opacity: 1; }
}

@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}

.hero-scroll {
  position: absolute;
  bottom: 3rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  opacity: 0;
  animation: fadeIn 1s ease 1.5s forwards;
}

.hero-scroll span {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.scroll-line {
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, var(--muted), transparent);
  position: relative;
  overflow: hidden;
}

.scroll-line::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 50%;
  background: var(--accent);
  animation: scrollDown 2s ease infinite;
}

@keyframes scrollDown {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(200%); }
}

/* Sections */
.section {
  padding: 8rem 3rem;
  scroll-margin-top: 80px;
  position: relative;
}

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

.section-index {
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 3px;
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 700;
  margin-bottom: 3rem;
  letter-spacing: -0.5px;
  text-wrap: balance;
}

/* About */
.about-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 3rem;
}

.about-text p {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 1rem;
  overflow-wrap: break-word;
}

.about-info {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}

.info-label {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 1px;
}

.info-value {
  font-size: 1rem;
  color: var(--text);
  overflow-wrap: break-word;
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 2rem;
}

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

.timeline-item {
  position: relative;
  margin-bottom: 3rem;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -2rem;
  top: 8px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.timeline-item:hover .timeline-dot {
  background: var(--accent);
  box-shadow: 0 0 12px rgba(77, 159, 255, 0.5);
}

.timeline-date {
  font-size: 0.8rem;
  color: var(--accent);
  letter-spacing: 1px;
}

.timeline-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0.4rem 0 0.2rem;
  text-wrap: balance;
}

.timeline-org {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.timeline-desc {
  color: var(--muted);
  font-size: 0.95rem;
  overflow-wrap: break-word;
}

/* Works */
.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.work-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.4s ease, border-color 0.4s ease;
  touch-action: manipulation;
}

.work-card:hover {
  transform: translateY(-6px);
  border-color: rgba(77, 159, 255, 0.3);
}

.work-image {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.work-placeholder {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 2px;
  transition: transform 0.4s ease, color 0.4s ease;
}

.work-card:hover .work-placeholder {
  transform: scale(1.1);
  color: rgba(255, 255, 255, 0.5);
}

.work-info {
  padding: 1.5rem;
  min-width: 0;
}

.work-info h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-wrap: balance;
}

.work-info p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  overflow-wrap: break-word;
}

.work-tag {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--accent);
  padding: 0.2rem 0.8rem;
  border: 1px solid rgba(77, 159, 255, 0.3);
  border-radius: 999px;
}

/* Contact */
.contact-intro {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 2.5rem;
}

.contact-links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.contact-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.3s ease, transform 0.3s ease;
  touch-action: manipulation;
  min-width: 0;
}

.contact-link:hover {
  border-color: var(--accent);
  transform: translateX(8px);
}

.contact-label {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 1px;
  flex-shrink: 0;
}

.contact-value {
  font-size: 1rem;
  color: var(--text);
  overflow-wrap: break-word;
  text-align: right;
}

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

/* Scroll Reveal */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
  .navbar {
    padding: 1rem 1.5rem;
  }
  .navbar.scrolled {
    padding: 0.8rem 1.5rem;
  }
  .nav-links {
    position: fixed;
    top: 0;
    right: -100%;
    width: 70%;
    height: 100vh;
    height: 100dvh;
    flex-direction: column;
    background: var(--bg-alt);
    padding: 5rem 2rem;
    padding-top: calc(5rem + env(safe-area-inset-top));
    padding-bottom: env(safe-area-inset-bottom);
    gap: 1.5rem;
    transition: right 0.4s ease;
    overscroll-behavior: contain;
    overflow-y: auto;
  }
  .nav-links.open {
    right: 0;
  }
  .menu-toggle {
    display: flex;
    z-index: 101;
  }
  .section {
    padding: 5rem 1.5rem;
  }
  .about-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .works-grid {
    grid-template-columns: 1fr;
  }
  .contact-link {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
  .contact-value {
    text-align: left;
  }
}

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

  .reveal {
    opacity: 1;
    transform: none;
  }

  .hero-greeting,
  .hero-name,
  .hero-typed,
  .hero-scroll {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
