/* ===== Portfolio Framework — Michael Guo ===== */
:root {
  --bg: #0c0c0c;
  --bg-elevated: #121212;
  --text: #f5f5f5;
  --muted: #8a8a8a;
  --accent: #d4854a;
  --accent-dim: rgba(212, 133, 74, 0.25);
  --border: rgba(255, 255, 255, 0.06);
  --radius: 12px;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-serif: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px;
  line-height: 1.6;
}

/* Custom cursor */
body,
body * {
  cursor: none;
}

.custom-cursor {
  position: fixed;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10000;
  transform: translate(-50%, -50%);
}

body.cursor-charging .custom-cursor {
  animation: cursor-charge-pulse 0.2s ease-in-out infinite;
}

body.cursor-charging-shake .custom-cursor {
  animation: cursor-shake 0.06s ease-in-out infinite;
}

@keyframes cursor-charge-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.15); }
}

@keyframes cursor-shake {
  0% { transform: translate(-50%, -50%) translate(0, 0); }
  25% { transform: translate(-50%, -50%) translate(-3px, -2px); }
  50% { transform: translate(-50%, -50%) translate(2px, 3px); }
  75% { transform: translate(-50%, -50%) translate(-2px, 2px); }
  100% { transform: translate(-50%, -50%) translate(0, 0); }
}

/* Click trail — traces movement when you click and drag */
body.click-trail-drawing {
  user-select: none;
  -webkit-user-select: none;
}

.click-trail-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
}

.click-trail-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transition: opacity 1.2s ease-out;
}

.click-trail-svg.click-trail-fade {
  opacity: 0;
}

.click-trail-outer {
  filter: blur(12px);
  transition: opacity 1.2s ease-out;
}

.click-trail-ribbon {
  transition: opacity 1.2s ease-out;
}

.click-trail-core {
  transition: opacity 1.2s ease-out;
}

.click-trail-spark {
  opacity: 0.85;
  animation: click-trail-spark-in 0.2s ease-out forwards;
  transform-origin: center;
}

.click-trail-spark-out {
  animation: click-trail-spark-out 0.8s ease-out forwards;
}

@keyframes click-trail-spark-in {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  to {
    opacity: 0.85;
    transform: scale(1);
  }
}

@keyframes click-trail-spark-out {
  to {
    opacity: 0;
    transform: scale(0.2);
  }
}

/* Galaxy background toggle — interactive hover button */
body .galaxy-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9997;
  width: 128px;
  overflow: hidden;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 10px 16px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.galaxy-toggle-btn:hover {
  border-color: var(--accent-dim);
}

