/* --- 1. DESIGN TOKENS (DEFAULT: DARK THEME) --- */
:root {
  --bg-body: #0b0f19;
  --bg-card: #111827;
  --bg-subtle: #1e293b;
  --bg-nav: rgba(17, 24, 39, 0.94);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #60a5fa;
  --accent-strong: #2563eb;
  --accent-light: rgba(96, 165, 250, 0.12);
  --border: #1f2937;
  --max-width: 880px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

/* --- LIGHT THEME OVERRIDES --- */
body.light-theme {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-nav: rgba(255, 255, 255, 0.95);
  --text-main: #0f172a;
  --text-muted: #475569;
  --accent: #1e3a8a;
  --accent-strong: #1e3a8a;
  --accent-light: #eff6ff;
  --border: #e2e8f0;
}

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

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

.hidden { display: none !important; }

/* --- 2. TOP NAVIGATION (DESKTOP & COMPACT MOBILE MENU) --- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-nav);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease;
}
.top-nav.nav-hidden {
  transform: translateY(-100%);
}
.nav-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.65rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Desktop navigation order: links on left, controls on right */
.nav-links {
  order: 1;
  display: flex;
  gap: 1rem;
  list-style: none;
  font-size: 0.85rem;
  font-weight: 500;
  flex-wrap: wrap;
}
.nav-controls {
  order: 2;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Mobile Hamburger Button (Hidden on Desktop) */
.btn-menu {
  display: none;
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-menu:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.btn-toggle {
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-toggle:hover, .btn-toggle.active {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-toggle.active {
  background: var(--accent-strong);
  color: #fff;
  border-color: var(--accent-strong);
}

.btn-print, .vault-link {
  background: var(--accent-strong);
  color: #fff;
  border: 1px solid var(--accent-strong);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn-print:hover, .vault-link:hover { opacity: 0.9; }

/* --- 3. MAIN DOCUMENT CARD --- */
main {
  max-width: var(--max-width);
  margin: 2rem auto;
  background: var(--bg-card);
  padding: 2.75rem 3rem;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
}

/* --- 4. HEADER & PROFILE PHOTO --- */
.cv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  padding-bottom: 1.75rem;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 1.75rem;
}
.cv-title h1 { font-size: 2rem; letter-spacing: -0.02em; line-height: 1.2; }
.cv-title .subtitle { font-size: 1.05rem; color: var(--accent); font-weight: 600; margin-top: 0.25rem; }
.executive-summary { margin-top: 0.65rem; font-size: 0.92rem; color: var(--text-muted); max-width: 65ch; }

.contact-bar {
  margin-top: 0.85rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
}
.contact-bar a { color: var(--accent); text-decoration: none; font-weight: 500; }
.contact-bar a:hover { text-decoration: underline; }

.email-slot a {
  color: var(--accent-color, #4da6ff); /* Fallback to light blue if variables aren't used */
  text-decoration: none;
}

.email-slot a:hover { text-decoration: underline; }

.reveal-btn {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px dashed var(--accent);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
}
.reveal-btn:hover { opacity: 0.85; }

.profile-img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: #fff;
  padding: 3px;
  flex-shrink: 0;
}
body.hide-photo .profile-img { display: none !important; }

/* --- 5. SECTIONS, TIMELINE & LINKS --- */
section { margin-bottom: 2.1rem; }
h2 {
  font-size: 1.02rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
  margin-bottom: 1.1rem;
}
.legal-page h2 { text-transform: none; letter-spacing: normal; border: none; margin-top: 1.5rem; margin-bottom: 0.4rem; }
.legal-page p { margin-bottom: 0.75rem; font-size: 0.94rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

.cv-entry {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.4rem 1.5rem;
  margin-bottom: 1.2rem;
}
.cv-date { font-size: 0.86rem; color: var(--text-muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.pub-status { font-size: 0.75rem; color: var(--accent); font-weight: 500; }
.cv-details h3 { font-size: 0.98rem; font-weight: 600; }
.cv-details .institution { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 0.3rem; }

/* Subtle Institution & Inline Links */
.cv-details a {
  color: var(--accent);
  text-decoration: none;
}
.cv-details .institution a {
  color: var(--text-muted);
  border-bottom: 1px dotted var(--text-muted);
  transition: color 0.15s, border-color 0.15s;
}
.cv-details .institution a:hover,
.cv-details a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.cv-details ul { padding-left: 1.1rem; font-size: 0.92rem; }
.cv-details li { margin-bottom: 0.25rem; }
.cv-details p { font-size: 0.92rem; }

.ref-list { list-style: none; padding-left: 0 !important; }
.ref-list li { margin-bottom: 0.4rem; }

/* Action Buttons (DOI & PDF Download) */
.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.45rem;
}
.btn-pub {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none !important;
  transition: opacity 0.15s;
}
.btn-doi {
  background: var(--accent-light);
  color: var(--accent) !important;
  border: 1px solid var(--accent);
}
.btn-pdf {
  background: var(--bg-subtle);
  color: var(--text-main) !important;
  border: 1px solid var(--border);
}
.btn-pub:hover { opacity: 0.85; }

/* --- 6. VAULT & FOOTER --- */
.vault-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.vault-info p { font-size: 0.88rem; color: var(--text-muted); }

footer {
  max-width: var(--max-width);
  margin: 0 auto 3rem;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--text-muted);
}
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--accent); }

/* --- 7. MOBILE VIEWPORT (FLOATING DROPDOWN OVERLAY) --- */
@media (max-width: 680px) {
  .nav-container {
    padding: 0.55rem 1rem;
    position: relative;
  }
  .btn-menu {
    display: inline-flex;
    align-items: center;
    order: 1;
  }
  .nav-controls {
    order: 2;
  }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 2px solid var(--accent);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
    flex-direction: column;
    gap: 0;
    padding: 0.35rem 1rem 0.6rem;
    z-index: 101;
  }
  .nav-links.open {
    display: flex;
  }
  .nav-links li a {
    display: block;
    padding: 0.55rem 0.25rem;
    font-size: 0.92rem;
    border-bottom: 1px solid var(--border);
  }
  .nav-links li:last-child a {
    border-bottom: none;
  }

  main { padding: 1.35rem 1.15rem; margin: 0; border-radius: 0; border: none; }
  .cv-header { flex-direction: column-reverse; align-items: flex-start; gap: 0.75rem; padding-bottom: 1.25rem; margin-bottom: 1.25rem; }
  .cv-title h1 { font-size: 1.6rem; }
  .cv-title .subtitle { font-size: 0.95rem; }
  .executive-summary { font-size: 0.88rem; margin-top: 0.45rem; }
  .contact-bar { margin-top: 0.65rem; font-size: 0.84rem; gap: 0.4rem 0.9rem; }
  .profile-img { width: 90px; height: 90px; }
  .cv-entry { grid-template-columns: 1fr; gap: 0.15rem; margin-bottom: 1rem; }
}

.print-only {
  display: none !important;
}

/* --- 8. A4 PRINT ENGINE (ALWAYS FORCES WHITE BACKGROUND & DARK TEXT) --- */
@media print {
  @page { size: A4 portrait; margin: 12mm 15mm; }
  body, body.light-theme {
    --bg-body: #ffffff !important;
    --bg-card: #ffffff !important;
    --bg-subtle: #f8fafc !important;
    --text-main: #000000 !important;
    --text-muted: #334155 !important;
    --accent: #1e3a8a !important;
    --border: #cbd5e1 !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 9.5pt;
    line-height: 1.38;
  }
  .top-nav, footer, .no-print, .btn-pdf {
    display: none !important;
  }
  main {
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: #ffffff !important;
  }
  .cv-header { padding-bottom: 1rem; margin-bottom: 1rem; }
  section { margin-bottom: 1.2rem; }
  .cv-entry {
    grid-template-columns: 95px 1fr !important;
    margin-bottom: 0.7rem;
    break-inside: avoid;
  }
  h2 { break-after: avoid; margin-bottom: 0.55rem; }
  a, .cv-details .institution a {
    color: #000 !important;
    text-decoration: none !important;
    border-bottom: none !important;
  }
  .btn-doi {
    border: none !important;
    background: none !important;
    padding: 0 !important;
    font-weight: normal;
    color: #334155 !important;
  }
  .print-only {
    display: block !important;
  }
  .no-print {
    display: none !important;
  }
}
/* Hidden on the live web version */
#print-link-container {
  display: none;
}

/* Visible only in the A4 print engine */
@media print {
  #print-link-container {
    display: block !important;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #cbd5e1;
    font-size: 8pt;
    line-height: 1.4;
    page-break-inside: avoid;
  }
  #print-link-container h3 {
    font-size: 9pt;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
    color: #1e3a8a !important;
  }
  #print-link-container ul {
    padding-left: 1.2rem;
  }
  #print-link-container li {
    margin-bottom: 0.25rem;
    word-break: break-all;
  }
}
