@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Inter:wght@300;400;500;600;700&display=swap');

:root, [data-theme="light"] {
  --bg: #fcfcfc;
  --bg-subtle: #f4f4f5;
  --border: #e4e4e7;
  --border-hover: #a1a1aa;
  --text: #18181b;
  --text-muted: #71717a;
  --text-subtle: #a1a1aa;
  --accent: #2563eb;
  --accent-light: rgba(37, 99, 235, 0.08);
  --code-bg: #f4f4f5;
  --tag-bg: #f4f4f5;
  --status-green: #10b981;
  --card-bg: #ffffff;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', 'Courier New', monospace;
}

[data-theme="dark"] {
  --bg: #09090b;
  --bg-subtle: #141417;
  --border: #27272a;
  --border-hover: #52525b;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-subtle: #71717a;
  --accent: #3b82f6;
  --accent-light: rgba(59, 130, 246, 0.12);
  --code-bg: #18181b;
  --tag-bg: #18181b;
  --status-green: #10b981;
  --card-bg: #0f0f12;
}

/* Fallback: if JS hasn't set data-theme yet, use OS preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090b;
    --bg-subtle: #141417;
    --border: #27272a;
    --border-hover: #52525b;
    --text: #f4f4f5;
    --text-muted: #a1a1aa;
    --text-subtle: #71717a;
    --accent: #3b82f6;
    --accent-light: rgba(59, 130, 246, 0.12);
    --code-bg: #18181b;
    --tag-bg: #18181b;
    --status-green: #10b981;
    --card-bg: #0f0f12;
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  transition: background-color 0.25s ease, color 0.25s ease;
  -webkit-font-smoothing: antialiased;
}

/* Container */
.lab-container {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header Navbar */
.lab-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  backdrop-filter: blur(12px);
  opacity: 0.98;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.lab-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.lab-brand {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lab-brand:hover {
  color: var(--accent);
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: var(--status-green);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
  list-style: none;
}

@media (max-width: 768px) {
  .nav-links {
    gap: 10px;
    font-size: 0.75rem;
  }
}

.nav-link-item {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

.theme-toggle-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Sections */
.lab-section {
  padding: 56px 0;
  border-bottom: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-subtle);
}

/* Hero Section */
.hero-section {
  padding-top: 120px;
  padding-bottom: 48px;
}

.hero-meta {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 12px;
}

.hero-title {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 16px;
}

.hero-bio {
  font-size: 1.02rem;
  color: var(--text-muted);
  max-width: 680px;
  margin-bottom: 28px;
  line-height: 1.6;
}

.hero-bio strong {
  color: var(--text);
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mono-btn {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mono-btn:hover {
  border-color: var(--border-hover);
  background: var(--bg-subtle);
  color: var(--accent);
  transform: translateY(-1px);
}

.mono-btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.mono-btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* Cards & Grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 20px;
}

@media (max-width: 576px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

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

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 12px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.card-title a {
  color: var(--text);
  text-decoration: none;
}

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

.card-subtitle {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
  margin-bottom: 12px;
}

.card-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

.card-desc ul {
  padding-left: 18px;
  margin-top: 6px;
}

.card-desc li {
  margin-bottom: 4px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mono-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--tag-bg);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 4px;
}

/* Metrics Terminal Box */
.terminal-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}

.terminal-header {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}

.metric-row:last-child {
  border-bottom: none;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--text);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
}

/* Article List */
.article-list {
  display: flex;
  flex-direction: column;
}

.article-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: padding-left 0.2s ease;
}

.article-item:last-child {
  border-bottom: none;
}

.article-item:hover {
  padding-left: 6px;
}

.article-title {
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--text);
  transition: color 0.2s ease;
}

.article-item:hover .article-title {
  color: var(--accent);
}

.article-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-subtle);
}

/* Footer */
.lab-footer {
  padding: 48px 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text);
}

/* Profile Photo & Hero Wrap */
.hero-profile-layout {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 24px;
}

