:root {
  /* @link https://utopia.fyi/type/calculator?c=360,16,1.2,1240,17,1.25,9,3,&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,l,xl,12 */
  --step--1: clamp(0.8333rem, 0.8265rem + 0.0303vw, 0.85rem);
  --step-0: clamp(1rem, 0.9744rem + 0.1136vw, 1.0625rem);
  --step-1: clamp(1.2rem, 1.1476rem + 0.233vw, 1.3281rem);
  --step-2: clamp(1.44rem, 1.3499rem + 0.4003vw, 1.6602rem);
  --step-3: clamp(1.728rem, 1.586rem + 0.6313vw, 2.0752rem);
  --step-4: clamp(2.0736rem, 1.8607rem + 0.9462vw, 2.594rem);

  --space-3xs: clamp(0.25rem, 0.25rem + 0vw, 0.25rem);
  --space-2xs: clamp(0.5rem, 0.4744rem + 0.1136vw, 0.5625rem);
  --space-xs: clamp(0.75rem, 0.7244rem + 0.1136vw, 0.8125rem);
  --space-s: clamp(1rem, 0.9744rem + 0.1136vw, 1.0625rem);
  --space-m: clamp(1.5rem, 1.4489rem + 0.2273vw, 1.625rem);
  --space-l: clamp(2rem, 1.9489rem + 0.2273vw, 2.125rem);
  --space-xl: clamp(3rem, 2.9233rem + 0.3409vw, 3.1875rem);
  --space-2xl: clamp(4rem, 3.8977rem + 0.4545vw, 4.25rem);
  --space-3xl: clamp(6rem, 5.8466rem + 0.6818vw, 6.375rem);

  /* One-up pairs */
  --space-3xs-2xs: clamp(0.25rem, 0.1222rem + 0.5682vw, 0.5625rem);
  --space-2xs-xs: clamp(0.5rem, 0.3722rem + 0.5682vw, 0.8125rem);
  --space-xs-s: clamp(0.75rem, 0.6222rem + 0.5682vw, 1.0625rem);
  --space-s-m: clamp(1rem, 0.7443rem + 1.1364vw, 1.625rem);
  --space-m-l: clamp(1.5rem, 1.2443rem + 1.1364vw, 2.125rem);
  --space-l-xl: clamp(2rem, 1.5142rem + 2.1591vw, 3.1875rem);
  --space-xl-2xl: clamp(3rem, 2.4886rem + 2.2727vw, 4.25rem);
  --space-2xl-3xl: clamp(4rem, 3.0284rem + 4.3182vw, 6.375rem);

  /* Custom pairs */
  --space-s-l: clamp(1rem, 0.5398rem + 2.0455vw, 2.125rem);
  --space-s-2xl: clamp(1rem, -0.3295rem + 5.9091vw, 4.25rem);

  --old-style:
    "Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, serif;
  --transitional: Charter, "Bitstream Charter", "Sitka Text", Cambria, serif;
  --monospace-code:
    ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas,
    "DejaVu Sans Mono", monospace;
  --neo-grotesque:
    Inter, Roboto, "Helvetica Neue", "Arial Nova", "Nimbus Sans", Arial,
    sans-serif;

  --bg: #f9f3ea;
  --fg: #311e1e;
  --bg-filled: hsl(0, 19%, 15%);
  --small-caps-kerning: 0.025em;
  --outline: rgba(49, 30, 30, 0.35);
  --outline-hover: rgba(49, 30, 30, 0.65);
  --border: rgba(49, 30, 30, 0.3);
  --shade: black 4%;
  --shade-1: black 8%;
  --display-font: var(--old-style);
  --body-font: var(--transitional);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: hsl(0, 0%, 80%);
    --bg: hsl(0, 0%, 7%);
    --bg-filled: hsl(0, 0%, 70%);
    --small-caps-kerning: 0.025em;
    --outline: hsl(0, 0%, 20%);
    --outline-hover: white;
    /*--outline: rgba(49, 30, 30, 0.35);*/
    --border: hsl(0, 0%, 20%);
    --shade: white 7%;
    --shade-1: white 14%;

    --display-font: var(--monospace-code);
    --body-font: var(--neo-grotesque);
  }
}

