:root {
  color-scheme: light dark;
  --bg: #fbfaf8;
  --fg: #17161a;
  --muted: #5f5c68;
  --line: #e3dfd7;
  --card: #ffffff;
  --accent: #3838c9;
  --radius: 14px;
  --maxw: 1180px;
  --gap: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #100f14;
    --fg: #f2f0ee;
    --muted: #a6a2ae;
    --line: #292730;
    --card: #191821;
    --accent: #a3a3ff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1.25rem 4rem;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 1rem;
  top: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border-radius: 8px;
  z-index: 10;
}

.header,
.footer,
main {
  max-width: var(--maxw);
  margin: 0 auto;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.5rem 0 2rem;
}
/* `flex: 1 1 0`, not `1 1 auto`. A flex container decides where to break lines
   from the items' base sizes, before any shrinking happens — so an identity
   whose base size is its full content width pushes the nav onto a second line,
   where it lands hard against the left margin, no matter how shrinkable it is.
   A zero base size takes the identity out of that calculation: it claims the
   space the nav leaves over, and the tagline wraps under the name instead. */
.header__identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  flex: 1 1 0;
  min-width: 0;
}
/* The file is 320px so it stays sharp on a dense screen, but the width and
   height attributes say 40 — the size it is actually drawn at. That way a
   missing or stale stylesheet renders a small square, not a 320px portrait.
   alt is empty on purpose: the name is the next element, and a screen reader
   should not read it twice. */
.header__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}
.header__name { font-weight: 650; font-size: 1.05rem; flex: none; }
.header__tagline { color: var(--muted); font-size: 0.95rem; min-width: 0; }

/* Wrapping is not optional here. The nav carries three pages, three external
   links and the language toggle; on a 375px screen that is wider than the
   viewport, and without wrapping the tail simply leaves the page. */
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; flex: 0 0 auto; }
.nav__link { color: var(--muted); text-decoration: none; }
.nav__external { color: var(--muted); text-decoration: none; }
.nav__link--current { color: var(--fg); font-weight: 600; }
.nav__lang {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.section__heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 2.5rem 0 1rem;
}

