/* ===== Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;14..32,400;14..32,500;14..32,600;14..32,700&family=Playfair+Display:ital,wght@0,400;0,600;1,400&display=swap');

/* ===== Design Tokens ===== */
:root {
  --bg: #f9f9f8;
  --bg-card: #ffffff;
  --bg-nav: rgba(249, 249, 248, 0.88);
  --text: #111118;
  --text-muted: #71717a;
  --border: #e4e4e7;
  --border-hover: #c4c4c7;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --nav-height: 56px;
}

[data-theme="dark"] {
  --bg: #09090b;
  --bg-card: #18181b;
  --bg-nav: rgba(9, 9, 11, 0.88);
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --border: #27272a;
  --border-hover: #3f3f46;
  --link: #60a5fa;
  --link-hover: #93c5fd;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== Navigation ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--bg-nav);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.nav-brand {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.015em;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.nav-brand:hover {
  color: var(--text);
  text-decoration: none;
  opacity: 0.75;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.125rem;
}

.nav-links a {
  font-size: 0.8125rem;
  font-weight: 450;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.625rem;
  border-radius: var(--radius-xs);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.045);
  text-decoration: none;
}

.nav-links a:visited {
  color: var(--text-muted);
}

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

[data-theme="dark"] .nav-links a:hover {
  background: rgba(255, 255, 255, 0.07);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  padding: 0;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: rgba(0, 0, 0, 0.045);
  border-color: var(--border-hover);
}

[data-theme="dark"] .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.07);
}

/* ===== Main Container ===== */
main.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 2rem 5rem;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  transition: color 0.3s ease;
}

h1 {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
  margin: 2rem 0 0.75rem;
}

h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
  margin: 1.5rem 0 0.5rem;
}

p {
  margin: 0 0 1rem;
  color: var(--text);
  transition: color 0.3s ease;
}

p:last-child {
  margin-bottom: 0;
}

li {
  color: var(--text);
  transition: color 0.3s ease;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:visited {
  color: var(--link);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
  transition: border-color 0.3s ease;
}

sub, sup {
  font-size: 0.75em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
  color: inherit;
}
sub { bottom: -0.25em; }
sup { top: -0.5em; }

code, pre {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.875em;
  background: var(--border);
  color: var(--text);
  border-radius: var(--radius-xs);
  padding: 0.1em 0.35em;
  transition: background 0.3s, color 0.3s;
}

/* ===== Hero (homepage only) ===== */
.hero {
  padding: 4.5rem 0 3.5rem;
  max-width: 620px;
}

.hero-eyebrow {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  opacity: 0;
  animation: heroFadeUp 0.5s ease 0s forwards;
}

.hero-name {
  font-size: clamp(2.5rem, 5vw, 3.75rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--text);
  line-height: 1.05;
  margin: 0 0 1rem;
  opacity: 0;
  animation: heroFadeUp 0.5s ease 0.1s forwards;
}

.hero-tagline {
  font-size: 1.0625rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 1.25rem;
  opacity: 0;
  animation: heroFadeUp 0.5s ease 0.2s forwards;
}

.hero-bio {
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.75;
  margin: 0 0 2rem;
  opacity: 0;
  animation: heroFadeUp 0.5s ease 0.3s forwards;
}

.hero-links {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
  opacity: 0;
  animation: heroFadeUp 0.5s ease 0.4s forwards;
}

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

/* ===== Hero Constellation ===== */
.hero-anim {
  margin: 2rem 0 2.5rem;
  display: flex;
  justify-content: center;
  opacity: 0;
  animation: heroFadeUp 0.5s ease 0s forwards;
}

.c-svg {
  width: 100%;
  max-width: 440px;
  height: auto;
  overflow: visible;
  display: block;
}

/* Outer hexagon frame */
.c-ring-line {
  stroke: var(--text);
  stroke-width: 1.8;
  opacity: 0.6;
  transition: stroke 0.3s, opacity 0.3s;
}

/* Animated dashed spokes */
.c-spoke {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 5;
  animation: cSpokeDash 2.8s linear infinite;
  opacity: 0.38;
  transition: stroke 0.3s;
}

@keyframes cSpokeDash {
  from { stroke-dashoffset: 8; }
  to   { stroke-dashoffset: 0; }
}

/* Center dot */
.c-center {
  fill: var(--text-muted);
  opacity: 0.2;
  transition: fill 0.3s;
}

/* Each node is an SVG <a> — color cascades to all children via currentColor */
.c-node {
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  outline: none;
  transition: color 0.2s;
}

.c-node:hover,
.c-node:focus {
  color: var(--text);
}

/* Node background disc */
.c-node-bg {
  fill: var(--bg-card);
  stroke: var(--border);
  stroke-width: 1.5;
  transition: stroke 0.2s, stroke-width 0.2s;
}

.c-node:hover .c-node-bg,
.c-node:focus .c-node-bg {
  stroke: var(--text-muted);
  stroke-width: 2;
}

/* Radial tiling lines: thin, faint, deform with shape */
.c-ray {
  stroke: var(--text);
  stroke-width: 0.6;
  opacity: 0.15;
  transition: stroke 0.3s;
}

/* Morphing shape outline polygon */
.c-ring-poly {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.8;
  opacity: 0.55;
  transition: stroke 0.3s, opacity 0.3s;
}

/* Materials hexagon spins on its own axis */
.c-hex-spin {
  transform-box: fill-box;
  transform-origin: center;
  animation: hexSpin 10s linear infinite;
}

@keyframes hexSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Fly wing fill */
.c-icon-wing {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 0.8;
  opacity: 0.45;
}

/* Recombination: dashed hole ring */
.c-icon-hole {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-dasharray: 3.5 2;
  opacity: 0.7;
}

/* Icon primitives — inherit color from .c-node */
.c-icon-path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.c-icon-dot  { fill: currentColor; }

.c-icon-bond {
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  stroke-linecap: round;
}

/* Teardrop — filled + light stroke so it reads clearly */
.c-icon-drop {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 0.5;
  opacity: 0.85;
}

/* PFAS atom colors */
.c-atom-c {
  fill: currentColor;
}

.c-atom-f {
  fill: var(--link);
}

.c-bond-cf {
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-linecap: round;
  fill: none;
  opacity: 0.7;
}

text.c-icon {
  fill: currentColor;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

/* Hover labels */
.c-label {
  font-size: 8.5px;
  fill: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
  letter-spacing: 0.03em;
}

.c-node:hover .c-label,
.c-node:focus .c-label {
  opacity: 1;
}

/* ===== Get In Touch ===== */
.get-in-touch {
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.git-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  transition: color 0.3s;
}

.git-email {
  font-size: 0.875rem;
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  margin: 0;
  transition: color 0.3s;
}

/* ===== Course Grid (Background page) ===== */
.course-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.875rem;
  margin: 1.25rem 0;
}

.course-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.course-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.course-subject {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.course-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: -0.375rem 0 0.75rem;
  font-style: italic;
}

.course-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.5rem;
}

