/* Removed Google Fonts @import to avoid double-loading; font is linked in index.html */

:root {
    /* Light theme (default) */
    --bg: #f8f9fb;
    --card: #ffffff;
    --muted: #4b5563;
    --text: #0f172a;
    --blue: #2563eb; /* retained for any future use */
    --link: #2563eb; /* darker link color (light) */
    --link-visited: #1e40af; /* darker visited color (light) */
    --chip-bg: rgba(15, 23, 42, 0.04);
    --border: rgba(15, 23, 42, 0.08);
    --shadow: 0 2px 8px rgba(15,23,42,0.05);
    --nav-link-hover: rgba(2,6,23,0.04);
    --pub-link-bg: rgba(2,6,23,0.04);
    --focus: rgba(37, 99, 235, 0.35);
}

/* Dark theme overrides */
:root[data-theme="dark"] {
    --bg: #0c1016;
    --card: #0f141b;
    --muted: #9aa4b2;
    --text: #e6e8eb;
    --blue: #3b82f6; /* retained for any future use */
    --link: #c9e1ff; /* slightly brighter link color (dark) */
    --link-visited: #a6c9ff; /* slightly brighter visited color (dark) */
    --chip-bg: rgba(255,255,255,0.04);
    --border: rgba(230, 232, 235, 0.10);
    --shadow: 0 2px 10px rgba(0,0,0,0.25);
    --nav-link-hover: rgba(255,255,255,0.06);
    --pub-link-bg: rgba(255,255,255,0.06);
    --focus: rgba(59, 130, 246, 0.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
    line-height: 1.7;
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    transition: background 0.25s ease, color 0.25s ease;
}

.container { max-width: 920px; margin: 48px auto 72px; padding: 0 24px; }

/* Header */
header {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    padding: 24px 22px;
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.header-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "text avatar";
  gap: 24px;
  align-items: center;
}
.header-text { 
  grid-area: text; 
  padding-right: 8px;
}

header h1 { margin: 0 0 8px 0; font-size: clamp(2rem, 4vw, 2.6rem); letter-spacing: -0.02em; }

/* Floating theme toggle (outside boxes) — refined */
.theme-toggle {
  position: fixed;
  top: clamp(10px, env(safe-area-inset-top) + 12px, 24px);
  right: clamp(10px, env(safe-area-inset-right) + 12px, 24px);
  z-index: 1000;
  width: 48px; height: 48px; /* slightly larger */
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  padding: 0; line-height: 0; /* prevent inner spacing */
  display: inline-block; /* no flex smush */
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease;
}
.theme-toggle:hover { background: var(--pub-link-bg); }
.theme-toggle:active { transform: translateY(1px); }
.theme-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Overlap icons; only one visible at a time */
.theme-toggle .icon {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 24px; height: 24px;
  stroke: currentColor; fill: none; opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
}
.theme-toggle .icon *, .theme-toggle .icon path { vector-effect: non-scaling-stroke; }
.theme-toggle .sun { opacity: 1; }
:root[data-theme="dark"] .theme-toggle .sun { opacity: 0; }
:root[data-theme="dark"] .theme-toggle .moon { opacity: 1; }

@media (max-width: 640px) {
  .theme-toggle { width: 46px; height: 46px; right: 14px; top: 14px; }
  .theme-toggle .icon { width: 22px; height: 22px; }
}

/* Chips + email */
.contact-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 11px; border-radius: 999px; background: var(--chip-bg);
    border: 1px solid var(--border); color: var(--text); text-decoration: none;
    font-weight: 600; font-size: 0.92rem; transition: background 0.2s ease, border-color 0.2s ease, transform 0.06s ease;
}
.chip:hover { background: var(--pub-link-bg); border-color: var(--border); }
.chip:active { transform: translateY(1px); }
.email-line { margin-top: 8px; color: var(--muted); }

/* Avatar visibility and sizing */
.avatar {
  grid-area: avatar;
  justify-self: end;
  width: clamp(128px, 18vw, 176px);
  height: clamp(128px, 18vw, 176px);
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 42%;
  border: 1px solid var(--border);
  display: block;
  margin-left: 8px;
}

/* Sections (softer cards) */
section { background: var(--card); border: 1px solid var(--border); padding: 18px; margin-top: 14px; border-radius: 12px; box-shadow: none; }

h2 { margin: 0 0 10px 0; font-size: 1.2rem; }

p { margin: 0; }

/* Paragraph rhythm in sections */
section p + p { margin-top: 10px; }

@media (min-width: 641px) {
  section p + p { margin-top: 14px; }
}

/* Publications */
.publications-list .publication { padding: 14px 0; border-bottom: 1px dashed var(--border); }
.publications-list .publication:last-child { border-bottom: none; }
.publications-list .publication-title { font-weight: 700; font-size: 1.02rem; margin: 0 0 6px 0; }
.publications-list .publication-authors { color: var(--muted); margin: 0 0 6px 0; }
.publications-list .publication-venue { color: var(--muted); margin: 0 0 10px 0; }
.publications-list .publication-links a { color: var(--text); text-decoration: none; margin-right: 12px; font-weight: 600; background: var(--pub-link-bg); padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); transition: background 0.15s ease, border-color 0.15s ease; }
.publications-list .publication-links a:hover { background: var(--nav-link-hover); }

/* Footer */
footer { text-align: center; padding: 28px 20px; margin-top: 18px; color: var(--muted); }

/* Inline links (hover-only underline, subtle) */
/* Override previous link styles */
a:not(.chip):not(.publication-links a) {
  color: var(--link);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 2px;
  transition: background-size 150ms ease, color 150ms ease;
}

a:not(.chip):not(.publication-links a):hover { background-size: 100% 2px; }

a:not(.chip):not(.publication-links a):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  background-size: 100% 2px;
}

a:not(.chip):not(.publication-links a):visited { color: var(--link-visited); }

/* Name row with pronouns badge */
.name-row {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.pronouns-badge {
  align-self: center;
  font-size: 0.9rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 999px;
  line-height: 1;
  background: transparent;
}

@media (max-width: 640px) {
  .header-inner { 
    grid-template-columns: 1fr; 
    grid-template-areas: "avatar" "text"; 
    gap: 16px; 
    text-align: center;
  }
  .header-text { text-align: center; }
  .contact-chips { justify-content: center; }
  .email-line { text-align: center; }
  .avatar { justify-self: center; margin: 4px auto 0; }
  .name-row { justify-content: center; gap: 8px; }
}
