/* Tokens ---------------------------------------------------------------- */

:root {
  --page-light: #f3f3f5;
  --page-dark: #141416;
  --surface-light: #ffffff;
  --surface-dark: #1d1d21;
  --sunken-light: #f8f8fa;
  --sunken-dark: #18181b;
  --ink-light: #2b2a33;
  --ink-dark: #ebe9e6;
  --muted-light: #6d6b78;
  --muted-dark: #a5a2ae;
  --line-light: #e9e8ee;
  --line-dark: #303036;
  --accent-light: #f0696b;
  --accent-dark: #f27f80;
  --link-light: #c2414b;
  --link-dark: #ff9d99;

  --page: var(--page-light);
  --surface: var(--surface-light);
  --sunken: var(--sunken-light);
  --ink: var(--ink-light);
  --muted: var(--muted-light);
  --line: var(--line-light);
  --accent: var(--accent-light);
  --link: var(--link-light);

  /* Fallback for browsers without light-dark() */
  @media (prefers-color-scheme: dark) {
    --page: var(--page-dark);
    --surface: var(--surface-dark);
    --sunken: var(--sunken-dark);
    --ink: var(--ink-dark);
    --muted: var(--muted-dark);
    --line: var(--line-dark);
    --accent: var(--accent-dark);
    --link: var(--link-dark);
  }

  @supports (color: light-dark(white, black)) {
    --page: light-dark(var(--page-light), var(--page-dark));
    --surface: light-dark(var(--surface-light), var(--surface-dark));
    --sunken: light-dark(var(--sunken-light), var(--sunken-dark));
    --ink: light-dark(var(--ink-light), var(--ink-dark));
    --muted: light-dark(var(--muted-light), var(--muted-dark));
    --line: light-dark(var(--line-light), var(--line-dark));
    --accent: light-dark(var(--accent-light), var(--accent-dark));
    --link: light-dark(var(--link-light), var(--link-dark));
  }

  color-scheme: light dark;

  /* Scrollbar: reserve its space so pages don't shift sideways, and keep it slim.
     The thumb has 3:1 contrast against the track in both themes. */
  --scroll-thumb: #85838f;
  --scroll-track: var(--page-light);

  @media (prefers-color-scheme: dark) {
    --scroll-thumb: #6b6975;
    --scroll-track: var(--page-dark);
  }

  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);

  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(1.25rem, 0.5rem + 4vw, 4rem);
  --measure: 40rem;
}

/* Older Safari and Chrome don't know scrollbar-color; give them the same look. */
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: var(--scroll-track);
  }

  ::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background: var(--scroll-thumb);
  }
}

/* Base ------------------------------------------------------------------ */

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

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
  margin: 0;
}

p {
  margin: 0;
}

a {
  color: var(--link);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

/* Colour changes on hover ease instead of snapping. These are not movement,
   so they stay on for people who ask for reduced motion. */
a,
summary,
.section-link {
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

/* Motion ---------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  /* Cross-fade between pages. Browsers without support just navigate normally. */
  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.22s;
  }

  /* Pictures and underline markers that exist on both pages glide to their new place. */
  ::view-transition-group(*) {
    animation-duration: 0.32s;
    animation-timing-function: cubic-bezier(0.2, 0, 0, 1);
  }

  /* The header is the same on every page, so it holds still while the rest changes. */
  .site-header {
    view-transition-name: site-header;
  }

  /* First visit or a full reload: the page content rises in once. */
  html:not(.arrived-by-transition) main > * {
    animation: rise-in 0.5s cubic-bezier(0.2, 0, 0, 1) both;
  }

  html:not(.arrived-by-transition) main > :nth-child(2) {
    animation-delay: 0.06s;
  }

  html:not(.arrived-by-transition) main > :nth-child(n + 3) {
    animation-delay: 0.12s;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    translate: 0 0.75rem;
  }
}

a:hover {
  text-decoration-thickness: 2px;
}

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

.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -4rem;
  background: var(--surface);
  padding: 0.5rem 1rem;
  z-index: 10;
}

