/* Dispatch: palette tokens and the variants that differ from the shared
   components. */
@layer presets {
  body[data-journal-presentation="dispatch"],
  .journal-surface[data-journal-presentation="dispatch"] {
    color-scheme: light;
    --color-canvas: #ffffff;
    --color-surface: #ffffff;
    --color-text: #252525;
    --color-text-muted: #69727a;
    --color-border: #dddddd;
    --color-border-strong: #cccccc;
    /* Reference blue is reserved for large headlines. The darker application
       accent retains 4.5:1 contrast for normal-sized links and controls. */
    --color-accent: #0075ad;
    --color-accent-strong: #006b9f;
    --color-focus: #006b9f;
    --color-selection: #ccecff;
    --font-reading: "Source Sans 3", Arial, Helvetica, sans-serif;
    --font-interface: Arial, Helvetica, sans-serif;
    --journal-canvas: #ffffff;
    --journal-width-feed: 45rem;
    --journal-width-reading: 45rem;
    --width-wide: 45rem;
    --width-reading: 45rem;
    --journal-meta-letter-spacing: 0.035em;
    --journal-meta-transform: uppercase;
    --journal-post-title-color: #0088cc;
    --journal-post-title-hover: #005580;
    --journal-featured-image-margin: 1.75rem 0 1rem;
    --journal-featured-caption-color: #69727a;
    /* Reference scale: blue `.title` headlines at 32px, section h2 at 28px. */
    --text-page-title: 2rem;
    --text-section-title: 1.75rem;
  }
}

/* Presets describe component variants here so they remain below the permanent
   component layer in the architecture while outranking its base selectors. */
