/* ============================================
   Honghuai Ke — Portfolio
   Unique dark theme: charcoal + indigo accent
   ============================================ */

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

:root {
  --bg: #09090b;
  --surface: #131316;
  --border: #1e1e24;
  --border-hover: #2a2a35;
  --text: #e4e4e7;
  --text-dim: #9295a0;
  --text-muted: #55576a;
  --accent: #818cf8;
  --accent-dim: rgba(129, 140, 248, 0.08);
  --accent-glow: rgba(129, 140, 248, 0.15);
  --white: #f4f4f5;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-dim);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

/* --- Mouse glow --- */
.mouse-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.mouse-glow.active {
  opacity: 1;
}

/* --- Custom cursor dot --- */
.cursor-dot {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: width 0.3s cubic-bezier(0.25,0.8,0.25,1),
              height 0.3s cubic-bezier(0.25,0.8,0.25,1),
              background 0.3s,
              opacity 0.3s,
              box-shadow 0.3s;
  mix-blend-mode: screen;
}

.cursor-dot.active {
  opacity: 0.8;
}

.cursor-dot.hovering {
  width: 48px;
  height: 48px;
  opacity: 0.12;
  background: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
}

.cursor-dot .cursor-emoji {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.cursor-dot.hovering .cursor-emoji {
  opacity: 1;
}

/* Hide system cursor on desktop (custom dot replaces it) */
@media (pointer: fine) {
  *, *::before, *::after {
    cursor: none !important;
  }
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
.mono { font-family: var(--mono); }

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

/* --- Layout: split-screen --- */
.layout {
  position: relative;
  z-index: 1;
  display: flex;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 48px;
  gap: 64px;
  min-height: 100vh;
}

/* --- Sidebar (left, sticky) --- */
.sidebar {
  position: sticky;
  top: 0;
  width: 44%;
  max-width: 480px;
  height: 100vh;
  padding: 96px 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.greeting {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.lang-toggle {
  background: var(--accent-dim);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  letter-spacing: 0.02em;
}

.lang-toggle:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

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

@keyframes blink {
  50% { opacity: 0; }
}

.name a {
  font-size: 48px;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.04em;
  line-height: 1;
  display: block;
  transition: color 0.2s;
}

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

.title {
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  margin-top: 12px;
  letter-spacing: -0.01em;
}

.tagline {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 12px;
  letter-spacing: 0.01em;
}

/* --- Sidebar Nav: dot indicators --- */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 56px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 0.2s;
}

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

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.nav-link:hover .nav-dot,
.nav-link.active .nav-dot {
  background: var(--accent);
  transform: scale(1.3);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* --- Social Links --- */
.social-links {
  display: flex;
  gap: 20px;
  align-items: center;
}

.social-links a {
  color: var(--text-muted);
  transition: color 0.2s, transform 0.2s;
}

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

.wechat-trigger {
  position: relative;
  color: var(--text-muted);
  transition: color 0.2s, transform 0.2s;
  display: flex;
}

.wechat-trigger:hover {
  color: var(--accent);
  transform: translateY(-2px);
}

.wechat-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.wechat-trigger:hover .wechat-tooltip {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* --- Content (right, scrolling) --- */
.content {
  flex: 1;
  padding: 96px 0;
  min-width: 0;
}

/* --- Section --- */
.section {
  margin-bottom: 100px;
  scroll-margin-top: 96px;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 32px;
  display: none;
}

/* --- Highlight text --- */
.hl {
  color: var(--white);
  font-weight: 500;
}

/* --- About --- */
.about-text p {
  margin-bottom: 16px;
  font-size: 15px;
  line-height: 1.8;
}

.about-text p:last-child {
  margin-bottom: 0;
}

.open-to-work {
  border-left: 2px solid var(--accent);
  padding-left: 1rem;
  margin-top: 1.2rem;
}

/* --- Highlight Cards --- */
.highlights {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 32px;
}

.hl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 16px;
  text-align: center;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.hl-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-dim);
}

.hl-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.hl-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* --- Education Cards --- */
.edu-card {
  display: flex;
  gap: 20px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  transition: border-color 0.25s;
}

.edu-card:hover {
  border-color: var(--accent);
}

.edu-logo {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
}

.edu-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}

.edu-logo-fallback {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.edu-school {
  font-size: 16px;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 4px;
}

.edu-degree {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.edu-focus {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.edu-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.edu-courses {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 10px;
  font-style: italic;
}

.edu-awards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.award {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-block;
}

/* --- Tags --- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tags span {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 4px 10px;
  border-radius: 9999px;
  line-height: 1;
}

/* --- Project Cards --- */
.project-card {
  display: flex;
  gap: 16px;
  padding: 24px;
  border-radius: 10px;
  margin-bottom: 8px;
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
}

.project-card:hover {
  background: var(--surface);
  border-color: var(--border);
}

.project-card:hover .project-title {
  color: var(--accent);
}

.project-card:hover .arrow {
  transform: translate(2px, -2px);
}

.project-icon {
  color: var(--text-muted);
  padding-top: 3px;
  flex-shrink: 0;
  transition: color 0.2s;
}

.project-card:hover .project-icon {
  color: var(--accent);
}

.cs2-logo img {
  opacity: 0.5;
  transition: opacity 0.2s;
}

.project-card:hover .cs2-logo img {
  opacity: 1;
}

.project-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1.4;
  transition: color 0.2s;
}

.project-title .arrow {
  flex-shrink: 0;
  transition: transform 0.2s;
  position: relative;
  top: 1px;
}

.project-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.project-desc {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-dim);
  margin-top: 8px;
}

/* --- Experience Cards --- */
.exp-card {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  padding: 24px;
  border-radius: 10px;
  margin-bottom: 8px;
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}

.exp-card:hover {
  background: var(--surface);
  border-color: var(--border);
}

.exp-date {
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 4px;
  white-space: nowrap;
  font-weight: 500;
}

.exp-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--white);
  line-height: 1.4;
}

.exp-desc {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-dim);
  margin-top: 8px;
}

/* --- Resume Link --- */
.resume-link {
  margin-top: 24px;
  padding-left: 24px;
}

.resume-link a {
  font-size: 14px;
  font-weight: 600;
  color: var(--white);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
  border-bottom: 1px solid transparent;
}

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

.resume-link a svg {
  transition: transform 0.2s;
}

.resume-link a:hover svg {
  transform: translate(2px, -2px);
}

/* --- Skills --- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.skill-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  transition: border-color 0.25s;
}

.skill-group:hover {
  border-color: var(--accent);
}

.skill-heading {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.skill-group p {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.8;
}

/* --- Footer --- */
.footer {
  padding: 48px 0 96px;
  border-top: 1px solid var(--border);
}

.footer p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* --- Diploma Modal --- */
.diploma-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  pointer-events: none;
  transition: background 0.4s, backdrop-filter 0.4s;
}