html {
  scroll-behavior: smooth;
  font-family: var(--body-font);
  font-size: var(--step-0);
  line-height: 1.3;
  color: var(--fg);
  background-color: var(--bg);
  scrollbar-gutter: stable;
}

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

body * {
  text-rendering: optimizeLegibility;
}

body {
  box-sizing: content-box;
  max-width: 30rem;
  font-size: var(--step-0);
  padding: var(--space-s-l) var(--space-s-2xl);
  margin-inline: auto;
}

:is(h1:has(a), h2:has(a), h3:has(a), h4:has(a)) {
  scroll-margin-top: var(--space-s);
}

h1,
h2,
h3,
h4 {
  font-size: inherit;
  font-family: var(--display-font);
  line-height: 1;
  margin-bottom: var(--space-2xs);
  font-variant: all-small-caps;
  font-feature-settings: "smcp";
  /*letter-spacing: var(--small-caps-kerning);*/
}

h2:not(.toc h2) {
  font-size: var(--step-2);
  border-bottom: 1px dashed var(--fg);
  padding-bottom: var(--space-2xs);
  margin-bottom: var(--space-2xs);
}

h3 {
  font-size: var(--step-1);

  &:has(a) {
    margin-top: var(--space-s);
  }
}

h4:has(a) {
  margin-top: var(--space-s);
}

h1,
h2 {
  margin-top: var(--space-l);
}

h1.blog {
  font-size: var(--step-1);
  /*text-align: center;*/
  margin-bottom: var(--space-xs);
  margin-top: -0.25em !important;
}

h2.blog {
  margin-top: -0.25em !important;
}

h1 a:not(.exception),
h2 a:not(.exception),
h3 a:not(.exception),
h4 a:not(.exception) {
  color: var(--fg);
  text-decoration: none;
}

:has(> .sidebar) {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sidebar-gap, 1rem);
}

.sidebar {
  /* ↓ The width when the sidebar *is* a sidebar */
  flex-basis: var(--sidebar-size, 20rem);
  flex-grow: 1;
}

:has(> .sidebar) > :not(.sidebar) {
  /* ↓ Grow from nothing */
  flex-basis: 0;
  flex-grow: 999;
  /* ↓ Wrap when the elements are of equal width */
  min-inline-size: var(--sidebar-wrap-at, 60%);
}

main > *:first-child {
  margin-top: 0;
}

main h2:not(:has(> a)) {
  padding-top: 0;
}

main li:not(article.release li),
main p:not(article.release p) {
  line-height: 1.3;
  text-align: justify;
  hyphens: auto;
}

p.ui {
  line-height: 1.3 !important;
}

ol,
ul,
p {
  margin-bottom: var(--space-s);
}

ol:last-child,
ul:last-child,
* p:last-child {
  margin-bottom: 0;
}

ul > ol,
ul > ul,
ol > ol,
ol > ul {
  margin-bottom: 0;
}

a[href] {
  color: var(--secondary);
  text-underline-offset: 0.15em;

  &:not(:has(code)) {
    font-style: italic;
  }

  &:has(code) {
    /*text-decoration-style: dashed;*/
    text-underline-offset: 0.1em;
  }
}

h1 a[href],
h2 a[href],
h3 a[href],
h4 a[href] {
  font-style: normal;
}

a:not([href]) {
  /* color: var(--secondary); */
  text-decoration: line-through;

  &:hover {
    text-decoration: line-through;
  }
}

/* a.active { */
/* background-color: var(--secondary); */
/* color: var(--bg); */
/* } */

a.active,
a:hover {
  text-decoration: none;
}

/* a:visited { */
/* color: var(--visited); */
/* } */

figure {
  /* margin-bottom: var(--space-m); */
  margin-bottom: var(--space-s);
}

figure:has(+ h2, + h3, + h4) {
  /* margin-bottom: var(--space-2xs); */
  margin-bottom: 0;
}

