/* Stratum — layout.
   Page shells, the asymmetric grid, the rail, and the section geometries.
   Spacing between sections is owned by .stx-section alone; nothing else sets a
   vertical margin at that level, so the two cannot fight. */

/* ------------------------------------------------------------------- shell */

.stx-shell {
  display: grid;
  gap: var(--stx-rail-gap, 32px);
  padding-block: var(--stx-gap-section);
  align-items: stretch;
}

.stx-shell__main { min-width: 0; }

/* The asymmetric split is the default: a wide column and a genuinely narrow
   rail, rather than two columns pretending to be equal. */
.stx-grid-asymmetric .stx-shell { grid-template-columns: minmax(0, 1fr); }
.stx-grid-even .stx-shell { grid-template-columns: minmax(0, 1fr); }

@media (min-width: 60rem) {
  .stx-grid-asymmetric .stx-shell:not(.stx-no-rail-shell) { grid-template-columns: minmax(0, 1fr) 19rem; }
  .stx-grid-even .stx-shell:not(.stx-no-rail-shell) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

  .stx-rail-left .stx-shell:not(.stx-no-rail-shell) { grid-template-columns: 19rem minmax(0, 1fr); }
  .stx-rail-left .stx-shell__main { order: 2; }
  .stx-rail-left .stx-rail { order: 1; }
}

.stx-no-rail .stx-shell,
.stx-grid-single .stx-shell { grid-template-columns: minmax(0, 1fr) !important; }

.stx-shell--narrow .stx-shell__main,
.stx-shell--page .stx-shell__main { margin-inline: auto; }

/* -------------------------------------------------------------------- rail */

.stx-rail {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.stx-rail--sticky { position: sticky; top: 5.5rem; align-self: start; }

/* Differential: the rail sits one plane further back and moves at a fraction
   of the page's rate. The offset is written by depth.js; without it the rail
   simply sticks, which is why the transform is expressed as a variable. */
.stx-rail--differential {
  position: sticky;
  top: 5.5rem;
  align-self: start;
  transform: translate3d(0, calc(var(--stx-rail-y, 0px)), 0);
  will-change: transform;
}

@media (max-width: 59.99rem) {
  .stx-rail--sticky,
  .stx-rail--differential { position: static; transform: none; }
}

/* -------------------------------------------------------------------- cards */

.stx-cards {
  display: grid;
  gap: clamp(1rem, 2vw, 1.6rem);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}

@media (min-width: 46rem) {
  .stx-cards--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stx-cards--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stx-cards--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stx-cards--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stx-cards--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 68rem) {
  .stx-cards--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stx-cards--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .stx-cards--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.stx-rows { display: flex; flex-direction: column; gap: 1rem; }
.stx-rows--stack { gap: 1.6rem; }

/* ------------------------------------------------------------------ mosaic */

.stx-mosaic { display: grid; gap: clamp(1rem, 2vw, 1.6rem); }

@media (min-width: 60rem) {
  .stx-mosaic { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
  .stx-mosaic__rest { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1rem, 2vw, 1.6rem); }
}

/* ------------------------------------------------------------------- split */

.stx-split { display: grid; gap: clamp(1.4rem, 3vw, 2.4rem); }

@media (min-width: 60rem) {
  .stx-split { grid-template-columns: minmax(0, 1fr) 19rem; align-items: start; }
  .stx-split__rail { display: flex; flex-direction: column; gap: 1.2rem; }
}

/* -------------------------------------------------------------------- lead */

.stx-lead { padding-top: clamp(1.6rem, 4vw, 3rem); padding-bottom: var(--stx-gap-section); }

.stx-lead__kicker {
  font-family: var(--stx-font-utility);
  font-size: var(--stx-fs-xs);
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--stx-fg-dim);
  margin-bottom: 1rem;
}

.stx-lead__grid { display: grid; gap: clamp(1.2rem, 2.6vw, 2rem); }

@media (min-width: 62rem) {
  /* The side column matches the lead's height instead of stopping short and
     leaving a block of empty space beside it. */
  .stx-lead--diorama .stx-lead__grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: stretch; }
  .stx-lead--diorama .stx-lead__side { height: 100%; justify-content: space-between; }
  .stx-lead--diorama .stx-lead__side > * { flex: 1 1 0; min-height: 0; }
  .stx-lead--split .stx-lead__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; }
}

.stx-lead__side { display: flex; flex-direction: column; gap: .9rem; }

.stx-lead__main {
  position: relative;
  border-radius: var(--stx-radius);
  overflow: clip;
  background: var(--stx-plane1);
  border: 1px solid var(--stx-hairline);
}

.stx-lead__media { display: block; aspect-ratio: 16 / 9; overflow: clip; }
.stx-lead__media img { width: 100%; height: 100%; object-fit: cover; }

