/* =====================================================
   ML/AI Portfolio Theme — Tianhao Cao
   Palette: Deep Space · Electric Cyan · Neural Purple
   ===================================================== */

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

/* --- Custom Properties --- */
:root {
  --accent:        #00d4ff;
  --accent-2:      #7c3aed;
  --accent-glow:   rgba(0, 212, 255, 0.18);
  --accent-2-glow: rgba(124, 58, 237, 0.18);
  --bg-base:       #0d1117;
  --bg-surface:    #161b22;
  --bg-card:       #1c2128;
  --border:        rgba(48, 54, 61, 0.9);
  --text:          #e6edf3;
  --text-muted:    #8b949e;
  --radius:        12px;
}

/* --- Base --- */
body {
  background-color: var(--bg-base) !important;
  color: var(--text) !important;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  animation: pageFadeIn 0.6s ease-out;
}

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

/* --- Navbar: Glassmorphism --- */
.navbar {
  background: rgba(13, 17, 23, 0.82) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s ease;
}

.navbar-brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text) !important;
}

.navbar-nav .nav-link {
  position: relative;
  padding-bottom: 4px;
  color: var(--text-muted) !important;
  font-weight: 500;
  transition: color 0.2s ease;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
  color: var(--accent) !important;
}

.navbar-nav .nav-link::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: 0;
  left: 50%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: all 0.3s ease;
  transform: translateX(-50%);
}

.navbar-nav .nav-link:hover::after {
  width: 80%;
}

/* --- Headings --- */
h1 {
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
  font-weight: 700;
}

h2 {
  color: var(--text) !important;
  font-weight: 700;
  padding-bottom: 0.45em;
  margin-bottom: 1.2em;
  position: relative;
}

h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), transparent);
}

h3, h4 {
  color: var(--text) !important;
  font-weight: 600;
}

/* --- Hero name (homepage) --- */
.about-entity h1,
.about-title h1 {
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
  background: none;
  animation: none;
  font-weight: 700;
}

/* --- Cards --- */
.card,
.listing-item {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),
              box-shadow 0.3s ease,
              border-color 0.3s ease;
}

.card:hover,
.listing-item:hover {
  transform: translateY(-6px) scale(1.015);
  box-shadow: 0 8px 32px var(--accent-glow), 0 0 0 1px var(--accent) !important;
  border-color: var(--accent) !important;
}

.card-body,
.card-footer {
  background: var(--bg-card) !important;
}

/* --- Category / Badge Tags --- */
.badge,
.listing-category,
.quarto-category {
  background: var(--bg-surface) !important;
  color: var(--accent) !important;
  border: 1px solid rgba(0, 212, 255, 0.3) !important;
  border-radius: 20px !important;
  font-size: 0.71rem !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-weight: 500 !important;
  padding: 3px 10px !important;
  transition: all 0.2s ease;
}

.badge:hover,
.listing-category:hover {
  background: rgba(0, 212, 255, 0.12) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* --- Buttons --- */
.btn,
.btn-primary,
.btn-outline-primary {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  background: transparent !important;
  border-radius: 8px !important;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all 0.25s ease;
}

.btn:hover,
.btn-primary:hover,
.btn-outline-primary:hover {
  background: var(--accent) !important;
  color: var(--bg-base) !important;
  box-shadow: 0 0 20px var(--accent-glow);
  transform: scale(1.04);
}

/* --- Tables --- */
table {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border) !important;
  width: 100%;
}

thead tr {
  background: var(--bg-surface) !important;
}

th {
  color: var(--accent) !important;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.75rem 1rem !important;
  border-bottom: 1px solid var(--border) !important;
}

td {
  color: var(--text) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 0.65rem 1rem !important;
}

tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02) !important;
}

tbody tr:hover td {
  background: var(--bg-surface) !important;
}

/* --- Code / Pre --- */
code,
pre {
  font-family: 'JetBrains Mono', monospace !important;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent) !important;
  font-size: 0.875em;
}

/* --- HR / Dividers --- */
hr {
  border: none !important;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  opacity: 0.35;
  margin: 2rem 0;
}

