/* Almanac page styles. Hand authored; every size, color and gap comes from tokens.css.
   Primary viewport 360dp (R14), dark first (R3). No cards, shadows or panels: the 20dp
   gutter, one hairline divider and whitespace do the separating. */

html {
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior-y: none;
  background: var(--color-bg);
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  margin: 0;
  min-width: 0;
  background: var(--color-bg);
  color: var(--color-headline);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Masthead: Almanac's own serif wordmark, centered in the measured 56dp band, below
   the status bar inset. Full bleed hairline at the module edge. */
.masthead {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(var(--chrome-masthead) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--color-bg);
  border-bottom: var(--divider-weight) solid var(--color-divider);
}

.wordmark {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--type-wordmark-size);
  line-height: var(--type-wordmark-line-height);
  font-weight: 700;
  letter-spacing: var(--type-wordmark-tracking);
  color: var(--color-headline);
}

.river {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* The whole row is the touch target. Pressed state is a quiet full-bleed tint. */
.story-link {
  display: block;
  min-height: var(--touch-min);
  padding: 0 var(--space-gutter);
  color: inherit;
  text-decoration: none;
  transition: background-color var(--motion-duration) var(--motion-ease);
}

.story-link:active {
  background: var(--color-pressed);
}

.story-link:focus-visible {
  outline: 2px solid var(--color-headline);
  outline-offset: -2px;
}

/* Row rhythm, from the NYT section front (nyt-measured, river): 37dp of dark from a
   meta's ink to the next headline's ink, with the inset hairline nearer the headline,
   about 24dp below the meta's ink and 12dp above the headline's, so a rule reads as
   the top of the story it opens (checked by row scan at true 360dp, D1). Text-only
   rows keep the same shape, a step tighter. */
.story-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 10px 0 22px;
}

.story--text-only .story-body {
  padding: 10px 0 19px;
}

/* The hero opens the page under the masthead's full-bleed rule, so it has no rule of
   its own and a little more air above. */
.story--hero .story-body {
  padding: 20px 0 22px;
}

/* One hairline weight, inset by the 20dp gutter between stories (the link's padding
   supplies the inset), never full bleed inside a list. */
.story + .story .story-body {
  border-top: var(--divider-weight) solid var(--color-divider);
}

/* Image slot, reserved for a later slice; nothing emits .story-media yet. Its box is
   sized before any image loads (hero 1:1 full bleed, river 88dp square on the right,
   both measured), so images will arrive without shifting the text. */
.story-media {
  display: block;
  aspect-ratio: 1 / 1;
  background: var(--color-nav-surface);
}

.story--hero .story-media {
  margin: 0 calc(-1 * var(--space-gutter)) 16px;
}

.story--river .story-body:has(.story-media) {
  grid-template-columns: minmax(0, 1fr) 88px;
  column-gap: 16px;
}

.story--river .story-media {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 88px;
}

/* Headlines wrap greedily, as NYT's do, with only the orphan guard of `pretty`:
   `balance` left two-line heads visibly short of the measure. */
.headline {
  display: block;
  text-wrap: pretty;
  overflow-wrap: break-word;
  font-family: var(--type-text-only-headline-family);
  font-size: var(--type-text-only-headline-size);
  line-height: var(--type-text-only-headline-line-height);
  font-weight: var(--type-text-only-headline-weight);
  letter-spacing: var(--type-text-only-headline-tracking);
  color: var(--color-headline);
}

/* Hero headline, its own token, not a scaled copy of the list headline. */
.headline--hero {
  font-family: var(--type-hero-headline-family);
  font-size: var(--type-hero-headline-size);
  line-height: var(--type-hero-headline-line-height);
  font-weight: var(--type-hero-headline-weight);
  letter-spacing: var(--type-hero-headline-tracking);
}

/* Secondary lead blocks and river rows share the river headline token. */
.headline--river {
  font-family: var(--type-river-headline-family);
  font-size: var(--type-river-headline-size);
  line-height: var(--type-river-headline-line-height);
  font-weight: var(--type-river-headline-weight);
  letter-spacing: var(--type-river-headline-tracking);
}