.stx-lead__body { padding: clamp(1.1rem, 2.4vw, 2rem); }

.stx-lead__title {
  font-size: clamp(var(--stx-fs-xl), 4.4vw, var(--stx-fs-4xl));
  margin-bottom: .5rem;
}

.stx-lead__title a { text-decoration: none; }
.stx-lead__title a:hover { color: var(--stx-z1); }

.stx-lead__excerpt {
  color: var(--stx-fg-mid);
  font-size: var(--stx-fs-lg);
  max-width: 46ch;
}

/* Cover lead: the title plate sits over the image rather than beside it. */
.stx-lead--cover .stx-lead__main { display: grid; }
.stx-lead--cover .stx-lead__media,
.stx-lead--cover .stx-lead__body { grid-area: 1 / 1; }
.stx-lead--cover .stx-lead__media { aspect-ratio: 21 / 9; }
.stx-lead--cover .stx-lead__body {
  align-self: end;
  background: linear-gradient(to top, color-mix(in srgb, var(--stx-substrate) 92%, transparent), transparent);
}

/* ------------------------------------------------------------------ ledger */

.stx-ledger { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }

.stx-ledger__row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  padding: clamp(.9rem, 2vw, 1.3rem) 0;
  border-top: 1px solid var(--stx-hairline);
}

.stx-ledger__row:first-child { border-top: 0; }

@media (min-width: 46rem) {
  .stx-ledger__row { grid-template-columns: auto minmax(0, 1fr) 9rem; }
}

.stx-ledger__rank {
  font-family: var(--stx-font-utility);
  font-size: var(--stx-fs-lg);
  color: var(--stx-z5);
  font-variant-numeric: tabular-nums;
}

.stx-ledger__title { font-size: var(--stx-fs-lg); margin: .2rem 0 .35rem; }
.stx-ledger__title a { text-decoration: none; }
.stx-ledger__title a:hover { color: var(--stx-z1); }

.stx-ledger__media {
  display: none;
  aspect-ratio: 3 / 2;
  border-radius: var(--stx-radius-sm);
  overflow: clip;
}

@media (min-width: 46rem) { .stx-ledger__media { display: block; } }

/* ----------------------------------------------------------------- section */

.stx-sechead {
  display: flex;
  align-items: baseline;
  gap: .9rem;
  margin-bottom: clamp(1rem, 2vw, 1.6rem);
  padding-bottom: .7rem;
  border-bottom: 1px solid var(--stx-hairline);
}

.stx-sechead__eyebrow { color: var(--stx-z5); }

.stx-sechead__title { font-size: var(--stx-fs-xl); margin: 0; }

.stx-sechead__all {
  margin-inline-start: auto;
  font-family: var(--stx-font-utility);
  font-size: var(--stx-fs-xs);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--stx-fg-dim);
  text-decoration: none;
}

.stx-sechead__all:hover { color: var(--stx-z1); }

/* ------------------------------------------------------------ archive head */

.stx-archhead { margin-bottom: clamp(1.4rem, 3vw, 2.4rem); }
.stx-archhead__eyebrow { color: var(--stx-z5); display: block; margin-bottom: .6rem; }
.stx-archhead__title { font-size: clamp(var(--stx-fs-xl), 5vw, var(--stx-fs-3xl)); margin: 0; }
.stx-archhead__desc { color: var(--stx-fg-mid); max-width: 58ch; margin-top: .7rem; }
.stx-archhead__avatar img { border-radius: 999px; margin-top: 1rem; }

/* --------------------------------------------------------------- index tiles */

/* The column count is a setting, so it has to be honoured. This grid used to
   auto-fill, which meant it fitted as many tiles per row as the width allowed
   and the setting did nothing. */
.stx-index { display: grid; gap: clamp(.8rem, 1.6vw, 1.2rem); grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); }

