/* Light/dark palette. light-dark() follows the system color scheme. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #16181c);
  --fg: light-dark(#222326, #b0b0b0);
  --muted: light-dark(#6b6e75, #9a9da3);
  --border: light-dark(#e2e3e6, #2c2f35);
  --surface: light-dark(#f5f6f7, #1f2227);
  --font: "Lato", system-ui, sans-serif;
  --body-size: 1.3rem;
  --dark-ratio: 85%;
  --page-bottom: 2rem;
  --v-space-large: 2rem;
  --v-space-small: 1rem;
}

@media (min-width: 80rem) {
  :root {
    --body-size: 1.3rem;
    --page-bottom: 5rem;
    --v-space-large: 6rem;
    --v-space-small: 2rem;
  }
}

.cat {
  --hero: light-dark(
    var(--base),
    color-mix(in oklab, var(--base) var(--dark-ratio), black)
  );
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--body-size);
  font-weight: 300;
  line-height: 1.6;
  padding: 1rem 0 var(--space-bottom) 0;

  /* Pagefind Component UI theme (its defaults are set on :root). */
  --pf-font: var(--font);
  --pf-text: var(--fg);
  --pf-text-secondary: var(--fg);
  --pf-text-muted: var(--muted);
  --pf-background: var(--bg);
  --pf-border: var(--border);
  --pf-border-focus: var(--hero);
  --pf-hover: var(--surface);
  --pf-mark: var(--fg);
  --pf-skeleton: var(--surface);
  --pf-outline-focus: var(--hero);
}

a { color: var(--hero); text-decoration: none; line-break: loose; }

h1, h2, h3 { line-height: 1.25; text-wrap: balance; }

h2 { padding-top: 1rem; }

/* Only Lato Light (300) and Black (900) are loaded: set bold explicitly,
   since the browser default `bolder` from 300 would give 400. */
b, strong, th, h1, h2, h3, h4, h5, h6 { font-weight: 900; }

/* Layout: 2×2 grid with a full-width rule between the rows. */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
  column-gap: 4rem;
  grid-template-areas:
    "tl tr"
    "rule rule"
    "bl br"
    "bl br"
    "foot foot";
  /* The last row takes any spare height, so the footer stays 10rem below
     the taller of the main column and sidebar. */
  grid-template-rows: auto auto auto auto 1fr;
  max-width: 70rem;
  min-height: 100vh;
  /* Split the spare width 3:2 between the left and right margins. */
  margin: 0 auto 0 max(0px, (100% - 70rem) * 0.6);
}
.tl   { grid-area: tl; }
.tr   { grid-area: tr; }
.bl   { grid-area: bl; }
.br   { grid-area: br; }
.rule { grid-area: rule; height: 4px; background: var(--hero); }

.v-space-large { margin-top: var(--v-space-large); }
.v-space-small { margin-top: var(--v-space-small); }

.two-column {
  columns: 2 auto;
}

.no-select { selection: none; }

#sidebar { display: contents; }

/* Pagefind components reset styles with `all: initial`, which drops
   color-scheme; inherit it so the light-dark() colours above resolve. */
pagefind-searchbox { color-scheme: inherit; }

/* Search box: compact until focused, then quickly expands to full width. */
.search { width: 12rem; max-width: 100%; transition: width 0.2s ease-out; }
.search:focus-within { width: 100%; }
@media (prefers-reduced-motion: reduce) {
  .search { transition: none; }
}

/* RSVP links: a lighter band sweeps once across the text after page load.
   The gradient starts and ends showing only the link colour. */
.rsvp {
  background: linear-gradient(100deg, var(--hero) 40%, color-mix(in oklch, var(--hero), white 60%) 50%, var(--hero) 60%) 100% 0 / 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rsvp-shimmer 1.2s ease-in-out 0.8s;
}
@keyframes rsvp-shimmer { to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .rsvp { animation: none; }
}

.tl, .tr, .bl, .br { padding: 1.25rem 1.5rem; }
/* Sponsors at the top of the right header, search pinned to the bottom. */
.tr { display: flex; flex-direction: column; }
.tr .search { margin-top: auto; }

.tl { position: relative; padding-right: 7rem; }
.tl p { margin: 0 0 0.5rem; }
/* Menu links: the .cat-uncategorised class on .menu makes --hero (the link
   colour) the Uncategorised grey. */
.menu {
  margin-top: var(--v-space-small);
  border-bottom: dotted 1px #808080;
  margin-bottom: 0.5rem;
}
.menu a { font-weight: 800; }
.controls { position: absolute; top: 1rem; right: 1.5rem; display: flex; gap: 0.5rem; }
.menu-btn {
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.35rem 0.55rem;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  z-index: 100;
}
.menu-btn { display: none; }

.logo { display: inline-block; margin-top: 0.80rem; }
.logo svg { display: block; }
.logo-a { width: 16rem; margin: var(--v-space-small) 0 var(--v-space-small); }
/* Hang the header logo into the left margin only when the window is wide
   enough for it not to be cut off. */
