/* styles/editorial-index.css
 * Editorial heroes, author, previously and end rule. The index pieces (featured post, filter,
 * post list item, pagination) live in editorial-index-list.css, loaded right after this file;
 * the article body lives in editorial.css and editorial-blocks.css. Fern heroes take
 * .surface--inverse-textured from surfaces.css; inside them type switches to white and mist.
 * Display sizes that would overflow between frame widths (index title, featured title and
 * figures) scale with the viewport and stop at the frame value, so no title breaks inside a
 * word and none wraps where the frame has one line. */
@layer editorial {
  .post-hero,
  .editorial-hero,
  .index-hero,
  .featured-post,
  .post-list-item {
    --ed-hero-title: 40px;
    --ed-hero-title-ls: -0.02em;
    --ed-hero-number-ls: -0.01em;
    --ed-hero-pad: 56px 24px 48px;
    --ed-editorial-title: 52px;
    --ed-editorial-title-ls: -0.02em;
    --ed-index-title: 76px;
    --ed-featured-title: 40px;
    --ed-featured-title-ls: -0.02em;
    --ed-featured-fig: 36px;
    --ed-featured-fig-lh: 1.05;
    --ed-featured-fig-ls: -0.015em;
    --ed-list-title: 20px;
  }

  @media (min-width: 900px) {
    .post-hero,
    .editorial-hero,
    .index-hero,
    .featured-post,
    .post-list-item {
      /* Scales below 1440 so a long single word ("Near-Decomposability") fits the hero at 900. */
      --ed-hero-title: min(88px, 6.12vw);
      --ed-hero-title-ls: -0.025em;
      --ed-hero-pad: 96px 80px 64px;
      --ed-editorial-title: 120px;
      --ed-editorial-title-ls: -0.03em;
      /* "Context Clues" sets 5.52em wide: one line from 900px, 176px from 1132px. */
      --ed-index-title: min(176px, calc((100vw - 160px) / 5.53));
      --ed-featured-title: clamp(52px, 6.12vw, 88px);
      --ed-featured-title-ls: -0.025em;
      --ed-featured-fig: clamp(40px, 4.45vw, 64px);
      --ed-featured-fig-lh: 0.95;
      --ed-featured-fig-ls: -0.025em;
      --ed-list-title: 24px;
    }
  }

  @media (min-width: 1680px) {
    .post-hero,
    .editorial-hero,
    .index-hero,
    .featured-post,
    .post-list-item {
      --ed-hero-title: 120px;
      --ed-hero-title-ls: -0.03em;
      --ed-hero-number-ls: -0.02em;
      --ed-hero-pad: 115px 120px 80px;
      --ed-editorial-title: 168px;
      --ed-index-title: min(300px, calc((100vw - 240px) / 5.53));
      --ed-list-title: 28px;
      --ed-featured-title: min(120px, 6.25vw);
      --ed-featured-title-ls: -0.03em;
      --ed-featured-fig: min(96px, 5vw);
      --ed-featured-fig-ls: -0.03em;
    }
  }

  /* Post hero: light, no rule below (the frames' hero stroke has no width). Margin track
     carries the issue number and category. */
  .post-hero {
    display: grid;
    gap: var(--space-32);
    padding: var(--ed-hero-pad);
    background: var(--white);
    color: var(--ink);
  }

  .post-hero__margin {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    padding-top: var(--space-14);
    font-size: 14px;
    color: var(--ink-2);
  }

  .post-hero__number {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: var(--ed-hero-number-ls);
    color: var(--fern);
  }

  .post-hero__main {
    display: flex;
    flex-direction: column;
    gap: var(--space-24);
    min-width: 0;
  }

  .post-hero__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--ed-hero-title);
    font-weight: 600;
    line-height: 0.95;
    letter-spacing: var(--ed-hero-title-ls);
    color: var(--fern);
    text-wrap: balance;
  }

  .post-hero__deck {
    margin: var(--space-24) 0 0;
    max-width: 900px;
    font-family: var(--font-display);
    font-size: 18px;
    font-style: italic;
    line-height: 1.5;
    color: var(--ink-2);
  }

  .post-hero__byline {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4) var(--space-16);
    padding-top: var(--space-8);
    font-size: 15px;
    color: var(--ink-2);
  }

  .post-hero__byline strong {
    font-weight: 400;
    color: var(--ink);
  }

  @media (min-width: 900px) {
    .post-hero {
      grid-template-columns: var(--rail-margin) minmax(0, 1fr);
      column-gap: var(--rail-gap);
      align-content: start;
      padding-inline: var(--page-gutter);
    }

    .post-hero__number {
      font-size: 24px;
    }

    .post-hero__deck {
      font-size: 20px;
    }
  }

  @media (min-width: 1680px) {
    .post-hero {
      padding-inline: max(var(--page-gutter), calc((100% - var(--container-max)) / 2));
    }

    .post-hero__number {
      font-size: 40px;
    }

    .post-hero__deck {
      max-width: 1100px;
    }
  }

  /* Editorial hero: fern, title over a foot with meta line and deck */
  .editorial-hero {
    display: flex;
    flex-direction: column;
    gap: var(--space-48);
    padding: 88px var(--space-16) 72px;
  }

  .editorial-hero__title {
    margin: 0;
    max-width: 14ch;
    font-family: var(--font-display);
    font-size: var(--ed-editorial-title);
    font-weight: 600;
    line-height: 0.95;
    letter-spacing: var(--ed-editorial-title-ls);
    color: var(--white);
    text-wrap: balance;
  }

  .editorial-hero__foot {
    display: flex;
    flex-direction: column;
    gap: var(--space-24);
  }

  .editorial-hero__deck {
    margin: 0;
    max-width: 560px;
    font-size: 18px;
    line-height: 1.5;
    color: var(--white-90);
  }

  @media (min-width: 900px) {
    .editorial-hero {
      gap: var(--space-80);
      padding: 144px var(--page-gutter) 120px;
    }

    .editorial-hero__title {
      max-width: 1120px;
    }

    .editorial-hero__foot {
      flex-direction: row;
      justify-content: space-between;
      align-items: flex-end;
      width: 100%;
      max-width: var(--container-max);
      margin-inline: auto;
    }

    .editorial-hero__deck {
      font-size: 20px;
    }
  }

  @media (min-width: 1680px) {
    .editorial-hero {
      gap: 120px;
      padding-block: 173px 144px;
    }

    .editorial-hero__title {
      max-width: 1560px;
    }

    .editorial-hero__foot {
      padding-top: var(--space-32);
      border-top: 1px solid var(--white-20);
    }

    .editorial-hero__deck {
      max-width: 620px;
    }
  }

  /* Index hero: publication name, deck, running line with subscribe */
  .index-hero {
    display: flex;
    flex-direction: column;
    gap: var(--space-20);
    padding: 56px var(--page-gutter) 0;
  }

  .index-hero__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--ed-index-title);
    font-weight: 600;
    line-height: 0.95;
    letter-spacing: -0.035em;
    color: var(--white);
  }

  .index-hero__deck {
    margin: 0;
    max-width: 560px;
    font-family: var(--font-body);
    font-size: 18px;
    font-style: italic;
    line-height: 1.5;
    color: var(--white-85);
  }

  .index-hero__foot {
    padding-bottom: var(--space-32);
  }

  .index-hero__running {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-16);
    padding-block: var(--space-20);
    border-block: 1px solid var(--white-25);
    font-size: 15px;
    color: var(--white-70);
  }

  /* Running-line link (RSS): link chip on fern per the actions board, background only:
     25% white on hover, solid white with fern text when pressed, 120ms. */
  .index-hero__running a:not([class]) {
    padding: 3px 6px;
    margin: -3px -6px;
    border-radius: var(--radius-sm);
    color: inherit;
    text-decoration: none;
    transition: background-color var(--dur-fast), color var(--dur-fast);
  }

  .index-hero__running a:not([class]):hover {
    background: var(--white-25);
  }

  .index-hero__running a:not([class]):active {
    background: var(--white);
    color: var(--fern);
  }

  /* Running-line signup: a boxed 280px field and an arrow link; the label is .sr-only. */
  .index-hero__running .inline-form {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-20);
  }

  .index-hero__running .inline-form__input {
    flex: none;
    width: 280px;
    max-width: 100%;
    min-height: 42px;
    padding: 0 var(--space-14);
    border: 1px solid var(--white-40);
    border-radius: 3px;
    font-size: 15px;
  }

  .index-hero__running .inline-form > button:not([class]) {
    min-height: 42px;
    padding: 0;
    font-size: 15px;
  }

  @media (min-width: 900px) {
    .index-hero {
      padding-top: 96px;
    }

    .index-hero__deck {
      font-size: 20px;
    }

    .index-hero__foot {
      padding-bottom: var(--space-48);
    }

    .index-hero__running {
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
      min-height: 84px;
    }

    .index-hero__running .inline-form {
      flex-direction: row;
      align-items: center;
    }
  }

  @media (min-width: 1680px) {
    .index-hero {
      padding-top: 115px;
    }

    .index-hero__deck {
      max-width: 760px;
    }
  }

  .index-hero__title,
  .index-hero__foot,
  .index-hero__running {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
  }

  /* Author, previously, end rule */
  .post-author,
  .post-nav {
    display: grid;
    gap: var(--space-10);
    padding-top: var(--space-24);
  }

  .post-author {
    padding-top: var(--space-8);
  }

  .post-author__label,
  .post-nav__label {
    font-family: var(--font-display);
    font-size: 15px;
    font-style: italic;
    line-height: 1.2;
    color: var(--ink-2);
  }

  .post-author__bio {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
    font-family: var(--font-display);
    font-size: 17px;
    line-height: 1.55;
  }

  .post-author__bio p {
    margin: 0;
  }

  .post-nav__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    padding-top: var(--space-20);
    border-top: 1px solid var(--ink-16);
  }

  .post-nav__number {
    font-size: 14px;
    line-height: 1.2;
    color: var(--ink-2);
  }

  .prose .post-nav .post-nav__title {
    display: block;
    padding-top: 0;
    counter-increment: none;
  }

  .prose .post-nav .post-nav__title::before {
    content: none;
  }

  .post-nav__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 23px;
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: -0.01em;
  }

  .post-nav__title a {
    color: var(--fern);
    text-decoration: none;
  }

  .post-nav__title a:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }

  .post-nav__deck {
    margin: 0;
    font-family: var(--font-display);
    font-size: 17px;
    font-style: italic;
    line-height: 1.5;
    color: var(--ink-2);
  }

  .prose-end {
    width: min(var(--ed-end-rule, 900px), 100%);
    height: 2px;
    margin: 0 auto;
    border: 0;
    background: var(--ink);
  }

  @media (min-width: 900px) {
    .article--rail .post-author,
    .article--rail .post-nav {
      grid-template-columns: subgrid;
      grid-column: 1 / -1;
      column-gap: var(--rail-gap);
    }

    .article--rail > .prose-end {
      grid-column: 1 / 3;
      width: 100%;
      margin: 0;
    }

    .post-author__label {
      grid-column: 1;
      padding-top: 3px;
    }

    .post-author__bio {
      grid-column: 2;
      font-size: var(--ed-size);
      line-height: 1.6;
    }

    .post-nav__label {
      grid-column: 1;
      padding-top: 23px;
    }

    .post-nav__body {
      grid-column: 2;
    }

    .post-nav__title {
      font-size: 32px;
      letter-spacing: -0.015em;
    }

    .post-nav__deck {
      font-size: var(--ed-size);
      line-height: 1.6;
    }
  }

  /* Author signup as a link (NEWSLETTER_URL): the lead-in, then the fern arrow link; one
     row from D, stacked on M. */
  .post-author__signup {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-12);
    padding-top: var(--space-16);
  }

  @media (min-width: 900px) {
    .post-author__signup {
      flex-direction: row;
      align-items: center;
      padding-top: var(--space-6);
      font-size: var(--ed-lead);
      line-height: 1.5;
    }
  }

  /* Author signup sentence (the forms.css inline form): on M it stacks lead, field and
     submit with the board's 16px lead-in and 14px gaps, and the lead drops to 17px. From D
     it is one row 6px under the bio; the field's 44px target rises 14px above the 30px
     line, so the row is pulled up by that much. */
  .post-author .inline-form {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding-top: var(--space-16);
  }

  .post-author .inline-form > label {
    font-size: 17px;
    line-height: normal;
  }

  .post-author .inline-form__input {
    flex: none;
    width: 100%;
  }

  @media (min-width: 900px) {
    .post-author .inline-form {
      flex-direction: row;
      align-items: flex-end;
      gap: var(--space-12);
      margin-top: -8px;
      padding-top: 0;
    }

    .post-author .inline-form > label {
      font-size: 20px;
      line-height: 1.5;
    }

    .post-author .inline-form__input {
      flex: 0 1 240px;
    }
  }

  @media (min-width: 1680px) {
    .post-nav__title {
      font-size: 40px;
      letter-spacing: -0.02em;
    }

    .prose-end {
      --ed-end-rule: 1140px;
    }
  }
}
