/* ================================================================
   HONG ZHE — Personal Academic Website
   Retro-futuristic symbolist design
   Inspired by: Claude.ai, OpenAI, Serial Experiments Lain, Maniac
   ================================================================ */

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

/* === CUSTOM PROPERTIES === */
:root {
  /* Base */
  --bg-primary:      #0a0a0f;
  --bg-secondary:    #12121a;
  --bg-tertiary:     #1a1a26;

  /* Text */
  --text-primary:    #e8e4dc;
  --text-secondary:  #9a968e;
  --text-tertiary:   #5c5955;

  /* Accent: Orange-Red (from ref image 3) */
  --accent-primary:  #d4644a;
  --accent-hover:    #e07860;
  --accent-glow:     rgba(212, 100, 74, 0.12);

  /* Accent: Signal Blue (from ref image 3) */
  --signal-blue:     #4a8fd4;
  --signal-dim:      rgba(74, 143, 212, 0.08);

  /* Accent: Phosphor Green (muted, from ref image 1) */
  --phosphor:        #7a9a6a;
  --phosphor-dim:    rgba(122, 154, 106, 0.15);

  /* Structural */
  --border-subtle:   rgba(232, 228, 220, 0.06);
  --border-medium:   rgba(232, 228, 220, 0.10);

  /* Category colors (extracted from ref images) */
  --cat-consciousness: #a084c4;   /* lavender — ref img 1 */
  --cat-alife:         #7a9a6a;   /* olive green — ref img 1 */
  --cat-metacognition: #d4644a;   /* orange-red — ref img 3 */
  --cat-minimal:       #4a8fd4;   /* vivid blue — ref img 3 */
  --cat-collective:    #c4a878;   /* warm beige — ref img 1 */
  --cat-magenta:       #c45a9a;   /* magenta — ref img 3 */

  /* Typography */
  --font-heading:    'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --font-body:       'Space Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --font-mono:       'IBM Plex Mono', 'SF Mono', 'Fira Code', monospace;

  /* Fluid type scale */
  --text-xs:     clamp(0.7rem,   0.65rem + 0.25vw,  0.8rem);
  --text-sm:     clamp(0.8rem,   0.75rem + 0.25vw,  0.9rem);
  --text-base:   clamp(0.95rem,  0.9rem  + 0.25vw,  1.05rem);
  --text-lg:     clamp(1.1rem,   1rem    + 0.5vw,   1.3rem);
  --text-xl:     clamp(1.4rem,   1.2rem  + 1vw,     1.9rem);
  --text-2xl:    clamp(1.6rem,   1.3rem  + 1.5vw,   2.4rem);
  --text-3xl:    clamp(2.2rem,   1.8rem  + 2vw,     3.8rem);

  /* Spacing */
  --leading-tight:   1.15;
  --leading-normal:  1.55;
  --leading-relaxed: 1.7;

  /* Letter spacing */
  --tracking-tight:  -0.02em;
  --tracking-normal:  0;
  --tracking-wide:    0.05em;
  --tracking-wider:   0.12em;
  --tracking-widest:  0.2em;

  /* Effects */
  --scanline-opacity: 0.025;
  --noise-opacity:    0.035;
}

/* === BASE === */
html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* === CRT SCANLINE OVERLAY === */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, var(--scanline-opacity)) 2px,
    rgba(0, 0, 0, var(--scanline-opacity)) 4px
  );
  animation: scanline-drift 10s linear infinite;
}

@keyframes scanline-drift {
  0%   { transform: translateY(0); }
  100% { transform: translateY(4px); }
}

/* === NOISE TEXTURE OVERLAY === */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: var(--noise-opacity);
  animation: noise-shift 0.4s steps(3) infinite;
}

@keyframes noise-shift {
  0%   { transform: translate(0, 0); }
  33%  { transform: translate(-1px, 1px); }
  66%  { transform: translate(1px, -1px); }
  100% { transform: translate(0, 0); }
}

/* === LAYOUT === */
.container {
  width: min(90vw, 780px);
  margin: 0 auto;
}

.container--wide {
  width: min(92vw, 1060px);
}

