@layer base {
  /* The colophon closes a public page, where the app has its bottom bar. */
  body.public #footer {
    color: var(--color-ink-medium);
    font-size: var(--text-small);
    padding: 2rem 1rem 1.5rem;
    text-align: center;
  }
}

@layer components {
  /* The app's top bar, as tall, with the mark alone in it. On paper it takes no room. */
  @media screen {
    body.public .header:has(> .site-header) {
      --top-bar-padding: 0.5rem; /* 8px */

      min-block-size: calc(var(--top-bar-height) + var(--custom-safe-inset-top));
      padding-block: var(--custom-safe-inset-top) 0;
      padding-inline:
        calc(var(--top-bar-padding) + var(--custom-safe-inset-left))
        calc(var(--top-bar-padding) + var(--custom-safe-inset-right));

      @media (width >= 800px) {
        --top-bar-padding: 0.42rem;
      }
    }
  }

  /* The account's logo, or the app's mark where it has none, as tall as the app's, then the account's name in the wordmark's type, cut short where the bar ends. */
  .site-header__brand {
    max-inline-size: 100%;

    :is(.site-header__logo, .site-header__account-logo) {
      block-size: var(--control-size);
      flex: none;
    }

    .site-header__account-logo {
      flex-shrink: 1;
    }
  }

  .site-header__account-name {
    color: var(--color-ink);
    font-size: var(--text-section);
    font-weight: 800;
    letter-spacing: -0.02em;
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The sheet ends where it ends, and the colophon reads on the ground under it. */
  .public .sheet {
    border-image-outset: 0;
  }

  /* A page that is one card, to sign in or to say who you are: the sheet steps back and the card stands on the ground, under the bar. */
  .public .sheet:has(> #main > .panel--centered) {
    border-image: none;
    box-shadow: none;
    inline-size: 100%;

    > #main {
      margin-block-end: auto;
    }
  }

  /* Over a banded card the page's name is centred on the ground, and a note under the card closes the page. */
  .public #main:has(> .panel--banded) {
    > .page-header {
      max-inline-size: 36rem;
      text-align: center;

      .page-header__heading {
        justify-content: center;
      }
    }

    > .panel--banded + p {
      margin-block-start: var(--block-space);
      max-inline-size: 30rem;
      text-align: center;
    }
  }

  /* Over that card the mark is centred across the bar, and so is the app's own, which names no account. */
  .public:has(#main > .panel--centered) .site-header__brand,
  .public .site-header__brand:only-child:not(:has(.site-header__account-name)) {
    grid-column: 1 / -1;
    justify-self: center;
  }
}
