@layer reset, theme;

@layer theme {
  :root {
    --max-width: 70ch;

    --font-main: "NV Charis", system-ui, sans-serif;

    --color-background: light-dark(
      oklch(0.86 0.0375 90),
      oklch(0.2178 0.002 345.36)
    );
    --color-text: light-dark(oklch(0.2565 0.004 84.58), oklch(0.88 0 0));
    --color-muted: oklch(from var(--color-text) l c h / 75%);
    --color-accent: light-dark(
      oklch(0.583947 0.190625 38),
      oklch(0.7369 0.179688 55)
    );

    --step--2: clamp(0.76rem, 0.7899rem + -0.0386vw, 0.7813rem);
    --step--1: clamp(0.9375rem, 0.9324rem + 0.0227vw, 0.95rem);
    --step-0: clamp(1.125rem, 1.0994rem + 0.1136vw, 1.1875rem);
    --step-1: clamp(1.35rem, 1.295rem + 0.2443vw, 1.4844rem);
    --step-2: clamp(1.62rem, 1.5237rem + 0.4281vw, 1.8555rem);
    --step-3: clamp(1.944rem, 1.7905rem + 0.6824vw, 2.3193rem);
    --step-4: clamp(2.3328rem, 2.1011rem + 1.0298vw, 2.8992rem);
    --step-5: clamp(2.7994rem, 2.462rem + 1.4993vw, 3.624rem);

    --space-3xs: clamp(0.3125rem, 0.3125rem + 0vw, 0.3125rem);
    --space-2xs: clamp(0.5625rem, 0.5369rem + 0.1136vw, 0.625rem);
    --space-xs: clamp(0.875rem, 0.875rem + 0vw, 0.875rem);
    --space-s: clamp(1.125rem, 1.0994rem + 0.1136vw, 1.1875rem);
    --space-m: clamp(1.6875rem, 1.6364rem + 0.2273vw, 1.8125rem);
    --space-l: clamp(2.25rem, 2.1989rem + 0.2273vw, 2.375rem);
    --space-xl: clamp(3.375rem, 3.2983rem + 0.3409vw, 3.5625rem);
    --space-2xl: clamp(4.5rem, 4.3977rem + 0.4545vw, 4.75rem);
    --space-3xl: clamp(6.75rem, 6.5966rem + 0.6818vw, 7.125rem);
  }

  html {
    font-family: var(--font-main);
    font-size: var(--step-0);
  }

  body {
    display: grid;
    grid-template-rows: auto 1fr auto;

    max-inline-size: var(--max-width);
    margin-inline: auto;

    padding-inline: var(--space-xs);

    background-color: var(--color-background);
    color: var(--color-text);

    position: relative;
  }

  header {
    padding-block: 2rem;
  }

  header nav {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-s);

    @media (width < 600px) {
      flex-direction: column;
    }

    div {
      display: flex;
      align-items: center;
      gap: var(--space-s);
    }

    a {
      font-size: 1.2rem;
      font-weight: 700;
      color: var(--color-text);
      text-decoration: none;

      &:hover {
        text-decoration: underline solid var(--color-accent) 2px;
      }
    }

    svg:hover {
      fill: var(--color-accent);
    }

    button {
      background-color: transparent;
      border: none;
      color: inherit;
      cursor: pointer;
    }
  }

  main {
    margin-block-end: 2rem;

    & > * + * {
      margin-block-start: var(--prose-flow, 1em);
    }
  }

  body > footer {
    padding-block: 1rem;
    border-top: 2px solid var(--color-text);

    p {
      font-size: 16px;
      color: var(--color-muted);
    }
  }

  h1 {
    font-size: var(--step-5);
    text-align: center;

    main > & {
      margin-block-end: 2rem;
    }

    svg {
      fill: var(--color-text);
      display: inline;
      width: 1em;
      height: 1em;
      vertical-align: middle;

      &:hover {
        fill: var(--color-accent);
      }
    }
  }

  h2 {
    font-size: var(--step-3);
  }

  h3 {
    font-size: var(--step-2);
  }

  h4 {
    font-size: var(--step-1);
  }

  h5, h6 {
    font-size: var(--step-0);
  }

  hr {
    margin-block: var(--space-l);
    border-style: solid;
    border-width: 2px 0 0;
    color: inherit;
    height: 0;
    overflow: visible;
  }

  a {
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
    color: var(--color-accent);

    &:not(:is(:hover, :focus)) {
      text-decoration-color: color-mix(in srgb, currentColor, transparent 50%);
    }
  }

  small {
    display: block;
    color: var(--color-muted);
  }

  pre, code, kbd, samp {
    font-family: ui-monospace, monospace;
  }

  pre {
    white-space: pre-wrap;
    padding: 1.5em;
  }

  table {
    caption-side: bottom;
    border-collapse: collapse;

    td {
      font-size: var(--step--1);
    }

    td, th {
      word-break: normal;
      border: 2px solid gray;
      padding: 0.5em;
    }
  }

  caption {
    font-size: var(--step--1);
    margin-block-start: 0.5rem;
  }

  figcaption {
    font-size: var(--step--1);
  }

  ul, ol, dl {
    margin-inline: 0;
    padding-inline-start: 1.5em;

    & > * + * {
      margin-block-start: var(--prose-flow, 1em);
    }
  }

  li {
    & > * + * {
      margin-block-start: var(--prose-flow, 1em);
    }
  }

  sub, sup {
    font-size: var(--step--2);
  }

  caption {
    font-size: var(--step--1);
    margin-block-start: 0.5rem;
  }

  h1 + time {
    color: var(--color-muted);
  }

  blockquote {
    padding-inline-start: 1rem;
    padding-block: 0.5rem;
    border-inline-start: 4px solid var(--color-text);
  }

  [role="region"][aria-labelledby][tabindex] {
    overflow: auto;
  }

  .zola-anchor {
    text-decoration: none;
    color: inherit;
  }

  .footnotes-list {
    margin-block-start: var(--space-s);
    padding-block-start: var(--space-s);
    border-top: 2px dotted oklch(from var(--color-text) l c h / 0.5);
  }

  .footnote-reference {
    margin-inline-end: 0.2em;
  }

  .skip {
    position: absolute;
    display: inline-block;
    padding: 0.375rem 0.75rem;
    line-height: 1;
    background-color: var(--color-accent);
    color: var(--color-background);
    text-decoration: none;
    transform: translateY(0);
    transition: transform 250ms ease-in;

    &:not(:focus) {
      transform: translateY(-2rem);
    }

    &:focus {
      outline: transparent;
    }
  }

  .post {
    display: flex;
    flex-direction: row;
    justify-content: space-between;

    @media (width < 600px) {
      flex-direction: column;

      time {
        order: 1;
      }

      a {
        order: 2;
      }
    }
  }
}

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
    background-repeat: no-repeat;
    font-size-adjust: ex-height 0.5;
  }

  *:not(dialog) {
    margin: 0;
    padding: 0;
  }

  * {
    line-height: calc(1em + 0.5rem);
  }

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

    html {
      interpolate-size: allow-keywords;
    }

    :has(:target) {
      scroll-behavior: smooth;
    }
  }

  html {
    -webkit-text-size-adjust: none;
    -webkit-font-smoothing: antialiased;
    tab-size: 2;
    hanging-punctuation: first allow-end last;
    scrollbar-gutter: stable;
    block-size: 100%;
  }

  body {
    min-block-size: 100%;
  }

  img, iframe, picture, audio, video, canvas, svg {
    block-size: auto;
    border-style: none;
    display: block;
    font-style: italic;
    max-inline-size: 100%;
  }

  svg:not([fill]) {
    fill: currentColor;
  }

  input, button, textarea, select {
    font: inherit;
  }

  textarea {
    resize: vertical;
  }

  p, h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
  }

  p, li, dd {
    text-wrap: pretty;
    font-variant-numeric: proportional-nums;
  }

  h1, h2, h3, h4, h5, h6 {
    text-wrap: balance;
    font-variant-numeric: lining-nums;
  }

  math, time, table {
    font-variant-numeric: tabular-nums lining-nums slashed-zero;
  }

  code {
    font-variant-numeric: slashed-zero;
  }

  table {
    border-collapse: collapse;
  }

  sub, sup {
    line-height: 0;
    position: relative;
    vertical-align: baseline;
  }
  sub {
    inset-block-end: -0.25em;
  }
  sup {
    inset-block-start: -0.5em;
  }

  ul, ol, dl {
    ul, ol, dl {
      margin-inline-start: 2ch;
    }
  }

  figure {
    inline-size: fit-content;
    margin-inline: auto;
  }

  figcaption {
    contain: inline-size;
  }

  pre {
    white-space: pre-wrap;
  }

  :disabled {
    opacity: 0.8;
    cursor: not-allowed;
  }

  :focus-visible {
    outline-offset: 0.2rem;
  }

  :target {
    scroll-margin: 3rlh;
  }
}
