/* ============================================================
   Niclas Hart — Personal Site
   Editorial / academic aesthetic: warm paper, ink, amber accent
   ============================================================ */

:root {
  --paper: #faf7f0;
  --paper-alt: #f1ece1;
  --ink: #1d1a14;
  --ink-soft: #55503f;
  --ink-faint: #8a8471;
  --accent: #b4540a;          /* burnt amber */
  --accent-dark: #8a3f05;
  --line: #ddd5c4;
  --card: #fffdf8;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --max-w: 74rem;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(29 26 20 / 0.04), 0 6px 18px rgb(29 26 20 / 0.045);
}

[data-theme="dark"] {
  --paper: #16140f;
  --paper-alt: #201c14;
  --ink: #ece6d8;
  --ink-soft: #b6ae9c;
  --ink-faint: #857e6c;
  --accent: #e08a3f;
  --accent-dark: #f0a05c;
  --line: #35301f;
  --card: #1d1a12;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 18px rgb(0 0 0 / 0.35);
}

[data-theme="dark"] body::before { opacity: 0.18; }

/* Experience section is already dark-on-light ink; keep it a deep panel in dark mode.
   It styles itself against --ink in light mode, so re-point its local --paper/--accent. */
[data-theme="dark"] .experience {
  background: #0f0d09;
  --paper: #ece6d8;
  --accent: #e08a3f;
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  margin-left: 0.5rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.theme-toggle:hover { border-color: var(--line); color: var(--accent); }
.theme-toggle svg { width: 1.15rem; height: 1.15rem; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

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

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* Subtle paper grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.03 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

main, header, footer { position: relative; z-index: 1; }

img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--paper-alt);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.container {
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.brand-dot { color: var(--accent); }
.nav { display: flex; gap: 1.4rem; align-items: center; }
.nav a {
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.95rem;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current] { color: var(--accent); }
.nav-toggle { display: none; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.nav-toggle > span:not(.sr-only) { display: block; width: 1.35rem; height: 1.5px; margin: 0.3rem 0; background: currentColor; transition: transform 0.2s; }
.nav-cta {
  border: 1.5px solid var(--ink);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  color: var(--ink) !important;
  transition: background 0.2s, color 0.2s;
}
.nav-cta:hover { background: var(--ink); color: var(--paper) !important; }

/* ---------- Hero ---------- */
.hero { padding: 6.25rem 0 5.25rem; border-bottom: 1px solid var(--line); }
.hero-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 3.5rem;
  align-items: center;
}
.eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 0.6rem;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.02;
  margin-bottom: 1rem;
}
.tagline {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  font-weight: 300;
  color: var(--ink-soft);
  margin-bottom: 1.2rem;
}
.tagline em { color: var(--accent); font-style: italic; }
.bio { color: var(--ink-soft); max-width: 36rem; margin-bottom: 1.8rem; }
.hero-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; }

.btn {
  display: inline-block;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s, color 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--ink); color: var(--paper); box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-ghost { border: 1.5px solid var(--line); color: var(--ink); background: var(--card); }
.btn-ghost:hover { border-color: var(--ink); }

.portrait-frame {
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, var(--paper-alt), var(--line));
  box-shadow: var(--shadow);
  transform: rotate(2deg);
  transition: transform 0.3s;
}
.portrait-frame:hover { transform: rotate(0deg) scale(1.02); }
.portrait-frame img { width: 100%; height: 100%; object-fit: cover; }
.portrait-frame.no-img::after {
  content: "Photo";
  display: grid;
  place-items: center;
  height: 100%;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink-faint);
  font-size: 1.4rem;
}
.portrait-caption {
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin-top: 0.7rem;
  text-align: center;
}

/* ---------- Sections ---------- */
.section { padding: 4.5rem 0; }
.section-alt { background: var(--paper-alt); }
.section-head { margin-bottom: 2.5rem; max-width: 40rem; }
.section-head h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.5vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.section-head h2::after {
  content: "";
  display: block;
  width: 3.2rem;
  height: 3px;
  background: var(--accent);
  margin-top: 0.55rem;
  border-radius: 2px;
}
.section-sub { color: var(--ink-soft); margin-top: 0.6rem; }

