/* The blog: gonglogic.com/blog and /blog/<slug> (BlogPageController). Loaded by the controller with
   Requirements::css, which stamps it, so there is no ?v= to bump. Colours, type and space are the
   family's tokens (family/tokens.css), which carry light and dark; nothing here names a colour.

   Two widths: --blog-text (the words, a comfortable measure) and --blog-wide (landscape photos and the
   list's grid). Every link is at least 24px each way, the tap-target floor (WCAG 2.2 AA). */

.blog { --blog-text: 40rem; --blog-wide: 72rem;
  width: 100%; max-width: calc(var(--blog-wide) + 2 * var(--gutter)); box-sizing: border-box; margin: 0 auto;
  padding: var(--s-8) var(--gutter) var(--s-16); overflow-wrap: break-word; color: var(--ink); }
.blog .blog__h1 { margin: 0 0 var(--s-2); font-family: var(--font-text); font-size: clamp(var(--fs-6), 5vw, var(--fs-7));
  font-weight: 600; line-height: 1.1; letter-spacing: -0.01em; color: var(--ink); text-wrap: balance; }
.blog__crumbs { margin: 0 0 var(--s-4); font-size: var(--fs-1); }
.blog__crumbs a, .blog__back a { display: inline-flex; align-items: center; min-width: 24px; min-height: 24px;
  padding-block: 4px; color: var(--accent-ink); text-decoration: none; font-weight: 500; }
.blog__crumbs a:hover, .blog__back a:hover { text-decoration: underline; }
.blog a:focus-visible { outline: 2px solid var(--brand-gold); outline-offset: 3px; border-radius: var(--radius-s); }
.blog__empty { color: var(--muted); }

/* The date · photo-count line, on the cards and under a post's title. */
.blog-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: 0;
  font-family: var(--font-ui); font-size: var(--fs-1); color: var(--muted); letter-spacing: 0.01em; }
.blog-meta__sep { opacity: 0.7; }

/* ---------- The list ---------- */
.blog-index__head { max-width: var(--blog-text); margin: 0 0 var(--s-8); }
.blog-index__lede { margin: 0; font-family: var(--font-text); font-size: var(--fs-3); line-height: 1.55; color: var(--ink-2); }

.blog-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-8) var(--s-6);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
.blog-list__item { margin: 0; display: flex; }
.blog-list__item--lead { grid-column: 1 / -1; }

.blog-card { display: flex; flex-direction: column; width: 100%; color: var(--ink); text-decoration: none;
  border-radius: var(--radius-m); }
.blog-card:hover { color: var(--ink); text-decoration: none; }
.blog-card__media { display: block; overflow: hidden; border-radius: var(--radius-m); background: var(--surface-2);
  aspect-ratio: 4 / 3; box-shadow: var(--shadow-1); }
.blog-card__img { display: block; width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1); }
.blog-card:hover .blog-card__img { transform: scale(1.03); }
.blog-card__text { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4) var(--s-1) 0; min-width: 0; }
.blog-card__title { font-family: var(--font-text); font-size: var(--fs-5); font-weight: 600; line-height: 1.15; }
.blog-card:hover .blog-card__title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
.blog-card__summary { color: var(--ink-2); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden; }
.blog-card__more { font-family: var(--font-ui); font-size: var(--fs-1); font-weight: 600; color: var(--accent-ink); }

/* The newest post: its cover wide, the words beside it on a big screen. */
.blog-card--lead .blog-card__media { aspect-ratio: 16 / 10; }
@media (min-width: 56rem) {
  .blog-card--lead { display: grid; grid-template-columns: 3fr 2fr; gap: var(--s-8); align-items: center; }
  .blog-card--lead .blog-card__media { aspect-ratio: 4 / 3; }
  .blog-card--lead .blog-card__text { padding: 0; }
  .blog-card--lead .blog-card__title { font-size: var(--fs-7); line-height: 1.05; }
  .blog-card--lead .blog-card__summary { font-family: var(--font-text); font-size: var(--fs-3); -webkit-line-clamp: 5; }
}

/* ---------- A post ---------- */
.blog-post__body, .blog-pager, .blog__back { max-width: var(--blog-text); margin-inline: auto; }
.blog-post__body { margin-bottom: var(--s-10); }
.blog-post__body img { max-width: 100%; height: auto; }