section {
  padding: clamp(2.5rem, 4vw, 4.5rem) 0;
  position: relative;
}

/* === LINKS === */
a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* === TYPOGRAPHY === */
strong {
  color: var(--text-primary);
  font-weight: 500;
}

em {
  font-style: italic;
}

/* === TERMINAL LABEL === */
.terminal-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--phosphor);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  padding: 3px 10px;
  border: 1px solid rgba(61, 220, 132, 0.2);
  border-radius: 2px;
  display: inline-block;
}

/* === SECTION HEADER === */
.section-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: clamp(1rem, 1.5vw, 1.5rem);
}

.section-number {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent-primary);
  letter-spacing: var(--tracking-widest);
  opacity: 0.6;
  flex-shrink: 0;
}

.section-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

.section-intro {
  color: var(--text-secondary);
  font-size: var(--text-base);
  max-width: 600px;
  margin-bottom: clamp(1.2rem, 2vw, 2rem);
  line-height: var(--leading-relaxed);
}

/* ================================================================
   HERO
   ================================================================ */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  z-index: 0;
}

/* Colorful geometric background SVG */
.hero-geo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.6;
  filter: blur(1.5px);
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.hero-content .terminal-label {
  margin-bottom: 2rem;
}

.hero-name {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  margin-bottom: 0;
  line-height: var(--leading-tight);
}

/* Scroll hint */
.hero-scroll-hint {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  z-index: 1;
}

.hero-scroll-text {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
}

.hero-scroll-line {
  width: 1px;
  height: 36px;
  background: linear-gradient(to bottom, var(--text-tertiary), transparent);
  animation: scroll-pulse 2.5s ease-in-out infinite;
}

@keyframes scroll-pulse {
  0%, 100% { opacity: 0.2; transform: scaleY(1); }
  50%      { opacity: 0.7; transform: scaleY(1.15); }
}

/* ================================================================
   ABOUT
   ================================================================ */
.about-content {
  max-width: 620px;
}

.about-content p {
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}

/* ================================================================
   FEATURED WORK
   ================================================================ */
.featured-paper {
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  padding: clamp(1.5rem, 2.5vw, 2.5rem);
  position: relative;
}

.featured-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.badge-published {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--phosphor);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  border: 1px solid rgba(61, 220, 132, 0.3);
  padding: 2px 8px;
  border-radius: 2px;
  display: inline-block;
}

.featured-title {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  margin-bottom: 0.5rem;
}

.featured-subtitle {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 300;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  line-height: var(--leading-normal);
}

.featured-desc {
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  max-width: 620px;
  margin-bottom: 1.5rem;
}

.featured-figure {
  margin: 1.25rem 0;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.featured-figure img {
  width: 100%;
  height: auto;
  display: block;
}

.figure-caption {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-subtle);
  line-height: var(--leading-normal);
}

/* CTA Button */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--accent-primary);
  padding: 0.65rem 1.4rem;
  border-radius: 3px;
  text-decoration: none;
  letter-spacing: var(--tracking-wide);
  transition: background 0.25s ease, color 0.25s ease;
}

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

/* ================================================================
   MOTIF STRIP — Five research themes
   ================================================================ */
.motif-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-bottom: clamp(1.5rem, 2.5vw, 2.5rem);
  padding: 0.8rem 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.motif {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0;
}

.motif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.motif[data-cat="metacognition"] .motif-dot { background: var(--cat-metacognition); }
.motif[data-cat="alife"]         .motif-dot { background: var(--cat-alife); }
.motif[data-cat="consciousness"] .motif-dot { background: var(--cat-consciousness); }
.motif[data-cat="minimal"]       .motif-dot { background: var(--cat-minimal); }
.motif[data-cat="collective"]    .motif-dot { background: var(--cat-collective); }

.motif-name {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: var(--tracking-normal);
}

.motif-desc {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  letter-spacing: var(--tracking-wide);
}

/* ================================================================
   RESEARCH VISION — PROJECT CARD GRID
   ================================================================ */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: clamp(0.6rem, 1vw, 1rem);
}