/* figure:has(+ p) { */
/* margin-bottom: var(--space-s); */
/* } */

img {
  transition:
    outline-color 200ms,
    border-color 200ms,
    transform 200ms,
    filter 200ms;
  display: block;
  /* margin-inline: auto; */
  width: 100%;
  height: auto;

  @media (prefers-color-scheme: light) {
    outline: 1px solid var(--outline);
    outline-offset: -1px;
    /*mix-blend-mode: multiply;*/
  }

  @media (prefers-color-scheme: dark) {
    /*filter: brightness(0.8);*/
    border: 1px solid hsl(0, 0%, 70%);
    /*outline: rgba(220, 220, 220, 0.55);*/

    &:hover {
      /*filter: brightness(0.9);*/
      border: 1px solid hsl(0, 0%, 90%);
    }
  }
  /*mix-blend-mode: difference;*/

  &:hover {
    outline-color: var(--outline-hover);
  }
}

img:not(article.release img) {
  width: auto;
  max-width: 100%;
}

figcaption {
  font-size: var(--step--1);
  line-height: 1.2;
  color: var(--fg);
  margin-block-start: var(--space-2xs);
  margin: var(--space-2xs);
  text-align: center;

  a {
    color: var(--fg);
  }
}

hr {
  border: 0;
  border-top: 1px dashed var(--fg);
  margin-block: var(--space-s);
}

header nav,
footer nav,
nav {
  ul {
    list-style: none;

    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3xs) var(--space-xs);
  }
}

header {
  margin-bottom: var(--space-s);
  /*padding-bottom: var(--space-s);
  border-block-end: 1px dashed var(--fg);*/
  padding: var(--space-s);
  border: 1px dashed var(--fg);
  outline: 1px dashed var(--fg);
  outline-offset: -3px;

  svg {
    display: none;
    height: var(--space-3xl);
    width: auto;
  }

  h1 {
    font-size: var(--step-4);
    text-transform: uppercase;
    margin-block-start: 0;
    margin-block-end: var(--space-3xs);
    /*text-align: center;*/
    font-weight: normal;
    font-variant: normal;
  }

  picture {
    flex-shrink: 0;
    transition: filter 200ms ease-in-out;

    &:hover {
      filter: brightness(75%);
      /* transform: rotate(10deg); */
    }
  }

  img {
    aspect-ratio: 1/1;
    height: 4.5rem;
    height: 6cap;
    width: auto;
    border-radius: 50%;
  }
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-s);

  .left > * {
    margin-bottom: var(--space-3xs) !important;
  }

  .left > *:last-child {
    margin-bottom: 0 !important;
  }

  .right svg {
    height: 4rem;
    width: auto;
    fill: red;
    stroke: var(--fg);
  }
}

footer {
  nav:first-child li:first-child {
    font-family: var(--display-font) !important;
    font-weight: bold;

    a {
      color: var(--fg);
      text-decoration: none;
      font-style: normal;

      &:hover ~ .logo {
        filter: brightness(75%);
      }
    }
    /* a.active { */
    /* background-color: var(--fg); */
    /* color: var(--bg); */
    /* text-decoration: none; */
    /* } */
  }
}

main ol,
main ul {
  margin-inline-start: var(--space-m);
}

article.release {
  /* display: grid; */
  /* grid-template-columns: 1fr 2fr; */
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s);
  padding-top: var(--space-s);
  margin-top: var(--space-s);
  align-items: center;

  h3 {
    font-variant: none;
    font-size: var(--step-0);
    line-height: 1.3;
    font-feature-settings: normal;
  }

  img {
    /* width: 160px; */
    aspect-ratio: 1/1;
    overflow: auto;

    /* &:hover {
      transform: translateY(-0.1rem);
    } */
  }

  p {
    text-wrap: pretty;
  }

  a.sidebar {
    --sidebar-size: 10rem;
  }

  > div {
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    > div {
      margin-top: -0.2em;

      h3 span {
        font-weight: normal;
      }

      h3,
      p,
      nav {
        padding-top: 0;
        margin-top: 0;
        margin-bottom: var(--space-3xs);
      }

      h4 {
        font-weight: normal;
      }

      nav ul {
        list-style: none;

        display: flex;
        flex-wrap: wrap;
        flex: 1 0 30ch;
        margin-inline-start: 0;
        gap: var(--space-3xs) var(--space-xs);
      }
    }
  }
}

