/* =====================================================================
   News & blog — news/index.html and news/<slug>.html, all built by
   scripts/news.js. An ink hero over a paper page, like the planner and
   the QR page. The post list is the services list's row: a navy fill
   rises behind it on hover and the title steps right.

   Depends on the tokens in css/styles.css.
   ===================================================================== */

/* Red text on the paper ground is --red-2: the brand --red measures
   3.83:1 on --paper, under the 4.5:1 AA floor for 12px labels; --red-2 is
   5.27:1. Red that is not text (rules, bullets, the progress line) stays
   the brand red. */

/* ---------- Listing ---------- */
.news {
  padding-block: clamp(2.5rem, 5vw, 4.5rem) var(--section);
}

.news-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: clamp(1.25rem, 3vw, 2.5rem);
}

/* Scrolls sideways on a narrow phone rather than wrapping. */
.filters {
  display: flex;
  gap: 0.4rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter,
.share-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line-dark);
  transition: color var(--duration-fast) ease, background-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}

.filter b {
  font-weight: 500;
  opacity: 0.6;
}

.filter:hover,
.share-link:hover {
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--text);
}

.filter.is-active {
  color: var(--paper);
  background: var(--navy);
  box-shadow: none;
}

.feed-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  transition: color var(--duration-base) ease;
}

.feed-link svg {
  width: 12px;
  height: 12px;
}

.feed-link:hover {
  color: var(--red-2);
}

.news-empty {
  padding-block: 3rem;
  color: var(--muted);
}

/* ---------- Post rows ---------- */
/* An <ol>, newest first; the reset in styles.css only clears <ul>. */
.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line-dark);
}

.post {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(96px, 26vw, 148px);
  grid-template-areas:
    "meta    meta"
    "title   title"
    "summary media";
  align-items: start;
  gap: 0.6rem 1rem;
  padding: clamp(1.5rem, 3vw, 2.25rem) 0;
  border-bottom: 1px solid var(--line-dark);
  color: var(--text);
  isolation: isolate;
  transition: color var(--duration-base) ease;
}

.post[hidden] {
  display: none;
}

.post::before {
  content: "";
  position: absolute;
  inset: 0 calc(var(--gutter) * -1);
  background: var(--navy);
  transform: scaleY(0);
  transform-origin: bottom center;
  transition: transform var(--duration-slow) var(--ease-out-expo);
  z-index: -1;
}

.post:hover::before,
.post:focus-within::before {
  transform: scaleY(1);
  transform-origin: top center;
}

.post:hover,
.post:focus-within {
  color: var(--paper);
}

.post-title {
  grid-area: title;
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(1.75rem, 3.4vw, 3rem);
  line-height: 0.98;
  letter-spacing: 0.005em;
  text-wrap: balance;
}

/* What steps right on hover is this span, never the heading or the link:
   a transform makes an element the containing block of its absolute
   descendants, so the link's ::after below would shrink from the whole
   row to the title the moment the pointer arrived, and a click on the
   summary or the photo would do nothing. */
.post-title span {
  display: inline-block;
  transition: transform var(--duration-slow) var(--ease-out-expo);
}

/* The one link in the row, stretched over all of it. */
.post-title a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.post-title a:focus-visible {
  outline: none;
}

.post-title a:focus-visible::after {
  outline: 2px solid var(--red);
  outline-offset: 4px;
  border-radius: 2px;
}

.post-meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  color: var(--muted);
  transition: color var(--duration-base) ease;
}

.post-type {
  color: var(--red-2);
  transition: color var(--duration-base) ease;
}

/* Neither red reads on the navy fill (3.4:1 at best). */
.post:hover .post-type,
.post:focus-within .post-type {
  color: var(--paper);
}

.post-summary {
  grid-area: summary;
  max-width: 52ch;
  color: var(--muted);
  transition: color var(--duration-base) ease;
}

.post:hover .post-meta,
.post:hover .post-summary,
.post:focus-within .post-meta,
.post:focus-within .post-summary {
  color: var(--fog);
}

.post-media {
  grid-area: media;
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: 4px;
  overflow: hidden;
  background: var(--paper-2);
}

.post-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease-out-expo);
}

.post:hover .post-media img {
  transform: scale(1.05);
}

.post-more,
.post-arrow {
  display: none;
}

/* Same circle as the services rows. */
.post-arrow {
  grid-area: arrow;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  place-items: center;
  box-shadow: inset 0 0 0 1px currentColor;
  opacity: 0.5;
  transition: opacity var(--duration-base) ease, transform var(--duration-slow) var(--ease-out-expo),
    background-color var(--duration-base) ease;
}

.post-arrow svg {
  width: 16px;
  height: 16px;
}

.post:hover .post-arrow {
  opacity: 1;
  transform: rotate(-45deg);
  background: var(--red);
  box-shadow: none;
}

/* The lead, the newest post showing: a photo and a large title rather
   than a row. On a phone the photo goes on top. news.js moves the class
   to whichever post is first when the list is filtered. */
