:root {
  --font-sans: "Schibsted Grotesk", sans-serif;
  --font-serif: "EB Garamond", serif;

  --background: oklch(97.4% 0.009 84);
  --foreground: oklch(42.4% 0.199 265.638);
  --muted-foreground: oklch(42.4% 0.199 265.638 / 0.7);
  --highlight: color-mix(in oklch, var(--foreground) 14%, transparent);
  --grain-blend: multiply;
  --grain-opacity: 0.07;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --background: oklch(20% 0.035 265);
  --foreground: oklch(86% 0.07 265);
  --muted-foreground: oklch(86% 0.07 265 / 0.7);
  --highlight: color-mix(in oklch, var(--foreground) 20%, transparent);
  --grain-blend: screen;
  --grain-opacity: 0.04;

  color-scheme: dark;
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.2s;
    animation-timing-function: ease-out;
  }
}

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

img {
  display: block;
  max-width: 100%;
  height: auto;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background-color: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-optical-sizing: auto;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

::selection {
  background: var(--foreground);
  color: var(--background);
}

time {
  color: var(--muted-foreground);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-serif);
  text-wrap: balance;
}

p,
li,
figcaption {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
}

article {
  width: 100%;
  max-width: 65ch;
  margin-inline: auto;
  padding: 4rem 1.5rem 6rem;
  font-size: 1.0625rem;
  line-height: 1.55;
}

article > * + * {
  margin-top: 1.25em;
}

article a,
.home > p a,
.currently a {
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px
    no-repeat;
  box-decoration-break: clone;
}

article mark {
  color: inherit;
  background: linear-gradient(var(--highlight), var(--highlight)) 0 0 / 100%
    100% no-repeat;
  padding-inline: 0.1em;
}

article mark[data-highlight="pending"] {
  background-size: 0% 100%;
}

article mark[data-highlight="play"] {
  transition: background-size 0.9s ease-out;
}

@supports (initial-letter: 2) {
  article > p:first-of-type::first-letter {
    initial-letter: 2;
    margin-right: 0.15em;
    font-family: var(--font-serif);
    font-weight: 500;
  }
}

article p {
  hanging-punctuation: first;
}

article h2 {
  scroll-margin-top: 2rem;
}

article .heading-anchor {
  margin-left: 0.35em;
  background: none;
  color: var(--muted-foreground);
  opacity: 0;
  transition: opacity 0.15s;
}

article h2:hover .heading-anchor,
article .heading-anchor:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  article .heading-anchor {
    opacity: 0.4;
  }
}

article .sidenote-ref {
  margin-left: 0.1em;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.7em;
  line-height: 0;
  vertical-align: super;
  cursor: pointer;
}

article .sidenote {
  width: min(20rem, 100vw - 3rem);
  padding: 0.75rem 1rem;
  border: 1px solid var(--foreground);
  background: var(--background);
  color: var(--foreground);
  font-size: 0.875rem;
  line-height: 1.45;
}

@supports (anchor-name: --note) {
  article .sidenote {
    inset: auto;
    margin: 0.5rem 0;
    position-area: bottom span-all;
    justify-self: center;
    position-try-fallbacks: flip-block;
  }
}

@media (min-width: 72rem) {
  article .sidenote-ref {
    pointer-events: none;
  }

  article .sidenote {
    display: block;
    position: static;
    float: right;
    clear: right;
    width: 13rem;
    margin: 0.25rem -15rem 0 0;
    padding: 0;
    overflow: visible;
    border: 0;
    background: none;
    color: var(--muted-foreground);
    font-size: 0.8125rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  article a:hover,
  .home > p a:hover,
  .currently a:hover {
    animation: underline-draw 0.45s ease-out;
  }
}

@keyframes underline-draw {
  from {
    background-size: 0% 1px;
  }
}

article h1 {
  font-size: 2.75rem;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

article header p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.875rem;
  margin-top: 0.75rem;
  color: var(--muted-foreground);
  font-size: 0.9375rem;
}

article header p > * + * {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

article header p > * + *::before {
  content: "/" / "";
  opacity: 0.4;
}

article h2 {
  margin-top: 2.5em;
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1.2;
}

article h2 + * {
  margin-top: 0.75em;
}

article ul,
article ol {
  padding-left: 1.25em;
}

article li + li {
  margin-top: 0.5em;
}

article blockquote {
  padding-left: 1.25em;
  border-left: 2px solid currentColor;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  line-height: 1.35;
}

article > img,
article > figure {
  --media-width: min(60rem, 100vw - 3rem);

  width: var(--media-width);
  max-width: none;
  margin-block: 3rem;
  margin-inline: calc((100% - var(--media-width)) / 2);
}

article > .article-end {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid color-mix(in oklch, var(--foreground) 20%, transparent);
  color: var(--muted-foreground);
}

article figure img {
  width: 100%;
}

article figcaption {
  max-width: 65ch;
  margin: 0.75rem auto 0;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.site-nav {
  width: 100%;
  max-width: 65ch;
  margin-inline: auto;
  padding: 4rem 1.5rem 0;
  font-size: 1.0625rem;
}

.site-nav:has(+ .home) {
  max-width: 48rem;
}

.site-nav + main article,
.site-nav + .home {
  padding-top: 3.5rem;
}

.site-nav a {
  background: none;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
  text-decoration: none;
}

.site-nav a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.home {
  width: 100%;
  max-width: 48rem;
  margin-inline: auto;
  padding: 4rem 1.5rem 6rem;
}

a:has(> [data-signature]) {
  display: block;
  width: fit-content;
}

.home header [data-signature] {
  display: block;
  height: 5rem;
}

.home header [data-signature] path {
  stroke-width: 9;
}

.home h1 {
  margin-top: 2rem;
  font-size: 2.25rem;
  font-weight: 500;
  line-height: 1.1;
}

.home header p {
  margin-top: 0.375rem;
  color: var(--muted-foreground);
}

.home > p {
  max-width: 36rem;
  margin-top: 2rem;
  font-size: 1.0625rem;
  line-height: 1.55;
}

.home > .currently {
  display: grid;
  gap: 0.375rem;
  margin-top: 1.5rem;
  font-size: 0.9375rem;
}

.currently > div {
  display: grid;
  grid-template-columns: 1rem 1fr;
  align-items: center;
  gap: 0.75rem;
}

.currently > div[hidden] {
  display: none;
}

.currently dt {
  display: flex;
  color: var(--muted-foreground);
}

.currently dt svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-now-playing="playing"] .played,
[data-now-playing="played"] .playing {
  display: none;
}

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

.experience {
  margin-top: 5rem;
}

.experience > h2,
.post-list > h2 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  font-weight: 500;
}

.experience ol {
  border-top: 1px solid var(--foreground);
  list-style: none;
}

.experience li {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 0.25rem 0;
  padding-block: 1rem;
}

.experience li + li {
  border-top: 1px solid color-mix(in oklch, var(--foreground) 20%, transparent);
}

.experience li > span {
  color: var(--muted-foreground);
  font-size: 0.9375rem;
}

.experience h3 {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
}

.experience li p {
  margin-top: 0.25rem;
  color: var(--muted-foreground);
  font-size: 0.9375rem;
}

.post-list {
  margin-top: 5rem;
}

.post-list > h2 a {
  text-decoration: none;
}

.post-list > h2 a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.post-list > div {
  display: grid;
  grid-template-columns: 10rem 1fr;
  border-top: 1px solid var(--foreground);
}

.post-list > div + div {
  margin-top: 3rem;
}

.post-list > div > :is(h2, h3) {
  padding-block: 1rem;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
}

.post-list ul {
  list-style: none;
}

.post-list li + li {
  border-top: 1px solid color-mix(in oklch, var(--foreground) 20%, transparent);
}

.post-list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding-block: 1rem;
  text-decoration: none;
}

