/* ============================================================
   DESIGN SYSTEM — CSS Variables
   ============================================================ */
:root {
  /* Colors — inspired by caiziqi.com */
  --accent:         #8B0012;
  --accent-light:   rgba(139, 0, 18, 0.08);
  --text:           #262626;
  --text-light:     rgba(38, 38, 38, 0.8);
  --text-muted:     #6b7280;
  --bg:             #f2f1f1;
  --card-bg:        #ffffff;
  --card-shadow:    0 8px 24px rgba(0, 0, 0, 0.06);
  --border:         #e5e7eb;
  --radius:         12px;

  /* Typography */
  --font-sans:      Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --font-serif:     "Noto Serif", "Source Han Serif SC", "Noto Serif CJK SC", Georgia, serif;
  --font-mono:      "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;

  /* Glass morphism */
  --glass-bg:       rgba(255, 255, 255, 0.15);
  --glass-border:   rgba(255, 255, 255, 0.3);
  --glass-blur:     6px;
  --glass-sat:      120%;
  --glass-shadow:   0 8px 32px rgba(31, 38, 135, 0.2);
  --glass-radius:   18px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.7;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  letter-spacing: 0.2px;
}

h2 { font-weight: 700; }

p { line-height: 1.7; }

a {
  color: #303030;
  text-decoration: none;
  position: relative;
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  transition: color 220ms ease, border-bottom-color 220ms ease;
}

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

a::before {
  content: '';
  position: absolute;
  width: 0;
  height: 1px;
  bottom: 0;
  left: 0;
  background-color: var(--accent);
  transition: width 260ms ease;
}

a:hover::before { width: 100%; }

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-bottom-color: transparent;
}

strong { color: var(--accent); }

img {
  max-width: 100%;
  height: auto;
}

/* ============================================================
   CONTAINER
   ============================================================ */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes hdrRotate {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.02); }
  100% { transform: rotate(360deg) scale(1); }
}

@keyframes hdrSweep {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================================
   GLASS MORPHISM
   ============================================================ */
.glass {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat)) brightness(1.1) contrast(1.15);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat)) brightness(1.1) contrast(1.15);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.6) 50%,
    transparent 100%
  );
  border-radius: var(--glass-radius) var(--glass-radius) 0 0;
  pointer-events: none;
}

.glass:hover {
  filter: saturate(120%) contrast(110%) brightness(105%);
  box-shadow:
    var(--glass-shadow),
    0 0 30px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* ============================================================
   HDR EFFECT
   ============================================================ */
.hdr {
  position: relative;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hdr::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: conic-gradient(from 0deg at 50% 50%,
    rgba(255, 255, 255, 0.8) 0deg,
    rgba(255, 223, 0, 0.6) 45deg,
    rgba(255, 140, 0, 0.7) 90deg,
    rgba(255, 69, 0, 0.8) 135deg,
    rgba(255, 20, 147, 0.6) 180deg,
    rgba(138, 43, 226, 0.7) 225deg,
    rgba(0, 191, 255, 0.6) 270deg,
    rgba(50, 205, 50, 0.7) 315deg,
    rgba(255, 255, 255, 0.8) 360deg
  );
  border-radius: inherit;
  filter: blur(8px) saturate(150%) contrast(120%) brightness(110%);
  opacity: 0;
  z-index: -1;
  animation: hdrRotate 3s linear infinite;
  transition: opacity 0.4s ease;
}

.hdr:hover::before {
  opacity: 0.8;
  filter: blur(12px) saturate(180%) contrast(140%) brightness(130%);
}

.hdr::after {
  content: '';
  position: absolute;
  inset: 0;
  background: inherit;
  border-radius: inherit;
  backdrop-filter: blur(20px) saturate(150%) contrast(110%) brightness(105%);
  z-index: -1;
}

/* HDR link */
.hdr-link {
  position: relative;
  background: linear-gradient(90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.1) 50%,
    rgba(255,255,255,0) 100%
  );
  background-size: 200% 100%;
  background-position: 100% 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hdr-link::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg,
    rgba(255,215,0,0.8),
    rgba(255,140,0,0.9),
    rgba(255,69,0,0.8),
    rgba(255,20,147,0.7),
    rgba(138,43,226,0.8),
    rgba(0,191,255,0.7),
    rgba(50,205,50,0.8)
  );
  filter: blur(1px) saturate(150%);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hdr-link:hover {
  background-position: 0% 0;
  filter: saturate(130%) contrast(115%) brightness(105%);
  text-shadow:
    0 0 10px rgba(255,255,255,0.5),
    0 0 20px rgba(255,215,0,0.3),
    0 0 30px rgba(255,140,0,0.2);
}

