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

:root {
  --bg: #f9f9fb;
  --surface: #ffffff;
  --border: #e4e4e7;
  --text: #18181b;
  --text-muted: #71717a;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #eef2ff;
  --tag-bg: #f4f4f5;
  --tag-text: #3f3f46;
  --radius: 12px;
  --nav-height: 60px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.10);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.13);
}

html { scroll-behavior: smooth; }

/* SERIF HEADINGS */

#hero h1,
section h2 {
  font-family: 'Playfair Display', Georgia, serif;
  letter-spacing: -0.02em;
}

#hero h1 { letter-spacing: -0.03em; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* LANGUAGE */

.sv { display: none; }
body.swedish .en { display: none; }
body.swedish .sv { display: revert; }

/* Fix: .skill-tags span has higher specificity than .sv — override explicitly */
.skill-tags .sv { display: none; }
body.swedish .skill-tags .en { display: none; }
body.swedish .skill-tags .sv { display: inline-block; }

.lang-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  font-family: inherit;
  letter-spacing: 0.06em;
}

.lang-btn:hover { border-color: #a1a1aa; color: var(--text); }

.theme-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1rem;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
}

.theme-btn:hover { border-color: #a1a1aa; background: var(--tag-bg); }

body.dark {
  --bg: #0f0f11;
  --surface: #1c1c1f;
  --border: #2e2e33;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --accent-light: #1e1b4b;
  --tag-bg: #27272a;
  --tag-text: #d4d4d8;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

body.dark #hero { background: linear-gradient(135deg, #0f0f11 55%, #1e1b4b 100%); }
body.dark header { background: rgba(15, 15, 17, 0.92); }

/* NAV */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(249, 249, 251, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  height: var(--nav-height);
}

nav {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-name { font-weight: 700; font-size: 0.95rem; }

nav ul {
  list-style: none;
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

nav ul a { color: var(--text-muted); font-size: 0.9rem; transition: color 0.15s; }
nav ul a:hover { color: var(--text); text-decoration: none; }

.nav-gh {
  background: var(--text);
  color: var(--bg) !important;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem !important;
  font-weight: 500;
  transition: opacity 0.15s;
}

.nav-gh:hover { opacity: 0.8; }

/* BUTTONS */

.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff !important;
  padding: 0.6rem 1.4rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
}

.btn-primary:hover { background: var(--accent-hover); text-decoration: none; transform: translateY(-1px); }

.btn-secondary {
  display: inline-block;
  border: 1px solid var(--border);
  color: var(--text) !important;
  padding: 0.6rem 1.4rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  text-decoration: none;
}

.btn-secondary:hover { border-color: #a1a1aa; background: var(--tag-bg); text-decoration: none; transform: translateY(-1px); }

/* SECTIONS */

section { padding: 5rem 0; border-top: 1px solid var(--border); }

section h2 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 2rem;
}

.section-sub {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 2.5rem 0 1.25rem;
}

/* HERO */

#hero {
  padding: 0;
  border-top: none;
  background: linear-gradient(135deg, #f9f9fb, #eef2ff, #e8eaff);
  background-size: 200% 200%;
  animation: heroGradient 7s ease infinite alternate;
  overflow: hidden;
}

.hero-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 5rem 1.5rem 0;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 3rem;
  align-items: end;
}

.hero-text { padding-bottom: 5rem; }

.hero-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

#hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 1.1rem;
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 460px;
  line-height: 1.8;
  margin-bottom: 2rem;
}

.hero-chips {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 2rem;
}

.hero-chips li {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.hero-chips li::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.hero-photo img {
  width: 100%;
  border-radius: 16px 16px 0 0;
  object-fit: cover;
  object-position: top center;
  aspect-ratio: 3 / 4;
  display: block;
  box-shadow: var(--shadow-lg);
}

/* ABOUT */

#about { background: var(--surface); }

.about-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 3.5rem;
  align-items: start;
}

.about-photos {
  position: relative;
  width: 300px;
  height: 420px;
  flex-shrink: 0;
}

.photo-main-wrap {
  width: 230px;
  height: 290px;
  position: absolute;
  top: 0;
  left: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.photo-main {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 55%;
  display: block;
  transform: scale(1.6);
  transform-origin: center 55%;
}

.photo-secondary {
  width: 165px;
  height: 200px;
  object-fit: cover;
  object-position: center 40%;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: block;
  position: absolute;
  top: 220px;
  right: 0;
  border: 3px solid var(--surface);
}

.about-content p { color: var(--text-muted); margin-bottom: 1rem; line-height: 1.8; }
.about-content a { color: var(--accent); }

.about-quote {
  border-left: 3px solid var(--accent);
  padding: 0.6rem 0 0.6rem 1.25rem;
  margin: 1.5rem 0 1.5rem;
  font-style: italic;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.05rem;
  color: var(--text);
  line-height: 1.75;
}

.about-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.5rem;
  width: fit-content;
}

.about-links a {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.15s, color 0.15s;
  text-align: center;
  text-decoration: none;
}

.about-links a:hover { color: var(--text); border-color: #a1a1aa; }

/* RESEARCH */

#research { background: var(--accent-light); }

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

.research-card {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.research-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(99,102,241,0.12);
  transform: translateY(-2px);
}

.research-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.5rem; }
.research-card p { font-size: 0.875rem; color: var(--text-muted); line-height: 1.7; }

/* TAGS */

.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-weight: 500;
}

.tag-active { background: #dcfce7; color: #15803d; }

.project-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }

/* FEATURED PROJECT */