.course-list li {
  font-size: 0.8rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.175rem 0.5rem;
  line-height: 1.5;
  transition: color 0.3s, background 0.3s, border-color 0.3s;
}

.page-subtitle {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin: 0 0 1.75rem;
}

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

/* ===== Buttons ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  padding: 0.4375rem 1rem;
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s;
  line-height: 1.4;
}

.btn-primary:hover {
  opacity: 0.8;
  text-decoration: none;
  color: var(--bg);
}

.btn-primary:visited {
  color: var(--bg);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 0.4375rem 1rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: var(--border-hover);
  text-decoration: none;
  color: var(--text);
}

.btn-secondary:visited {
  color: var(--text);
}

[data-theme="dark"] .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* ===== Page Header (non-home) ===== */
main.container > h1:first-child {
  padding-top: 2.5rem;
  margin-bottom: 1.25rem;
}

/* ===== Content Cards ===== */
.content-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1rem 0;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.content-container:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

.content-container p:last-child,
.content-container ul:last-child {
  margin-bottom: 0;
}

/* ===== Text Box ===== */
.text-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin: 0.75rem 0;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.text-box:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-hover);
}

.text-box h1, .text-box h2, .text-box h3,
.text-box h4, .text-box h5, .text-box h6 {
  margin-top: 0;
}

/* ===== Research Grid ===== */
.research-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.research-grid.two-columns {
  grid-template-columns: repeat(2, 1fr);
  max-width: 480px;
}

.research-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  text-decoration: none;
  display: block;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.research-box:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  text-decoration: none;
  color: var(--text);
}

.research-box:visited {
  color: var(--text);
}

.research-box .box-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  line-height: 1.45;
}

.research-box .box-title em {
  font-style: italic;
}

/* ===== Thematic Grid ===== */
.thematic-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.thematic-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 90px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.thematic-box:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  text-decoration: none;
  color: var(--text);
}

.thematic-box-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

/* ===== Repertoire (Music) ===== */
.repertoire-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 0.5rem 0;
  cursor: pointer;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
}

.repertoire-box:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-hover);
}

.repertoire-header {
  padding: 0.875rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.repertoire-header::after {
  content: '+';
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.repertoire-box.expanded .repertoire-header::after {
  content: '−';
}

.repertoire-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0 1.25rem;
}

.repertoire-box.expanded > .repertoire-content {
  max-height: 2000px;
  padding: 0 1.25rem 1rem;
}

.repertoire-content ul {
  margin: 0.25rem 0 0.5rem;
  padding-left: 1.25rem;
}

.repertoire-content li {
  margin: 0.2rem 0;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.55;
}

/* ===== Feynman Quote ===== */
.feynman-quote {
  margin: 3rem 0 2rem;
  padding: 1.25rem 1.75rem;
  border-left: 2px solid var(--border);
  background: transparent;
  transition: border-color 0.3s ease;
}

.quote-text {
  font-family: 'Playfair Display', 'Georgia', serif;
  font-size: 1.0625rem;
  font-style: italic;
  color: var(--text-muted);
  margin: 0 0 0.625rem;
  line-height: 1.7;
  transition: color 0.3s ease;
}

.quote-author {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0;
  letter-spacing: 0.01em;
  transition: color 0.3s ease;
}

/* ===== Misc ===== */
.colored-text {
  color: var(--link);
}

.colored-block {
  text-align: center;
  margin: 0.8rem 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .navbar {
    padding: 0 1rem;
  }

  .nav-hide-mobile {
    display: none;
  }

  main.container {
    padding: 0 1rem 4rem;
  }

  .hero {
    padding: 3rem 0 2.5rem;
  }

  .hero-name {
    font-size: 2.5rem;
  }

  .research-grid,
  .research-grid.two-columns,
  .thematic-grid {
    grid-template-columns: 1fr;
    max-width: 100%;
  }
}
