:root {
  --bg: #1a1714;
  --surface: #2a2520;
  --stone: #3d3630;
  --text: #e8e3d9;
  --accent: #d48a5a;
  --accent-hover: #e8a06e;
  --glow: rgba(212, 138, 90, 0.3);
  --font-heading: 'Bebas Neue', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  overflow-x: hidden;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  background: var(--surface);
  border-bottom: 2px solid var(--stone);
}
.logo { font-family: var(--font-heading); font-size: 1.8rem; letter-spacing: 2px; }
.nav a {
  color: var(--text);
  text-decoration: none;
  margin-left: 1.5rem;
  font-weight: 500;
  transition: color 0.2s;
}
.nav a:hover { color: var(--accent); }

/* === BIO SECTION === */
.bio-section {
  position: relative;
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  overflow: hidden;
}

/* Background Image */
.bio-bg {
  position: absolute;
  inset: 0;
  background-image: url('assets/cave-bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 1;
  transition: filter 0.4s ease;
  image-rendering: pixelated;
}

/* Torch Hotspots (invisible trigger zones) */
.torch-hotspot {
  position: absolute;
  width: 18%;
  height: 22%;
  z-index: 3;
  cursor: pointer;
}

/* When any torch is hovered, brighten the background */
.torch-hotspot:hover ~ .bio-bg {
  filter: brightness(1.12) contrast(1.05) saturate(1.05);
}

/* Enhanced Fireplace Flicker */
.flicker-overlay {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at 50% 65%, rgba(212, 138, 90, 0.4), transparent 50%),
    radial-gradient(circle at 48% 68%, rgba(255, 165, 0, 0.25), transparent 40%);
  mix-blend-mode: screen;
  z-index: 2;
  animation: flicker-fire 3.5s infinite alternate ease-in-out;
  pointer-events: none;
}

@keyframes flicker-fire {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  15% { opacity: 1; transform: scale(1.02); }
  30% { opacity: 0.8; transform: scale(0.98); }
  50% { opacity: 0.95; transform: scale(1.01); }
  70% { opacity: 0.85; transform: scale(0.99); }
  85% { opacity: 0.9; transform: scale(1.03); }
}

/* Text Container */
.bio-content {
  position: relative;
  z-index: 4;
  background: rgba(26, 23, 20, 0.75);
  padding: 2rem 2.5rem;
  border-radius: 12px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  max-width: 680px;
  text-align: center;
}
.bio-content h2, .bio-content p, .bio-content .tag {
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}

/* === AI GLITCH LINK === */
.ai-link-section {
  padding: 3rem 2rem;
  text-align: center;
  background: var(--bg);
}

.ai-glitch-link {
  position: relative;
  display: inline-block;
  padding: 1rem 2.5rem;
  background: #0a0a0a;
  color: #00ff41;
  border: 2px solid #00ff41;
  text-decoration: none;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  letter-spacing: 2px;
  overflow: hidden;
  transition: all 0.3s;
  z-index: 10;
}

/* Scanlines */
.ai-glitch-link::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 65, 0.04) 2px,
    rgba(0, 255, 65, 0.04) 4px
  );
  z-index: 1;
  pointer-events: none;
}

/* CRT Tear / Glitch layers */
.ai-glitch-link::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(0, 255, 65, 0.15) 50%, transparent 100%);
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s;
}

.ai-glitch-link:hover {
  animation: crt-glitch 0.4s infinite;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.6), 2px 0 #ff0040, -2px 0 #00ffff;
}
.ai-glitch-link:hover::after { opacity: 1; }

@keyframes crt-glitch {
  0% { transform: translate(0); clip-path: inset(0 0 0 0); filter: contrast(1); }
  10% { transform: translate(-1px, 1px); clip-path: inset(20% 0 60% 0); filter: contrast(1.2); }
  20% { transform: translate(1px, -1px); clip-path: inset(60% 0 10% 0); filter: contrast(0.9); }
  30% { transform: translate(-2px, 0); clip-path: inset(40% 0 40% 0); filter: contrast(1.1); }
  40% { transform: translate(2px, 1px); clip-path: inset(10% 0 70% 0); filter: contrast(1); }
  50% { transform: translate(0); clip-path: inset(0 0 0 0); filter: contrast(1); }
  100% { transform: translate(0); clip-path: inset(0 0 0 0); filter: contrast(1); }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .flicker-overlay { animation: none; opacity: 0.8; }
  .ai-glitch-link:hover { animation: none; text-shadow: 0 0 8px rgba(0, 255, 65, 0.4); }
}