/* Dek: hero and lead blocks only. Feed descriptions run long, so the hero shows at
   most four lines and a lead block three. */
.dek {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  margin-top: 8px;
  font-family: var(--type-dek-family);
  font-size: var(--type-dek-size);
  line-height: var(--type-dek-line-height);
  font-weight: var(--type-dek-weight);
  letter-spacing: var(--type-dek-tracking);
  color: var(--color-dek);
}

/* Hero: 14dp from the headline's baseline ink to the dek's caps (measured). */
.story--hero .dek {
  -webkit-line-clamp: 4;
  line-clamp: 4;
  margin-top: 1px;
}

/* Meta: source, the quiet source count, age. Only the source name may truncate. */
.meta {
  display: flex;
  min-width: 0;
  margin-top: 11px;
  white-space: nowrap;
  font-family: var(--type-meta-family);
  font-size: var(--type-meta-size);
  line-height: var(--type-meta-line-height);
  font-weight: var(--type-meta-weight);
  letter-spacing: var(--type-meta-tracking);
  text-transform: var(--type-meta-transform);
  color: var(--color-meta);
}

/* After a dek the meta sits about 15dp below the dek's ink (measured, hero). */
.dek + .meta {
  margin-top: 10px;
}

.story--text-only .meta {
  margin-top: 9px;
}

.meta-source {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-rest {
  flex: none;
  white-space: pre;
}

/* A module edge: full-bleed hairline, then a quiet sans label over the text-only tier,
   set like a section tab label (sentence case, not the shouting meta caps). */
.module {
  margin-top: 8px;
  border-top: var(--divider-weight) solid var(--color-divider);
}

.module-label {
  margin: 0;
  padding: 28px var(--space-gutter) 6px;
  font-family: var(--type-tab-label-family);
  font-size: var(--type-tab-label-size);
  line-height: var(--type-tab-label-line-height);
  font-weight: var(--type-tab-label-weight);
  letter-spacing: var(--type-tab-label-tracking);
  color: var(--color-headline);
}

/* The rest of the pool: one quiet full-width row under an inset hairline, the whole
   row the target. Opening it lays out the rows below and the row goes away. */
.more-toggle {
  display: flex;
  align-items: center;
  min-height: var(--touch-min);
  margin: 0 var(--space-gutter);
  padding: 14px 0 16px;
  border-top: var(--divider-weight) solid var(--color-divider);
  list-style: none;
  cursor: pointer;
  font-family: var(--type-meta-family);
  font-size: var(--type-meta-size);
  line-height: var(--type-meta-line-height);
  font-weight: var(--type-meta-weight);
  letter-spacing: var(--type-meta-tracking);
  text-transform: var(--type-meta-transform);
  color: var(--color-headline);
  transition: background-color var(--motion-duration) var(--motion-ease);
}

.more-toggle::-webkit-details-marker {
  display: none;
}

.more-toggle:active {
  background: var(--color-pressed);
}

.more-toggle:focus-visible {
  outline: 2px solid var(--color-headline);
  outline-offset: 2px;
}

.more-rest[open] > .more-toggle {
  display: none;
}

/* The first opened row continues the list above, so it takes the list's hairline. */
.more-rest .story:first-child .story-body {
  border-top: var(--divider-weight) solid var(--color-divider);
}

/* Colophon: freshness line after the last story, full-bleed hairline above it. */
.colophon {
  border-top: var(--divider-weight) solid var(--color-divider);
  padding: 24px var(--space-gutter) 32px;
}

/* The colophon may wrap, so it gets open leading, not the one-line meta box. */
.colophon-text {
  margin: 0;
  font-family: var(--type-meta-family);
  font-size: var(--type-meta-size);
  line-height: 1.6;
  font-weight: var(--type-meta-weight);
  letter-spacing: var(--type-meta-tracking);
  text-transform: var(--type-meta-transform);
  color: var(--color-meta);
}

@media (prefers-reduced-motion: reduce) {
  .story-link,
  .more-toggle {
    transition: none;
  }
}
