@font-face {
  font-family: "Open Sans";
  src: url("/assets/fonts/open-sans-normal.woff2") format("woff2");
  font-weight: 300 800;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: "Open Sans";
  src: url("/assets/fonts/open-sans-italic.woff2") format("woff2");
  font-weight: 300 800;
  font-style: italic;
  font-display: block;
}

@font-face {
  font-family: "Averia Serif Libre";
  src: url("/assets/fonts/averia-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: "Averia Serif Libre";
  src: url("/assets/fonts/averia-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: block;
}

@font-face {
  font-family: "Averia Serif Libre";
  src: url("/assets/fonts/averia-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: block;
}

:root {
  color-scheme: light;
  --bg: #f3e5c8;
  --text: #3a2414;
  --muted: #7a4f2c;
  --faint: #85592f;
  --accent: #b5450f;
  --accent-strong: #8f3207;
  --track: #e4cfa6;
  --selection: #f0b45a;
  --card-line: #e0c79a;
  --card-pad: 1.75rem;

  --font-body: "Open Sans", system-ui, sans-serif;
  --font-display: "Averia Serif Libre", Georgia, serif;

  --column: 40rem;
  --edge: 1.5rem;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a120b;
  --text: #f7c27a;
  --muted: #c98d4c;
  --faint: #b07a45;
  --accent: #ff8a3d;
  --accent-strong: #ffad6e;
  --track: #3a2716;
  --selection: #6b3c14;
  --card-line: #3e2a17;
}

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

html {
  background: var(--bg);
  scrollbar-color: var(--faint) var(--bg);
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  padding: 6rem var(--edge) 4rem;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.75 var(--font-body);
  caret-color: var(--accent);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

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

a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
  transition: color 160ms var(--ease-out);
}

a:hover {
  color: var(--accent-strong);
}

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

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

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

/* Header */

.site-header {
  position: absolute;
  inset: var(--edge) var(--edge) auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.site-header > * {
  pointer-events: auto;
}

.home-button {
  display: inline-grid;
  place-items: center;
  min-width: 2.75rem;
  height: 2.75rem;
  padding-inline: 0.25rem;
  color: var(--text);
  transition: color 160ms var(--ease-out);
}

.home-button:hover {
  color: var(--accent);
}

.home-bat {
  display: block;
  width: 3.25rem;
  height: auto;
  transition: transform 260ms var(--ease-out);
}

.bat-body {
  fill: currentColor;
}

/* The face details are cut-outs, so they take the page background in either theme. */
.bat-detail {
  fill: var(--bg);
}

@media (hover: hover) {
  .home-button:hover .home-bat {
    transform: translateY(-0.125rem);
  }
}

theme-toggle {
  display: inline-flex;
}

.theme-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  color: var(--muted);
  font: 400 0.95rem/1 var(--font-display);
  cursor: pointer;
  user-select: none;
}

.theme-control:hover {
  color: var(--text);
}

.when-os-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .when-os-light {
    display: none;
  }

  .when-os-dark {
    display: inline;
  }
}

.toggle-input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.toggle-track {
  position: relative;
  display: inline-block;
  width: 3.25rem;
  height: 1.75rem;
  border: 3px solid currentColor;
  border-radius: 999px;
  background: transparent;
  transition: background-color 220ms var(--ease-out);
}

.toggle-knob {
  position: absolute;
  top: 50%;
  left: 0.2rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-50%);
  transition: transform 260ms var(--ease-out), background-color 220ms var(--ease-out);
}

/* "On" means the page theme differs from the browser's default; pure CSS so it never flashes. */
@media (prefers-color-scheme: light) {
  [data-theme="dark"] .toggle-track {
    background: var(--accent);
    border-color: var(--accent);
  }

  [data-theme="dark"] .toggle-knob {
    background: var(--bg);
    transform: translate(1.45rem, -50%);
  }
}

@media (prefers-color-scheme: dark) {
  [data-theme="light"] .toggle-track {
    background: var(--accent);
    border-color: var(--accent);
  }

  [data-theme="light"] .toggle-knob {
    background: var(--bg);
    transform: translate(1.45rem, -50%);
  }
}

.toggle-input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Column width + both header controls + edges; below this they would collide with the posts. */
@media (max-width: 72rem) {
  body {
    padding-top: var(--edge);
  }

  .site-header {
    position: static;
    max-width: var(--column);
    margin: 0 auto 3rem;
    pointer-events: auto;
  }

  .home-button {
    margin-left: -0.25rem;
  }
}

/* Home */

.site-title {
  margin: 0 0 1rem;
  color: var(--text);
  font-size: 3rem;
}

.site-intro {
  max-width: 39rem;
  margin: 0;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.65;
  text-wrap: pretty;
}

.category-filters {
  margin: 2rem 0 2.5rem;
}

.category-filter-title {
  margin: 0 0 0.35rem;
  color: var(--faint);
  font: 400 0.9rem/1.4 var(--font-display);
}

.category-filter-list,
.post-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.category-filter-list a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.75rem;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  font-family: var(--font-display);
  text-decoration: none;
}

