/* =====================================================================
   Styles. To change the main colour, use "theme" in content.js.
   The values below are the rest of the palette if you want to go further.
   ===================================================================== */

:root {
  --bg: #F5F7F6;          /* page background (mist) */
  --ink: #15201D;         /* main text (pine black) */
  --muted: #56635E;       /* secondary text */
  --rule: #D6DEDA;        /* lines and borders */
  --accent: #0F6B57;      /* overridden by theme.accent in content.js */
  --on-accent: #FFFFFF;   /* text on accent-coloured buttons */
  --accent-soft: #E1ECE8;
  --accent-soft: color-mix(in srgb, var(--accent) 11%, var(--bg));
  --accent-ink: color-mix(in srgb, var(--accent) 75%, var(--ink));

  --font: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --page: 1080px;
  --pad: clamp(20px, 5vw, 48px);
  --gutter: 200px;
  --measure: 680px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0F1513;
  --ink: #E4EBE8;
  --muted: #9BA9A4;
  --rule: #26322E;
  --accent: #5CC7A8;
  --on-accent: #0B1311;
  --accent-soft: #18302A;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--bg));
  --accent-ink: color-mix(in srgb, var(--accent) 80%, var(--ink));
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1513;
    --ink: #E4EBE8;
    --muted: #9BA9A4;
    --rule: #26322E;
    --accent: #5CC7A8;
    --on-accent: #0B1311;
    --accent-soft: #18302A;
    --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--bg));
    --accent-ink: color-mix(in srgb, var(--accent) 80%, var(--ink));
    color-scheme: dark;
  }
}

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

html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
#main:focus { outline: none; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 8px;
  text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--bg); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--rule);
}