/* ---------- Publications ---------- */
.pub-list { display: flex; flex-direction: column; gap: 1.5rem; }
.pub {
  position: relative;
  display: grid;
  grid-template-columns: 13rem 1fr;
  gap: 1.6rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}
.pub-thumb {
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--paper-alt), var(--line));
  align-self: start;
}
.pub-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.pub-thumb:hover img { transform: scale(1.05); }
.pub-thumb.no-img { display: none; }
.pub-venue {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.pub-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 0.4rem;
}
.pub-title a { color: var(--ink); }
.pub-title a:hover { color: var(--accent); }
.pub-authors { font-size: 0.95rem; color: var(--ink-soft); margin-bottom: 0.5rem; }
.pub-abstract { font-size: 0.95rem; color: var(--ink-soft); margin-bottom: 0.8rem; }
.pub-links { display: flex; gap: 1rem; flex-wrap: wrap; }
.pub-links a, .pub-bib {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  border-bottom: 2px solid transparent;
}
.pub-links .icon {
  width: 1em;
  height: 1em;
  fill: currentColor;
  flex-shrink: 0;
}
.pub-links a:hover, .pub-bib:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.bibtex {
  margin-top: 0.9rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre;
}
.hidden { display: none; }

/* ---------- Projects ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 1.25rem;
}
.project {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
}
.project:hover { transform: translateY(-4px); box-shadow: 0 4px 8px rgb(29 26 20 / 0.08), 0 16px 40px rgb(29 26 20 / 0.1); }
.project-body { padding: 1.3rem 1.4rem 1.5rem; display: flex; flex-direction: column; gap: 0.6rem; flex: 1; }
.project-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.project-head > div { min-width: 0; }
.project-head h3 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }
.project-category { margin-bottom: 0.25rem; color: var(--accent) !important; font-family: var(--font-mono); font-size: 0.66rem !important; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.project-year { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-faint); }
.project-body > p { font-size: 0.95rem; color: var(--ink-soft); }
.project-stack { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.project-stack span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--paper-alt);
  border: 1px solid var(--line);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  color: var(--ink-soft);
}
.project .pub-links { margin-top: auto; padding-top: 0.4rem; }

/* ---------- Certifications ---------- */
.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 1.25rem;
}
.cert {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.3rem 1.4rem 1.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.cert:hover { transform: translateY(-4px); box-shadow: 0 4px 8px rgb(29 26 20 / 0.08), 0 16px 40px rgb(29 26 20 / 0.1); }
.cert-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.cert-head > div { min-width: 0; }
.cert-head h3 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; line-height: 1.25; }
.cert-issuer { margin-bottom: 0.25rem; color: var(--accent); font-family: var(--font-mono); font-size: 0.66rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.cert-year { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-faint); }
.cert > p { font-size: 0.92rem; color: var(--ink-soft); }
.cert-link { margin-top: auto; padding-top: 0.4rem; font-size: 0.88rem; font-weight: 500; color: var(--accent); }