.category-filter-list a:hover,
.category-filter-list a[aria-current="page"] {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.category-count {
  color: var(--faint);
  font: 400 0.8rem/1 var(--font-body);
  font-variant-numeric: tabular-nums;
}

.category-results {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.category-results strong {
  color: var(--text);
  font-family: var(--font-display);
}

.post-categories {
  position: relative;
  z-index: 2;
  gap: 0.25rem 0.9rem;
  margin-top: 1rem;
  font: 400 0.9rem/1.4 var(--font-display);
}

.post-categories a {
  color: var(--muted);
  text-decoration-thickness: 1px;
}

.post-categories a:hover {
  color: var(--accent-strong);
}

.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-list > li + li {
  margin-top: 3.5rem;
}

.post-card {
  position: relative;
  margin-inline: calc(var(--card-pad) * -1);
  padding: var(--card-pad);
  border: 2px solid transparent;
  border-radius: 1.25rem;
  cursor: pointer;
  transition: border-color 200ms var(--ease-out);
}

@media (hover: hover) {
  .post-card:hover {
    border-color: var(--card-line);
  }

  .post-card:hover .post-card-title a {
    color: var(--accent);
  }

  .post-card:hover .post-cta {
    color: var(--accent-strong);
    transform: translateX(0.25rem);
  }
}

.post-date {
  margin: 0 0 0.75rem;
  color: var(--faint);
  font: 400 0.95rem/1.4 var(--font-display);
  font-style: italic;
  font-variant-numeric: tabular-nums;
}

.post-card-title {
  margin: 0 0 1.5rem;
  font-size: clamp(1.9rem, 5vw, 2.6rem);
}

.post-page-categories {
  margin-top: 1rem;
}

.post-card-title a {
  color: var(--text);
  text-decoration: none;
}

/* z-index keeps the overlay above the masked excerpt, which forms its own stacking context. */
.post-card-title a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.post-excerpt {
  max-height: max(40vh, 16rem);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent);
  mask-image: linear-gradient(to bottom, #000 45%, transparent);
}

.post-cta {
  margin: 0.5rem 0 0;
  color: var(--accent);
  font: 700 1rem/1.4 var(--font-display);
  letter-spacing: 0.02em;
  transition: color 160ms var(--ease-out), transform 260ms var(--ease-out);
}

.post-cta::after {
  content: " \2192";
}

.post-card:has(.post-card-title a:focus-visible) .post-card-title a {
  color: var(--accent);
}

.post-card:has(.post-card-title a:focus-visible) .post-cta {
  color: var(--accent-strong);
  transform: translateX(0.25rem);
}

.post-card:focus-within .post-card-title a:focus-visible {
  outline: none;
}

.post-card:has(.post-card-title a:focus-visible) {
  border-color: var(--card-line);
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 44rem) {
  :root {
    --card-pad: 1rem;
  }

  .site-title {
    font-size: 2.35rem;
  }
}

/* Pagination */

.pagination {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  margin-top: 4rem;
  font-family: var(--font-display);
}

.pagination-count {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.pagination-arrow {
  display: inline-grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  color: var(--accent);
}

.pagination-arrow svg {
  width: 1.75rem;
  height: 1.75rem;
}

a.pagination-arrow:hover {
  color: var(--accent-strong);
}

a.pagination-arrow[rel="prev"]:hover svg {
  transform: translateX(-0.2rem);
}

a.pagination-arrow[rel="next"]:hover svg {
  transform: translateX(0.2rem);
}

.pagination-arrow svg {
  transition: transform 260ms var(--ease-out);
}

.pagination-arrow[aria-disabled="true"] {
  color: var(--faint);
  opacity: 0.45;
}

/* Post */

.post-header {
  margin-bottom: 3rem;
}

.post-title {
  margin: 0;
  font-size: clamp(2.3rem, 7vw, 3.5rem);
}

.post-description {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.2rem;
  font-style: italic;
  line-height: 1.5;
  text-wrap: pretty;
}

/* Prose */

.prose {
  overflow-wrap: break-word;
  text-wrap: pretty;
}

.prose > :first-child {
  margin-top: 0;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote {
  margin: 0 0 1.4em;
}

.prose h2 {
  margin: 2.4em 0 0.6em;
  font-size: 1.6rem;
}

.prose h3 {
  margin: 2em 0 0.5em;
  font-size: 1.3rem;
}

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

.prose li::marker {
  color: var(--accent);
  font-family: var(--font-display);
}

.prose blockquote {
  margin-inline: 0;
  padding-left: 1.5em;
  color: var(--muted);
  font: italic 400 1.3rem/1.5 var(--font-display);
  text-indent: -0.45em;
}

.prose blockquote p::before {
  content: "\201C";
  color: var(--accent);
}

.prose img {
  max-width: 100%;
  height: auto;
  outline: 1px solid oklch(0 0 0 / 0.1);
  outline-offset: -1px;
}

[data-theme="dark"] .prose img {
  outline-color: oklch(1 0 0 / 0.1);
}

.prose pre {
  overflow-x: auto;
}

/* Footer */

.site-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem 3rem;
  margin-top: 9rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.site-footer p {
  margin: 0;
}

.footer-title,
.footer-elsewhere h2 {
  margin: 0 0 0.5rem;
  color: var(--text);
  font: 700 1.05rem/1.3 var(--font-display);
}

.footer-elsewhere ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-elsewhere li + li {
  margin-top: 0.25rem;
}

.footer-copyright {
  grid-column: 1 / -1;
  color: var(--faint);
  font-size: 0.85rem;
}

@media (max-width: 34rem) {
  .site-footer {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