.topbar-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--pad);
  height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.topbar-name {
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-nav { margin-left: auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topbar-nav::-webkit-scrollbar { display: none; }
.topbar-nav ul {
  list-style: none;
  padding: 0;
  display: flex;
  gap: 2px;
}
.topbar-nav a {
  display: block;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-nav a:hover { color: var(--ink); }
.topbar-nav a[aria-current="true"] { color: var(--ink); background: var(--accent-soft); }

.theme-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--ink); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* ---------- Page width ---------- */
#main {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--pad);
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 40px;
  padding: clamp(56px, 10vw, 120px) 0 clamp(48px, 7vw, 80px);
  border-bottom: 1px solid var(--rule);
}

.hero-name {
  font-size: clamp(2.75rem, 1.1rem + 7.2vw, 6.5rem);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.045em;
  margin-bottom: 0.3em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.hero-headline {
  max-width: 34ch;
  font-size: clamp(1.2rem, 1rem + 0.7vw, 1.55rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

.hero-meta {
  list-style: none;
  padding: 0;
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  color: var(--muted);
  font-size: 15.5px;
}

.hero-availability { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }

.pulse {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0;
  animation: pulse 2.6s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(0.5); opacity: 0.8; }
  70%, 100% { transform: scale(1.6); opacity: 0; }
}

.hero-actions {
  margin-top: 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.hero-links {
  list-style: none;
  padding: 0 0 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  font-weight: 500;
}

.hero-print-contact { display: none; }

.hero-photo {
  display: block;
  width: 168px;
  height: 168px;
  border-radius: 36px;
  object-fit: cover;
}
.hero-monogram {
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 60px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  padding: 0 22px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--ink); color: var(--bg); }

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

.btn-small { height: 34px; padding: 0 14px; font-size: 14px; border-color: var(--rule); }
.btn-small:hover { border-color: var(--ink); }

/* ---------- Sections ---------- */
.section {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  gap: 32px;
  padding: 64px 0;
  border-bottom: 1px solid var(--rule);
}
.section-compact { padding: 44px 0; }

.section-title {
  position: sticky;
  top: 88px;
  align-self: start;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: -0.005em;
}

.section-body { max-width: var(--measure); min-width: 0; }

.prose p { font-size: 1.1875rem; line-height: 1.65; text-wrap: pretty; }
.prose p + p { margin-top: 1em; }

/* ---------- Timeline (experience, education, extras) ---------- */
.timeline { list-style: none; padding: 0; }

.entry {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 20px;
}

.entry-when {
  padding-top: 2px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
.nowrap { white-space: nowrap; }

.entry-body {
  position: relative;
  padding: 0 0 40px 26px;
  border-left: 1px solid var(--rule);
}
.entry-body::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--muted);
}
.entry.is-current .entry-body::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.entry:last-child .entry-body { padding-bottom: 0; border-left-color: transparent; }
.entry:last-child .entry-body::after {
  content: "";
  position: absolute;
  left: -1px;
  top: 0;
  height: 10px;
  border-left: 1px solid var(--rule);
}
.entry:only-child .entry-body::after { display: none; }

.entry-title { font-size: 1.1875rem; font-weight: 700; line-height: 1.35; letter-spacing: -0.01em; }
.entry-org { margin-top: 2px; color: var(--muted); }
.entry-org a { color: var(--accent-ink); }
.entry-org a:hover { color: var(--accent); }
.entry-text { margin-top: 10px; text-wrap: pretty; }
.entry-facts { margin: 10px 0 0; display: grid; gap: 4px; }
.entry-facts div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; }
.entry-facts dt { color: var(--muted); }
.entry-facts dd { margin: 0; text-wrap: pretty; }

.entry-points { margin-top: 10px; padding-left: 1.15em; }
.entry-points li { margin-top: 6px; padding-left: 0.2em; text-wrap: pretty; }
.entry-points li::marker { color: var(--accent); }

.timeline-quiet .entry-body { padding-bottom: 28px; }
.timeline-quiet .entry:last-child .entry-body { padding-bottom: 0; }

.tags {
  list-style: none;
  padding: 0;
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tags li {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.6;
}

/* ---------- Projects ---------- */
.projects {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 36px 32px;
}
.project { padding-top: 16px; border-top: 2px solid var(--ink); }
.project-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.project-name { font-size: 1.1875rem; font-weight: 700; line-height: 1.35; letter-spacing: -0.01em; }
.project-name a { color: var(--accent-ink); }
.project-name a:hover { color: var(--accent); }
.project-year { color: var(--muted); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.project p { margin-top: 8px; text-wrap: pretty; }

/* ---------- Skills ---------- */
.skill-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
}
.skill-row:first-child { padding-top: 0; border-top: 0; }
.skill-row dt { font-weight: 600; }

/* ---------- Simple rows (certifications, languages, contact) ---------- */
.rows { list-style: none; padding: 0; }
.rows li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
}
.rows li:first-child { padding-top: 0; border-top: 0; }
.row-main { font-weight: 600; min-width: 0; }
.row-main a { color: var(--accent-ink); }
.row-sub { display: block; font-weight: 400; color: var(--muted); font-size: 15.5px; }
.row-side { color: var(--muted); text-align: right; overflow-wrap: anywhere; }

/* ---------- Contact ---------- */
.section-contact { border-bottom: 0; padding-bottom: 96px; }
.contact-note { font-size: 1.1875rem; line-height: 1.6; color: var(--muted); text-wrap: pretty; }

.contact-email-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin: 18px 0 36px;
}
.contact-email {
  font-size: clamp(1.5rem, 0.9rem + 2.6vw, 2.6rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--accent-ink);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.16em;
  overflow-wrap: anywhere;
}
.contact-email:hover { color: var(--accent); }
.copy-status { font-size: 14px; color: var(--accent-ink); opacity: 0; transition: opacity 0.2s; }
.copy-status.is-visible { opacity: 1; }
.contact-rows .row-main { font-weight: 500; color: var(--muted); }
.contact-rows .row-side { color: var(--ink); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--rule); }
.footer-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: 28px var(--pad);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 14.5px;
}

/* ---------- Messages ---------- */
.notice {
  max-width: 560px;
  margin: 80px auto;
  padding: 24px 28px;
  border: 1px solid var(--rule);
  border-radius: 14px;
}
.notice-error { border-color: #E4A49B; background: #FDF1EF; color: #6E2418; }
.notice h1 { font-size: 1.375rem; margin-bottom: 8px; }
.notice p + p { margin-top: 8px; }
.notice code { font-size: 0.95em; background: rgba(0, 0, 0, 0.06); padding: 1px 5px; border-radius: 4px; }

/* ---------- The one entrance moment ---------- */
.rise { animation: rise 0.75s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 90ms); }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rise, .pulse::after { animation: none; }
  .btn, .copy-status { transition: none; }
}

/* ---------- Tablet and phone ---------- */
@media (max-width: 820px) {
  .section { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 48px 0; }
  .section-compact { padding: 40px 0; }
  .section-title { position: static; font-size: 1.5rem; letter-spacing: -0.02em; }
}