@media (min-width: 32rem ) {
  .logo-a { width: 24rem; margin-right: 2rem; }
}
@media (min-width: 80rem) {
  .logo-a { width: 31rem; }
}
@media (min-width: 87rem) {
  .logo-a { margin-left: -7.25rem; }
}
.logo-a svg { width: 100%; height: auto; }

/* The main column and sidebar share a title row and a body row (subgrid),
   so the sidebar logo lines up with the start of the body text. */
.bl, .br { display: grid; grid-template-rows: subgrid; }
.page-head { grid-row: 1; padding-bottom: 2rem; }
.page-body, .br-body { grid-row: 2; }
.page-body > :first-child,
.page-body > article > :first-child { margin-top: 0; }

/* Body content in Lora; headings and bold text stay in Lato. */
.page-body { font-family: "Lora", Georgia, serif; font-weight: 400; }
.page-body :is(h1, h2, h3, h4, h5, h6, b, strong, th) { font-family: var(--font); }
/* Links in the main column are bold (Lato, like all bold text), except in
   the meta line under the title. */
.bl a:not(.meta a) { font-family: var(--font); font-weight: 900; }
.logo-b { margin: var(--v-space-large) 0 var(--v-space-small); }

.logo-header-icon { width: 40%; margin: var(--v-space-small) 0; }

/* Footer: icon and small print, 10rem below the main column and sidebar. */
.site-foot { grid-area: foot; align-self: start; margin-top: var(--v-space-large); padding: 5rem 1.5rem 5rem; }
.site-foot a { font-weight: 800; }
.logo-icon { display: block; width: 3rem; margin: 0; }
.logo-icon svg { width: 100%; height: auto; }
/* Sidebar body items: no margins or padding of their own, 2rem apart. */
.br-body { display: flex; flex-direction: column; gap: 3rem; }
.br-body > * { margin: 0; padding: 0; }

/* Embedded videos and maps fill the content column at 16:9. */
.bl iframe { display: block; width: 90%; height: auto; aspect-ratio: 16 / 9; border: 0; margin: 2rem 0; }

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

/* Sidebar */
.sponsors { padding-top: 2rem; max-width: 20rem; }
.sponsors ul, .links ul { padding-left: 1.1rem; margin: 0; }
.sponsors img { display: block; width: 100%; height: auto; margin: 0 0 3rem 0; opacity: 0.1; }

.sponsors .w-66 { width: 66%; }
.sponsors .w-70 { width: 70%; }
.sponsors .w-80 { width: 80%; }
.sponsors .w-90 { width: 90%; }


/* Hide the image version that doesn't match the system light/dark mode.
   (:root raises specificity above rules like `.sponsors img`.) */
@media (prefers-color-scheme: light) {
  :root .dark-only { display: none; }
}
@media (prefers-color-scheme: dark) {
  :root .light-only { display: none; }
}

/* Swap logo on mobile. */
@media (max-width: 80rem) {
  :root .desktop-only { display: none; }
}
@media (min-width: 80rem) {
  :root .mobile-only { display: none; }
}

.cat-buttons { display: flex; flex-direction: column; gap: 0.65rem; }
.cat-row { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.cat-btn {
  padding: 0.05rem 0.7rem;
  border-radius: 6px;
  background: light-dark(var(--hero), color-mix(in oklab, var(--hero) var(--dark-ratio), black));
  color: light-dark(#f8f8f8, #222);
  font-size: 1.1rem;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}
a.cat-btn:hover { filter: brightness(1.2); }
@media (prefers-color-scheme: dark) {
  a.cat-btn:hover { filter: brightness(1.25); }
}
.count { color: #8a8a8a; font-size: 0.85em; }

/* Tags styled like the hashtags in an article's meta line: "#a · #b". */
.tag-list { list-style: none; padding: 0; color: var(--muted); }
.tag-list li { display: inline; }
.tag-list a { color: inherit; }

/* Listings: a coloured marker per article's category. */
.article-list { font-family: var(--font); list-style: none; padding: 0; }
.article-list li { padding: 0.4rem 0 0.4rem 0; margin-bottom: 0.5rem; }
.article-list li a { font-weight: 800; }
.article-list time { color: var(--muted); }

/* Phone: single column, sidebar becomes a slide-in drawer. */
@media (max-width: 80rem) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "tl" "rule" "bl" "foot";
    grid-template-rows: auto auto auto 1fr;
  }
  .bl, .br { display: block; }
  .menu-btn { display: block; }
  /* Header logo: use the cell's full width (cancel the extra right padding
     kept for the menu button) and align it right. */
  .tl .v-space-large { margin-right: calc(1.5rem - 7rem); text-align: right; }

  #sidebar {
    display: block;
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 10;
    width: min(22rem, 85vw);
    overflow-y: auto;
    background: var(--bg);
    border-left: 4px solid var(--hero);
    box-shadow: -8px 0 24px rgb(0 0 0 / 0.2);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s;
  }
  .menu-open #sidebar { transform: none; visibility: visible; }
}