.smcp,
smallcaps {
  font-variant: all-small-caps;
  font-feature-settings: "smcp";
  /*letter-spacing: var(--small-caps-kerning);*/
}

time,
.oldstyle {
  font-variant-numeric: oldstyle-nums;
  font-feature-settings: "onum";
}

article.resource {
  /* text-align: center; */
  padding: var(--space-s);
  border-inline-start: 1px solid var(--fg);
  background-color: color-mix(in oklab, var(--bg), var(--shade));
  border-radius: 0 0.25rem 0.25rem 0;

  &.blog {
  }

  @media (prefers-color-scheme: dark) {
    /*background-color: var(--bg-filled);

    * {
      color: var(--bg);
    }*/
  }

  h2,
  p:first-child {
    font-family: var(--display-font) !important;
    text-transform: uppercase;

    @media (prefers-color-scheme: light) {
      font-variant: all-small-caps;
      font-feature-settings: "smcp";
    }
    @media (prefers-color-scheme: dark) {
      font-size: var(--step--1);
    }

    /*letter-spacing: 0.05em;*/
    margin-block-end: var(--space-3xs);
    line-height: 1.2;
    font-weight: bold;
    text-align: start;

    a[href] {
      font-style: normal;
      text-decoration-style: dotted;
    }
  }

  p {
    margin-block-end: var(--space-2xs);
  }

  ul {
    padding-block-start: var(--space-2xs);
    border-block-start: 1px dashed var(--fg);
    list-style: none;
    margin-inline-start: 0;
  }

  p:not(:first-child) {
    font-size: var(--step-0);
  }

  margin-block-end: var(--space-s);

  figure {
    padding: var(--space-3xs);
    background-color: var(--bg);
    border: 1px dashed var(--fg);
  }

  img {
    margin-inline: auto;
  }

  > *:last-child {
    margin-block-end: 0;
  }
}

#toc {
  padding-top: var(--space-s);

  .toc {
    padding: var(--space-2xs) 0;
    border-inline-start: 2px solid var(--border);
    padding-inline-start: var(--space-s);

    nav ul {
      list-style: none;
      margin-inline-start: 0;
      display: flex;
      flex-wrap: wrap;
      gap: 0 var(--space-s);
      font-family: var(--display-font);
      text-transform: uppercase;

      @media (prefers-color-scheme: light) {
        font-variant: all-small-caps;
        font-feature-settings: "smcp";
      }

      @media (prefers-color-scheme: dark) {
        font-size: var(--step--1);
      }
      /*letter-spacing: var(--small-caps-kerning);*/
      margin-block-end: var(--space-2xs);

      a {
        font-style: normal;
      }
    }

    h2 {
      padding-top: 0;
      margin-top: 0;
      margin-bottom: 0;
      font-size: var(--step-0);
    }
  }
}

main p:has(+ h3, + h4, + #toc) {
  margin-bottom: 0;
}

h2 + article.release {
  padding-top: 0;
  margin-top: 0;
  margin-bottom: var(--space-s);
}

article.release:has(+ p.ui) {
  margin-bottom: var(--space-s);
}

a[href=""],
a:not([href]) {
  text-decoration: line-through;
  color: var(--fg);
  cursor: default;
  pointer-events: none;
}