/* The hero: title and facts, then the cover across the gallery's width. A portrait cover stands beside
   the title on a big screen instead, so it is never a screen and a half tall. */
.blog-hero { max-width: var(--blog-wide); margin: 0 auto var(--s-10); display: grid; gap: var(--s-6); }
.blog-hero .blog-post__head { max-width: var(--blog-text); }
.blog-cover { margin: 0; }
.blog-cover .blog-photo__img { width: 100%; max-height: 80vh; object-fit: cover; }
@media (min-width: 56rem) {
  .blog-hero--portrait { grid-template-columns: 1fr minmax(0, 26rem); align-items: center; gap: var(--s-10); }
  .blog-hero--portrait .blog-post__head { align-self: center; }
  .blog-hero--portrait .blog-cover .blog-photo__img { max-height: 78vh; }
}

/* The photos: groups of justified rows, every row the gallery's width. Each photo's share of its row
   is its aspect ratio (--ar, flex-grow), so a row's photos come out one height with no cropping. */
.blog-photos { max-width: var(--blog-wide); margin: 0 auto; }
.blog-group { margin: 0 0 var(--s-12); display: grid; gap: var(--s-3); }
.blog-photos > .blog-prose { margin-bottom: var(--s-6); }
.blog-row { display: flex; gap: var(--s-3); align-items: flex-start; }
.blog-photo { flex: var(--ar, 1.5) 1 0; min-width: 0; margin: 0; }
/* A row of one portrait: as tall as most of the screen allows, centred. */
.blog-row--single .blog-photo { flex: 0 1 auto; width: min(100%, calc(78vh * var(--ar, 1.5))); margin-inline: auto; }
/* A spread: two or three photos side by side, each with its own words right above it (BlogPost::
   PhotoGroups). Columns are sized by aspect ratio, so the photos come out one height; the words sit at
   the foot of their row (subgrid), so each paragraph hugs its own photo whatever its length. */
.blog-spread { display: grid; grid-template-rows: auto auto; column-gap: var(--s-6); margin: 0 0 var(--s-12); }
.blog-spread__unit { display: grid; grid-row: span 2; grid-template-rows: subgrid; row-gap: var(--s-4); min-width: 0; }
.blog-spread .blog-spread__text { align-self: end; max-width: none; margin: 0; }
/* A side: one portrait beside its words, alternating sides down the post. */
.blog-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 24rem); gap: var(--s-10); align-items: center;
  margin: 0 0 var(--s-12); }
.blog-side--flip { grid-template-columns: minmax(0, 24rem) minmax(0, 1fr); }
.blog-side--flip .blog-photo { order: -1; }
.blog-side .blog-side__text { max-width: none; margin: 0; }
.blog-photo, .blog-cover { scroll-margin-top: calc(var(--head-h, 64px) + var(--s-6)); }

/* The link holds the photo's 24px copy, blown up and blurred by the browser, until the photo arrives. */
.blog-photo__link { display: block; position: relative; overflow: hidden; border-radius: var(--radius-s);
  background-color: var(--surface-2); background-size: cover; background-position: center; cursor: zoom-in; }
.blog-photo__img { display: block; width: 100%; height: auto; aspect-ratio: var(--ar, 1.5); object-fit: cover;
  border-radius: inherit; transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.2s; }
.blog-photo__link:hover .blog-photo__img { transform: scale(1.015); }
.blog-photo__link:focus-visible { outline: 2px solid var(--brand-gold); outline-offset: 3px; }
.blog-photo__caption { margin: var(--s-2) 0 0; font-family: var(--font-ui); font-size: var(--fs-1); line-height: 1.5;
  color: var(--ink-2); text-wrap: pretty; }
.blog-cover .blog-photo__caption { max-width: var(--blog-text); }