.galaxy-toggle-text {
  display: inline-block;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.galaxy-toggle-btn:hover .galaxy-toggle-text {
  transform: translateX(4px);
  opacity: 0;
}

.galaxy-toggle-hover {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--accent);
  transform: translateX(48px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.galaxy-toggle-btn:hover .galaxy-toggle-hover {
  transform: translateX(-4px);
  opacity: 1;
}

.galaxy-toggle-arrow {
  font-size: 1rem;
}

/* Revealable sections — hidden until terminal command */
.panel.revealable {
  display: none;
}

.panel.revealable.revealed {
  display: block;
  animation: fadeIn 0.4s ease forwards;
}

/* Inline terminal beneath hero */
.terminal-inline {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 13px;
  margin-bottom: 32px;
}

.terminal-inline .terminal-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  max-width: 480px;
}

.terminal-inline .terminal-panel.terminal-open {
  display: flex;
  flex-direction: column;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}

.terminal-title {
  color: var(--muted);
  font-size: 12px;
}

.terminal-body {
  padding: 12px;
  overflow-y: auto;
  max-height: 320px;
}

.terminal-output {
  margin-bottom: 12px;
}

.terminal-output p {
  margin: 0 0 6px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.terminal-output p:last-child {
  margin-bottom: 0;
}

.terminal-output code {
  color: var(--accent);
}

.terminal-input-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-prompt {
  color: var(--accent);
  flex-shrink: 0;
}

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.terminal-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

/* Skills section */
.skills-section {
  margin-bottom: 40px;
}

.skills-section h2,
.skills-section h3 {
  margin: 0 0 16px 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.skills-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.skill-tag {
  display: inline-block;
  padding: 10px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  transition: border-color 0.2s ease, color 0.2s ease;
}

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

/* Subtle geometric background */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, var(--accent-dim) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(212, 133, 74, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, #0a0a0a 100%);
}

.galaxy-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  pointer-events: none;
}

.galaxy-bg canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 100vh;
  max-width: 1100px;
  margin: 0 auto;
}

/* Sidebar */
.sidebar {
  padding: 48px 24px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.brand {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
}

.brand .accent {
  color: var(--accent);
  font-style: italic;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav a.nav-revealable {
  display: none;
}

.nav a.nav-revealable.nav-revealed {
  display: block;
}

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

/* Progress bar */
.sidebar-progress {
  margin-top: 8px;
}

.sidebar-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.sidebar-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.social {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.social a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s ease;
}

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

/* Easter egg — hidden hint */
.easter-egg {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--muted);
  opacity: 0.5;
  z-index: 9997;
  transition: opacity 0.3s ease;
}

.easter-egg:hover {
  opacity: 0.9;
  color: var(--accent);
}

.easter-egg::after {
  content: attr(title);
  position: absolute;
  left: 100%;
  bottom: 50%;
  transform: translateY(50%);
  margin-left: 10px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.easter-egg:hover::after {
  opacity: 1;
}

/* Main content */
.main {
  padding: 48px 40px 64px;
}

.panel {
  padding: 40px 0;
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.6s ease forwards;
}

.panel:last-of-type {
  border-bottom: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Typography */
h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.25rem;
  color: var(--muted);
  margin: 0 0 16px 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* Hero */
.hero {
  padding-top: 24px;
  display: grid;
  grid-template-columns: 1fr auto 60px;
  gap: 32px;
  align-items: center;
}

.hero-photo {
  flex-shrink: 0;
  position: relative;
}

.hero-photo-secret-tooltip {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  white-space: normal;
  max-width: 220px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 100;
}

.hero-photo:hover .hero-photo-secret-tooltip {
  opacity: 1;
}

.hero-photo img {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--accent-dim);
}

.hero-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px 0;
}

.hero h1 {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  margin: 0 0 16px 0;
  line-height: 1.15;
}

.tag {
  color: var(--muted);
  max-width: 42ch;
  margin: 0;
}

.cta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:first-child {
  background: var(--accent);
  color: #0c0c0c;
}

.btn.primary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
}

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

/* 3D blob — interactive */
.blob3d-container {
  width: 180px;
  height: 180px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  cursor: grab;
  pointer-events: auto;
}

.blob3d-container:active {
  cursor: grabbing;
}

body .blob3d-container {
  cursor: grab;
}

.blob3d-container canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 12px;
}

/* About */
.about p {
  color: var(--muted);
  max-width: 55ch;
}

.about-tagline {
  font-style: italic;
  margin-bottom: 0.5em;
}

.about-serious {
  margin-top: 1.25em;
  padding-top: 1.25em;
  border-top: 1px solid var(--border);
  line-height: 1.7;
}

/* Projects */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 8px;
}

.card {
  background: var(--bg-elevated);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

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

.card-num {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--accent);
  display: block;
  margin-bottom: 12px;
}

.card h3 {
  font-size: 1.15rem;
  margin: 0 0 8px 0;
}

.card p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 12px 0;
}

.card-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: gap 0.2s ease;
}

.card-link:hover {
  text-decoration: underline;
}

/* Resume section */
.resume p {
  color: var(--muted);
  margin-bottom: 20px;
}

.resume code {
  font-size: 0.85em;
  padding: 2px 6px;
  background: var(--bg-elevated);
  border-radius: 4px;
  color: var(--accent);
}

.resume-download {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  background: var(--accent);
  color: #0c0c0c;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.resume-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-dim);
}

.resume-icon {
  font-size: 1.2rem;
}

/* Contact */
.contact p {
  color: var(--muted);
}

.contact a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.contact a:hover {
  text-decoration: underline;
}

/* Project detail pages */
.project-main {
  padding-top: 32px;
}

.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 32px;
  transition: color 0.2s ease;
}

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