.heroes__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(310px, 100%), 1fr));
  gap: var(--gap);
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card__cover { display: block; line-height: 0; }
.card__cover svg,
img.card__cover { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; }
.card__body { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.1rem 1.15rem 1.15rem; flex: 1; }
.card__title { margin: 0; font-size: 1.1rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.card__badge {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
}
.card__summary { margin: 0; color: var(--muted); font-size: 0.95rem; }
.card__details { font-size: 0.9rem; }
.card__details summary { cursor: pointer; color: var(--accent); }
.card__details p { margin: 0.5rem 0 0; color: var(--muted); }
.card__stack { display: flex; flex-wrap: wrap; gap: 0.35rem; list-style: none; margin: 0; padding: 0; }
.card__stack li {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}
.card__foot {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 0.5rem;
  font-size: 0.85rem;
}
.card__year { color: var(--muted); font-variant-numeric: tabular-nums; }
.card__action { text-decoration: none; font-weight: 550; }
.card__action--primary::after { content: " \2192"; }
.card__repo { color: var(--muted); font-size: 0.78rem; }
.card__closed, .row__closed {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.filter { display: flex; flex-wrap: wrap; gap: 1.25rem; border: 0; padding: 0; margin: 0 0 1.5rem; }
.filter__group { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.filter__group legend { float: left; margin-right: 0.6rem; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }
.filter__chip {
  font: inherit;
  font-size: 0.82rem;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.filter__chip.is-on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.filter__empty { color: var(--muted); }

.catalogue__heading { font-size: 0.95rem; margin: 1.75rem 0 0.6rem; }
.catalogue__list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}
.row__main { flex: 1 1 460px; }
.row__title { margin: 0; font-size: 1rem; font-weight: 600; }
.row__summary { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.92rem; }
.row__details { font-size: 0.88rem; margin-top: 0.35rem; }
.row__details summary { cursor: pointer; color: var(--accent); }
.row__meta {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.row__link { text-decoration: none; }
.row[hidden] { display: none; }

.podcast__where {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.9rem;
  margin: 0 0 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.podcast__channel {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  text-decoration: none;
  font-size: 0.85rem;
}

.podcast__table { width: 100%; border-collapse: collapse; margin-bottom: 2rem; }
.podcast__table th, .podcast__table td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.podcast__table th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em; }

/* The intro is one short paragraph on purpose: the hero grid has to stay in the
   first screen. */
.intro {
  margin: 0 0 2rem;
  max-width: 46rem;
  font-size: 1.05rem;
  line-height: 1.6;
}

.music__lead { color: var(--muted); margin: 0 0 1.5rem; max-width: 46rem; }
.music__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: 0.75rem;
  list-style: none;
  padding: 0;
  margin: 0;
}
.music__link {
  display: block;
  height: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
}

.lab__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 1rem; }
.lab__item {
  display: block;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  text-decoration: none;
  color: inherit;
}
.lab__item h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.lab__item p { margin: 0; color: var(--muted); font-size: 0.88rem; }

.footer {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding-top: 3rem;
  margin-top: 3rem;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
}

/* --- blog ---------------------------------------------------------------- */

.blog__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2rem;
  max-width: 68ch;
}

.blog__item {
  display: grid;
  gap: 0.35rem;
}

.blog__date {
  color: var(--muted);
  font-size: 0.9rem;
}

.blog__title {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.3;
}

.blog__title a {
  text-decoration: none;
}

.blog__title a:hover {
  text-decoration: underline;
}

.blog__summary {
  margin: 0;
  color: var(--muted);
}

.blog__empty {
  color: var(--muted);
}

.latest__all {
  margin: 1.5rem 0 0;
}

/* --- a post -------------------------------------------------------------- */

/* A column of prose reads worse the wider it gets, and --maxw is sized for a
   grid of cards. 68ch is about eleven words a line. */
.post {
  max-width: 68ch;
}

.post__meta {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.post__title {
  margin: 0 0 2rem;
  font-size: 2rem;
  line-height: 1.2;
}

.post__body h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.5rem;
  line-height: 1.3;
}

.post__body h3 {
  margin: 2rem 0 0.5rem;
  font-size: 1.2rem;
}

.post__body p,
.post__body ul,
.post__body ol {
  margin: 0 0 1.15rem;
}

.post__body li {
  margin: 0.3rem 0;
}

.post__body blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.post__body hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.post__body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.post__body code {
  padding: 0.1em 0.35em;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

/* A long line of code must scroll inside its own box. Without this it widens
   the whole page on a phone, and every paragraph goes with it. */
.post__body pre {
  overflow-x: auto;
  margin: 0 0 1.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.post__body pre code {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: 0.9em;
}

/* Same reason as pre: display:block is what makes a table scrollable at all. */
.post__body table {
  display: block;
  overflow-x: auto;
  width: 100%;
  margin: 0 0 1.5rem;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.post__body th,
.post__body td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.post__body th {
  background: var(--card);
}

.post__back {
  margin: 3rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

/* The nav is about 500px of links. Below roughly 900px there is no honest way to
   keep it beside the identity: squeezing the identity into the leftover turns it
   into a narrow column with the avatar stranded on its own line. So give each of
   them a full-width row instead — the same arrangement that works on a phone. */
@media (max-width: 900px) {
  .header { align-items: flex-start; }
  .header__identity { flex: 1 1 100%; }
  .nav { width: 100%; }
}

@media (max-width: 620px) {
  .header { padding-bottom: 1.25rem; }
  .header__tagline { flex-basis: 100%; }
  .nav { gap: 0.45rem 0.85rem; }
  .row__meta { width: 100%; }
  /* Five columns do not fit a phone. Let the table scroll inside its own box
     rather than making the whole page scroll sideways. */
  .podcast__table { display: block; overflow-x: auto; white-space: nowrap; }
  .podcast__table td:nth-child(4) { white-space: normal; min-width: 16rem; }
}
