/* Personal page. Tokens and rules: DESIGN_SYSTEM.md. */

@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/schibsted-grotesk-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/schibsted-grotesk-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/schibsted-grotesk-latin-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- tokens ---------- */

:root {
  --fs-display: clamp(44px, 4vw, 56px);
  --fs-title: 24px;
  --fs-body: 17px;
  --fs-small: 14px;
  --lh-display: 1;
  --lh-title: 1.2;
  --lh-text: 1.45;
  --tr-display: -.04em;
  --tr-title: -.02em;
  --tr-text: -.01em;

  --bg: #F5F5F7;
  --label: #1D1D1F;
  --label2: #6E6E73;
  --sep: rgba(60, 60, 67, .14);
  --fill: rgba(118, 118, 128, .12);
  --fill2: rgba(118, 118, 128, .28);
  /* 0 in light, 1 in dark: drives the theme icon's sun/moon morph. */
  --dark: 0;
  color-scheme: light;

  --spring: linear(0, .009, .035 2.1%, .141, .281 6.7%, .723 12.9%, .938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, .991, .977 51%, .975 57.1%, .997 69.8%, 1.003 76.9%, 1);
  --smooth: cubic-bezier(.32, .72, 0, 1);
}

/* Dark: the system preference, unless the visitor chose light; or the visitor's explicit choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F0F10;
    --label: #F5F5F7;
    --label2: #A1A1A6;
    --sep: rgba(84, 84, 88, .42);
    --fill: rgba(118, 118, 128, .22);
    --fill2: rgba(118, 118, 128, .4);
    --dark: 1;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F0F10;
  --label: #F5F5F7;
  --label2: #A1A1A6;
  --sep: rgba(84, 84, 88, .42);
  --fill: rgba(118, 118, 128, .22);
  --fill2: rgba(118, 118, 128, .4);
  --dark: 1;
  color-scheme: dark;
}

/* ---------- base ---------- */

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

body {
  background: var(--bg);
  color: var(--label);
  font: 400 var(--fs-body) / var(--lh-text) "Schibsted Grotesk", system-ui, sans-serif;
  letter-spacing: var(--tr-text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; letter-spacing: inherit; }
ul { list-style: none; padding: 0; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--label) 35%, transparent);
  outline-offset: 2px;
  border-radius: 8px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- text roles ---------- */

.display {
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  font-weight: 700;
  letter-spacing: var(--tr-display);
}
.lead {
  max-width: 30ch;
  font-size: var(--fs-title);
  line-height: var(--lh-title);
  font-weight: 700;
  letter-spacing: var(--tr-title);
}
.small { font-size: var(--fs-small); }
.secondary { color: var(--label2); }

/* ---------- layout ---------- */

.page {
  display: grid;
  gap: 96px;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px 120px;
}

.hero {
  container-type: inline-size;
  padding-top: clamp(64px, 14vh, 136px);
}
/* One line at every width: the name is about 8.26em wide, so the column caps its size. */
.name {
  margin-top: 4px;
  white-space: nowrap;
  font-size: min(var(--fs-display), 100cqi / 8.6);
}
.intro { margin-top: 16px; }
.hero + .list { margin-top: -48px; }

.section > .list { margin-top: 24px; }
.section-text {
  max-width: 46ch;
  margin-top: 12px;
}

/* ---------- hairline list ---------- */

.list { border-top: 1px solid var(--sep); }
.list > * { border-bottom: 1px solid var(--sep); }

.row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 4px 24px;
  align-items: baseline;
  padding: 16px 0;
}
.detail {
  display: block;
  margin-top: 2px;
}

.project {
  grid-template-columns: 1fr auto;
  align-items: start;
}
.project-main {
  display: grid;
  gap: 2px;
}
.project-name { font-weight: 600; }
.project-host {
  padding-top: 2px;
  white-space: nowrap;
}
.project-arrow { display: inline-block; }
.project:hover { padding-left: 8px; }
.project:hover .project-arrow { transform: translateX(4px); }

/* ---------- link ---------- */

.link {
  text-decoration: underline dotted 1.5px;
  text-decoration-color: var(--label2);
  text-underline-offset: 4px;
}
.link:hover {
  text-decoration-style: solid;
  text-decoration-color: currentColor;
}
.link-arrow {
  display: inline-block;
  margin-left: 2px;
}
.link:hover .link-arrow { transform: translate(2px, -2px); }

/* ---------- email and Copy ---------- */

.email {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 2px;
}

.copy {
  display: none;
  place-items: center;
  min-width: 88px;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--label);
  color: var(--bg);
  font-size: var(--fs-small);
  font-weight: 600;
  cursor: pointer;
}
.js .copy { display: grid; }
.copy > * { grid-area: 1 / 1; }
.copy:active { transform: scale(.92); }
.copy-check {
  width: 18px;
  height: 18px;
  opacity: 0;
  transform: scale(.4);
}
.copy.is-done .copy-label {
  opacity: 0;
  transform: scale(.6);
}
.copy.is-done .copy-check {
  opacity: 1;
  transform: none;
}
.copy.is-fail {
  background: var(--fill);
  color: var(--label);
}