.hdr-link:hover::before { width: 100%; }

/* HDR button */
.hdr-btn {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg,
    rgba(255,255,255,0.1),
    rgba(255,255,255,0.05)
  );
  backdrop-filter: blur(10px) saturate(120%) contrast(110%);
  border: 1px solid rgba(255,255,255,0.2);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hdr-btn::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg,
    transparent 0deg,
    rgba(255,255,255,0.3) 30deg,
    rgba(255,215,0,0.4) 60deg,
    rgba(255,140,0,0.5) 90deg,
    rgba(255,69,0,0.4) 120deg,
    rgba(255,20,147,0.3) 150deg,
    transparent 180deg,
    rgba(138,43,226,0.3) 210deg,
    rgba(0,191,255,0.4) 240deg,
    rgba(50,205,50,0.5) 270deg,
    rgba(255,255,255,0.3) 300deg,
    transparent 360deg
  );
  opacity: 0;
  animation: hdrSweep 4s linear infinite;
  transition: opacity 0.4s ease;
}

.hdr-btn:hover {
  filter: saturate(140%) contrast(120%) brightness(110%);
  box-shadow:
    0 0 20px rgba(255,255,255,0.3),
    0 0 40px rgba(255,215,0,0.2),
    0 0 60px rgba(255,140,0,0.1),
    inset 0 1px 0 rgba(255,255,255,0.4);
  transform: translateY(-2px) scale(1.02);
}

.hdr-btn:hover::before {
  opacity: 0.6;
  animation-duration: 2s;
}

/* ============================================================
   HEADER / STICKY NAV
   ============================================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 12px 0;
  margin-bottom: 2rem;
}

.header .glass {
  padding: 16px 24px;
  margin: 0;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 1.1rem;
  border: none !important;
  gap: 12px;
}

.navbar-brand::before { display: none; }

.navbar-brand .brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: var(--font-sans);
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  color: var(--text-light);
  text-decoration: none;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 12px;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  border: none !important;
  background: linear-gradient(135deg,
    rgba(255,255,255,0.08),
    rgba(255,255,255,0.04)
  );
  backdrop-filter: blur(8px) saturate(110%) contrast(105%);
}

.nav-link::before { display: none; }

.nav-link::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, rgba(139,0,18,0.1), rgba(139,0,18,0.05));
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: inherit;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.15);
  transform: translateY(-1px);
  box-shadow:
    0 0 15px rgba(255,255,255,0.2),
    0 0 30px rgba(139,0,18,0.1),
    0 4px 12px rgba(0,0,0,0.1);
  text-shadow: 0 0 8px rgba(255,255,255,0.4);
}

.nav-link:hover::after { opacity: 0.3; }

.nav-link.active {
  color: var(--accent);
  background: linear-gradient(135deg, rgba(139,0,18,0.12), rgba(139,0,18,0.08));
  transform: translateY(-1px);
  box-shadow:
    0 0 20px rgba(139,0,18,0.3),
    0 0 40px rgba(139,0,18,0.1),
    0 4px 12px rgba(139,0,18,0.2);
  text-shadow: 0 0 10px rgba(139,0,18,0.5);
}

.nav-link.active::after { opacity: 1; }

/* ============================================================
   CARD
   ============================================================ */
.card {
  padding: 0;
  margin-bottom: 24px;
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  background: var(--card-bg);
  animation: fadeIn 0.5s ease both;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6) { animation-delay: 0.3s; }

.card-body {
  padding: 28px 32px;
  background: rgba(255, 255, 255, 0.86);
  border-radius: var(--radius);
}

.card-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
  font-family: var(--font-serif);
}

/* ============================================================
   PROFILE CARD
   ============================================================ */
.profile-card {
  margin-top: 0;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 0;
}

.profile-col-img {
  flex: 0 0 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.profile-img-wrapper {
  width: 112px;
  height: 140px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(135deg, #e0e0e0, #ccc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--accent);
  flex-shrink: 0;
}

.profile-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.profile-col-text {
  flex: 1;
  padding: 24px 24px 24px 0;
}

.profile-name {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.profile-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.profile-links li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.profile-links a {
  border-bottom: 1px solid rgba(0,0,0,0.12);
  padding-bottom: 2px;
}

.profile-links svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
}

/* ============================================================
   TIMELINE (Work & Education)
   ============================================================ */
.timeline-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.timeline-item:last-child { border-bottom: none; padding-bottom: 0; }

.timeline-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 8px;
}

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

.timeline-org {
  font-weight: 600;
  color: var(--accent);
}

.timeline-period {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.timeline-duties {
  list-style: none;
  padding: 0;
}

.timeline-duties li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 6px;
  color: var(--text-light);
  font-size: 0.93rem;
  line-height: 1.6;
}

.timeline-duties li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
}

