/* Brand New. Colours are tokens; dark mode follows the system unless the visitor picks one. */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --fg: #1c1a17;
  --muted: #6a645b;
  --line: #e6e0d6;
  --accent: #c2410c;
  --accent-fg: #ffffff;
  --accent-soft: #fdeee6;
  --focus: #2563eb;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 12px rgb(0 0 0 / .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141311;
    --surface: #1e1c19;
    --fg: #eeeae3;
    --muted: #a8a197;
    --line: #34302b;
    --accent: #fb8a55;
    --accent-fg: #1c1a17;
    --accent-soft: #3a2519;
    --focus: #7aa7ff;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141311;
  --surface: #1e1c19;
  --fg: #eeeae3;
  --muted: #a8a197;
  --line: #34302b;
  --accent: #fb8a55;
  --accent-fg: #1c1a17;
  --accent-soft: #3a2519;
  --focus: #7aa7ff;
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3, .logo { font-family: ui-serif, Georgia, "Times New Roman", serif; line-height: 1.2; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.icon { flex: none; vertical-align: -4px; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2;
        stroke-linecap: round; stroke-linejoin: round; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
ul[role="list"] { list-style: none; margin: 0; padding: 0; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.bar { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 1.3rem; font-weight: 700; color: var(--fg); text-decoration: none; }
.logo-mark { flex: none; width: 30px; height: 30px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { color: var(--fg); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.nav a:hover, .nav a[aria-current] { background: var(--accent-soft); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--fg); cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); }
.logo { white-space: nowrap; }
@media (max-width: 480px) {
  .bar { gap: 6px; }
  .logo { font-size: 1.1rem; gap: 6px; }
  .logo-mark { width: 26px; height: 26px; }
  .nav { gap: 0; }
  .nav a { padding: 6px 7px; font-size: .95rem; }
  .icon-btn { width: 36px; height: 36px; }
}
.when-dark { display: none; }
:root[data-theme="dark"] .when-dark { display: inline; }
:root[data-theme="dark"] .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .when-dark { display: inline; }
  :root:not([data-theme="light"]) .when-light { display: none; }
}

main { padding-top: 24px; padding-bottom: 48px; min-height: 60vh; }
.intro h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 8px 0; }
.intro p { color: var(--muted); max-width: 60ch; margin: 0 0 8px; }
h1 { font-size: clamp(1.7rem, 5vw, 2.3rem); margin: 8px 0 16px; }
h2 { font-size: 1.45rem; margin: 32px 0 12px; }
.kicker { display: block; font: 600 .8rem/1 system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
a.kicker { width: fit-content; text-decoration: none; }
a.kicker:hover, .kind-link:hover { text-decoration: underline; }
.kind-link { color: inherit; text-decoration: none; }

/* Home: genre tiles */
.kind h2 { display: flex; align-items: center; gap: 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  color: var(--fg); text-decoration: none; transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile-name { font-family: ui-serif, Georgia, serif; font-size: 1.2rem; font-weight: 700; }
.tile-blurb { color: var(--muted); font-size: .92rem; }
.tile-count { margin-top: auto; padding-top: 6px; font-size: .85rem; color: var(--accent); font-weight: 600; }

/* Genre switcher */
.chips { margin: 0 -16px; overflow-x: auto; scrollbar-width: thin; }
.chips ul { display: flex; gap: 8px; padding: 2px 16px 8px; width: max-content; }
.chips a {
  display: block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--fg); text-decoration: none; font-size: .9rem; white-space: nowrap; background: var(--surface);
}
.chips a:hover { border-color: var(--accent); }
.chips a[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

/* Release cards */
.month { font-size: 1.05rem; color: var(--muted); margin: 24px 0 10px; font-family: system-ui, sans-serif; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px 12px; }
@media (max-width: 400px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* A card's seven parts (cover, title, author, date, extras, button, source link) share row
   heights with the other cards in the same row, so everything lines up across the row. */
.card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); font-size: .9rem;
}
@supports (grid-template-rows: subgrid) {
  .card { display: grid; grid-row: span 7; grid-template-rows: subgrid; row-gap: 0; }
}
.card > :not(.cover) { padding: 0 10px; }
.card-title { padding-top: 10px !important; }
.card-source { padding-bottom: 10px !important; }
.card-buy { margin-top: auto; }  /* keeps the button at the bottom without subgrid too */
.cover { position: relative; aspect-ratio: 2 / 3; background: var(--accent-soft); display: grid; place-items: center; }
.cover-music { aspect-ratio: 1; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-fallback { color: var(--accent); opacity: .6; }
.cover-fallback .icon { width: 40px; height: 40px; }
.card-title {
  font-size: 1rem; margin: 0; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.card-by, .card-date, .card-tags { margin: 0; }
.card-by {
  color: var(--fg); margin-top: 2px;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.card-date { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag { font-size: .72rem; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.buy {
  margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 10px; border-radius: 8px; background: var(--accent); color: var(--accent-fg);
  font-weight: 600; text-decoration: none; font-size: .88rem;
}
.buy:hover { filter: brightness(1.08); }
.buy .icon { width: 16px; height: 16px; }
.more-shops {
  margin-top: 6px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent;
  color: var(--fg); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.more-shops:hover { background: var(--accent-soft); }
.more-shops .icon { width: 16px; height: 16px; }
/* Other bookshops: a popover, so it sits above the page instead of being cut off by the card. */
.shops {
  width: min(340px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 14px 16px; margin: auto;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg);
  box-shadow: 0 8px 30px rgb(0 0 0 / .25); font-size: .92rem;
}
.shops::backdrop { background: rgb(0 0 0 / .35); }
.shops-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.shops-title { margin: 0; overflow-wrap: anywhere; }
.shops-group { margin: 12px 0 6px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.shops-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.shops-list small { font-weight: 400; color: var(--muted); margin-left: 4px; }
.shops-list a {
  display: flex; align-items: center; justify-content: space-between; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--fg); text-decoration: none; font-weight: 600;
}
.shops-list a:hover { background: var(--accent-soft); }
.shops-list .icon { width: 16px; height: 16px; color: var(--muted); }
.shops-note { margin: 0 0 8px; font-size: .8rem; color: var(--muted); }
.amazon-formats { margin: 6px 0 0; text-align: center; font-size: .78rem; color: var(--muted); }
.amazon-formats a { color: var(--fg); }
.card-source { text-align: center; }
.source-link { display: inline-block; margin-top: 6px; font-size: .8rem; color: var(--muted); }
.powered { display: flex; align-items: center; gap: 6px; margin: -8px 0 8px; font-size: .8rem; color: var(--muted); }
/* Google's logo is dark text on transparent, so it sits on a light chip in dark mode. */
.powered img { height: 18px; width: auto; background: #fff; border-radius: 4px; padding: 2px 4px; box-sizing: content-box; }
.empty { color: var(--muted); font-style: italic; }

/* About */
.prose { max-width: 68ch; }
.prose li { margin-bottom: 6px; }
.prose code { font-size: .9em; padding: 1px 5px; border-radius: 4px; background: var(--accent-soft); overflow-wrap: anywhere; }
.callout { padding: 12px 14px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 8px 8px 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 24px 0 32px; font-size: .9rem; color: var(--muted); }
.site-footer p { margin: 0 0 10px; }
.disclosure { color: var(--fg); font-weight: 600; }
.site-footer { padding-bottom: 80px; }  /* room for the Support me button */
.kofi-line { margin: 40px 0 8px; text-align: center; color: var(--muted); }
.kofi-line a { font-weight: 600; }

/* Support me (Ko-fi): bottom-left, like the blog's; the panel opens above it. It matches Ko-fi's
   own floating button: its colour, DM Sans and the Ko-fi logo, both hosted here, so nothing is
   fetched from Ko-fi or Google until the panel is opened. */
@font-face {
  font-family: "DM Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("fonts/dm-sans-600-latin.woff2") format("woff2");
}
.support-btn {
  position: fixed; left: 16px; bottom: 16px; z-index: 20; display: flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 20px; border-radius: 100px; background: #a84e2b; color: #fff;
  font: 600 16px/normal "DM Sans", sans-serif; text-decoration: none;
  transition: transform .2s ease, opacity .2s ease;
}
.support-btn img { width: 39px; height: auto; }
.support-btn.is-tucked { transform: translateY(calc(100% + 24px)); opacity: 0; pointer-events: none; }
.support-btn.is-tucked:focus-visible { transform: none; opacity: 1; pointer-events: auto; }  /* keyboard users can still reach it */
.support-panel {
  position: fixed; inset: auto auto 72px 16px; margin: 0; padding: 0;
  width: min(340px, calc(100vw - 32px)); height: min(600px, calc(100dvh - 96px));
  flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: var(--surface); color: var(--fg); box-shadow: 0 8px 30px rgb(0 0 0 / .3);
}
.support-panel:popover-open { display: flex; }
.support-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); }
.support-head p { margin: 0; }
.support-frame { flex: 1; background: #fff; }  /* Ko-fi's form is light */
.support-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.support-foot { margin: 0; padding: 8px 14px; font-size: .8rem; text-align: center; border-top: 1px solid var(--line); }
.updated { font-size: .85rem; color: var(--muted); }

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

/* "Running late" notice (see app.js) */
.stale {
  margin: 16px 0 0; padding: 10px 14px; border: 1px solid var(--accent); border-left-width: 4px;
  border-radius: 0 8px 8px 0; background: var(--accent-soft); color: var(--fg); font-size: .9rem;
}