.post-list a span {
  font-weight: 500;
}

.post-list a:hover span {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.post-list time {
  flex-shrink: 0;
  font-size: 0.9375rem;
}

footer {
  --dash: 2px;
  --dash-gap: 4px;

  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.5rem;
  margin-top: auto;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--foreground);
}

footer ul {
  display: flex;
  gap: 1rem;
  list-style: none;
}

footer ul a {
  display: block;
}

[data-theme-toggle] {
  display: none;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

:root[data-theme] [data-theme-toggle] {
  display: block;
}

:root[data-theme="light"] [data-theme-toggle] .sun,
:root[data-theme="dark"] [data-theme-toggle] .moon {
  display: none;
}

[data-theme-toggle] svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

footer ul svg {
  display: block;
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

footer [data-signature] {
  display: block;
  height: 7rem;
}

footer [data-signature] path {
  stroke-width: 6;
}

footer p {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.25rem 1.25rem;
  grid-column: 3;
  justify-self: end;
  font-size: 0.8125rem;
}

[data-draw] path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

[data-draw="play"] path {
  animation: draw 0.7s ease-in-out forwards;
}

[data-draw="play"] path:nth-child(2) {
  animation-duration: 1.4s;
  animation-delay: 0.6s;
}

[data-draw="play"] path:nth-child(3) {
  animation-duration: 0.3s;
  animation-delay: 2s;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@media (max-width: 640px) {
  article {
    padding-top: 2.5rem;
    font-size: 1rem;
  }

  article h1 {
    font-size: 2.125rem;
  }

  article header p {
    gap: 0.25rem 0.5rem;
    font-size: 0.8125rem;
  }

  article header p > * + * {
    gap: 0.5rem;
  }

  article h2 {
    font-size: 1.5rem;
  }

  .home,
  .site-nav {
    padding-top: 2.5rem;
  }

  .post-list > div,
  .experience li {
    grid-template-columns: 1fr;
  }

  .post-list > div > :is(h2, h3) {
    padding-bottom: 0;
  }

  footer {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  footer p {
    grid-column: auto;
    justify-self: center;
  }
}

@media print {
  :root {
    --background: white;
    --foreground: black;
    --muted-foreground: oklch(40% 0 0);
  }

  @page {
    margin: 2cm;
  }

  body::before,
  footer ul,
  footer p {
    display: none;
  }

  footer {
    border: 0;
  }

  [data-draw] path {
    stroke-dashoffset: 0;
    animation: none;
  }

  article {
    max-width: none;
    padding: 0;
    font-size: 11pt;
  }

  article > img,
  article > figure {
    width: 100%;
    margin-inline: 0;
    break-inside: avoid;
  }

  article h2 {
    break-after: avoid;
  }

  article p {
    orphans: 3;
    widows: 3;
  }

  article a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
  }

  article mark,
  article mark[data-highlight] {
    background-size: 100% 100%;
    print-color-adjust: exact;
  }

  article .sidenote {
    display: block;
    position: static;
    float: none;
    width: auto;
    margin: 0.5rem 0 0.75rem 1rem;
    padding: 0 0 0 0.75rem;
    border: 0;
    border-left: 1px solid var(--muted-foreground);
    background: none;
    color: var(--muted-foreground);
  }

  article .heading-anchor {
    display: none;
  }
}