.skip-link:focus {
  top: 1rem;
}

/* Sheet: the white page floating on the grey background ----------------- */

.sheet {
  max-width: 60rem;
  margin: clamp(0rem, -2rem + 6vw, 3rem) auto;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(20 20 40 / 0.04), 0 12px 40px rgb(20 20 40 / 0.06);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding: 1.75rem var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img {
  display: block;
  width: auto;
  height: 1.75rem;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-header nav a {
  color: var(--ink);
  text-decoration: none;
  padding-block: 0.5rem;
}

.site-header nav a:hover {
  color: var(--link);
}


.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding: 2rem var(--gutter);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8125rem;
}

/* Page headers ---------------------------------------------------------- */

.page-header,
.post-header {
  padding: clamp(2rem, 1rem + 4vw, 3.5rem) var(--gutter) 2rem;
  text-align: center;
}

.page-header h1,
.post-header h1 {
  font-size: clamp(1.9rem, 1.3rem + 2.6vw, 2.75rem);
  max-width: 22em;
  margin-inline: auto;
}

.page-header p {
  color: var(--muted);
  margin-top: 0.75rem;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0;
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.post-meta span + span {
  margin-inline-start: 0.9rem;
  padding-inline-start: 0.9rem;
  border-inline-start: 1px solid var(--line);
}

.draft-badge {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0.15rem 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 99px;
  color: var(--link);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Illustrations --------------------------------------------------------- */

.illo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 20 / 9;
  object-fit: cover;
}

.post-art {
  margin: 0 var(--gutter);
}

/* Article body ---------------------------------------------------------- */

.prose {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding: 2.5rem var(--gutter) 1rem;
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  line-height: 1.8;
}

.prose > * + * {
  margin-top: 1.4em;
}

.prose p,
.prose li {
  text-wrap: pretty;
}

.prose h2,
.prose h3 {
  margin-top: 2.2em;
  font-size: 1.4em;
}

.prose h3 {
  font-size: 1.2em;
}

.prose h2 + *,
.prose h3 + * {
  margin-top: 0.7em;
}

.prose ul,
.prose ol {
  padding-inline-start: 1.4em;
}

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

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

.prose img {
  max-width: 100%;
  height: auto;
}

.prose hr {
  width: 3rem;
  height: 3px;
  margin: 3em auto;
  border: 0;
  background: var(--accent);
}

/* Blockquotes and pull quotes are set between two short accent rules. */
.prose blockquote,
.prose .pullquote {
  max-width: 31rem;
  margin: 2.6em auto;
  padding: 1.6em 0;
  background:
    linear-gradient(var(--accent) 0 100%) top center / 3rem 3px no-repeat,
    linear-gradient(var(--accent) 0 100%) bottom center / 3rem 3px no-repeat;
  color: var(--muted);
  font-size: 1.2em;
  font-style: italic;
  line-height: 1.55;
  text-align: center;
}

.prose blockquote > * + *,
.prose .pullquote > * + * {
  margin-top: 0.8em;
}

.prose code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--sunken);
  font-size: 0.9em;
}

.prose pre {
  overflow-x: auto;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  background: var(--sunken);
  font-size: 0.875rem;
  line-height: 1.6;
}

.prose pre code {
  padding: 0;
  background: none;
}

/* Article footer -------------------------------------------------------- */

.post-footer {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding: 1.5rem var(--gutter) 3rem;
}

.share {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  padding-block: 1.25rem;
  border-block: 1px solid var(--line);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.share span {
  color: var(--muted);
}

.author {
  display: flex;
  gap: 1.25rem;
  margin-top: 2.5rem;
  font-size: 0.9375rem;
}

.author-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--accent);
  color: #2b2a33;
  font-family: var(--serif);
  font-weight: 600;
}

.author-name {
  font-weight: 600;
}

.author a {
  display: inline-block;
  margin-top: 0.6rem;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2.5rem;
}