.profile-photo-lab {
  width: 130px;
  height: 130px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.profile-photo-lab:hover {
  transform: scale(1.03);
  border-color: var(--accent);
}

@media (max-width: 576px) {
  .hero-profile-layout {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 16px;
  }
  .profile-photo-lab {
    width: 100px;
    height: 100px;
  }
}

/* ===== ISOTOPIC LAB SIGNATURE UI ENHANCEMENTS ===== */

/* 1. Subtle Engineering Grid Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.4;
  pointer-events: none;
  z-index: -1;
}

/* 2. Command Palette (Ctrl+K) Modal */
.cmd-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.cmd-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.cmd-modal {
  width: 100%;
  max-width: 560px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  font-family: var(--font-mono);
}

.cmd-input-wrap {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.cmd-prompt {
  color: var(--accent);
  margin-right: 10px;
  font-weight: 600;
}

.cmd-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.cmd-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px 0;
}

.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.cmd-item:hover, .cmd-item.selected {
  background: var(--accent-light);
  color: var(--accent);
}

.cmd-key {
  font-size: 0.72rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-subtle);
}

.cmd-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-subtle);
  display: flex;
  justify-content: space-between;
}

/* 3. Tech Tag Hover Tooltip */
.mono-tag[data-tooltip] {
  position: relative;
  cursor: help;
}

.mono-tag[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #18181b;
  color: #f4f4f5;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.18s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 100;
  border: 1px solid #3f3f46;
}

[data-theme="light"] .mono-tag[data-tooltip]::after {
  background: #18181b;
  color: #ffffff;
}

.mono-tag[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 4. Click-to-Copy Email Toast */
.copy-toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--card-bg);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 10px 18px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 3000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.copy-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.copy-clickable {
  cursor: pointer;
  transition: color 0.2s ease;
}

.copy-clickable:hover {
  color: var(--accent);
}

/* ===== DEDICATED MOBILE PHONE OPTIMIZATIONS (< 768px) ===== */
@media (max-width: 768px) {
  /* Container & Section Spacing */
  .lab-container {
    padding: 0 16px;
  }
  
  .lab-section {
    padding: 40px 0;
  }

  /* Compact Mobile Header Navbar */
  .lab-nav-inner {
    height: 56px;
  }

  .lab-brand {
    font-size: 0.88rem;
  }

  .nav-links {
    gap: 8px;
  }

  .nav-link-item {
    font-size: 0.75rem;
    padding: 4px 6px;
  }

  /* Hide minor navbar items on mobile to prevent overflow */
  .nav-link-item[href="#writing"],
  .nav-link-item[href="#achievements"] {
    display: none;
  }

  /* Hero Section Mobile Styling */
  .hero-section {
    padding-top: 96px;
    padding-bottom: 32px;
  }

  .hero-title {
    font-size: 1.75rem;
    line-height: 1.25;
  }

  .hero-bio {
    font-size: 0.95rem;
    margin-bottom: 20px;
  }

  .quick-links {
    gap: 8px;
  }

  .mono-btn {
    font-size: 0.78rem;
    padding: 6px 12px;
  }

  /* Single Column Cards for Mobile */
  .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  .lab-card {
    padding: 18px;
    border-radius: 8px;
  }

  .card-title {
    font-size: 0.98rem;
  }

  .card-desc {
    font-size: 0.88rem;
    line-height: 1.5;
  }

  /* Terminal Box Mobile Padding */
  .terminal-box {
    padding: 16px;
  }

  .metric-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 8px 0;
  }

  .metric-value {
    font-size: 0.82rem;
  }

  /* Mobile Command Palette Modal */
  .cmd-backdrop {
    padding-top: 40px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .cmd-modal {
    max-width: 100%;
  }

  .cmd-input-wrap {
    padding: 12px;
  }

  .cmd-item {
    padding: 12px 14px;
    font-size: 0.82rem;
  }

  /* Mobile Copy Toast */
  .copy-toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    text-align: center;
    font-size: 0.78rem;
  }
}

/* Extra Small Phones (< 480px) */
@media (max-width: 480px) {
  .nav-link-item[href="#academics"] {
    display: none;
  }
  
  .hero-title {
    font-size: 1.5rem;
  }
}