@media (max-width: 640px) {
  body { font-size: 16.5px; }
  .topbar-inner { gap: 8px; }
  .topbar-name { display: none; }
  .topbar-nav {
    margin-left: -8px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
    mask-image: linear-gradient(90deg, #000 85%, transparent);
  }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .topbar-nav a { padding: 6px 10px; }

  .hero { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 40px; }
  .hero-figure { order: -1; }
  .hero-photo { width: 88px; height: 88px; border-radius: 22px; }
  .hero-monogram { font-size: 32px; }
  .hero-links { padding-left: 0; width: 100%; margin-top: 8px; }

  .entry { display: block; position: relative; padding: 0 0 32px 24px; border-left: 1px solid var(--rule); }
  .entry-when { padding: 0; margin-bottom: 2px; }
  .entry-body { position: static; padding: 0; border: 0; }
  .entry:last-child { padding-bottom: 0; border-left-color: transparent; }
  .timeline-quiet .entry { padding-bottom: 24px; }
  .timeline-quiet .entry:last-child { padding-bottom: 0; }
  .timeline-quiet .entry-body { padding-bottom: 0; }

  .skill-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .rows li { flex-direction: column; gap: 2px; }
  .row-side { text-align: left; }
  .footer-inner { flex-direction: column; gap: 4px; }
}

/* ---------- Printing / Save as PDF ---------- */
@media print {
  @page { margin: 12mm 13mm 13mm; }

  :root, :root[data-theme="dark"] {
    --bg: #FFFFFF;
    --ink: #111111;
    --muted: #4A4A4A;
    --rule: #CFCFCF;
    --accent-soft: #FFFFFF;
    --accent-ink: #111111;
    color-scheme: light;
  }

  body { font-size: 9.5pt; line-height: 1.42; background: #fff; }
  .topbar, .footer, .skip-link, .hero-actions, .hero-monogram, .pulse,
  .section-contact { display: none !important; }

  #main { max-width: none; padding: 0; }
  .rise { animation: none; }

  .hero { padding: 0 0 12pt; gap: 16pt; grid-template-columns: minmax(0, 1fr) auto; }
  .hero-name { font-size: 26pt; letter-spacing: -0.03em; margin-bottom: 4pt; }
  .hero-headline { font-size: 12pt; max-width: none; }
  .hero-meta { margin-top: 6pt; font-size: 9.5pt; }
  .hero-photo { width: 72pt; height: 72pt; border-radius: 14pt; }
  .hero-print-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 2pt 14pt;
    list-style: none;
    padding: 0;
    margin-top: 6pt;
    font-size: 9.5pt;
  }
  .hero-print-contact a { text-decoration: none; }

  .section { grid-template-columns: 96pt minmax(0, 1fr); gap: 12pt; padding: 8pt 0; }
  .section-title { position: static; font-size: 11pt; break-after: avoid; }
  .section-body { max-width: none; }
  .prose p { font-size: 9.5pt; }
  .prose p + p { margin-top: 4pt; }

  .entry { grid-template-columns: 70pt minmax(0, 1fr); gap: 10pt; }
  .entry-title, .entry-org { break-after: avoid; }
  .entry-points li, .entry-facts div, .tags { break-inside: avoid; }
  .entry-when { font-size: 9pt; }
  .entry-body, .timeline-quiet .entry-body { padding: 0 0 8pt 14pt; }
  .entry:last-child .entry-body { padding-bottom: 0; }
  .entry-body::before { top: 5pt; }
  .entry.is-current .entry-body::before { background: #111; border-color: #111; box-shadow: none; }
  .entry-title, .project-name { font-size: 10.5pt; }
  .entry-text, .entry-points, .entry-facts { margin-top: 3pt; }
  .entry-facts { gap: 1pt; }
  .entry-facts div { grid-template-columns: 56pt minmax(0, 1fr); gap: 6pt; }
  .entry-points li { margin-top: 1pt; }

  .tags { display: none; }                 /* Skills already lists these on paper… */
  #education .tags { display: flex; margin-top: 4pt; gap: 3pt; }   /* …but keep key courses */
  .tags li { padding: 0 5pt; border: 0.5pt solid #BBB; font-size: 8pt; }

  .projects { grid-template-columns: 1fr 1fr; gap: 10pt 16pt; }
  .project { border-top-width: 1pt; padding-top: 5pt; break-inside: avoid; }
  .project p { margin-top: 2pt; }

  .skill-row { grid-template-columns: 90pt minmax(0, 1fr); padding: 4pt 0; }
  .rows li { padding: 3pt 0; break-inside: avoid; }
  .row-sub { font-size: 9pt; }
  a { text-decoration: none; color: inherit !important; }
}