@media (min-width: 46rem) {
  .stx-index--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stx-index--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stx-index--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stx-index--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 68rem) {
  .stx-index--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stx-index--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.stx-index__tile {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: 1.1rem;
  border-radius: var(--stx-radius);
  background: var(--stx-plane1);
  border: 1px solid var(--stx-hairline);
  text-decoration: none;
}

.stx-index__name { font-family: var(--stx-font-display); font-weight: 700; font-size: var(--stx-fs-lg); }
.stx-index__count { font-family: var(--stx-font-utility); font-size: var(--stx-fs-xs); color: var(--stx-z5); text-transform: uppercase; letter-spacing: .08em; }
.stx-index__latest { color: var(--stx-fg-dim); font-size: var(--stx-fs-sm); }

/* ------------------------------------------------------------------ signup */

.stx-signup {
  display: grid;
  gap: 1.4rem;
  padding: clamp(1.4rem, 3vw, 2.4rem);
  border-radius: var(--stx-radius);
  background: var(--stx-plane1);
  border: 1px solid var(--stx-rim);
}

@media (min-width: 52rem) { .stx-signup { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; } }

.stx-signup__text { color: var(--stx-fg-mid); margin: 0; font-size: var(--stx-fs-lg); }
.stx-signup__empty { color: var(--stx-fg-dim); font-family: var(--stx-font-utility); font-size: var(--stx-fs-xs); margin: 0; }

/* --------------------------------------------------------------------- 404 */

.stx-404 { padding-block: clamp(3rem, 10vw, 8rem); text-align: center; }

.stx-404__stack {
  position: relative;
  height: clamp(6rem, 18vw, 12rem);
  margin-bottom: 1.5rem;
  font-family: var(--stx-font-display);
  font-weight: 900;
  font-size: clamp(4rem, 16vw, 11rem);
  line-height: 1;
}

.stx-404__stack span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.stx-404__stack span[data-plane="3"] { color: var(--stx-plane3); transform: translate(-14px, 10px); }
.stx-404__stack span[data-plane="2"] { color: var(--stx-plane2); transform: translate(-7px, 5px); }
.stx-404__stack span[data-plane="1"] { color: var(--stx-z3); }

.stx-404__title { font-size: var(--stx-fs-2xl); }
.stx-404__text { color: var(--stx-fg-mid); max-width: 44ch; margin-inline: auto; }
.stx-404 .stx-search { max-width: 26rem; margin: 1.5rem auto; }

.stx-404__sections,
.stx-none__sections {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
}

.stx-404__sections a,
.stx-none__sections a {
  display: inline-block;
  padding: .38rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--stx-hairline);
  background: var(--stx-plane2);
  font-family: var(--stx-font-utility);
  font-size: var(--stx-fs-xs);
  text-transform: uppercase;
  letter-spacing: .08em;
  text-decoration: none;
}

.stx-404__sections a:hover,
.stx-none__sections a:hover { border-color: var(--stx-z1); color: var(--stx-z1); }

.stx-none { text-align: center; }
.stx-none__title { font-size: var(--stx-fs-xl); }
.stx-none__text { color: var(--stx-fg-mid); }
.stx-none .stx-search { max-width: 24rem; margin-inline: auto; }

/* ------------------------------------------------------------------ footer */

.stx-foot { margin-top: var(--stx-gap-section); border-top: 1px solid var(--stx-hairline); }

.stx-foot--strata { background: linear-gradient(to bottom, var(--stx-substrate), var(--stx-plane1)); }
.stx-foot--columns { background: var(--stx-plane1); }

.stx-foot__cols { padding-block: clamp(2rem, 5vw, 3.5rem); }

.stx-foot__grid { display: grid; gap: clamp(1.4rem, 3vw, 2.4rem); }

@media (min-width: 46rem) {
  .stx-foot__grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stx-foot__grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stx-foot__grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 64rem) { .stx-foot__grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.stx-fwidget__title {
  font-family: var(--stx-font-utility);
  font-size: var(--stx-fs-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--stx-fg-dim);
  margin-bottom: .8rem;
}

.stx-fwidget ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.stx-fwidget a { text-decoration: none; color: var(--stx-fg-mid); }
.stx-fwidget a:hover { color: var(--stx-fg); }

/* The oversized wordmark is the only purely decorative element in the theme.
   It is clipped rather than scrolled, so it never adds horizontal overflow. */
.stx-foot__mark {
  overflow: clip;
  line-height: .8;
  padding-inline: 1.2rem;
  color: color-mix(in srgb, var(--stx-fg) 7%, transparent);
}

.stx-foot__mark span {
  display: block;
  font-family: var(--stx-font-display);
  font-weight: 900;
  font-size: clamp(3rem, 15vw, 12rem);
  letter-spacing: -.04em;
  white-space: nowrap;
  text-align: center;
}

.stx-foot__bottom { border-top: 1px solid var(--stx-hairline); }

.stx-foot__bottominner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding-block: 1.1rem;
}

.stx-foot__copy {
  margin: 0;
  font-family: var(--stx-font-utility);
  font-size: var(--stx-fs-xs);
  color: var(--stx-fg-dim);
}

/* The legal menu is a row. It is declared with the same specificity as the
   footer widget lists above so the two cannot silently swap places. */
.stx-foot__bottominner .stx-foot__legal {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1rem;
}

.stx-foot__legal a {
  font-family: var(--stx-font-utility);
  font-size: var(--stx-fs-xs);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--stx-fg-dim);
  text-decoration: none;
}

.stx-foot__legal a:hover { color: var(--stx-fg); }

/* ------------------------------------------------------------------ to top */

.stx-totop {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 60;
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--stx-rim);
  border-radius: 999px;
  background: var(--stx-plane1);
  color: var(--stx-fg-mid);
  cursor: pointer;
  box-shadow: var(--stx-elev-2);
}

