:root {
  --bg: #faf8f3;
  --surface: #f1eee5;
  --raised: #ffffff;
  --ink: #1b1c1a;
  --muted: #5e605a;
  --faint: #8b8d85;
  --line: #e1ddd2;
  --accent: #1f5a47;
  --accent-soft: #e3ece6;
  --on-accent: #faf8f3;
  --shadow: 0 1px 2px rgba(27, 28, 26, 0.04), 0 8px 24px -12px rgba(27, 28, 26, 0.12);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --page: 1080px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121412;
    --surface: #1a1d1a;
    --raised: #1f221f;
    --ink: #ece9e1;
    --muted: #a6a89f;
    --faint: #7c7e77;
    --line: #2c302c;
    --accent: #8fcdb2;
    --accent-soft: #1d2b25;
    --on-accent: #121412;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #121412;
  --surface: #1a1d1a;
  --raised: #1f221f;
  --ink: #ece9e1;
  --muted: #a6a89f;
  --faint: #7c7e77;
  --line: #2c302c;
  --accent: #8fcdb2;
  --accent-soft: #1d2b25;
  --on-accent: #121412;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4, p, ol, ul, dl, dd { margin: 0; padding: 0; }
ol, ul { list-style: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent-soft); }
.icon { width: 17px; height: 17px; flex: none; }
.icon-sm { width: 14px; height: 14px; }

/* Toppmeny */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 14px var(--gutter);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
body.scrolled .topbar { border-bottom-color: var(--line); }
.brand { font-family: var(--serif); font-size: 18px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.nav-links { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap;
  padding: 5px 10px; border-radius: 999px; transition: color 0.15s, background 0.15s;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a.active { color: var(--ink); background: var(--surface); }
.controls { display: flex; align-items: center; gap: 10px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.lang button {
  font: inherit; font-size: 12px; letter-spacing: 0.06em; color: var(--muted);
  background: none; border: 0; border-radius: 999px; padding: 3px 10px; cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.theme-toggle {
  display: grid; place-items: center; width: 30px; height: 30px;
  color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 50%; cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); }

/* Sideoppsett */
main, .footer { max-width: var(--page); margin: 0 auto; padding: 0 var(--gutter); }

/* Toppseksjon */
.hero {
  display: grid; grid-template-columns: 1fr auto; gap: 40px 56px; align-items: center;
  padding: clamp(48px, 9vw, 112px) 0 clamp(40px, 6vw, 64px);
}
.kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 18px;
}
.kicker::before { content: ""; width: 28px; height: 1px; background: currentColor; }
h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(46px, 8vw, 88px); line-height: 1.02; letter-spacing: -0.025em;
  text-wrap: balance;
}
.lead { margin-top: 24px; max-width: 32em; font-size: clamp(18px, 2.1vw, 21px); line-height: 1.55; color: var(--muted); text-wrap: pretty; }

.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 500; text-decoration: none; color: var(--ink);
  padding: 10px 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--raised);
  transition: transform 0.15s ease, border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--faint); transform: translateY(-1px); }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.portrait {
  position: relative;
  width: clamp(180px, 24vw, 260px); aspect-ratio: 1;
  display: grid; place-items: center; overflow: hidden;
  background: var(--surface); border-radius: 50%;
  font-family: var(--serif); font-size: 48px; color: var(--muted);
  box-shadow: 0 0 0 1px var(--line), 0 0 0 10px var(--bg), 0 0 0 11px var(--line);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }

.hero-facts {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  margin-top: 8px;
}
.hero-facts div { padding: 18px 0 18px 20px; border-left: 1px solid var(--line); }
.hero-facts div:first-child { border-left: 0; padding-left: 0; }
.hero-facts dt, .facts dt {
  font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin-bottom: 4px;
}
.hero-facts dd { font-family: var(--serif); font-size: 19px; line-height: 1.3; }

/* Seksjoner */
.section {
  display: grid; grid-template-columns: 210px 1fr; gap: 40px;
  padding: clamp(48px, 7vw, 88px) 0;
  border-top: 1px solid var(--line);
}
.hero + .section { border-top: 0; }
.section-label {
  font-family: var(--sans); font-weight: 600; font-size: 13px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  position: sticky; top: 88px; align-self: start;
  display: flex; flex-direction: column; gap: 6px;
}
.section-no { font-family: var(--serif); font-weight: 400; font-size: 15px; letter-spacing: 0; color: var(--accent); }
.section-body { min-width: 0; }

.prose { max-width: 38em; color: var(--muted); text-wrap: pretty; }
.prose + .prose { margin-top: 1em; }
.prose-lead { font-family: var(--serif); font-size: clamp(21px, 2.5vw, 26px); line-height: 1.45; color: var(--ink); }
#om .prose:not(.prose-lead) { font-size: 18px; }
.display { font-family: var(--serif); font-weight: 400; font-size: clamp(24px, 3.2vw, 32px); line-height: 1.25; margin-bottom: 20px; max-width: 24em; text-wrap: balance; }
.small-label { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); margin: 0 0 12px; }