.project-detail h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  margin: 0 0 24px 0;
}

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

.project-btn {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--accent);
  color: #0c0c0c;
  transition: transform 0.2s ease;
}

.project-btn:hover {
  transform: translateY(-1px);
}

.project-btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
}

.project-description {
  margin-bottom: 40px;
}

.project-description h2 {
  margin-bottom: 12px;
}

.project-description p {
  color: var(--muted);
  max-width: 65ch;
  margin: 0 0 16px 0;
}

.project-description p:last-child {
  margin-bottom: 0;
}

.project-demo h2 {
  margin-bottom: 12px;
}

.demo-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 16px 0;
}

.demo-placeholder {
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 320px;
}

.demo-placeholder img {
  width: 100%;
  height: auto;
  display: block;
}

.demo-fallback {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.demo-fallback code {
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 4px;
}

/* Responsive */
@media (max-width: 768px) {
  .app-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 20px 24px;
    gap: 20px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    order: 3;
    width: 100%;
  }

  .social {
    margin-top: 0;
    margin-left: auto;
    flex-direction: row;
  }

  .main {
    padding: 32px 24px 48px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .hero-photo {
    order: -1;
  }

  .hero-photo img {
    width: 140px;
    height: 140px;
  }

  .blob3d-container {
    width: 140px;
    height: 140px;
    order: -1;
    justify-self: center;
  }

  .panel {
    padding: 32px 0;
  }

  .terminal-inline .terminal-panel {
    max-width: none;
  }
}

/* ===== Welcome screen (first visit) ===== */
body.welcome-active > *:not(.welcome-screen) {
  visibility: hidden;
  pointer-events: none;
}

.welcome-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
  background: var(--bg);
}

.welcome-screen.welcome-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.welcome-aurora {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.welcome-aurora canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.welcome-target-cursor {
  position: fixed;
  width: 32px;
  height: 32px;
  left: 0;
  top: 0;
  margin-left: 0;
  margin-top: 0;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
  transition: transform 0.2s ease, width 0.2s ease, height 0.2s ease, border-color 0.2s ease;
}

.welcome-target-cursor.welcome-cursor-hover {
  width: 48px;
  height: 48px;
  border-color: var(--accent);
  border-width: 2px;
}

body.welcome-active,
body.welcome-active * {
  cursor: none !important;
}

.welcome-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 48px 32px;
  max-width: 420px;
}

.welcome-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 400;
  margin: 0 0 8px;
  color: var(--text);
}

.welcome-subtitle {
  color: var(--muted);
  font-size: 1rem;
  margin: 0 0 32px;
}

.welcome-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

@media (min-width: 480px) {
  .welcome-buttons {
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
  }
}

.welcome-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, background 0.25s ease;
  animation: welcome-btn-float 3s ease-in-out infinite;
}

.welcome-btn:nth-child(2) {
  animation-delay: 0.5s;
}

.welcome-btn:hover {
  animation: none;
  transform: scale(1.05);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
}

.welcome-btn:active {
  transform: scale(0.98);
}

.welcome-btn-stars {
  --welcome-accent: var(--accent);
  border-color: rgba(212, 133, 74, 0.35);
  background: rgba(212, 133, 74, 0.08);
}

.welcome-btn-stars:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 32px var(--accent-dim);
}

.welcome-btn-plain {
  --welcome-accent: var(--muted);
}

@keyframes welcome-btn-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ===== Home tutorial (first visit) ===== */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: auto;
}

.tutorial-tooltip {
  position: fixed;
  left: 50%;
  top: 50%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(18, 18, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.tutorial-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  margin-bottom: 6px;
}

.tutorial-text {
  color: var(--muted);
  font-size: 0.95rem;
}

.tutorial-controls {
  position: relative;
  left: auto;
  bottom: auto;
  right: auto;
  transform: none;
  display: flex;
  justify-content: center;
  width: 100%;
  gap: 12px;
  pointer-events: auto;
  margin-top: 12px;
}

.tutorial-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tutorial-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.20);
  background: rgba(255, 255, 255, 0.09);
}

.tutorial-highlight {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
  border-radius: 12px;
  box-shadow: 0 0 0 6px rgba(212, 133, 74, 0.14);
}