.pager a {
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.35;
  text-decoration: none;
}

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

.pager span {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pager-next {
  text-align: end;
}

/* Bands and cards ------------------------------------------------------- */

.band {
  padding: 2.5rem var(--gutter) 3rem;
  background: var(--sunken);
}

.band + .band {
  padding-top: 0;
}

.band-title {
  margin-bottom: 1.5rem;
  font-size: 1.35rem;
}

.band-more {
  margin-top: 2rem;
  text-align: center;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr));
  gap: 1.5rem;
}

.card-grid.two {
  grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(20 20 40 / 0.05);
  transition: translate 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  translate: 0 -3px;
  box-shadow: 0 10px 24px rgb(20 20 40 / 0.09);
}

@media (prefers-reduced-motion: reduce) {
  .card {
    transition: none;
  }

  .card:hover {
    translate: none;
  }
}

.card-art {
  display: block;
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.1rem 1.25rem 1.25rem;
}

.card h3 {
  font-size: 1.0625rem;
  line-height: 1.35;
  text-wrap: pretty;
}

.card h3 a {
  color: var(--ink);
  text-decoration: none;
}

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

.card-desc {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.55;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-top: auto;
  padding-top: 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.card-meta a {
  color: var(--muted);
}

/* Category filter ------------------------------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0.25rem 1.5rem;
  padding: 0 var(--gutter) 2.25rem;
  font-size: 0.875rem;
  scroll-margin-top: 1rem;
}

.chips a,
.chips summary {
  padding-block: 0.25rem;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

.chips a:hover,
.chips summary:hover {
  color: var(--ink);
}

.chips a[aria-current] {
  position: relative;
  color: var(--ink);
}

/* The underline under the current tab or page number. */
.marker {
  position: absolute;
  inset-inline: 0;
  bottom: -2px;
  height: 2px;
  background: var(--accent);
}

.chips .marker {
  view-transition-name: filter-marker;
}

.chips .more {
  position: relative;
}

.chips summary {
  cursor: pointer;
  list-style: none;
}

.chips summary::-webkit-details-marker {
  display: none;
}

.chips summary::after {
  content: "";
  display: inline-block;
  width: 0.4em;
  height: 0.4em;
  margin-inline-start: 0.45em;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  translate: 0 -0.2em;
  rotate: 45deg;
}

.chips .more[open] summary::after {
  translate: 0 0.05em;
  rotate: 225deg;
}

.chips .more ul {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 0.5rem);
  z-index: 5;
  min-width: 13rem;
  margin: 0;
  padding: 0.5rem 0;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 10px 24px rgb(20 20 40 / 0.09);
  list-style: none;
  text-align: start;
}

.chips .more li a {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.35rem 1rem;
  border: 0;
}

.chips .more li a:hover {
  background: var(--sunken);
}

.chips .more li a[aria-current] {
  color: var(--ink);
  font-weight: 600;
}

/* Pagination ------------------------------------------------------------ */

.pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin-top: 2.5rem;
  font-size: 0.875rem;
}

.pagination a {
  color: var(--muted);
  text-decoration: none;
}

.pagination a:hover {
  color: var(--ink);
}

.pagination-step {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pagination-step:last-child {
  text-align: end;
}

.pagination-numbers {
  display: flex;
  gap: 0.25rem;
}

.pagination-numbers > * {
  min-width: 2rem;
  padding-block: 0.25rem;
  border-bottom: 2px solid transparent;
  text-align: center;
}

.pagination-numbers [aria-current] {
  position: relative;
  color: var(--ink);
}

.pagination .marker {
  view-transition-name: page-marker;
}

/* Landing page ---------------------------------------------------------- */

.sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
  gap: 1.5rem;
  padding: 2.5rem var(--gutter);
}