/* Tidslinje */
.timeline { position: relative; }
.entry { position: relative; display: grid; grid-template-columns: 48px 1fr; gap: 22px; padding-bottom: 36px; }
.entry:last-child { padding-bottom: 0; }
.entry::before {
  content: ""; position: absolute; left: 23.5px; top: 56px; bottom: 8px;
  width: 1px; background: var(--line);
}
.entry:last-child::before { display: none; }
.badge {
  width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 13px; font-weight: 650; letter-spacing: 0.02em; color: var(--accent);
}
.entry-main { min-width: 0; padding-top: 2px; }
.entry-period { font-size: 14px; color: var(--faint); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.now {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px;
}
.entry-role { font-family: var(--serif); font-weight: 400; font-size: 22px; line-height: 1.3; margin-top: 2px; }
.entry-org { font-size: 15px; color: var(--accent); margin: 2px 0 10px; }
.entry-org .sep { color: var(--faint); margin: 0 2px; }
.entry-text { font-size: 16px; color: var(--muted); max-width: 40em; }
.entry-text + .entry-text { margin-top: 6px; }

/* Flere stillinger hos samme arbeidsgiver */
.roles { margin-top: 14px; }
.roles li { position: relative; padding: 0 0 22px 24px; }
.roles li:last-child { padding-bottom: 0; }
.roles li::before {
  content: ""; position: absolute; left: 0; top: 9px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent);
}
.roles li::after {
  content: ""; position: absolute; left: 4.5px; top: 24px; bottom: 0;
  width: 1px; background: var(--line);
}
.roles li:last-child::after { display: none; }
.role-title { font-family: var(--serif); font-weight: 400; font-size: 19px; line-height: 1.35; }
.role-period { font-size: 14px; color: var(--faint); margin: 0 0 6px; font-variant-numeric: tabular-nums; }

/* Vis flere */
.timeline[data-collapsed="true"] .is-extra { display: none; }
.timeline[data-collapsed="true"] .entry:nth-last-child(1 of :not(.is-extra))::before { display: none; }
.more {
  margin: 28px 0 0 70px;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--ink);
  background: none; border: 1px dashed var(--faint); border-radius: 999px; padding: 7px 16px; cursor: pointer;
}
.more:hover { border-style: solid; }

.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 28px; margin-top: 44px; padding-top: 32px; border-top: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { font-size: 14px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--raised); }

/* Masteroppgave */
.panel {
  background: var(--surface); border-radius: var(--radius);
  padding: clamp(24px, 4vw, 40px);
  border-left: 3px solid var(--accent);
}
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 20px 28px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.facts dd { overflow-wrap: anywhere; }

/* Opptatt av */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 32px 0 36px; }
.cards article {
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow); transition: transform 0.2s ease;
}
.cards article:hover { transform: translateY(-2px); }
.card-icon {
  width: 36px; height: 36px; padding: 8px; margin-bottom: 14px;
  color: var(--accent); background: var(--accent-soft); border-radius: 9px;
}
.cards h3, .two-col h3 { font-family: var(--serif); font-weight: 400; font-size: 21px; margin-bottom: 8px; }
.cards p { font-size: 15.5px; color: var(--muted); }
.links { display: flex; flex-wrap: wrap; gap: 8px 24px; }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 40px; }
.two-col p { color: var(--muted); }
.plain { margin-top: 12px; }
.plain li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 15.5px; }

.posts li { display: grid; grid-template-columns: 110px 1fr; gap: 20px; padding: 14px 0; border-top: 1px solid var(--line); }
.posts li:first-child { border-top: 0; padding-top: 0; }
.posts time, .posts p { font-size: 14px; color: var(--muted); }

/* Kontakt */
.contact {
  background: var(--ink); color: var(--bg);
  border-radius: var(--radius); padding: clamp(28px, 5vw, 48px);
}
.contact-heading { font-family: var(--serif); font-size: clamp(30px, 4.4vw, 44px); line-height: 1.1; letter-spacing: -0.015em; margin-bottom: 10px; }
.contact .prose { color: color-mix(in srgb, var(--bg) 70%, var(--ink)); }
.contact .buttons { margin-top: 26px; }
.contact .btn { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 30%, var(--ink)); }
.contact .btn:hover { border-color: var(--bg); }
.contact .btn-primary { background: var(--bg); color: var(--ink); border-color: var(--bg); }
.contact .btn-primary:hover { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--ink); }

.footer { padding-top: 28px; padding-bottom: 48px; font-size: 13px; color: var(--faint); }
.footer p { display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: center; border-top: 1px solid var(--line); padding-top: 24px; }
.footer a { margin-left: auto; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.footer a:hover { color: var(--ink); }

/* Myke animasjoner (slås av ved redusert bevegelse) */
.anim .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
.anim .reveal.in { opacity: 1; transform: none; }
.anim .hero > * { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.anim .hero .portrait { animation-delay: 0.08s; }
.anim .hero .hero-facts { animation-delay: 0.16s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) {
  .nav-links { display: none; }
  .controls { margin-left: auto; }
  .section { grid-template-columns: 1fr; gap: 24px; }
  .section-label { position: static; flex-direction: row; align-items: baseline; gap: 12px; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 36px; }
  .portrait { order: -1; width: 128px; font-size: 32px; box-shadow: 0 0 0 1px var(--line), 0 0 0 6px var(--bg), 0 0 0 7px var(--line); }
  .hero-facts { grid-template-columns: 1fr; }
  .hero-facts div, .hero-facts div:first-child { border-left: 0; padding: 12px 0; border-top: 1px solid var(--line); }
  .hero-facts div:first-child { border-top: 0; }
  .btn { padding: 9px 15px; font-size: 14px; }
  .entry { grid-template-columns: 38px 1fr; gap: 14px; }
  .badge { width: 38px; height: 38px; border-radius: 10px; font-size: 11px; }
  .entry::before { left: 18.5px; top: 46px; }
  .more { margin-left: 52px; }
  .posts li { grid-template-columns: 1fr; gap: 2px; }
  .footer a { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .cards article { transition: none; }
}
@media print {
  .topbar, .buttons, .more { display: none; }
  .timeline[data-collapsed="true"] .is-extra { display: grid; }
  .section { break-inside: avoid; }
  .anim .reveal { opacity: 1; transform: none; }
}