/* --- Links --- */
a:not(.nav-link):not(.btn):not(.navbar-brand):not(.about-link):not(.listing-item) {
  color: var(--accent) !important;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

a:not(.nav-link):not(.btn):not(.navbar-brand):not(.about-link):not(.listing-item):hover {
  border-bottom-color: var(--accent);
}

/* --- TOC Sidebar --- */
#TOC {
  border-left: 2px solid var(--accent);
  padding-left: 1rem;
  font-size: 0.875rem;
}

#TOC a {
  color: var(--text-muted) !important;
  border-bottom: none !important;
  transition: color 0.2s ease;
}

#TOC a:hover,
#TOC a.active {
  color: var(--accent) !important;
}

/* --- Title Banner (Projects / Resume pages) --- */
.quarto-title-banner {
  background: linear-gradient(135deg, var(--bg-base) 60%, var(--bg-surface)) !important;
  border-bottom: 1px solid var(--border);
}

/* --- About / Profile image --- */
.about-image img {
  border: 3px solid var(--accent) !important;
  box-shadow: 0 0 30px var(--accent-glow), 0 0 60px var(--accent-2-glow);
  border-radius: 50% !important;
  transition: box-shadow 0.4s ease;
}

.about-image img:hover {
  box-shadow: 0 0 40px var(--accent-glow), 0 0 80px var(--accent-2-glow);
}

/* --- About page social/action links --- */
.about-links .about-link {
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  color: var(--text-muted) !important;
  transition: all 0.25s ease;
  background: var(--bg-surface) !important;
}

.about-links .about-link:hover {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  box-shadow: 0 0 14px var(--accent-glow);
  transform: translateY(-2px);
}

/* --- Inline bold/strong accent --- */
strong {
  color: var(--text) !important;
  font-weight: 600;
}

/* --- Blockquotes --- */
blockquote {
  border-left: 3px solid var(--accent);
  background: var(--bg-surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.8rem 1.2rem;
  color: var(--text-muted);
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--accent), var(--accent-2));
  border-radius: 3px;
}

/* --- Selection highlight --- */
::selection {
  background: rgba(0, 212, 255, 0.22);
  color: var(--text);
}

/* --- AOS overrides (ensure dark bg during animation) --- */
[data-aos] {
  background: transparent;
}

/* =======================================================
   BUG FIXES
   ======================================================= */

/* Fix 1 — 移动端头像过大 */
@media (max-width: 768px) {
  .about-image img,
  .about-entity .about-image img {
    max-width: 180px !important;
    max-height: 180px !important;
    width: 180px !important;
    height: 180px !important;
    object-fit: cover;
  }

  /* jolla 模板的首页头像 */
  .about-entity img {
    max-width: 180px !important;
    max-height: 180px !important;
  }
}

/* Fix 2 — 头像白色背景融合深色主题 */
.about-image img,
.about-entity img {
  /* 在圆形裁切下添加阴影覆盖白色硬边 */
  box-shadow: 0 0 0 4px var(--bg-base),
              0 0 30px var(--accent-glow),
              0 0 60px var(--accent-2-glow) !important;
  border: 2px solid var(--accent) !important;
  border-radius: 50% !important;
  background: var(--bg-base);
  /* 柔化照片与背景的边界 */
  filter: contrast(1.02) brightness(0.97);
  transition: box-shadow 0.4s ease, filter 0.4s ease;
}

.about-image img:hover,
.about-entity img:hover {
  box-shadow: 0 0 0 4px var(--bg-base),
              0 0 50px var(--accent-glow),
              0 0 100px var(--accent-2-glow) !important;
  filter: contrast(1.04) brightness(1.02);
}

/* Fix 3 — 提升小字对比度 */
.listing-date,
.listing-subtitle,
.card-subtitle,
.card-text small,
small,
.text-muted,
.quarto-listing-item .metadata {
  color: #adbac7 !important;
}

/* Fix 4 — 首页 CTA 按钮区域（每个独立边框块） */
.hero-cta {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
  padding: 0.5rem 0 1rem;
}

.hero-cta .cta-btn {
  display: inline-block;
  color: var(--text-muted) !important;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius);
  background: var(--bg-surface) !important;
  padding: 0.45rem 1.1rem;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.hero-cta .cta-btn:hover {
  color: var(--text) !important;
  border-color: var(--text-muted) !important;
  background: var(--bg-card) !important;
}

