/* ------------------------------------------------------------------
   hafthorarinsson.is: calm, minimal, light and dark
   ------------------------------------------------------------------ */

:root {
  --bg: #fbfaf8;
  --surface: #f2f0ec;
  --text: #1c1c1e;
  --muted: #5a5a60;
  --line: #e2dfd9;
  --accent: #2f5d8a;
  --accent-strong: #234a70;
  --accent-soft: #e4ecf4;
  --focus: #2f5d8a;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wrap: 60rem;
  --gutter: clamp(1rem, 4vw, 2rem);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --surface: #1d1e21;
    --text: #ecebe8;
    --muted: #a5a5ab;
    --line: #2e2f33;
    --accent: #93b6de;
    --accent-strong: #b5cdea;
    --accent-soft: #1f2a36;
    --focus: #93b6de;
  }
}

/* Base ------------------------------------------------------------- */

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0; font-weight: 650; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
img { max-width: 100%; height: auto; display: block; }

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

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

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -3rem;
  padding: 0.5rem 0.9rem;
  background: var(--text);
  color: var(--bg);
  border-radius: 8px;
  z-index: 10;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; color: var(--bg); }

/* Header ----------------------------------------------------------- */

.site-header { border-bottom: 1px solid var(--line); }

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 4rem;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
  font-size: 1.05rem;
}
.brand:hover { color: var(--accent); }

.header-inner nav { margin-left: auto; }

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.25rem;
  font-size: 0.95rem;
}
.nav-links a { color: var(--muted); text-decoration: none; }
.nav-links a:hover { color: var(--text); text-decoration: underline; }

.lang-switch {
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
}
.lang-switch:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 700px) {
  .header-inner nav { display: none; }
  .lang-switch { margin-left: auto; }
}

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

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: clamp(1.5rem, 5vw, 4rem);
  padding-block: clamp(3rem, 9vw, 6.5rem);
}

.hero h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  letter-spacing: -0.02em;
  font-weight: 700;
}

.hero-role {
  margin-top: 0.75rem;
  font-size: clamp(1.15rem, 2.4vw, 1.35rem);
  font-weight: 550;
}

.hero-tagline {
  margin-top: 0.75rem;
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.hero-aside {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 1rem;
}

.portrait {
  width: 280px;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--line);
}

@media (prefers-color-scheme: dark) {
  .portrait { filter: brightness(0.92); }
}

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .portrait { width: 200px; order: -1; }
}

.link-row {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.75rem;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--bg);
  font-size: 0.95rem;
  font-weight: 550;
  text-decoration: none;
}
.button:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--bg); text-decoration: none; }

.button-quiet {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.button-quiet:hover { background: var(--surface); border-color: var(--muted); color: var(--text); }

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

.section {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 1rem 2.5rem;
  padding-block: clamp(2.5rem, 6vw, 4rem);
  border-top: 1px solid var(--line);
}

.section-title {
  font-size: 0.85rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding-top: 0.3rem;
}

@media (max-width: 760px) {
  .section { grid-template-columns: 1fr; }
}

.section-body { min-width: 0; }

.prose > * + * { margin-top: 1rem; }
.prose p { max-width: 40rem; }

.subhead {
  font-size: 1rem;
  font-weight: 650;
  margin: 2.5rem 0 1rem;
}

.text-link { font-weight: 550; }
.text-link::after { content: " →"; }

/* Timeline --------------------------------------------------------- */

.timeline { list-style: none; }

.timeline li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 1.25rem;
  padding-block: 1.1rem;
  border-bottom: 1px solid var(--line);
}
.timeline li:first-child { padding-top: 0; }
.timeline li:last-child { border-bottom: 0; }

.when {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  padding-top: 0.1rem;
}

.timeline h3 { font-size: 1.05rem; font-weight: 600; }
.timeline .org { display: block; font-weight: 450; color: var(--muted); font-size: 0.95rem; }
.timeline p:not(.when) { margin-top: 0.4rem; }

@media (max-width: 520px) {
  .timeline li { grid-template-columns: 1fr; gap: 0.25rem; }
}

/* Education -------------------------------------------------------- */

.plain-list { list-style: none; }
.plain-list li + li { margin-top: 0.75rem; }

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

.contact-list { list-style: none; }
.contact-list li + li { margin-top: 0.5rem; }
.contact-list .label {
  display: inline-block;
  min-width: 6rem;
  color: var(--muted);
  font-size: 0.95rem;
}

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

.site-footer {
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: center;
  padding-block: 2rem 2.5rem;
}
.footer-inner a { margin-left: auto; }

/* 404 -------------------------------------------------------------- */

.not-found {
  min-height: 70vh;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 1rem;
  padding-block: 4rem;
}
.not-found .code {
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.not-found h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); }
.not-found .link-row { justify-content: center; margin-top: 0.5rem; }
