/* ========================================
   Magnus Lundgren — Academic Homepage
   Scandinavian minimal with accent color
   ======================================== */

:root {
  --color-bg: #fafafa;
  --color-bg-alt: #f0f2f5;
  --color-text: #1a1a2e;
  --color-text-light: #5a5a72;
  --color-accent: #2d5f8a;
  --color-accent-light: #3a7bb8;
  --color-accent-subtle: #e8f0f8;
  --color-warm: #c4754b;
  --color-border: #e0e2e8;
  --color-white: #ffffff;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --max-width: 960px;
  --nav-height: 64px;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-height);
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--color-accent-light);
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.3;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- Navigation ---- */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-height);
  transition: background 0.3s, box-shadow 0.3s;
}

.nav.scrolled {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-name {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 32px;
}

.nav-links a {
  color: var(--color-text-light);
  font-size: 0.9rem;
  font-weight: 450;
  letter-spacing: 0.01em;
  transition: color 0.2s;
}

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

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
  transition: transform 0.3s, opacity 0.3s;
}

.nav-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ---- Hero ---- */

.hero {
  padding: calc(var(--nav-height) + 64px) 0 80px;
  background: var(--color-white);
}

.hero-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 64px;
}

.hero-text {
  flex: 1;
}

.hero-text h1 {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-text);
  margin-bottom: 8px;
}

.hero-title {
  font-size: 1.15rem;
  color: var(--color-accent);
  font-weight: 500;
  margin-bottom: 2px;
}

.hero-affiliation {
  font-size: 1rem;
  color: var(--color-text-light);
  margin-bottom: 20px;
}

.hero-summary {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--color-text-light);
  line-height: 1.7;
  margin-bottom: 28px;
  max-width: 520px;
}

.hero-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  border: 1.5px solid transparent;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-white);
  border-color: var(--color-accent);
}

.btn-primary:hover {
  background: var(--color-accent-light);
  border-color: var(--color-accent-light);
  color: var(--color-white);
}

.btn-outline {
  border-color: var(--color-border);
  color: var(--color-text);
  background: var(--color-white);
}

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

.hero-photo {
  flex-shrink: 0;
}

.hero-photo img {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 15%;
  border: 4px solid var(--color-bg-alt);
}

/* ---- Sections ---- */

.section {
  padding: 80px 0;
}

.section-alt {
  background: var(--color-bg-alt);
}

.section h2 {
  font-size: 1.8rem;
  margin-bottom: 36px;
  letter-spacing: -0.02em;
  position: relative;
  padding-bottom: 12px;
}

.section h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 48px;
  height: 3px;
  background: var(--color-accent);
  border-radius: 2px;
}

/* ---- About ---- */

.about-content {
  max-width: 720px;
}

.about-content p {
  margin-bottom: 16px;
  color: var(--color-text);
  line-height: 1.8;
}

.about-content a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.about-metrics {
  display: flex;
  gap: 48px;
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--color-border);
}

.metric {
  display: flex;
  flex-direction: column;
}

.metric-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: -0.02em;
}

.metric-label {
  font-size: 0.85rem;
  color: var(--color-text-light);
  margin-top: 2px;
}

/* ---- Research ---- */

.research-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.research-card {
  background: var(--color-white);
  border-radius: 10px;
  padding: 28px;
  border: 1px solid var(--color-border);
  transition: box-shadow 0.2s;
}

.research-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.research-icon {
  width: 36px;
  height: 36px;
  color: var(--color-accent);
  margin-bottom: 14px;
}

.research-icon svg {
  width: 100%;
  height: 100%;
}

.research-card h3 {
  font-size: 1.05rem;
  margin-bottom: 10px;
  color: var(--color-text);
}

.research-card p {
  font-size: 0.92rem;
  color: var(--color-text-light);
  line-height: 1.7;
}

/* ---- Publications ---- */

.pub-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.pub-filter {
  background: none;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  padding: 6px 18px;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.pub-filter:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.pub-filter.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-white);
}

.pub-list {
  max-width: 780px;
}

.pub-section-title {
  font-size: 1.05rem;
  color: var(--color-accent);
  margin-top: 32px;
  margin-bottom: 0;
  padding-bottom: 0;
  letter-spacing: -0.01em;
}

.pub-section-title:first-child {
  margin-top: 0;
}

.pub-item {
  display: flex;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border);
}

.pub-item:first-child {
  border-top: 1px solid var(--color-border);
}

.pub-year {
  flex-shrink: 0;
  width: 52px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-accent);
  padding-top: 2px;
}

.pub-details {
  flex: 1;
}

