:root {
  --color-gray-100: oklch(96% 0 0);
  --color-gray-200: oklch(92% 0 0);
  --color-gray-300: oklch(87% 0 0);
  --color-gray-500: oklch(55% 0 0);
  --color-gray-600: oklch(37% 0 0);
  --color-gray-700: oklch(27% 0 0);
  --color-gray-800: oklch(20% 0 0);
  --color-gray-900: oklch(17% 0 0);

  --bg: oklch(100% 0 0);
  --bg-subtle: var(--color-gray-100);
  --text-color: var(--color-gray-600);
  --text-strong: var(--color-gray-800);
  --text-muted: var(--color-gray-500);
  --link-color: var(--color-gray-600);
  --link-hover-color: var(--color-gray-800);
  --border-color: var(--color-gray-300);

  --space: calc(1.618034 * 1rem);
  --space-small: calc(1.618034 * 0.3rem);
  --space-large: calc(1.618034 * 1.618034 * 1rem);

  --border-radius: 3px;
  /*
   * The one spacing value for media. It is the distance between two thumbnails
   * and, equally, the distance from a thumbnail to the edge of the viewport —
   * so the grid sits just off the edge rather than against it. Change it here
   * and both move together.
   */
  --gap: 8px;

  /* The text margin. Prose needs more room than pictures do. */
  --edge: clamp(1rem, 3vw, 3.25rem);
}

/* System preference — unless an explicit light choice overrides it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--color-gray-900);
    --bg-subtle: var(--color-gray-800);
    --text-color: var(--color-gray-300);
    --text-strong: var(--color-gray-100);
    --text-muted: var(--color-gray-500);
    --link-color: var(--color-gray-300);
    --link-hover-color: var(--color-gray-100);
    --border-color: var(--color-gray-700);
  }
}

/* An explicit choice wins in both directions. */
:root[data-theme="dark"] {
  --bg: var(--color-gray-900);
  --bg-subtle: var(--color-gray-800);
  --text-color: var(--color-gray-300);
  --text-strong: var(--color-gray-100);
  --text-muted: var(--color-gray-500);
  --link-color: var(--color-gray-300);
  --link-hover-color: var(--color-gray-100);
  --border-color: var(--color-gray-700);
}

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

html {
  margin: 0;
  padding: 0;
  height: 100%;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-color);
  background: var(--bg);
}

h1,
h2,
h3 {
  margin: 0 0 var(--space-small) 0;
  padding: 0;
  font-weight: 400;
  color: var(--text-strong);
  text-wrap: balance;
}

h1 {
  font-size: 1.6rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-small);
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
}

a {
  color: var(--link-color);
  text-decoration: none;
}

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

:focus-visible {
  outline: 2px solid var(--text-strong);
  outline-offset: 2px;
}

ul,
li {
  list-style: none;
  margin: 0;
  padding: 0;
}

img,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* The footer: one row, on the page background, never fixed. */
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-small) var(--space);
  padding-block: 0.55rem;
  padding-inline: var(--edge);
  min-height: 3rem;
  background: var(--bg);
  border-block: 1px solid var(--border-color);
}

.site-footer {
  margin-top: auto;
  border-bottom: none;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.site-footer p {
  margin: 0;
  max-width: none;
}

.brand {
  color: var(--text-muted);
}

.brand a {
  color: var(--text-strong);
}

.bar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-small);
  font-size: 0.85rem;
}

.bar-nav a {
  padding: 0.15rem 0.4rem;
  border-radius: var(--border-radius);
}

.bar-nav a:hover,
.bar-nav a:focus-visible {
  background: var(--bg);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--link-color);
  background: none;
  border: none;
  cursor: pointer;
}

.theme-toggle svg {
  width: 1.1rem;
  height: 1.1rem;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--link-hover-color);
  background: var(--bg);
}

main {
  flex: 1;
  padding-block: var(--gap) var(--space);
  padding-inline: var(--edge);
}

/* Media reaches the edges of the viewport; text does not. */
.crumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 var(--space-small) 0;
}

/*
 * The album title doubles as a breadcrumb. There is no header bar, so this and
 * the site name in the footer are the only links home.
 */
.crumb-home,
.crumb-sep {
  color: var(--text-muted);
}

.crumb-home:hover,
.crumb-home:focus-visible {
  color: var(--text-strong);
}

.prose {
  max-width: 68ch;
}

.prose p {
  margin-block: var(--space-small);
}

/*
 * Same treatment as the photo grid: columns stretch to fill the width exactly and
 * the gutter lives inside each card, so the covers reach both edges. Fixed-width
 * columns would leave whatever is left after the last whole card as dead space.
 */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: var(--gap);
  margin-top: var(--space-large);
  margin-inline: calc(var(--gap) - var(--edge));
}