/* Mobile */
@media (max-width: 768px) {
  .bio-section { min-height: 60vh; padding: 1.5rem 1rem; }
  .bio-content { padding: 1.5rem; max-width: 90%; }
  .bio-content h2 { font-size: 2.2rem; }
  .bio-bg { background-position: 60% 50%; }
  .torch-hotspot { width: 20%; height: 25%; }
}


@keyframes flicker {
  0%, 100% { opacity: 0.8; filter: brightness(1); }
  25% { opacity: 1; filter: brightness(1.08); }
  50% { opacity: 0.85; filter: brightness(0.95); }
  75% { opacity: 0.95; filter: brightness(1.05); }
}

/* Readable text container */
.bio-content {
  position: relative;
  z-index: 2;
  background: rgba(26, 23, 20, 0.7);
  padding: 2rem 2.5rem;
  border-radius: 12px;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  max-width: 680px;
  text-align: center;
}

/* Ensure text pops */
.bio-content h2,
.bio-content p,
.bio-content .tag {
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.65);
}

/* Accessibility: disable flicker if user prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  .flicker-overlay {
    animation: none;
    opacity: 0.8;
  }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .bio-section { min-height: 60vh; padding: 1.5rem 1rem; }
  .bio-content { padding: 1.5rem; max-width: 90%; }
  .bio-content h2 { font-size: 2.2rem; }
  /* Shift background slightly so key details aren't cropped */
  .bio-bg { background-position: 60% 50%; }
}

.tag {
  display: inline-block;
  background: var(--stone);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.bio-content h2 {
  font-family: var(--font-heading);
  font-size: 3.5rem;
  line-height: 1.1;
  margin-bottom: 1rem;
  color: var(--accent);
}
.bio-content p { font-size: 1.1rem; opacity: 0.9; }

.projects-section {
  padding: 4rem 2rem;
  background: var(--surface);
}
.section-title {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 3rem;
  color: var(--accent);
}
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
}
.project-card {
  background: var(--stone);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
  transition: transform 0.3s, box-shadow 0.3s;
}
.project-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}
.project-card h3 { font-family: var(--font-heading); font-size: 1.6rem; margin-bottom: 0.5rem; }
.project-card p { font-size: 0.95rem; opacity: 0.85; margin-bottom: 1rem; }
.project-card a {
  display: inline-block;
  background: var(--accent);
  color: var(--bg);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s;
}
.project-card a:hover { background: var(--accent-hover); }

.ai-link-section {
  padding: 3rem 2rem;
  text-align: center;
  background: var(--bg);
}
.ai-link:hover { border-color: var(--accent-hover); }
.ai-text {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  display: block;
  margin-bottom: 0.3rem;
  position: relative;
}
.ai-sub { font-size: 0.9rem; opacity: 0.8; }

/* Glitch effect */
.ai-link:hover .ai-text {
  animation: glitch 0.4s infinite;
  color: var(--accent);
}
@keyframes glitch {
  0% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(2px, -2px); }
  60% { transform: translate(-1px, -1px); }
  80% { transform: translate(1px, 1px); }
  100% { transform: translate(0); }
}

.contact-section {
  padding: 4rem 2rem;
  background: var(--surface);
}
.contact-form {
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.contact-form input,
.contact-form textarea {
  padding: 0.8rem;
  border: 1px solid var(--stone);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}
.contact-form textarea { min-height: 120px; resize: vertical; }
.submit-btn {
  padding: 0.8rem 1.5rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.submit-btn:hover { background: var(--accent-hover); }

.site-footer {
  padding: 2rem;
  text-align: center;
  background: var(--bg);
  border-top: 1px solid var(--stone);
}
.social-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.social-links a { color: var(--text); opacity: 0.7; transition: opacity 0.2s; }
.social-links a:hover { opacity: 1; color: var(--accent); }
.copyright { font-size: 0.85rem; opacity: 0.6; }

@media (max-width: 768px) {
  .bio-content h2 { font-size: 2.5rem; }
  .section-title { font-size: 2rem; }
  .site-header { flex-direction: column; gap: 1rem; }
  .nav a { margin: 0 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