.timeline-note {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ============================================================
   SKILL TAGS
   ============================================================ */
.skills-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px 32px;
}

.skill-category h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 10px;
  font-family: var(--font-sans);
  color: var(--text);
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-tag {
  display: inline-block;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  background: rgba(139, 0, 18, 0.06);
  border: 1px solid rgba(139, 0, 18, 0.12);
  border-radius: 9999px;
  transition: all 0.25s ease;
  font-family: var(--font-sans);
}

.skill-tag:hover {
  background: rgba(139, 0, 18, 0.12);
  border-color: rgba(139, 0, 18, 0.25);
  transform: translateY(-1px);
}

/* ============================================================
   PROJECT CARDS
   ============================================================ */
.project-row {
  display: flex;
  align-items: flex-start;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  gap: 24px;
}

.project-row:last-child { border-bottom: none; padding-bottom: 0; }

.project-thumb {
  flex-shrink: 0;
  width: 176px;
  height: 112px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f8f9fa;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

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

.project-thumb-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
}

.project-info { flex: 1; }

.project-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.project-tech {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  font-family: var(--font-mono);
  margin-bottom: 6px;
}

.project-desc {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 8px;
  line-height: 1.6;
}

.project-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.project-links a {
  font-size: 0.85rem;
  font-weight: 600;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  background: var(--accent);
  color: #fff;
  text-align: center;
  padding: 24px 0;
  margin-top: 32px;
}

.footer a {
  color: #fff;
  text-decoration: none;
  border-bottom-color: rgba(255,255,255,0.3);
}

.footer a:hover {
  color: #fff;
  text-decoration: underline;
  border-bottom-color: #fff;
}

.footer a::before { display: none; }

.footer-text {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.9;
}

/* ============================================================
   CARD TITLE with accent underline
   ============================================================ */
.card-title-accent {
  display: inline-block;
  position: relative;
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.card-title-accent::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

/* ============================================================
   RESPONSIVE — Tablet
   ============================================================ */
@media (max-width: 768px) {
  .container { padding: 0 16px; }

  .header { padding: 8px 0; margin-bottom: 1.5rem; }
  .header .glass { padding: 12px 16px; margin: 0; }

  .navbar-brand { font-size: 0.95rem; }
  .navbar-brand .brand-icon { width: 28px; height: 28px; font-size: 0.75rem; }

  .nav-link { padding: 8px 12px; font-size: 0.9rem; min-height: 44px; }

  .profile-row { flex-direction: column; text-align: center; }
  .profile-col-img { flex: 0 0 auto; padding-bottom: 0; }
  .profile-col-text { padding: 16px 24px 24px; }
  .profile-links { justify-content: center; }

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

  .card-body { padding: 20px; }

  .project-row { flex-direction: column; }
  .project-thumb { width: 100%; height: 160px; }

  /* mobile glass tweaks */
  .glass {
    --glass-bg: rgba(255,255,255,0.08);
    --glass-blur: 15px;
  }

  .glass:hover {
    transform: none;
    box-shadow: var(--glass-shadow);
  }
  .glass:active { transform: scale(0.98); transition: transform 0.1s ease; }
}

/* ============================================================
   RESPONSIVE — Phone
   ============================================================ */
@media (max-width: 480px) {
  .header .glass { margin: 0 8px; padding: 8px 12px; }
  .navbar { flex-wrap: nowrap; }
  .navbar-brand { font-size: 0.85rem; white-space: nowrap; }
  .navbar-brand .brand-icon { width: 24px; height: 24px; font-size: 0.7rem; }
  .nav-links { gap: 4px; }
  .nav-link { padding: 6px 10px; font-size: 0.85rem; min-height: 40px; }

  .card-body { padding: 16px; }
  .profile-name { font-size: 1.4rem; }
  .timeline-header { flex-direction: column; gap: 2px; }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  :root {
    --bg: #fff;
    --card-bg: #fff;
  }

  body { font-size: 11px; color: #000; }

  .header { position: static; }
  .glass {
    background: #fff !important;
    border: 1px solid #ccc !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
  }
  .hdr::before, .hdr::after, .hdr-btn::before, .hdr-link::before { display: none !important; }

  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; margin-bottom: 12px; }
  .footer { background: #fff; color: #000; border-top: 1px solid #ccc; }

  .nav-links, .project-links, .back-to-top { display: none; }
  a { color: #000; border-bottom: none; }

  .skill-tag {
    background: #f0f0f0;
    color: #000;
    border: 1px solid #ccc;
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