.album-item {
  min-width: 0;
}

/*
 * A justified gallery, the way Flickr and Google Photos lay one out — and with no
 * JavaScript at all.
 *
 * Each item gets a flex-basis and a flex-grow both proportional to its aspect
 * ratio. Flexbox distributes a row's free space in proportion to grow factors, so
 * every item's final width stays proportional to its ratio, which means every item
 * in a row resolves to the *same height*. Rows are therefore flush left and flush
 * right, and the bottom of the grid is flush too.
 *
 * Separation comes from `gap` rather than padding on purpose: padding sits inside
 * the border-box basis and would break the proportionality, leaving rows a few
 * pixels uneven.
 *
 * The ::after absorbs the last row's free space so a half-full final row keeps its
 * natural size instead of stretching a lone picture across the viewport.
 */
.grid {
  --row: 240px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  margin-top: var(--space-small);
  margin-inline: calc(var(--gap) - var(--edge));
}

.grid::after {
  content: "";
  flex-grow: 1000000;
}

.cell {
  flex: var(--ar) 1 calc(var(--ar) * var(--row));
}

/* Whatever opens the page has nothing above it to separate from. */
main > .grid:first-child,
main > .album-grid:first-child {
  margin-top: 0;
}

.tile {
  aspect-ratio: var(--ar);
  width: 100%;
}

.audio-tile {
  aspect-ratio: 4 / 3;
}

/* Album covers are always wide, whatever the cover picture's own shape. */
.album-item .tile {
  aspect-ratio: 4 / 3;
}

.album-item h3 {
  margin: var(--space-small) 0 0 0;
  font-size: 1rem;
}

.album-item .meta {
  margin: 0;
  font-size: 0.85rem;
}

.tile {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--border-radius);
  background: var(--bg-subtle);
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.15s ease;
}

.tile:hover img,
.tile:focus-visible img {
  opacity: 0.85;
}

.tile .badge {
  position: absolute;
  inset-block-end: var(--space-small);
  inset-inline-start: var(--space-small);
  padding: 0.1rem 0.4rem;
  border-radius: var(--border-radius);
  background: oklch(17% 0 0 / 0.72);
  color: oklch(100% 0 0);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.audio-tile {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--space-small);
  padding: var(--space-small);
  width: 100%;
  height: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-subtle);
}

.audio-tile span {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.audio-tile audio {
  width: 100%;
}

.stage {
  margin: 0 0 var(--space) 0;
  text-align: center;
}

.stage img,
.stage video {
  margin-inline: auto;
  border-radius: var(--border-radius);
  max-height: 80vh;
  width: auto;
}

.stage--audio {
  max-width: 720px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space);
  min-height: 220px;
  padding: var(--space);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-subtle);
}

.audio-heading {
  margin: 0;
  color: var(--text-strong);
  font-size: 1.05rem;
  text-align: center;
}

.stage--audio audio {
  width: min(520px, 100%);
}

/* Title, date, description — centred and kept narrow so it reads as a caption. */
.item-meta {
  max-width: 640px;
  margin: var(--space) auto 0;
  text-align: center;
}

.item-meta h1 {
  font-size: 1.3rem;
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: var(--space-small);
}

.item-date {
  margin: 0 0 var(--space-small);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.item-description {
  margin: 0 auto;
  max-width: 640px;
}

.caption {
  max-width: 68ch;
  margin: 0 0 var(--space) 0;
}

/*
 * A link inside an album's description is otherwise invisible: --link-color and
 * --text-color are the same grey, so the underline is the only thing marking it.
 * The chrome's links do not need one — their position says what they are.
 */
.caption a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

/*
 * Centred: album title above, then three targets big enough to hit. The gap is a
 * full --space rather than the small step because the crumb is a link sitting
 * directly over the icon row, and eight pixels of separation made it easy to hit
 * the album on the way to Next.
 */
.pager {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space);
  padding-top: var(--space-large);
}

.pager-crumb {
  margin: 0;
  text-align: center;
  text-wrap: balance;
}

.pager-album {
  font-size: 1rem;
  color: var(--text-strong);
}

.pager-icons {
  display: flex;
  align-items: center;
  gap: var(--space-small);
}

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
}

.icon svg {
  width: 1.35rem;
  height: 1.35rem;
}

.icon:hover,
.icon:focus-visible {
  background: var(--bg-subtle);
  color: var(--link-hover-color);
}

.icon.is-off {
  opacity: 0.25;
}

.empty {
  color: var(--text-muted);
  font-style: italic;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 16px;
  }
}