.section-link {
  display: block;
  padding: 1.5rem;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

a.section-link:hover {
  border-color: var(--accent);
}

.section-link h2 {
  font-size: 1.25rem;
}

.section-link p {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.section-link span {
  display: inline-block;
  margin-top: 1rem;
  color: var(--link);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-link.is-soon {
  border-style: dashed;
}

.section-link.is-soon span {
  color: var(--muted);
}

/* Small screens --------------------------------------------------------- */

@media (max-width: 40rem) {
  .post-art {
    margin-inline: 0;
  }

  .post-meta {
    gap: 0.15rem 1rem;
  }

  .post-meta span + span {
    margin-inline-start: 0;
    padding-inline-start: 0;
    border: 0;
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .pager-next {
    text-align: start;
  }
}

/* Forms ----------------------------------------------------------------- */

.field,
.subscribe form {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

label {
  font-size: 0.8125rem;
  font-weight: 600;
}

input:where([type="text"], [type="email"], [type="password"]),
textarea {
  width: 100%;
  min-height: 3rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--muted);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: max(1rem, 1em);
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

:is(input, textarea):user-invalid {
  border-color: var(--link);
  box-shadow: inset 3px 0 0 var(--link);
}

button[type="submit"],
.button {
  min-height: 3rem;
  padding: 0.65rem 1.4rem;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--surface);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

:is(button[type="submit"], .button):hover {
  border-color: var(--link);
  background: var(--link);
}

.button.quiet {
  background: none;
  color: var(--ink);
}

.button.quiet:hover {
  color: var(--surface);
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.stack-form {
  display: grid;
  gap: 1.1rem;
  justify-items: start;
}

.stack-form .field {
  width: 100%;
}

.hint {
  color: var(--muted);
  font-size: 0.8125rem;
}

.form-status {
  font-size: 0.9375rem;
}

.form-status:empty {
  display: none;
}

/* The mark says which kind of message it is, so colour is not the only cue. */
.form-status[data-state="error"] {
  color: var(--link);
}

.form-status[data-state="error"]::before {
  content: "! ";
  font-weight: 600;
}

.form-status[data-state="ok"]::before {
  content: "✓ ";
  color: var(--link);
  font-weight: 600;
}

/* A field for scripts to fill in and people never to see. */
.hp {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  white-space: nowrap;
}

/* Reads and reactions ---------------------------------------------------- */

.react {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding-bottom: 1.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.react button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.4rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

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

.react svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.react button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--link);
}

.react button[aria-pressed="true"] svg {
  fill: var(--accent);
  stroke: var(--accent);
}

@media (prefers-reduced-motion: no-preference) {
  .react button[aria-pressed="true"] svg {
    animation: pop 0.3s cubic-bezier(0.2, 0, 0, 1);
  }
}

@keyframes pop {
  50% {
    scale: 1.3;
  }
}

/* Subscribe -------------------------------------------------------------- */

.subscribe {
  margin-top: 2.5rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
}

.subscribe h2 {
  font-size: 1.25rem;
}

.subscribe > p {
  margin: 0.4rem 0 1.1rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.subscribe-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.subscribe-row input {
  flex: 1 1 14rem;
  width: auto;
}

.subscribe .form-status {
  margin-top: 0.5rem;
}

.subscribe-wrap {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding: 0.5rem var(--gutter) 3rem;
}

/* Comments --------------------------------------------------------------- */

.comments {
  margin-top: 3rem;
}

.comments h2 {
  font-size: 1.35rem;
}

.comments h3 {
  font-size: 1.1rem;
}

.comments-empty {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

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

.comment {
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.comment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.9rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.comment-meta strong {
  color: var(--ink);
  font-size: 0.9375rem;
}

.comment-body {
  margin-top: 0.4rem;
  font-size: 0.9375rem;
  white-space: pre-line;
}

.comment-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.comments .stack-form {
  margin-top: 2rem;
}

/* Message pages and comment review -------------------------------------- */

.message {
  padding-bottom: 5rem;
}

.message p + p {
  margin-top: 1.5rem;
}

.admin {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding: 0 var(--gutter) 4rem;
}

.admin .form-status {
  margin-top: 1rem;
}

.site-footer a {
  color: var(--muted);
}
