/*
 * The homepage (homepage/show and frames/homepage/*; tasks/redesign, D7): the
 * index strip under the masthead, the hero beside the market map for a
 * signed-out visitor (the map alone at full width signed in), then the news.
 *
 *   .home              the page
 *   .home__lead        the hero and the map, side by side from 1024px
 *   .home-hero         the signed-out hero (homepage/_hero): the serif
 *                      headline and lead, the large search under a caps
 *                      label, the popular tickers, three ruled blurbs
 *   .index-cards       the three indexes, a sideways-scrolling strip below
 *                      1024px
 *   .index-card        one index: name and symbol, level and today's change,
 *                      the year and the future, the trend line in ink
 *   .trend-line        the SVG from `trend_line_tag`
 *   .market-map        the treemap section: header, range toggle, legend,
 *                      chart
 *   .ramp-legend       the six colour steps and the two ends of the scale
 *   .home__news        the news
 */
@layer pages {
  .home {
    /* The finished strip's content height, which its placeholder reserves. */
    --index-card-height: 4.875rem;

    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-lg);
  }

  .home__lead {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-xl);

    @media (width >= 1024px) {
      &:has(> .home-hero) {
        grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
        gap: var(--space-2xl);
      }
    }
  }

  /* The signed-out hero */

  .home-hero {
    display: grid;
    align-content: start;
    gap: var(--space-md);
  }

  .home-hero__title {
    margin-block-end: 0;
    font-size: var(--text-h1);
    line-height: var(--leading-h1);
  }

  .home-hero__lead {
    margin: 0;
    color: var(--color-ink);
    font-family: var(--font-prose);
    font-size: var(--text-lead);
    line-height: var(--leading-lead);
  }

  .home-hero__search {
    display: grid;
    gap: var(--space-xs);
    max-inline-size: 36rem;
  }

  .home-hero__popular {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2xs) var(--space-sm);
    margin: 0;
    color: var(--color-ink-muted);
    font-size: var(--text-ui-sm);
  }

  .home-hero__ticker {
    display: inline-flex;
    align-items: center;
    color: var(--color-link);
    font-size: var(--text-caps);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-caps);
    text-decoration: none;

    &:hover {
      text-decoration: underline;
    }

    @media (pointer: coarse) {
      min-block-size: var(--target-min);
    }
  }

  /* Three blurbs on hairlines under a heavy rule: a bold lead-in, a
     sentence, a link. */
  .home-hero__blurbs {
    display: grid;
    margin: var(--space-xs) 0 0;
    padding: 0;
    border-block-start: var(--rule-width) solid var(--color-rule-strong);
    list-style: none;
  }

  .home-hero__blurb {
    display: grid;
    gap: var(--space-3xs);
    padding-block: var(--space-sm);
    border-block-end: var(--rule-hairline);
    font-size: var(--text-ui-sm);
    line-height: 1.5;

    & p {
      margin: 0;
      color: var(--color-ink-soft);
    }

    & strong {
      color: var(--color-ink);
    }
  }

  /* The strip of three indexes under the masthead: three columns on the
     paper, a hairline closing them (tasks/redesign, D7). Below 1024px three
     would be too narrow for a level and a trend line side by side, so the
     strip scrolls sideways instead. Wider, each column stops at 26rem and
     the three sit at the left, rather than drifting apart across a wide
     window. */
  .index-cards {
    display: flex;
    gap: var(--space-xl);
    margin-inline: calc(-1 * var(--gutter));
    padding: var(--space-sm) var(--gutter);
    border-block-end: var(--rule-hairline);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    scrollbar-width: none;

    & > .index-card {
      flex: none;
      inline-size: 19rem;
      scroll-snap-align: start;
    }

    @media (width >= 1024px) {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 26rem));
      justify-content: start;
      gap: var(--space-2xl);
      margin-inline: 0;
      padding-inline: 0;
      overflow: visible;

      & > .index-card {
        inline-size: auto;
      }
    }
  }

  .index-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);

    /* The placeholder's block, before the frame lands. */
    & > .skeleton {
      flex: 1;
    }
  }

  .index-card__text {
    display: grid;
    flex: none;
    gap: var(--space-3xs);
  }

  .index-card__header {
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
  }

  .index-card__name {
    margin-block-end: 0;
    font-size: var(--text-caps);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-caps);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
  }

  .index-card__link {
    color: var(--color-ink);
    text-decoration: none;

    &:hover {
      text-decoration: underline;
    }
  }

  .index-card__symbol {
    color: var(--color-ink-muted);
    font-size: var(--text-caps);
    letter-spacing: var(--tracking-caps);
  }

  .index-card__level {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2xs) var(--space-sm);
  }

  .index-card__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-3xs) var(--space-md);
    color: var(--color-ink-muted);
    font-size: var(--text-meta);

    & .figure {
      font-size: inherit;
    }

    & .index-card__future {
      color: var(--color-ink);
    }
  }

  .index-card__change {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-2xs);
    font-size: var(--text-ui-sm);

    & .figure {
      font-size: inherit;
      font-weight: var(--weight-semibold);
    }
  }

  .index-card__trend {
    flex: 1 1 8rem;
    min-inline-size: 4rem;
    max-inline-size: 9rem;
    block-size: 2.5rem;
  }

  /* The path is drawn in a fixed box and stretched to fit; the stroke keeps
     its width however far it is stretched. In ink, like a line in a
     printed chart, whichever way the year has gone. */
  .trend-line {
    display: block;
    overflow: visible;
  }

  .trend-line__line {
    fill: none;
    stroke: var(--color-ink);
    stroke-width: 1.25;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
  }

  /* Market map */

  .market-map {
    /* The chart's height, which its placeholder reserves too: 585px from
       768px, what the treemap has always been drawn at. */
    --market-map-height: 22rem;

    @media (width >= 768px) {
      --market-map-height: 36.5625rem;
    }
  }

  .market-map__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-xs) var(--space-xl);
    margin-block-end: var(--space-xs);
  }

  .market-map__title {
    margin-block-end: 0;
  }

  .market-map__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs) var(--space-lg);
  }

  .market-map__chart {
    block-size: var(--market-map-height);
  }

  .ramp-legend {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
  }

  .ramp-legend__bound {
    color: var(--color-ink-subtle);
    font-size: var(--text-meta-xs);
    font-variant-numeric: tabular-nums lining-nums;
  }

  .ramp-legend__steps {
    display: flex;
    flex: 1;
    gap: 1px;
  }

  .ramp-legend__step {
    flex: 1;
    min-inline-size: 1rem;
    block-size: 0.75rem;
    background-color: var(--swatch);
  }

  /* News: the front page sits on the page's column, a step below the map. */
  .home__news {
    margin-block-start: var(--space-md);
  }
}