/* Individual project card */
.project-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  padding: clamp(1rem, 1.5vw, 1.25rem);
  position: relative;
  transition: border-color 0.3s ease, transform 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.project-card:hover {
  border-color: var(--card-accent, var(--text-tertiary));
  transform: translateY(-2px);
}

/* Card top row: number + category tag */
.project-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.project-number {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  letter-spacing: var(--tracking-wide);
}

/* Category dot + label */
.project-cat {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--card-accent, var(--text-tertiary));
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.project-cat::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--card-accent, var(--text-tertiary));
  flex-shrink: 0;
}

/* Card category colors */
.project-card[data-cat="consciousness"] { --card-accent: var(--cat-consciousness); }
.project-card[data-cat="alife"]         { --card-accent: var(--cat-alife); }
.project-card[data-cat="metacognition"] { --card-accent: var(--cat-metacognition); }
.project-card[data-cat="minimal"]       { --card-accent: var(--cat-minimal); }
.project-card[data-cat="collective"]    { --card-accent: var(--cat-collective); }

/* Card title */
.project-title {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  line-height: var(--leading-tight);
}

.project-title .badge-published {
  vertical-align: middle;
  margin-left: 0.4rem;
}

/* Card question */
.project-question {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
  font-style: italic;
  flex: 1;
}

/* Card Sigil — geometric icon at top of each card */
.card-sigil {
  width: 48px;
  height: 48px;
  margin-bottom: 0.3rem;
  color: var(--card-accent, var(--text-tertiary));
  opacity: 0.55;
  transition: opacity 0.3s ease;
}

.project-card:hover .card-sigil {
  opacity: 0.85;
}

.card-sigil svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ================================================================
   CV & PUBLICATIONS
   ================================================================ */
.cv-subhead {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  margin-top: 2.5rem;
}

.cv-subhead:first-child {
  margin-top: 0;
}

.cv-entry {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

.cv-year {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  padding-top: 1px;
}

.cv-note {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-left: 0.5rem;
}

.cv-entry a {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.cv-languages {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: 2rem;
}

/* ================================================================
   CONTACT
   ================================================================ */
.contact-content p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  max-width: 480px;
  line-height: var(--leading-relaxed);
}

.contact-email {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  color: var(--accent-primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease;
  display: inline-block;
}

.contact-email:hover {
  border-bottom-color: var(--accent-primary);
  color: var(--accent-hover);
}

/* ================================================================
   FOOTER
   ================================================================ */
.footer {
  padding: 2.5rem 0;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  letter-spacing: var(--tracking-wide);
}

/* ================================================================
   SCROLL REVEAL ANIMATIONS
   ================================================================ */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Stagger reveal for project cards */
.project-grid .project-card { transition-delay: 0ms; }
.project-grid .project-card:nth-child(3n+2) { transition-delay: 60ms; }
.project-grid .project-card:nth-child(3n+3) { transition-delay: 120ms; }

/* Word-by-word reveal */
.word-reveal span {
  display: inline-block;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  margin-right: 0.3em;
}

.word-reveal.revealed span {
  opacity: 1;
  transform: translateY(0);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

/* Tablet (640px+) */
@media (min-width: 640px) {
  .project-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Wide desktop (1200px+) */
@media (min-width: 1200px) {
  .project-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  section {
    padding: 5rem 0;
  }
}

/* Mobile adjustments */
@media (max-width: 639px) {
  .hero {
    min-height: 90vh;
  }

  .section-header {
    gap: 0.5rem;
  }

  .featured-paper {
    padding: 1.25rem;
  }

  .cv-entry {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .cv-year {
    font-size: var(--text-xs);
  }

  .project-card {
    padding: 0.85rem;
  }
}

/* Touch targets */
@media (pointer: coarse) {
  .btn-primary {
    min-height: 44px;
    padding: 0.75rem 1.5rem;
  }

  .project-card {
    min-height: 48px;
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .word-reveal span {
    opacity: 1;
    transform: none;
    transition: none;
  }

  body::after,
  body::before {
    animation: none;
  }

  .hero-scroll-line {
    animation: none;
  }

  .project-card {
    transition: none;
  }
}