@layer components {
  body[data-journal-presentation="dispatch"] {
    background: #ffffff;
    font-family: var(--font-interface);
  }

  /* The reference sets every content heading in regular-weight Source Sans
     on a 1.48 line box; only page and post titles take the blue headline.
     Sizes stay with the shared title tokens set above; `:where` keeps this
     below the title rules that follow. */
  body[data-journal-presentation="dispatch"] :where(.site-main) :is(h1, h2, h3, h4) {
    color: #333333;
    font-family: var(--font-reading);
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.48;
  }

  body[data-journal-presentation="dispatch"]
    :is(
      .page-header__title,
      .feed__title,
      .personal-header__title,
      .discovery-header__title,
      .identity-roster__title,
      .community-management-header__title,
      .community-profile__name,
      .journal-profile__name
    ) {
    max-width: none;
    color: var(--journal-post-title-color);
    font-size: var(--text-page-title);
    line-height: 1.695;
  }

  /* List links sized like section headings share their regular weight.
     `:not(.error-layout)` matches the component rule's specificity, which
     loads later and would otherwise keep its heavier weight. */
  body[data-journal-presentation="dispatch"]:not(.error-layout)
    :is(.tag-index__link, .admin-dashboard__link) {
    font-weight: 400;
  }

  body[data-journal-presentation="dispatch"] .site-header {
    border-color: #dddddd;
    background: #ffffff;
    font-family: Arial, Helvetica, sans-serif;
  }

  body[data-journal-presentation="dispatch"] .site-header__inner {
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    width: min(100%, 45rem);
    min-height: 5rem;
    padding: 0;
  }

  body[data-journal-presentation="dispatch"] .site-header__brand {
    justify-content: center;
    min-width: 1.5rem;
    min-height: 5rem;
    padding: 0;
    border: 0;
    color: #69727a;
    font-family: Arial, Helvetica, sans-serif;
  }

  /* Reference brand treatment: 16px, heaviest available weight, uppercase,
     #565656 (7.4:1 on white), clearly above the 12px navigation. */
  body[data-journal-presentation="dispatch"] .site-header__brand-mark {
    align-self: center;
    color: #565656;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
  }

  body[data-journal-presentation="dispatch"] .site-nav {
    margin-inline-start: auto;
  }

  body[data-journal-presentation="dispatch"] .site-nav__primary {
    justify-content: flex-end;
    gap: 1.25rem;
  }

  body[data-journal-presentation="dispatch"] .site-nav__primary > li {
    border: 0;
  }

  body[data-journal-presentation="dispatch"] .site-nav a,
  body[data-journal-presentation="dispatch"] .site-nav summary,
  body[data-journal-presentation="dispatch"] .site-nav button {
    min-height: 5rem;
    padding: 0;
    color: #69727a;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
  }

  body[data-journal-presentation="dispatch"] .site-nav a:hover,
  body[data-journal-presentation="dispatch"] .site-nav summary:hover,
  body[data-journal-presentation="dispatch"] .site-nav button:hover {
    background: #f7f7f7;
    color: #0075ad;
  }

  body[data-journal-presentation="dispatch"] .site-nav__new-post,
  body[data-journal-presentation="dispatch"] .site-nav__sign-up {
    border-bottom: 0;
  }

  body[data-journal-presentation="dispatch"] .site-nav__secondary {
    top: calc(100% + 1px);
    border-color: #cccccc;
    background: #ffffff;
    box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 10%);
  }

  body[data-journal-presentation="dispatch"] .site-nav__secondary a,
  body[data-journal-presentation="dispatch"] .site-nav__secondary button {
    min-height: 2.5rem;
    padding: var(--space-2) var(--space-3);
  }

  /* Arial lifts digit ink further than the Journal interface face. */
  body[data-journal-presentation="dispatch"] .site-header__unread-count {
    --nav-badge-nudge: 0.3em;
  }

  /* Dispatch keeps the More text at every width: with the bell icon, its row
     fits on one line down to 320px, so the shared menu symbol is not used. */
  @media (max-width: 389px) {
    body[data-journal-presentation="dispatch"] .site-nav__more-label {
      position: static;
      width: auto;
      height: auto;
      margin: 0;
      overflow: visible;
      clip: auto;
    }

    body[data-journal-presentation="dispatch"] .site-nav__more > summary {
      min-width: 0;
    }

    body[data-journal-presentation="dispatch"] .site-nav__menu-icon {
      display: none;
    }

    body[data-journal-presentation="dispatch"] .site-nav__more-indicator {
      display: block;
    }
  }

  .journal-surface[data-journal-presentation="dispatch"] {
    width: min(100%, 45rem);
    padding-block: 3rem 6rem;
    background: #ffffff;
    color: #252525;
    font-family: Arial, Helvetica, sans-serif;
  }

  .journal-surface[data-journal-presentation="dispatch"] a {
    color: #0075ad;
  }

  .journal-surface[data-journal-presentation="dispatch"] .journal-profile {
    grid-template-columns: 4.5rem minmax(0, 1fr);
    gap: 1.5rem;
    width: 100%;
    padding-bottom: 2.5rem;
    border-color: #dddddd;
  }

  .journal-surface[data-journal-presentation="dispatch"]
    .journal-profile__userpic,
  .journal-surface[data-journal-presentation="dispatch"]
    .journal-profile__userpic .userpic-image,
  .journal-surface[data-journal-presentation="dispatch"]
    .journal-profile__userpic .userpic-placeholder {
    width: 4.5rem;
    height: 4.5rem;
  }

  .journal-surface[data-journal-presentation="dispatch"]
    .journal-profile__userpic .userpic-placeholder {
    font-size: 2rem;
  }

  .journal-surface[data-journal-presentation="dispatch"]
    .journal-profile__handle,
  .journal-surface[data-journal-presentation="dispatch"]
    .journal-profile__meta,
  body[data-journal-presentation="dispatch"] .post-card__meta,
  body[data-journal-presentation="dispatch"] .post-reading__byline,
  body[data-journal-presentation="dispatch"] .post-card__footer {
    color: #69727a;
    font-size: 0.72rem;
    letter-spacing: 0.035em;
    text-transform: uppercase;
  }

  .journal-surface[data-journal-presentation="dispatch"]
    .journal-profile__handle {
    margin-top: 0.5rem;
  }

  .journal-surface[data-journal-presentation="dispatch"]
    .journal-profile__bio {
    margin-top: 1rem;
    color: #333333;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1rem;
    line-height: 1.55;
  }

  .journal-surface[data-journal-presentation="dispatch"]
    .journal-profile__meta {
    margin-top: 1rem;
  }

  .journal-surface[data-journal-presentation="dispatch"] .journal-posts {
    width: 100%;
    margin-top: 4.5rem;
  }

  .journal-surface[data-journal-presentation="dispatch"]
    .journal-posts__title {
    margin: 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #dddddd;
    color: #69727a;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    line-height: 1.55;
    text-transform: uppercase;
  }

  /* One post-card anatomy wherever a card renders under Dispatch: blog,
     Feed, tag and community lists. Title, then "time by author", excerpt,
     and footer; no userpic, as in the reference. Listing surfaces are
     denser than the blog, and only the blog shows featured images. */
  /* As in the reference, each card closes with its footer rule, so it opens
     without a top rule of its own. */
  body[data-journal-presentation="dispatch"] .post-card {
    --card-title-size: 2rem;

    display: flex;
    flex-direction: column;
    padding: 2.5rem 0 2.25rem;
    border-top: 0;
  }

  .journal-surface[data-journal-presentation="dispatch"] .post-card {
    padding: 3.75rem 0 3.25rem;
  }

  body[data-journal-presentation="dispatch"] .post-card__title {
    max-width: none;
    margin: 0;
    font-family: "Source Sans 3", Arial, Helvetica, sans-serif;
    font-size: var(--card-title-size);
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.695;
  }

  /* A real underline rather than an inline border: a border boxes each
     wrapped line fragment and reads as a rule between lines. `:not(.error-layout)`
     matches the component rule's specificity, which loads later and would
     otherwise keep `text-decoration: none`. */
  body[data-journal-presentation="dispatch"]:not(.error-layout)
    .post-card__title
    a {
    color: #0088cc;
    text-decoration-line: underline;
    text-decoration-color: #f5f5f5;
    text-decoration-thickness: 3px;
    text-underline-offset: 0.2em;
  }

  body[data-journal-presentation="dispatch"]:not(.error-layout)
    .post-card__title
    :is(a:hover, a:focus-visible) {
    color: #005580;
    text-decoration-color: #dddddd;
  }

  body[data-journal-presentation="dispatch"] .post-card__header {
    gap: 0;
    margin: 0.6rem 0 0;
  }

  body[data-journal-presentation="dispatch"]
    :is(.post-card__userpic, .post-reading__userpic, .byline-separator) {
    display: none;
  }

  body[data-journal-presentation="dispatch"]
    :is(.post-card__timestamp, .post-reading__timestamp) {
    order: 1;
    color: inherit;
    font-size: inherit;
  }

  body[data-journal-presentation="dispatch"] .byline-connector {
    display: inline;
    order: 2;
  }

  body[data-journal-presentation="dispatch"]
    :is(.post-card__author, .post-reading__author-link) {
    order: 3;
  }

  body[data-journal-presentation="dispatch"] .post-edited-indicator {
    order: 4;
  }

  body[data-journal-presentation="dispatch"] .post-featured-image__image {
    aspect-ratio: 16 / 9;
  }

  body[data-journal-presentation="dispatch"] .post-featured-image__caption {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.72rem;
  }

  /* Dispatch headings are regular weight, so size alone carries the body
     heading levels, the deepest included; the card title is twice the text
     size, which leaves room for every level to stand clear of the text. */
  body[data-journal-presentation="dispatch"] .post-card__excerpt {
    --card-h3-share: 0.5;
    --card-h4-share: 0.35;
    --card-h5-share: 0.22;
    --card-h6-share: 0.1;

    margin: 0;
    color: #333333;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.96rem;
    line-height: 1.55;
  }

  body[data-journal-presentation="dispatch"] .post-card__footer {
    margin-top: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #dddddd;
  }

  .journal-surface[data-journal-presentation="dispatch"].post-reading-page {
    padding-top: 4.5rem;
  }

  body[data-journal-presentation="dispatch"] .post-reading {
    width: 100%;
  }

  body[data-journal-presentation="dispatch"] .post-reading__header {
    display: flex;
    flex-direction: column;
    margin-bottom: 2.5rem;
  }

  body[data-journal-presentation="dispatch"] .post-reading__title {
    max-width: none;
    color: #0088cc;
    font-family: "Source Sans 3", Arial, Helvetica, sans-serif;
    font-size: 2rem;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.695;
  }

  body[data-journal-presentation="dispatch"] .post-reading__author {
    margin: 0.75rem 0 0;
  }

  body[data-journal-presentation="dispatch"] .post-reading__body {
    color: #333333;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1rem;
    line-height: 1.55;
  }

  body[data-journal-presentation="dispatch"]
    .post-body
    :is(h2, h3, h4) {
    color: #333333;
    font-family: var(--font-reading);
    font-weight: 400;
    letter-spacing: 0;
  }

  /* Card bodies demote headings as far as h6 (post-cut.md §6.2). These
     match the headings above, regular weight included, so no deeper level
     looks heavier than a higher one. */
  body[data-journal-presentation="dispatch"]
    .post-card__excerpt
    :is(h5, h6) {
    color: #333333;
    font-family: var(--font-reading);
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.48;
  }

  body[data-journal-presentation="dispatch"] .comments-section {
    border-color: #dddddd;
  }

  /* The Dispatch footer already closes the card with a rule, so the expanded
     conversation continues beneath it without a second divider. */
  body[data-journal-presentation="dispatch"] .post-card__conversation {
    margin-top: 0;
    border-top: 0;
  }

  body[data-journal-presentation="dispatch"] .post-card-conversation__title {
    color: #333333;
    font-family: "Source Sans 3", Arial, Helvetica, sans-serif;
    font-weight: 600;
    letter-spacing: 0;
  }

  @media (max-width: 40rem) {
    .appearance-choice {
      grid-template-columns: auto minmax(0, 1fr);
    }

    .appearance-choice__preview {
      display: none;
    }

    body[data-journal-presentation="dispatch"] .site-header__inner {
      gap: 0.75rem;
      min-height: 3.5rem;
      padding-inline: 1rem;
    }

    body[data-journal-presentation="dispatch"] .site-header__brand,
    body[data-journal-presentation="dispatch"] .site-nav a,
    body[data-journal-presentation="dispatch"] .site-nav summary,
    body[data-journal-presentation="dispatch"] .site-nav button {
      min-height: 3.5rem;
      padding: 0;
      font-size: 0.7rem;
    }

    body[data-journal-presentation="dispatch"] .site-nav__secondary a,
    body[data-journal-presentation="dispatch"] .site-nav__secondary button {
      min-height: 2.5rem;
      padding: var(--space-2) var(--space-3);
    }

    body[data-journal-presentation="dispatch"] .site-nav__primary {
      flex-wrap: nowrap;
      gap: 0.75rem;
    }

    .journal-surface[data-journal-presentation="dispatch"] {
      padding-block: 2rem 4rem;
    }

    .journal-surface[data-journal-presentation="dispatch"] .journal-profile {
      grid-template-columns: 3.5rem minmax(0, 1fr);
      gap: 1rem;
    }

    .journal-surface[data-journal-presentation="dispatch"]
      .journal-profile__tools {
      justify-content: center;
      text-align: center;
    }

    .journal-surface[data-journal-presentation="dispatch"]
      .journal-profile__userpic,
    .journal-surface[data-journal-presentation="dispatch"]
      .journal-profile__userpic .userpic-image,
    .journal-surface[data-journal-presentation="dispatch"]
      .journal-profile__userpic .userpic-placeholder {
      width: 3.5rem;
      height: 3.5rem;
    }
  }
}