.post.is-lead {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "media"
    "meta"
    "title"
    "summary"
    "more";
  gap: 0.85rem;
  padding-top: clamp(1.25rem, 3vw, 2rem);
  color: var(--text);
}

.post.is-lead::before {
  display: none;
}

.post.is-lead .post-meta,
.post.is-lead .post-summary {
  color: var(--muted);
}

.post.is-lead .post-meta .post-type {
  color: var(--red-2);
}

.post.is-lead .post-media {
  aspect-ratio: 3 / 2;
  border-radius: 6px;
  margin-bottom: 0.4rem;
}

.post.is-lead .post-title {
  font-size: clamp(2.3rem, 4.6vw, 4.75rem);
  line-height: 0.92;
}

.post.is-lead .post-summary {
  font-size: var(--text-lead);
  line-height: 1.55;
  max-width: 40ch;
}

.post.is-lead .post-more {
  grid-area: more;
  display: inline-flex;
  margin-top: 0.6rem;
  color: var(--red-2);
  transition: transform var(--duration-slow) var(--ease-out-expo);
}

.post.is-lead:hover .post-more {
  transform: translateX(0.5rem);
}

.post.is-lead .post-arrow {
  display: none;
}

@media (min-width: 900px) {
  .post {
    grid-template-columns: 9.5rem minmax(0, 1fr) clamp(160px, 16vw, 240px) 44px;
    grid-template-areas:
      "meta title   media arrow"
      "meta summary media arrow";
    grid-template-rows: auto 1fr;
    gap: 0.75rem clamp(1.5rem, 3vw, 3rem);
  }
  .post-meta {
    flex-direction: column;
    gap: 0.45rem;
    padding-top: 0.55em;
  }
  .post:hover .post-title span,
  .post:focus-within .post-title span {
    transform: translateX(0.75rem);
  }
  .post-arrow {
    display: grid;
    align-self: center;
  }

  .post.is-lead {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-areas:
      "media meta"
      "media title"
      "media summary"
      "media more";
    grid-template-rows: auto auto auto 1fr;
    gap: 1.1rem clamp(2rem, 4vw, 4.5rem);
    padding-block: clamp(2rem, 3vw, 2.75rem);
  }
  .post.is-lead .post-meta {
    flex-direction: row;
    padding-top: 0.25rem;
  }
  .post.is-lead .post-media {
    margin-bottom: 0;
  }
  .post.is-lead .post-more {
    align-self: end;
  }
  .post.is-lead:hover .post-title span,
  .post.is-lead:focus-within .post-title span {
    transform: none;
  }
}

/* ---------- Article ---------- */
.article-hero {
  padding-bottom: clamp(2.5rem, 6vw, 4.5rem);
}

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--fog);
}

.crumbs li + li::before {
  content: "/";
  margin-right: 0.5rem;
  color: var(--fog-2);
}

.crumbs a {
  transition: color var(--duration-base) ease;
}

.crumbs a:hover {
  color: var(--paper);
}

.page-hero .article-title {
  margin-top: 1.4rem;
  max-width: 17ch;
  font-size: clamp(2.6rem, 6.2vw, 6.25rem);
  line-height: 0.9;
  text-wrap: balance;
}

.article-hero .lead {
  max-width: 48ch;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  margin-top: clamp(1.75rem, 3vw, 2.5rem);
  color: var(--fog);
}

/* The cover sits across the seam between the ink hero and the paper. */
.article-cover {
  background: linear-gradient(180deg, var(--ink) 50%, var(--paper) 50%);
}

.article-cover img {
  width: 100%;
  max-height: min(72vh, 760px);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: var(--ink-3);
}

.article-body {
  padding-block: clamp(2.5rem, 6vw, 5rem) clamp(3.5rem, 8vw, 7rem);
}

.article-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
}

/* Under the article on a phone, ruled off from it. */
.article-aside {
  display: grid;
  gap: 1rem;
  align-content: start;
  padding-top: 2rem;
  border-top: 1px solid var(--line-dark);
}

/* On a desktop the prose is centred and the share column sits to its
   left, held in view while the article scrolls past. */
@media (min-width: 1024px) {
  .article-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 43rem) minmax(0, 1fr);
    column-gap: clamp(2rem, 4vw, 4.5rem);
  }
  .prose {
    grid-column: 2;
    grid-row: 1;
  }
  .article-aside {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    justify-self: end;
    position: sticky;
    top: calc(var(--header-h) + 1.5rem);
    width: min(100%, 12.5rem);
    padding-top: 0.5rem;
    border-top: 0;
  }
  .article-aside .share {
    flex-direction: column;
    align-items: flex-start;
  }
}

.article-aside > .mono {
  color: var(--muted);
}

.share {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.share-link[hidden] {
  display: none;
}

.share-status {
  min-height: 1.5em;
  font-size: 0.85rem;
  color: var(--muted);
}

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  width: fit-content;
  color: var(--text);
  transition: color var(--duration-base) ease;
}