.stx-totop:hover { color: var(--stx-z1); border-color: var(--stx-z1); }

/* ---------------------------------------------------------------- progress */

.stx-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 80;
  background: transparent;
  pointer-events: none;
}

.stx-progress__bar {
  display: block;
  height: 100%;
  width: var(--stx-read, 0%);
  background: linear-gradient(90deg, var(--stx-z5), var(--stx-z3), var(--stx-z1));
}

/* A view that renders no rail must not reserve a column for it. The modifier is
   set by the template rather than inferred, because the rail can be suppressed
   per post as well as per site. */
.stx-shell.stx-no-rail-shell { grid-template-columns: minmax(0, 1fr); }

/* --------------------------------------------------------- small fixups */

.stx-site { display: flow-root; }

.stx-archlead { margin-bottom: clamp(1.2rem, 2.6vw, 2rem); }

.stx-mosaic__main,
.stx-split__main,
.stx-ledger__body,
.stx-authorbox__body,
.stx-storylist__body,
.stx-signup__copy,
.stx-signup__form { min-width: 0; }

/* stx_thumb() wraps the image in a div, so the wrapper needs the height for
   object-fit on the image inside it to have anything to fit. */
.stx-lead__mediainner,
.stx-spot__mediainner { width: 100%; height: 100%; }

.stx-comments__closed {
  font-family: var(--stx-font-utility);
  font-size: var(--stx-fs-xs);
  color: var(--stx-fg-dim);
}

.stx-foot__cols .stx-foot__menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.stx-foot__menu a { text-decoration: none; color: var(--stx-fg-mid); }
.stx-foot__menu a:hover { color: var(--stx-fg); }


/* ------------------------------------------------------------- lead fitting */
/* "Fit" caps the lead to roughly one screen on a laptop: the image gets a
   height rather than an aspect ratio, and the headline and standfirst are
   trimmed to a fixed number of lines so a long title cannot push the fold. */

@media (min-width: 62rem) {
  .stx-lead--fit { padding-top: clamp(.9rem, 1.8vw, 1.5rem); padding-bottom: clamp(1.2rem, 2.4vw, 2rem); }

  .stx-lead--fit .stx-lead__media {
    aspect-ratio: auto;
    height: clamp(15rem, 34vh, 22rem);
  }

  .stx-lead--fit .stx-lead__body { padding: clamp(.9rem, 1.6vw, 1.3rem); }

  .stx-lead--fit .stx-lead__title {
    font-size: clamp(var(--stx-fs-xl), 2.6vw, var(--stx-fs-2xl));
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .stx-lead--fit .stx-lead__excerpt {
    font-size: var(--stx-fs-md);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .stx-lead--fit .stx-lead__side { gap: .7rem; }

  .stx-lead--fit .stx-lead__side .stx-card__title {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* --------------------------------------------------------- ledger columns */
/* Two columns for a ranked list. The row separator becomes a top border on
   every row, so both columns keep their own rules and the two do not join
   across the gap. */

@media (min-width: 60rem) {
  .stx-ledger--cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: clamp(1.5rem, 3vw, 2.6rem); }
  .stx-ledger--cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: clamp(1.2rem, 2.4vw, 2rem); }

  .stx-ledger--cols-2 .stx-ledger__row,
  .stx-ledger--cols-3 .stx-ledger__row { border-top: 1px solid var(--stx-hairline); }

  /* Only the first row of each column loses its rule, not just the first
     row overall. */
  .stx-ledger--cols-2 .stx-ledger__row:nth-child(-n+2),
  .stx-ledger--cols-3 .stx-ledger__row:nth-child(-n+3) { border-top: 0; }

  .stx-ledger--cols-2 .stx-ledger__row,
  .stx-ledger--cols-3 .stx-ledger__row { grid-template-columns: auto minmax(0, 1fr); }

  .stx-ledger--cols-2 .stx-ledger__media,
  .stx-ledger--cols-3 .stx-ledger__media { display: none; }
}

.stx-ledger--section .stx-ledger__title { font-size: var(--stx-fs-md); }

/* ------------------------------------------------------- footer columns */

.stx-foot__text { color: var(--stx-fg-mid); font-size: var(--stx-fs-sm); }
.stx-foot__text p:last-child { margin-bottom: 0; }

.stx-foot__stories { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.stx-foot__stories a { display: block; text-decoration: none; color: var(--stx-fg-mid); font-size: var(--stx-fs-sm); line-height: 1.3; }
.stx-foot__stories a:hover { color: var(--stx-fg); }
.stx-foot__date { display: block; margin-top: .15rem; font-family: var(--stx-font-utility); font-size: calc(var(--stx-fs-xs) * .92); color: var(--stx-fg-dim); }