/* ---------- Experience ---------- */
.experience { background: var(--ink); color: var(--paper); }
.experience .section-head h2::after { background: #d7813f; }
.experience .section-sub { color: #c9c2b4; }
.experience-grid { display: grid; grid-template-columns: 1.25fr 0.85fr; gap: clamp(2.5rem, 7vw, 6rem); }
.timeline { border-top: 1px solid rgb(250 247 240 / 0.25); }
.timeline-item { display: grid; grid-template-columns: 9rem 1fr; gap: 1.5rem; padding: 1.6rem 0; border-bottom: 1px solid rgb(250 247 240 / 0.25); }
.timeline-date { color: #d9a174; font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; }
.timeline-item h3 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; line-height: 1.25; }
.timeline-org { margin: 0.25rem 0 0.7rem; color: #d9a174; font-size: 0.82rem; font-weight: 500; }
.timeline-item div > p:last-child { color: #c9c2b4; font-size: 0.9rem; }
.expertise { border-top: 1px solid rgb(250 247 240 / 0.25); }
.expertise-group { padding: 1.15rem 0; border-bottom: 1px solid rgb(250 247 240 / 0.25); }
.expertise-group h3 { margin-bottom: 0.45rem; color: #d9a174; font-family: var(--font-mono); font-size: 0.7rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.expertise-group p { color: #ddd7cc; font-size: 0.88rem; line-height: 1.7; }
.expertise-group strong { color: var(--paper); font-size: 0.7rem; font-weight: 500; text-transform: uppercase; }

/* ---------- CV ---------- */
.cv-summary { display: grid; grid-template-columns: 0.9fr 1.35fr; gap: clamp(2rem, 7vw, 6rem); padding: clamp(1.6rem, 4vw, 3rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.cv-intro h3 { margin-bottom: 2rem; font-family: var(--font-display); font-size: clamp(1.55rem, 3vw, 2.25rem); font-weight: 600; line-height: 1.15; letter-spacing: -0.025em; }
.cv-facts { border-top: 1px solid var(--line); }
.cv-facts div { display: grid; grid-template-columns: 7rem 1fr; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.cv-facts dt { color: var(--accent); font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase; }
.cv-facts dd { color: var(--ink-soft); font-size: 0.95rem; }

/* ---------- Contact ---------- */
.contact-inner { text-align: center; max-width: 42rem; margin-inline: auto; }
.contact-inner h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.5vw, 2.4rem);
  font-weight: 600;
}
.contact-inner .section-sub { margin-top: 0.6rem; }
.contact-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 2.2rem;
}
.contact-btn {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.2s;
  text-align: left;
}
.contact-btn:hover { transform: translateY(-3px); border-color: var(--accent); color: var(--ink); }
.contact-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  flex-shrink: 0;
}
.contact-icon svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 1.8rem 0; }
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: var(--ink-faint);
}
.to-top { color: var(--ink-soft); font-weight: 600; }

/* ---------- Reveal animation ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible { opacity: 1; transform: none; }
.reveal.delay-1 { transition-delay: 0.12s; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------- Mobile ---------- */
@media (max-width: 52rem) {
  .hero { padding: 3.5rem 0 3rem; }
  .hero-grid { grid-template-columns: 1fr; gap: 2.2rem; }
  .hero-portrait { max-width: 17rem; }
  .pub { grid-template-columns: 1fr; gap: 1rem; }
  .pub-thumb { aspect-ratio: 16 / 9; }
  .pub-thumb.no-img { display: none; }
  .cv-summary { grid-template-columns: 1fr; }
  .experience-grid { grid-template-columns: 1fr; }
}
@media (max-width: 40rem) {
  .header-inner { position: relative; }
  .nav-toggle { display: block; }
  .nav { position: absolute; top: calc(100% + 1px); right: 1.25rem; left: 1.25rem; display: none; flex-direction: column; align-items: stretch; gap: 0; padding: 0.65rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
  .nav.is-open { display: flex; }
  .nav a { padding: 0.8rem 0.75rem; }
  .nav-cta { margin-top: 0.35rem; justify-content: center; }
  .section { padding: 3.2rem 0; }
  .hero { padding: 3.5rem 0; }
  .hero-portrait { max-width: 15rem; }
  .pub { padding: 1.1rem; }
  .cv-facts div { grid-template-columns: 1fr; gap: 0.35rem; }
  .timeline-item { grid-template-columns: 1fr; gap: 0.55rem; }
  .contact-buttons { gap: 0.45rem; }
  .contact-btn { flex-direction: column; justify-content: center; gap: 0.45rem; padding: 0.7rem 0.35rem; text-align: center; }
  .contact-btn strong { font-size: 0.8rem; }
  .contact-icon { width: 2.1rem; height: 2.1rem; }
}
