/* ════════════════════════════════════════════
   BG Portfolio · Style System
   ════════════════════════════════════════════ */

:root {
  /* Teal accent */
  --accent: #2dd4bf;
  --accent-glow: rgba(45,212,191,0.35);
  --accent-dim: rgba(45,212,191,0.12);

  /* Dark theme */
  --bg: #060d18;
  --bg2: #0d1b2a;
  --bg3: #111f35;
  --surface: rgba(13,27,42,0.85);
  --surface2: rgba(17,31,53,0.9);
  --border: rgba(45,212,191,0.15);
  --text: #e8f0fe;
  --text2: #8fa8c8;
  --text3: #4a6280;

  --nav-h: 64px;
  --radius: 16px;
  --radius-sm: 10px;
  --font-head: 'Syne', sans-serif;
  --font-mono: 'Space Mono', monospace;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="light"] {
  --bg: #f0f4ff;
  --bg2: #e4ecf8;
  --bg3: #d8e4f4;
  --surface: rgba(255,255,255,0.85);
  --surface2: rgba(240,244,255,0.95);
  --border: rgba(45,212,191,0.25);
  --text: #0d1b2a;
  --text2: #2a4060;
  --text3: #6080a0;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-head);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.4s, color 0.4s;
}

/* ── Particle Canvas ── */
#particleCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ── Nav ── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 48px);
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(6,13,24,0.7);
  border-bottom: 1px solid var(--border);
  transition: background 0.4s;
}
[data-theme="light"] .nav { background: rgba(240,244,255,0.75); }

.nav-logo {
  font-family: var(--font-head);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
}
.nav-logo .dot { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
}
.nav-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text2);
  text-decoration: none;
  letter-spacing: 0.05em;
  position: relative;
  transition: color var(--transition);
}
.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 0; right: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform var(--transition);
}
.nav-link:hover, .nav-link.active { color: var(--accent); }
.nav-link:hover::after, .nav-link.active::after { transform: scaleX(1); }

.nav-actions { display: flex; align-items: center; gap: 12px; }

.theme-toggle {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
}
.theme-toggle:hover { border-color: var(--accent); transform: scale(1.1); }

/* ── Sections ── */
.section {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding-top: var(--nav-h);
}

/* ── Hero ── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--nav-h) + 40px) clamp(16px,5vw,80px) 60px;
}

.hero-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
  max-width: 1200px;
  width: 100%;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--accent-dim);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 24px;
  width: fit-content;
}

.hero-title {
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -2px;
  margin-bottom: 20px;
}
.hero-title .accent { color: var(--accent); }

.hero-sub {
  font-size: 1rem;
  color: var(--text2);
  line-height: 1.7;
  max-width: 420px;
  margin-bottom: 36px;
  font-weight: 400;
}

.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }

.btn-primary {
  padding: 13px 28px;
  border-radius: 100px;
  background: var(--accent);
  color: #060d18;
  border: none;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--accent-glow);
}

.btn-ghost {
  padding: 13px 28px;
  border-radius: 100px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

/* ── Avatar ── */
.avatar-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 460px;
}

.avatar-glow {
  position: absolute;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  animation: glowPulse 3s ease-in-out infinite;
}
@keyframes glowPulse {
  0%,100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
}

.avatar-orb {
  position: relative;
  width: 280px; height: 380px;
  cursor: none;
  transition: transform 0.1s ease-out;
  will-change: transform;
}

.avatar-inner {
  width: 100%; height: 100%;
  animation: float 4s ease-in-out infinite;
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}

.avatar-svg { width: 100%; height: 100%; filter: drop-shadow(0 20px 40px rgba(45,212,191,0.3)); }

/* Floating badges */
.float-badge {
  position: absolute;
  padding: 6px 14px;
  border-radius: 100px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  backdrop-filter: blur(10px);
  white-space: nowrap;
  animation: floatBadge 3s ease-in-out infinite;
}
.b1 { top: 30px;  left: -20px; animation-delay: 0s; }
.b2 { top: 80px;  right: -30px; animation-delay: 0.8s; }
.b3 { bottom: 100px; left: -40px; animation-delay: 1.5s; }
.b4 { bottom: 60px; right: -20px; animation-delay: 2.2s; }
@keyframes floatBadge {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ── Stats ── */
.stats-row {
  display: flex;
  align-items: center;
  gap: 40px;
  margin-top: 60px;
  padding: 24px 40px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
}
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-num { font-size: 1.8rem; font-weight: 800; color: var(--accent); line-height: 1; }
.stat-label { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text3); margin-top: 4px; letter-spacing: 0.08em; }
.stat-divider { width: 1px; height: 36px; background: var(--border); }

/* ── Projects ── */
.projects-section { background: var(--bg2); padding: 100px clamp(16px,5vw,80px); min-height: auto; }
.section-inner { max-width: 1200px; margin: 0 auto; }
.section-header { margin-bottom: 48px; }
.section-tag { font-family: var(--font-mono); font-size: 0.75rem; color: var(--accent); letter-spacing: 0.12em; }
.section-title { font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; letter-spacing: -1px; margin-top: 8px; }

.projects-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap: 20px; }

.project-card {
  position: relative;
  padding: 32px 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
}
.project-card:hover { border-color: var(--accent); transform: translateY(-4px); }
.project-card.featured { grid-column: span 2; }

.project-glow {
  position: absolute;
  top: -40px; right: -40px;
  width: 150px; height: 150px;
  border-radius: 50%;
  background: var(--accent-glow);
  filter: blur(40px);
  opacity: 0;
  transition: opacity var(--transition);
}
.project-card:hover .project-glow { opacity: 1; }

