/* Registered as colors so the page's gradient can transition between
   themes, which a gradient itself can't. */
@property --background {
  syntax: "<color>";
  inherits: true;
  initial-value: #fdfdfc;
}

@property --glow {
  syntax: "<color>";
  inherits: true;
  initial-value: #9583ffaa;
}

@property --glow-edge {
  syntax: "<color>";
  inherits: true;
  initial-value: #bdfffd;
}

:root {
  --text: #1f2328;
  --muted: #59636e;
  --background: #fdfdfc;
  --glow: #9583ffaa;
  --glow-edge: #bdfffd;
  --surface: #f2f1ee;
  --border: #dedcd7;
  --link: #3787c7;
  --link-hover: #d92792;
  --measure: 40rem;
  color-scheme: light;
  transition:
    --background 0.6s,
    --glow 0.6s,
    --glow-edge 0.6s;
}

/* The theme plugin sets data-theme from the toggle, or the system setting
   when nothing has been chosen. Both blocks are needed so the page still
   follows the system setting without scripts. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --text: #e6e4df;
    --muted: #a3a09a;
    --background: #161616;
    --glow: #6a55ffaa;
    --glow-edge: #2e8f8c;
    --surface: #222221;
    --border: #3a3936;
    --link: #45a9f9;
    --link-hover: #ff75b5;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --text: #e6e4df;
  --muted: #a3a09a;
  --background: #161616;
  --glow: #6a55ffaa;
  --glow-edge: #2e8f8c;
  --surface: #222221;
  --border: #3a3936;
  --link: #45a9f9;
  --link-hover: #ff75b5;
  color-scheme: dark;
}

body {
  font-family: "Zalando Sans", system-ui, sans-serif;
  font-size: 1.125rem;
  line-height: 1.65;
  color: var(--text);
  background: linear-gradient(
    178deg,
    var(--glow-edge),
    var(--glow) 6rem,
    var(--background) 7rem
  );
  padding: 0 1.25rem;
}

.site-header,
main {
  max-width: var(--measure);
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem 0 3rem;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.site-brand img {
  border-radius: 4px;
}

/* The dot sits left in light mode and right in dark mode. */
.theme-toggle {
  position: relative;
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
}

.theme-toggle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.2rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--link);
  transform: translateY(-50%);
  transition: left 0.2s;
}

:root[data-theme="dark"] .theme-toggle::before {
  left: calc(100% - 1.2rem);
}

.site-title {
  font-weight: 700;
  font-stretch: 112%;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
}

/* Spacing between blocks, rather than on each element. */
.post-content > * + * {
  margin-top: 1.25em;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  font-weight: 700;
}

h1 {
  font-size: 2.25rem;
  font-stretch: 112%;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.6rem;
}

h3 {
  font-size: 1.3rem;
}

.post-content > :is(h2, h3, h4) {
  margin-top: 2em;
}

a {
  color: var(--link);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--link-hover);
}

blockquote {
  padding-left: 1em;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

ul,
ol {
  padding-left: 1.5em;
}

li + li {
  margin-top: 0.4em;
}

img,
video {
  border-radius: 6px;
}

video {
  width: 100%;
}

/* The images the lightbox plugin opens. */
.post-content img {
  box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.2);
  cursor: zoom-in;
}

/* Images in the same paragraph sit side by side and share its width. */
.post-content p:has(> img + img) {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.post-content p:has(> img + img) > img {
  flex: 1;
  min-width: 0;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5em 0;
}

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.875em;
}

:not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--surface);
}

pre {
  overflow-x: auto;
  border-radius: 8px;
  line-height: 1.5;
}

pre code.hljs {
  display: block;
  padding: 1rem 1.25rem;
}

/* The date comes before the post's content, and sits beside its title on
   wider screens. */
.post-date {
  display: block;
  color: var(--muted);
  font-size: 0.95rem;
  white-space: nowrap;
}

a.post-date {
  text-decoration: none;
}

.post .post-content > :first-child {
  margin-top: 0.25rem;
}

/* The content's wrapper is left out of the layout, so its title can share
   the date's row. */
@media (min-width: 36rem) {
  .post {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 1.5rem;
    align-items: baseline;
  }

  .post .post-content {
    display: contents;
  }

  .post > *,
  .post .post-content > * {
    grid-column: 1 / -1;
  }

  .post > .post-date {
    grid-row: 1;
    grid-column: 2;
  }

  .post .post-content > h1:first-child {
    grid-column: 1;
    margin-top: 0;
  }
}

main > * + *,
.post + .post,
.post-footer {
  margin-top: 4rem;
}

.post-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.5rem;
}

.post-nav a[rel="next"] {
  margin-left: auto;
  text-align: right;
}