p.metadata {
  line-height: 1.3;
  font-variant-numeric: oldstyle-nums;
  font-feature-settings: "onum";

  a[href] {
    font-style: normal;
    text-decoration-style: dotted;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::after,
  *::before {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

main {
  display: flex;
  flex-direction: column;
  column-gap: var(--space-s);
  row-gap: var(--space-s);

  .secondary > section > h2:first-child {
    margin-block-start: -0.25em;
  }

  .primary > *:first-child {
    padding-block-start: 0;
    margin-block-start: 0;
  }

  section {
    height: fit-content;

    > *:first-child {
      margin-block-start: 0;
    }

    > *:last-child {
      margin-block-end: 0;
    }
  }

  .secondary {
    display: flex;
    flex-direction: column;
    gap: var(--space-s);

    section {
      border-block-start: 1px dashed var(--fg);
      padding-block-start: var(--space-s);
    }

    section:nth-child(1) {
      grid-area: left;
    }

    section:nth-child(2) {
      grid-area: right;
    }
  }
}

@media (min-width: 58rem) {
  body {
    max-width: 50rem;
  }

  main {
    display: grid;
    grid-template-columns: 34rem 1fr;
    grid-template-areas:
      "primary left"
      "primary right";
    row-gap: 0;

    .primary {
      border-inline-end: 1px dashed var(--fg);
      padding-inline-start: 0;
      padding-inline-end: var(--space-s);
      min-height: 100%;
    }

    .secondary {
      gap: 0;

      section {
        padding-inline: 0;
      }

      .left {
        border-block-start: none;
        padding-block-start: 0;
      }

      .right {
        display: block;
        padding-block-start: var(--space-s);
        border-block-start: 1px dashed var(--fg);
        margin-block-start: var(--space-s);
      }
    }
  }
}

svg {
  fill: var(--fg);
  stroke: var(--fg);
}

svg.title {
  margin-block-end: var(--space-xs);
}

@media (min-width: 74rem) {
  header {
    display: flex;
    flex-direction: column;
    align-items: center;

    svg {
      display: block;
      fill: var(--fg);
      stroke: var(--fg);
    }
  }

  body {
    max-width: 66rem;
  }

  header {
    h1 {
      text-align: center;
    }

    nav ul {
      justify-content: center;
    }
  }

  main {
    display: grid;
    grid-template-columns: 1fr 34rem 1fr;
    grid-template-areas: "left primary right";
    row-gap: 0;

    section {
      min-height: 100%;
    }

    .primary {
      border-inline: 1px dashed var(--fg);
      padding-inline: var(--space-s);
    }

    .secondary {
      display: contents;

      .right {
        padding-block-start: 0;
        border-block-start: none;
        margin-block-start: 0;
      }

      section:nth-child(1) {
        padding-inline-start: 0;
      }

      section:nth-child(2) {
        padding-inline-end: 0;
      }
    }
  }
}

.secondary {
  h2 {
    border-block-end: none !important;
    padding-block-end: 0 !important;
    /*text-align: center;*/
  }

  .left p {
    font-size: var(--step--1);
  }

  .left,
  .right {
    > *:first-child {
      padding-block-start: 0;
    }
  }
}

.box {
  padding: var(--space-s);

  &:not(.inversed) {
    border: 1px dashed var(--fg);
    outline: 1px dashed var(--fg);
    outline-offset: -3px;
  }

  ul {
    list-style: none;
    margin-inline-start: 0;

    > * + * {
      margin-block-start: var(--space-3xs);
    }
  }

  h2 {
    font-size: var(--step-1) !important;
    text-align: center;
    padding-block-end: 0 !important;
    border-block-end: none !important;
    /*margin-block-start: -0.25em !important;*/
  }

  p,
  li {
    font-size: var(--step--1);
    text-align: left !important;
  }

  &.inversed {
    background-color: var(--bg-filled);
    color: var(--bg);
    border-radius: 2px;
    outline: 1px dashed var(--bg);
    outline-offset: -6px;

    p,
    li,
    a {
      color: var(--bg);
    }
  }
}

* > h2:first-child {
  margin-block-start: 0;
}

.profiles {
  ul {
    list-style: none;

    display: flex;
    flex-wrap: wrap;
    margin-inline-start: 0;
    gap: var(--space-3xs) var(--space-xs);
  }
}

code {
  font-family: var(--monospace-code);
  font-size: var(--step--1);
  background-color: color-mix(in oklab, var(--bg), var(--shade-1));
  border-radius: 2px;
  padding-inline: 4px;
}