.article-back svg {
  width: 12px;
  height: 12px;
  transition: transform var(--duration-base) var(--ease-out-quart);
}

.article-back:hover {
  color: var(--red-2);
}

.article-back:hover svg {
  transform: translateX(-3px);
}

/* Over the header, which hides on the way down; the line stays. */
.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 950;
  pointer-events: none;
}

.read-progress i {
  display: block;
  height: 100%;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left center;
}

html:not(.js) .read-progress,
html.menu-open .read-progress {
  display: none;
}

/* ---------- Prose ---------- */
.prose {
  min-width: 0;
  font-size: clamp(1.0625rem, 0.3vw + 0.98rem, 1.1875rem);
  line-height: 1.75;
  color: var(--text);
  counter-reset: section;
}

.prose > * + * {
  margin-top: 1.25em;
}

/* Numbered like the site's sections: 01, 02 in red mono above each. */
.prose h2 {
  counter-increment: section;
  margin-top: 2.6em;
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(1.9rem, 3vw, 2.6rem);
  line-height: 1;
  letter-spacing: 0.005em;
  text-wrap: balance;
}

.prose h2::before {
  content: counter(section, decimal-leading-zero);
  display: block;
  margin-bottom: 0.85rem;
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--red-2);
}

.prose h3 {
  margin-top: 2em;
  font-size: 1.2em;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.prose h4 {
  margin-top: 1.75em;
  font-family: var(--font-mono);
  font-size: var(--text-mono);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.prose h2,
.prose h3,
.prose h4 {
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.prose :is(h2, h3, h4) + * {
  margin-top: 0.75em;
}

.prose a {
  color: var(--navy);
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color var(--duration-base) ease;
}

.prose a:hover {
  color: var(--red-2);
  text-decoration-thickness: 2px;
}

.prose strong {
  font-weight: 700;
}

.prose ul,
.prose ol {
  padding-left: 1.6em;
}

.prose ul {
  list-style: none;
}

.prose ul > li {
  position: relative;
}

.prose ul > li::before {
  content: "";
  position: absolute;
  left: -1.3em;
  top: 0.85em;
  width: 0.5em;
  height: 2px;
  background: var(--red);
}

.prose ol > li::marker {
  font-family: var(--font-mono);
  font-size: 0.8em;
  font-weight: 500;
  color: var(--red-2);
}

.prose li + li,
.prose li > :is(ul, ol) {
  margin-top: 0.5em;
}

.prose li > p + p {
  margin-top: 0.75em;
}

.prose blockquote {
  margin: 1.75em 0 0;
  padding-left: 1.4em;
  border-left: 2px solid var(--red);
  font-size: 1.15em;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.prose blockquote > * + * {
  margin-top: 0.8em;
}

.prose figure {
  margin-block: 2.25em;
}

.prose figure img {
  width: 100%;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--line-dark);
}

.prose figcaption {
  margin-top: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  line-height: 1.6;
  text-transform: uppercase;
  color: var(--muted);
}

.prose hr {
  height: 1px;
  margin-block: 2.75em;
  border: 0;
  background: var(--line-dark);
}

.prose code {
  padding: 0.12em 0.38em;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--paper-2);
}

.prose pre {
  overflow-x: auto;
  padding: 1.1rem 1.25rem;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--paper);
  background: var(--ink);
}

.prose pre code {
  padding: 0;
  font-size: inherit;
  background: none;
}

/* A wide table scrolls inside its own box rather than the page. */
.table-wrap {
  overflow-x: auto;
  margin-block: 2em;
}

.table-wrap:focus-visible {
  outline-offset: 2px;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.prose th {
  padding: 0 1rem 0.7rem 0;
  border-bottom: 1px solid var(--text);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
}

.prose td {
  padding: 0.75rem 1rem 0.75rem 0;
  border-bottom: 1px solid var(--line-dark);
  vertical-align: top;
}

.prose :is(th, td):last-child {
  padding-right: 0;
}

.prose :is(th, td).ar {
  text-align: right;
}

.prose :is(th, td).ac {
  text-align: center;
}

/* ---------- Keep reading ---------- */
.more {
  padding-bottom: var(--section);
}

.more-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  padding-top: clamp(3rem, 6vw, 5rem);
  margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
  border-top: 1px solid var(--line-dark);
}

.more-head .display {
  margin-top: 1.25rem;
  font-size: var(--text-title-sm);
}

.more-all {
  color: var(--text);
  transition: color var(--duration-base) ease;
}

.more-all:hover {
  color: var(--red-2);
}

/* Shown only on a build made with --drafts. */
.draft-flag {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 1300;
  padding: 0.5rem 0.8rem;
  border-radius: 4px;
  color: var(--white);
  background: var(--red);
}

@media (pointer: coarse) {
  .filter,
  .share-link {
    min-height: 44px;
  }
  .feed-link,
  .article-back,
  .more-all {
    min-height: 44px;
  }
}