/* ---------- experience scale: 2011 → now, mark at 2015 (--commercial-start is set by the Worker) ---------- */

.experience { margin-top: 32px; }
.experience-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 40px;
}
/* Tabular figures only on numbers: in this typeface they widen punctuation in running text. */
.experience-stats .display { font-variant-numeric: tabular-nums; }
.experience-stats p {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.scale-start { --at: 0; }
.scale-commercial-start { --at: var(--commercial-start); }
.scale-now { --at: 1; }

.scale {
  position: relative;
  height: 2px;
  margin: 40px 4px 0;
  border-radius: 999px;
  background: var(--fill2);
}
.scale-commercial {
  position: absolute;
  inset-block: 0;
  left: calc(var(--commercial-start) * 100%);
  right: 0;
  border-radius: inherit;
  background: var(--label);
  transform-origin: left;
}
.scale-dot {
  position: absolute;
  top: 50%;
  left: calc(var(--at) * 100%);
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--label);
}
.scale-dot.scale-start { background: var(--label2); }

.scale-axis {
  position: relative;
  height: 20px;
  margin: 12px 4px 0;
}
.scale-axis > * {
  position: absolute;
  left: calc(var(--at) * 100%);
  transform: translateX(-50%);
}
.scale-axis > .scale-start { transform: none; }
.scale-axis > .scale-now { transform: translateX(-100%); }

/* ---------- theme icon: a sun that morphs into a crescent moon ---------- */

.theme-toggle {
  display: none;
  place-items: center;
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--label2);
  cursor: pointer;
}
.js .theme-toggle { display: grid; }
/* Only real pointers: on touch screens a tap would leave the hover state stuck. */
@media (hover: hover) {
  .theme-toggle:hover { color: var(--label); }
}
.theme-toggle:active { transform: scale(.88); }
.theme-toggle svg {
  width: 20px;
  height: 20px;
  overflow: visible;
  transform: rotate(calc(var(--dark) * -40deg));
}
.theme-toggle-core { r: calc(5px + var(--dark) * 3px); }
/* The cut lands at -5° so that, after the icon turns -40°, the crescent stands with its bite at the upper right. */
.theme-toggle-cut {
  cx: calc(24px - var(--dark) * 5px);
  cy: calc(4px + var(--dark) * 7.4px);
}
.theme-toggle-rays {
  transform-origin: 12px 12px;
  transform: scale(calc(1 - var(--dark) * .6)) rotate(calc(var(--dark) * -45deg));
  opacity: calc(1 - var(--dark));
}

/* ---------- narrow screens ---------- */

@media (max-width: 700px) {
  .page {
    gap: 80px;
    padding: 0 20px 96px;
  }
  .hero { padding-top: 64px; }
  .hero + .list { margin-top: -40px; }
  .row { grid-template-columns: 1fr; }
  .project { grid-template-columns: 1fr auto; }
}

/* ---------- motion: opt-in, so reduced motion simply gets none ---------- */

@media (prefers-reduced-motion: no-preference) {
  body { transition: background-color .4s var(--smooth), color .4s var(--smooth); }

  /* Sections fade up once as they enter the viewport. The hidden state needs JS (.js), so nothing is lost without it. */
  .reveal { transition: opacity .8s var(--smooth), transform .8s var(--smooth); }
  .js .reveal:not(.is-revealed) {
    opacity: 0;
    transform: translateY(12px);
  }

  /* The scale draws itself: the Commercial experience segment grows from 2015, then each dot pops in along the line. */
  .scale-commercial { transition: transform 1.2s .3s var(--smooth); }
  .js .reveal:not(.is-revealed) .scale-commercial { transform: scaleX(0); }
  .scale-dot { transition: transform .5s var(--spring) calc(.2s + var(--at) * 1.2s); }
  .js .reveal:not(.is-revealed) .scale-dot { transform: scale(0); }

  .link { transition: text-decoration-color .2s; }
  .link-arrow,
  .project-arrow { transition: transform .35s var(--spring); }
  .project { transition: padding .35s var(--smooth); }

  .copy { transition: transform .35s var(--spring), background-color .25s; }
  .copy > * { transition: opacity .2s, transform .45s var(--spring); }
  .copy.is-done .copy-check path {
    stroke-dasharray: 20;
    animation: draw-check .35s .05s var(--smooth) both;
  }

  .theme-toggle { transition: color .2s, background-color .4s var(--smooth), transform .3s var(--spring); }
  .theme-toggle svg { transition: transform .6s var(--spring); }
  .theme-toggle-core { transition: r .5s var(--spring); }
  .theme-toggle-cut { transition: cx .5s var(--smooth), cy .5s var(--smooth); }
  .theme-toggle-rays { transition: transform .5s var(--spring), opacity .3s; }
}

@keyframes draw-check {
  from { stroke-dashoffset: 20; }
}
