@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,100..700;1,100..700&family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap");

:root {
  --spacing: 0.25rem;
  --font-sans: "IBM Plex Sans", sans-serif;
  --font-mono: "Roboto Mono", monospace;

  --text-sm: 0.875rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  /* Convert fixed line heights to multiples of respective font sizes */
  --text-xl-line-height: calc(1.75 / 1.25);
  --text-2xl-line-height: calc(2 / 1.5);
  --text-3xl-line-height: calc(2.25 / 1.875);
  --content-width: 42rem;

  --color-slate-100: #f1f5f9;
  --color-slate-300: #cbd5e1;
  --color-slate-600: #475569;
  --color-slate-800: #1e293b;
  --color-slate-900: #0f172a;
  --color-slate-950: #020617;
  --color-cyan-600: #0891b2;
  --color-blue-400: #60a5fa;

  /* Theme variables */
  --color-background: var(--color-slate-100);
  --color-text: var(--color-slate-900);
  --color-faint: var(--color-slate-600);
  --color-link-hovered: var(--color-cyan-600);
  --color-code-bg: var(--color-slate-300);
  --code-roundness: 0.2rem;
}

/* Theme classes */
[data-theme="dark"] {
  --color-background: var(--color-slate-950);
  --color-text: var(--color-slate-100);
  --color-link-hovered: var(--color-blue-400);
  --color-code-bg: var(--color-slate-800);
  --color-faint: var(var(--color-slate-600));

  .dark-only {
    display: block;
  }
  .light-only {
    display: none;
  }
}

[data-theme="light"],
html:not([data-theme]) {
  .dark-only {
    display: none;
  }
  .light-only {
    display: block;
  }
}

/* Base element styles. */
h1,
h2 {
  font-weight: bold;
  font-size: var(--text-3xl);
  line-height: var(--text-3xl-line-height);
}

a {
  color: inherit;
  transition-duration: 100ms;
  &:hover {
    color: var(--color-link-hovered);
  }
  &.no-underline {
    text-decoration: none;
  }
}

button {
  border: none;
  background-color: transparent;
  border-radius: 0;
  color: inherit;
  padding: 0;
}

span,
div {
  &.nowrap {
    text-wrap: nowrap;
  }
  &.faint {
    color: var(--color-faint);
  }
  &.flex-row {
    display: flex;
    flex-direction: row;
    gap: calc(var(--spacing) * 3);
  }
  &.flex-col {
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing) * 2);
  }
  &.center {
    max-width: var(--content-width);
    margin-inline: auto;
  }
}

svg {
  display: block;
}

/* Layout styles */
html {
  background-color: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: 1.5;
}

body {
  margin: calc(var(--spacing) * 4);
  font-size: var(--text-xl);
  line-height: var(--text-xl-line-height);

  @media (width >= 48rem) {
    & {
      margin: calc(var(--spacing) * 12);
      font-size: var(--text-2xl);
      line-height: var(--text-2xl-line-height);
    }
  }
}

header {
  margin-bottom: calc(var(--spacing) * 16);
  h1 {
    margin-block: calc(var(--spacing) * 4);
  }
}
nav {
  display: flex;
  flex-direction: row;
  gap: calc(var(--spacing) * 3);
  font-weight: bold;
  font-size: var(--text-2xl);
  line-height: var(--text-2xl-line-height);
}

main,
footer {
  max-width: var(--content-width);
}

/* Blog post */
article {
  font-size: var(--text-xl);
  line-height: var(--text-xl-line-height);

  .author {
    font-size: var(--text-xl);
    line-height: var(--text-xl-line-height);
    @media (width >= 48rem) {
      font-size: var(--text-2xl);
      line-height: var(--text-2xl-line-height);
    }
  }
  h1 {
    margin-block: calc(var(--spacing) * 7);
  }

  /* Dividers */
  hr {
    color: var(--color-faint);
    margin-block: calc(var(--spacing) * 10);
  }

  /* Caption space (if needed) */
  img {
    margin-bottom: calc(var(--spacing) * 2);
    max-width: 100%;
  }

  /* Paragraph spacing */
  p,
  pre,
  ul,
  ol {
    margin-block: calc(var(--spacing) * 6);
  }

  ul {
    padding-left: calc(var(--spacing) * 8);
  }

  ol {
    list-style-type: decimal;
  }

  /* Tables */
  th,
  td {
    padding-inline: calc(var(--spacing) * 2);
  }
  pre,
  code {
    border-radius: var(--code-roundness);
  }
  pre {
    padding: 1em;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
  }
  /* Inline code */
  :not(pre) > code {
    padding: 0.15em 0.2em;
    font-size-adjust: 0.4;
    background-color: var(--color-code-bg);
  }
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: calc(var(--spacing) * 2);
  margin: 0;
  padding: 0;
  li {
    list-style-type: none;
    display: flex;
    flex-direction: column;
    @media (width >= 40rem) {
      & {
        flex-direction: row;
        gap: calc(var(--spacing) * 3);
      }
    }
  }
}

footer {
  display: flex;
  flex-direction: column-reverse;
  margin-top: calc(var(--spacing) * 8);
  gap: calc(var(--spacing) * 3);
  color: var(--color-faint);

  @media (width >= 48rem) {
    & {
      flex-direction: row;
    }
  }
}