@media (max-width: 42rem) {
  /* A phone: one column, edge to edge, each caption tight under its photo. */
  .blog-hero { gap: var(--s-4); }
  .blog-cover, .blog-group, .blog-spread, .blog-side { margin-inline: calc(-1 * var(--gutter)); }
  .blog-spread, .blog-side, .blog-spread__unit { display: block; }
  .blog-spread__unit + .blog-spread__unit { margin-top: var(--s-10); }
  .blog-spread, .blog-side { margin-bottom: var(--s-10); }
  .blog-spread .blog-spread__text, .blog-side .blog-side__text { padding-inline: var(--gutter); margin-bottom: var(--s-4); }
  .blog-row { flex-direction: column; gap: var(--s-4); }
  .blog-group { gap: var(--s-4); margin-bottom: var(--s-10); }
  .blog-row--single .blog-photo, .blog-photo { width: 100%; flex: none; }
  .blog-photo__link { border-radius: 0; }
  .blog-photo__caption { margin: var(--s-2) var(--gutter) 0; }
  .blog-cover .blog-photo__img { max-height: none; }
}
@media (prefers-reduced-motion: reduce) { .blog-photo__img { transition: none; } .blog-photo__link:hover .blog-photo__img { transform: none; } }

/* Newer / older at the foot of a post. */
.blog-pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); margin-top: var(--s-12);
  padding-top: var(--s-8); border-top: 1px solid var(--line); }
.blog-pager:not(:has(a)) { display: none; }
.blog-pager__link { display: flex; flex-direction: column; gap: var(--s-1); min-height: 24px; padding: var(--s-4);
  border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); color: var(--ink);
  text-decoration: none; }
.blog-pager__link:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); color: var(--ink); text-decoration: none; }
.blog-pager__link--older { grid-column: 2; text-align: right; }
.blog-pager__dir { font-family: var(--font-ui); font-size: var(--fs-1); color: var(--muted); }
.blog-pager__title { font-family: var(--font-text); font-size: var(--fs-4); font-weight: 600; line-height: 1.2; }
.blog__back { margin-top: var(--s-8); margin-bottom: 0; font-size: var(--fs-2); }

/* The words: before the photos, between them (a photo's text) and after them (the outro). */
.blog-prose { max-width: var(--blog-text); margin: 0 auto var(--s-8); font-family: var(--font-text); font-size: var(--fs-3);
  line-height: 1.7; color: var(--ink); }
.blog-prose p { margin: 0 0 var(--s-4); }
.blog-prose p:last-child { margin-bottom: 0; }
.blog-prose--lead > p:first-child { font-size: var(--fs-4); line-height: 1.5; }
.blog-post__outro { margin-top: var(--s-4); }

.blog .visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* An outside link, visibly so: the ↗ after it. */
.blog-ext { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
.blog-ext:hover { text-decoration-thickness: 2px; }
.blog-ext__mark { display: inline-block; margin-left: 0.15em; font-size: 0.85em; text-decoration: none; }

/* Where and when: a strip of facts under the title. */
.blog-strip { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-6); margin: var(--s-4) 0 0; padding: 0;
  font-family: var(--font-ui); font-size: var(--fs-2); color: var(--ink); }
.blog-strip__item { display: flex; flex-direction: column; gap: 2px; }
.blog-strip__label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* The map and the stops beside it (under it on a phone). */
.blog-where { max-width: var(--blog-wide); margin: 0 auto var(--s-10); display: grid; gap: var(--s-4) var(--s-6); }
.blog-where__h { margin: 0; font-family: var(--font-ui); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); }
@media (min-width: 56rem) {
  .blog-where:has(.blog-stops) { grid-template-columns: 3fr 2fr; grid-template-rows: auto 1fr; }
  .blog-where:has(.blog-stops) .blog-where__h { grid-column: 1 / -1; }
  /* The map grows with the list beside it, so every stop shows without a scrollbar. */
  .blog-where:has(.blog-stops) .blog-map { height: auto; min-height: 22rem; }
}
.blog-map { height: 22rem; border-radius: var(--radius-m); overflow: hidden; background: var(--surface-2);
  border: 1px solid var(--line); z-index: 0; }
.blog-map--index { height: 20rem; }
@media (max-width: 42rem) { .blog-map { height: 17rem; } }
.blog-stops { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-1); align-content: start; }
.blog-stops__item { display: grid; grid-template-columns: 1.75rem 1fr; gap: var(--s-3); align-items: start; padding: var(--s-2) 0;
  border-bottom: 1px solid var(--line); font-family: var(--font-ui); font-size: var(--fs-2); line-height: 1.4; }