.project-num { font-family: var(--font-mono); font-size: 0.7rem; color: var(--accent); margin-bottom: 12px; opacity: 0.7; }
.project-info h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 10px; }
.project-info p { font-size: 0.88rem; color: var(--text2); line-height: 1.6; margin-bottom: 16px; }
.project-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.project-tags span {
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--accent-dim);
  border: 1px solid rgba(45,212,191,0.2);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent);
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 32px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text3);
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

/* ══════════ CHAT MODAL ══════════ */
.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  padding: 0 16px 80px;
}
.chat-overlay.open { opacity: 1; pointer-events: all; }

.chat-modal {
  width: 100%;
  max-width: 480px;
  border-radius: 24px 24px 16px 16px;
  border: 1px solid var(--border);
  background: var(--surface2);
  backdrop-filter: blur(20px);
  overflow: hidden;
  transform: translateY(60px);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 -20px 80px rgba(0,0,0,0.5);
}
.chat-overlay.open .chat-modal { transform: translateY(0); }

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.chat-avatar-mini {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  background: #0d1b2a;
}
.chat-avatar-mini svg { width: 100%; height: 100%; }
.online-dot {
  position: absolute;
  bottom: 1px; right: 1px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--surface);
}
.chat-title-wrap { flex: 1; }
.chat-title { display: block; font-weight: 700; font-size: 0.9rem; }
.chat-sub { display: block; font-family: var(--font-mono); font-size: 0.65rem; color: var(--text3); margin-top: 1px; }

.chat-mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg2);
  border-radius: 100px;
  padding: 3px;
}
.mode-btn {
  padding: 5px 12px;
  border-radius: 100px;
  border: none;
  background: transparent;
  color: var(--text3);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.mode-btn.active { background: var(--accent); color: #060d18; font-weight: 700; }

.chat-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.chat-close:hover { background: rgba(255,0,0,0.15); border-color: red; color: red; }

/* ── Chat Messages ── */
.chat-body { display: flex; flex-direction: column; height: 420px; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.msg { display: flex; }
.msg.bot { justify-content: flex-start; }
.msg.user { justify-content: flex-end; }
.msg-bubble {
  max-width: 80%;
  padding: 11px 16px;
  border-radius: 18px;
  font-size: 0.875rem;
  line-height: 1.5;
}
.msg.bot .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px 18px 18px 18px;
}
.msg.user .msg-bubble {
  background: var(--accent);
  color: #060d18;
  font-weight: 600;
  border-radius: 18px 18px 4px 18px;
}
.msg-typing .msg-bubble { padding: 14px 18px; }
.typing-dots { display: flex; gap: 4px; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text3);
  animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); }
  30% { transform: translateY(-6px); background: var(--accent); }
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 10px 18px;
  color: var(--text);
  font-family: var(--font-head);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition);
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text3); }
.chat-send {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #060d18;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.chat-send svg { width: 16px; height: 16px; }
.chat-send:hover { transform: scale(1.1); box-shadow: 0 4px 20px var(--accent-glow); }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Voice Mode ── */
.voice-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 32px 24px;
  height: 420px;
}
.voice-body.hidden { display: none; }
.chat-body.hidden { display: none; }

.voice-visual { position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center; }
.voice-rings { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.vring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: ringExpand 2.4s ease-out infinite;
}
.r1 { width: 120px; height: 120px; animation-delay: 0s; }
.r2 { width: 120px; height: 120px; animation-delay: 0.8s; }
.r3 { width: 120px; height: 120px; animation-delay: 1.6s; }
@keyframes ringExpand {
  0% { transform: scale(0.6); opacity: 0.8; }
  100% { transform: scale(1.8); opacity: 0; }
}
.vring.listening { animation-duration: 1s; }

.voice-mic-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: #060d18;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  z-index: 1;
  box-shadow: 0 0 30px var(--accent-glow);
}
.voice-mic-btn svg { width: 30px; height: 30px; }
.voice-mic-btn:hover { transform: scale(1.1); }
.voice-mic-btn.recording { background: #ef4444; box-shadow: 0 0 30px rgba(239,68,68,0.5); }

.voice-status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-align: center;
}
.voice-transcript {
  font-size: 0.9rem;
  color: var(--text2);
  text-align: center;
  min-height: 40px;
  padding: 0 16px;
  font-style: italic;
}
.voice-reply {
  font-size: 0.88rem;
  color: var(--text);
  text-align: center;
  min-height: 40px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  width: 100%;
  line-height: 1.5;
  display: none;
}

/* ── Chat FAB ── */
.chat-fab {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #060d18;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  box-shadow: 0 4px 30px var(--accent-glow);
  transition: all var(--transition);
}
.chat-fab svg { width: 24px; height: 24px; }
.chat-fab:hover { transform: scale(1.12); }

.fab-pulse {
  position: absolute;
  top: 0; right: 0;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--bg);
  animation: fabPulse 2s ease-in-out infinite;
}
@keyframes fabPulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

/* ── Utilities ── */
.hidden { display: none !important; }
.accent { color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .hero-content { grid-template-columns: 1fr; text-align: center; gap: 40px; }
  .hero-sub { margin: 0 auto 36px; }
  .hero-cta { justify-content: center; }
  .avatar-wrap { height: 340px; order: -1; }
  .avatar-orb { width: 200px; height: 270px; }
  .float-badge { display: none; }
  .stats-row { gap: 20px; padding: 20px 24px; }
  .project-card.featured { grid-column: span 1; }
  .chat-overlay { padding: 0 8px 70px; }
  .nav-links { gap: 16px; }
  .mode-btn { font-size: 0.6rem; padding: 4px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .avatar-inner, .avatar-glow, .float-badge, .vring, .fab-pulse { animation: none; }
}