.pub-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  margin-bottom: 3px;
  line-height: 1.5;
}

.pub-authors {
  font-size: 0.88rem;
  color: var(--color-text-light);
  margin-bottom: 2px;
}

.pub-venue {
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.pub-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-accent);
  padding: 2px 10px;
  border: 1px solid var(--color-accent);
  border-radius: 4px;
  transition: all 0.2s;
}

.pub-link:hover {
  background: var(--color-accent);
  color: var(--color-white);
}

.pub-link-data {
  border-color: var(--color-warm);
  color: var(--color-warm);
}

.pub-link-data:hover {
  background: var(--color-warm);
  color: var(--color-white);
}

/* ---- Teaching ---- */

.teaching-intro {
  max-width: 680px;
  margin-bottom: 32px;
}

.teaching-intro p {
  color: var(--color-text);
  line-height: 1.8;
}

.teaching-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 0;
}

.teaching-card {
  background: var(--color-white);
  border-radius: 10px;
  padding: 24px;
  border: 1px solid var(--color-border);
}

.teaching-card h3 {
  font-size: 1rem;
  margin-bottom: 14px;
  color: var(--color-accent);
}

.teaching-card ul {
  list-style: none;
  padding: 0;
}

.teaching-card li {
  font-size: 0.88rem;
  color: var(--color-text);
  padding: 5px 0;
  border-bottom: 1px solid var(--color-bg-alt);
  line-height: 1.5;
}

.teaching-card li:last-child {
  border-bottom: none;
}

/* ---- Teaching sim link ---- */

.teaching-simlink {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--color-border);
  max-width: 640px;
}

.teaching-simlink h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.teaching-simlink p {
  color: var(--color-text-light);
  margin-bottom: 16px;
  line-height: 1.7;
}

/* ---- Simulations ---- */

.simulations h3 {
  font-size: 1.3rem;
  margin-bottom: 10px;
}

.sim-intro {
  color: var(--color-text-light);
  margin-bottom: 24px;
  max-width: 640px;
}

.sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.sim-card {
  display: flex;
  flex-direction: column;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 20px;
  transition: all 0.2s;
  text-decoration: none;
}

.sim-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  transform: translateY(-2px);
}

.sim-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.sim-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  margin-bottom: 4px;
}

.sim-desc {
  font-size: 0.83rem;
  color: var(--color-text-light);
  line-height: 1.5;
}

/* ---- Simulations page ---- */

.sim-page-header {
  margin-bottom: 40px;
}

.sim-back {
  display: inline-block;
  font-size: 0.88rem;
  color: var(--color-text-light);
  margin-bottom: 16px;
  transition: color 0.2s;
}

.sim-back:hover {
  color: var(--color-accent);
}

.sim-page-header h1 {
  font-size: 2rem;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.sim-page-intro {
  color: var(--color-text-light);
  max-width: 640px;
  line-height: 1.7;
}

.sim-empty {
  padding: 48px 0;
  text-align: center;
}

.sim-empty p {
  color: var(--color-text-light);
  font-size: 1.05rem;
}

/* ---- Contact ---- */

.contact-grid {
  max-width: 480px;
}

.contact-info p {
  line-height: 1.8;
  margin-bottom: 24px;
}

.contact-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contact-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text);
  font-size: 0.95rem;
  transition: color 0.2s;
}

.contact-links a:hover {
  color: var(--color-accent);
}

.contact-links svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--color-accent);
}

/* ---- Footer ---- */

.footer {
  padding: 32px 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.footer p {
  font-size: 0.82rem;
  color: var(--color-text-light);
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
  .hero-inner {
    flex-direction: column-reverse;
    gap: 32px;
    text-align: center;
  }

  .hero-text h1 {
    font-size: 2.2rem;
  }

  .hero-summary {
    max-width: 100%;
  }

  .hero-links {
    justify-content: center;
  }

  .hero-photo img {
    width: 180px;
    height: 180px;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    flex-direction: column;
    padding: 16px 24px 24px;
    gap: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  }

  .nav-links.open {
    display: flex;
  }

  .research-grid {
    grid-template-columns: 1fr;
  }

  .teaching-grid {
    grid-template-columns: 1fr;
  }

  .about-metrics {
    gap: 32px;
  }

  .section h2::after {
    left: 0;
  }

  .sim-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .hero-text h1 {
    font-size: 1.8rem;
  }

  .section {
    padding: 56px 0;
  }

  .about-metrics {
    flex-direction: column;
    gap: 20px;
  }

  .pub-item {
    flex-direction: column;
    gap: 4px;
  }

  .pub-year {
    width: auto;
  }
}