.project-featured {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.project-featured h3 { font-size: 1.3rem; font-weight: 700; margin: 0.5rem 0 0.75rem; }
.project-featured p { color: var(--text-muted); max-width: 560px; line-height: 1.7; }

.project-links {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
}

/* PROJECT GRID */

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

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.15s;
}

.project-card:hover {
  border-color: #a1a1aa;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.project-card h4 { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; }
.project-card p { font-size: 0.875rem; color: var(--text-muted); line-height: 1.6; }

.project-card code {
  font-size: 0.8rem;
  background: var(--tag-bg);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

.project-card .project-links { margin-top: 1rem; }

.project-card .project-links a {
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: color 0.15s;
  text-decoration: none;
}

.project-card .project-links a:first-child { color: var(--accent); font-weight: 500; }
.project-card .project-links a:hover { color: var(--text); }

/* PROJECT LIST */

.project-list {
  display: flex;
  flex-direction: column;
}

.project-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  gap: 1rem;
}

.project-list-item:last-child { border-bottom: none; }

.project-list-item:hover .project-list-title { color: var(--accent); }

.project-list-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  transition: color 0.15s;
  margin-bottom: 0.2rem;
}

.project-list-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.project-list-arrow {
  color: var(--accent);
  font-size: 1.15rem;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.project-list-item:hover .project-list-arrow { transform: translateX(4px); }

.projects-more {
  margin-top: 1.75rem;
  font-size: 0.875rem;
}

.projects-more a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.projects-more a:hover { color: var(--accent); }

/* EXERCISES */

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

.exercise-group h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.exercise-group ul { list-style: none; }

.exercise-group li {
  font-size: 0.875rem;
  color: var(--text-muted);
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.exercise-group li:last-child { border-bottom: none; }
.exercise-group li a { color: var(--text); font-weight: 500; text-decoration: none; }
.exercise-group li a:hover { color: var(--accent); }

/* VALUES */

#values { background: var(--bg); }

.section-lead {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 2rem;
  max-width: 480px;
}

.values-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.values-item {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.values-item:hover {
  box-shadow: 0 4px 20px rgba(99,102,241,0.12);
  transform: translateY(-2px);
}

.values-item:nth-child(1) { border-left: 3px solid #6366f1; }
.values-item:nth-child(2) { border-left: 3px solid #8b5cf6; }
.values-item:nth-child(3) { border-left: 3px solid #06b6d4; }
.values-item:nth-child(4) { border-left: 3px solid #10b981; }

.values-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  font-family: 'Playfair Display', Georgia, serif;
  margin-bottom: 0.5rem;
}

.values-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* WRITING */

.writing-list {
  display: flex;
  flex-direction: column;
  max-width: 600px;
}

.writing-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1.5rem;
}

.writing-item:last-child { border-bottom: none; }

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

.writing-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* FOOTER */

footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  background: var(--surface);
}

.footer-inner { display: flex; align-items: center; justify-content: space-between; }
.footer-links { display: flex; gap: 1.25rem; }
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--text); }

.footer-icon-link {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  transition: color 0.15s;
}

.footer-icon-link:hover { color: var(--text); }

/* RESPONSIVE */

@media (max-width: 760px) {
  .hero-inner {
    grid-template-columns: 1fr;
    align-items: start;
    padding-bottom: 0;
  }

  .hero-text { padding-bottom: 1.5rem; }

  .hero-photo img {
    border-radius: 16px;
    aspect-ratio: 3 / 4;
    max-height: 420px;
  }

  .about-layout { grid-template-columns: 1fr; }

  .about-photos { width: 100%; height: 300px; }

  .photo-main-wrap { position: absolute; width: 100%; height: 300px; top: 0; left: 0; }
  .photo-secondary { display: none; }

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

@media (max-width: 760px) and (orientation: portrait) {
  .hero-photo img {
    aspect-ratio: 3 / 4;
    max-height: 420px;
  }
}

@media (max-width: 640px) {
  nav ul { gap: 0.75rem; }
  nav ul li:not(:last-child):not(:nth-last-child(2)) { display: none; }

  .footer-inner { flex-direction: column; gap: 0.75rem; text-align: center; }
}

/* ANIMATIONS */

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

.hero-text { animation: fadeSlideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) both; }
.hero-photo { animation: fadeSlideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both; }

.fade-in {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* NOW */

#now {
  padding: 0.9rem 0;
  background: var(--accent-light);
}

.now-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.now-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: nowPulse 2.5s ease-in-out infinite;
}

@keyframes nowPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(99,102,241,0.5); }
  50%       { opacity: 0.7; box-shadow: 0 0 0 5px rgba(99,102,241,0); }
}

/* HERO GRADIENT ANIMATION */

@keyframes heroGradient {
  0%   { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

/* RESEARCH CARD ACCENTS */

.research-card:nth-child(1) { border-left: 3px solid #6366f1; }
.research-card:nth-child(2) { border-left: 3px solid #8b5cf6; }
.research-card:nth-child(3) { border-left: 3px solid #06b6d4; }
.research-card:nth-child(4) { border-left: 3px solid #10b981; }

/* ACTIVE NAV LINK */

nav ul a.active { color: var(--text); font-weight: 600; }

/* BACK TO TOP */

.back-top {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s, background 0.15s;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

.back-top.visible { opacity: 1; transform: translateY(0); }
.back-top:hover { background: var(--accent-hover); }

/* REDUCED MOTION */

@media (prefers-reduced-motion: reduce) {
  #hero { animation: none; }
  .hero-text, .hero-photo { animation: none; }
  .now-pulse { animation: none; }
  .fade-in { opacity: 1; transform: none; transition: none; }
}