.diploma-overlay.active {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.diploma-modal {
  position: relative;
  max-width: 640px;
  width: 90%;
  transform: scale(0.8);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s;
}

.diploma-overlay.active .diploma-modal {
  transform: scale(1);
  opacity: 1;
}

/* Invisible close button covering the overlay background */
.diploma-close {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: none;
  border: none;
  cursor: default;
  z-index: 0;
}

.diploma-scroll {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-hover);
  box-shadow: 0 0 60px rgba(129, 140, 248, 0.1), 0 25px 50px rgba(0, 0, 0, 0.5);
  /* Scroll-unroll: clip height from 0 to full */
  max-height: 0;
  transition: max-height 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.diploma-overlay.active .diploma-scroll {
  max-height: 600px;
}

.diploma-scroll-inner {
  background: #f5f0e6;
  padding: 8px;
}

.diploma-scroll-inner img {
  width: 100%;
  display: block;
  border-radius: 4px;
}

.edu-card[data-diploma] {
  position: relative;
}

.edu-card[data-diploma]::after {
  content: 'Click to view diploma';
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s;
}

.edu-card[data-diploma]:hover::after {
  opacity: 1;
}

/* ===========================
   Scroll fade-in animation
   =========================== */
.section {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

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

/* ===========================
   Responsive
   =========================== */
@media (max-width: 1024px) {
  .layout {
    flex-direction: column;
    gap: 0;
    padding: 0 24px;
  }

  .sidebar {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: auto;
    padding: 80px 0 40px;
  }

  .sidebar-nav {
    display: none;
  }

  .content {
    padding-top: 0;
  }

  .section-label {
    display: block;
    position: sticky;
    top: 0;
    background: var(--bg);
    padding: 16px 0;
    z-index: 10;
  }

  .section {
    margin-bottom: 64px;
    scroll-margin-top: 48px;
  }

  .highlights {
    grid-template-columns: repeat(2, 1fr);
  }

  .skills-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .layout {
    padding: 0 16px;
  }

  .sidebar {
    padding: 64px 0 24px;
  }

  .name a {
    font-size: 36px;
  }

  .title {
    font-size: 15px;
  }

  .highlights {
    grid-template-columns: repeat(2, 1fr);
  }

  .exp-card {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .project-card {
    flex-direction: column;
    gap: 8px;
    padding: 16px;
  }

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

  .footer {
    padding-bottom: 48px;
  }
}

/* ---- Project sub-pages: sticky header ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 16px 0;
  background: transparent;
  pointer-events: none;
}
.page-header a,
.page-header button {
  pointer-events: auto;
  background: rgba(9, 9, 11, 0.7);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: 9999px;
}