.blog-stops__n, .blog-pin { display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%;
  background: var(--brand-gold); color: #18171c; font-family: var(--font-ui); font-size: 0.8rem; font-weight: 700; }
.blog-stops__text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s-3); min-width: 0; padding-top: 2px; }
.blog-stops__text a { min-height: 24px; display: inline-flex; align-items: center; }
.blog-stops__name { font-weight: 500; }
.blog-stops__note { flex-basis: 100%; font-size: var(--fs-1); color: var(--ink-2); }
.blog-stops__jump { font-size: var(--fs-1); color: var(--muted); text-decoration: none; }
.blog-stops__jump:hover { color: var(--accent-ink); text-decoration: underline; }
.blog-photo:target .blog-photo__link, .blog-cover:target .blog-photo__link { outline: 3px solid var(--brand-gold); outline-offset: 3px; }

/* Leaflet, in the family's colours. */
.blog-map .leaflet-container, .blog-map.leaflet-container { font-family: var(--font-ui); background: var(--surface-2); }
.blog-pin { border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
.blog-pin-icon { background: none; border: 0; }
.blog-map .leaflet-popup-content { margin: 10px 14px; font-size: 0.9rem; line-height: 1.45; }
.blog-map .leaflet-popup-content a { color: #835a0c; }
.blog-map .leaflet-popup-content strong { display: block; font-size: 0.95rem; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .blog-map .leaflet-tile-pane { filter: brightness(0.78) contrast(1.08) saturate(0.85); } }
:root[data-theme="dark"] .blog-map .leaflet-tile-pane { filter: brightness(0.78) contrast(1.08) saturate(0.85); }

/* Further reading. */
.blog-reading { max-width: var(--blog-text); margin: var(--s-12) auto 0; padding: var(--s-6); border-radius: var(--radius-m);
  background: var(--surface-2); }
.blog-reading__h { margin: 0 0 var(--s-3); font-family: var(--font-ui); font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.blog-reading__list { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--s-2); font-family: var(--font-ui); font-size: var(--fs-2); }
.blog-reading__list a { display: inline-flex; align-items: center; min-height: 24px; }
.blog-reading__src { font-size: var(--fs-1); color: var(--muted); }

/* Reading progress, a thin gold line along the top of the window (blog.js). */
.blog-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50; pointer-events: none; }
.blog-progress__bar { display: block; height: 100%; width: 100%; background: var(--brand-gold); transform-origin: 0 50%; transform: scaleX(0); }

/* ---------- The full-size viewer (blog.js) ---------- */
.blog-viewer { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0;
  padding: 0; border: 0; background: rgba(8, 8, 10, 0.94); color: #f4f2ee; overscroll-behavior: contain; }
.blog-viewer::backdrop { background: rgba(8, 8, 10, 0.94); }
.blog-viewer[open] { display: grid; grid-template-rows: 1fr auto; }
.blog-viewer__stage { position: relative; display: grid; place-items: center; min-height: 0; padding: var(--s-4);
  touch-action: pan-y pinch-zoom; }
.blog-viewer__img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  border-radius: var(--radius-s); user-select: none; -webkit-user-drag: none; }
.blog-viewer__bar { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-3) var(--s-4) max(var(--s-4), env(safe-area-inset-bottom)); }
.blog-viewer__caption { flex: 1; margin: 0; font-family: var(--font-ui); font-size: var(--fs-1); line-height: 1.5; color: #d9d6d0; }
.blog-viewer__count { font-family: var(--font-ui); font-size: var(--fs-1); color: #a9a5ad; white-space: nowrap; }
.blog-viewer__btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0;
  border-radius: var(--radius-pill); background: rgba(255, 255, 255, 0.12); color: #fff; font-size: 1.4rem; line-height: 1;
  cursor: pointer; }
.blog-viewer__btn:hover { background: rgba(255, 255, 255, 0.22); }
.blog-viewer__btn:focus-visible { outline: 2px solid var(--brand-gold); outline-offset: 2px; }
.blog-viewer__btn[disabled] { opacity: 0.3; cursor: default; }
.blog-viewer__close { position: absolute; top: max(var(--s-3), env(safe-area-inset-top)); right: var(--s-3); z-index: 1; }
.blog-viewer__prev, .blog-viewer__next { position: absolute; top: 50%; transform: translateY(-50%); z-index: 1; }
.blog-viewer__prev { left: var(--s-3); }
.blog-viewer__next { right: var(--s-3); }
@media (hover: none) { .blog-viewer__prev, .blog-viewer__next { display: none; } }
@media (prefers-reduced-motion: reduce) { .blog-card__img { transition: none; } .blog-card:hover .blog-card__img { transform: none; } }
