/* Site: the public page layout (header, main, footer). Partial API: website/templates/components/site.html.
   Contract: docs/ui/CONVENTIONS.md. */
@layer components {
  /* The header logo has a file per theme. Inherit visibility from the nearest theme container
     so split style-guide demos work independently of the page theme. The footer is always dark. */
  :root, [data-theme="light"] {
    --site-logo-light-display: block;
    --site-logo-dark-display: none;
  }
  [data-theme="dark"] {
    --site-logo-light-display: none;
    --site-logo-dark-display: block;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
      --site-logo-light-display: none;
      --site-logo-dark-display: block;
    }
  }
  .site {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: var(--color-bg);
  }
  /* Header and footer share one centred column: --site-max less --site-inset each side (1164px of content). */
  .site-bar {
    width: 100%;
    max-width: var(--site-max);
    margin-inline: auto;
    padding-inline: var(--site-inset);
  }
  .site-header {
    > .site-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); height: 72px; }
  }
  .site-logo {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    &:hover { text-decoration: none; }
    > img { width: auto; height: 28px; object-fit: contain; }
  }
  /* Cap the header logo at 32px; the footer remains 28px tall. */
  .site-header .site-logo > img { height: var(--space-8); max-height: var(--space-8); }
  .site-header .site-logo > [data-logo="light"] { display: var(--site-logo-light-display); }
  .site-header .site-logo > [data-logo="dark"] { display: var(--site-logo-dark-display); }
  .site-actions { display: flex; align-items: center; gap: var(--space-2); }

  /* Reading width for long text, as on most legal and docs pages. */
  .site-main {
    flex: 1;
    width: 100%;
    max-width: calc(680px + 2 * var(--space-6));
    margin-inline: auto;
    padding: var(--space-12) var(--space-6) 0;
  }

  .site-footer {
    /* Both footer surfaces are dark, including on a light page. */
    --color-text: #fff;
    --color-text-muted: #eee;
    margin-top: 250px; /* the only space between the content and the footer */
    padding-block: 74px var(--space-10);
    background: light-dark(#251f2b, #000);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    line-height: var(--line-sm);
    ul { display: grid; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
    a:not(.site-logo) { color: var(--color-text-muted); &:hover { color: var(--color-text); } }
    section[aria-label="Partners"] {
      margin-top: calc(var(--space-10) + var(--space-4));
      > .site-footer-title { font-size: var(--text-xs); font-weight: var(--weight-regular); color: var(--color-text-muted); }
      > div { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-6); }
      img { object-fit: contain; }
    }
  }
  .site-footer-grid { display: grid; grid-template-columns: 3fr 1fr; gap: var(--space-10); }
  .site-footer-title {
    margin-bottom: var(--space-4);
    color: var(--color-text);
    font-size: var(--text-sm);
    line-height: var(--line-sm);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }
  .site-copyright {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: calc(var(--space-10) + var(--space-4));
    padding-top: var(--space-6);
    border-top: 1px solid #333;
    > span:last-child { margin-inline-start: auto; }
  }

  @media (max-width: 520px) {
    .site-bar { padding-inline: var(--space-4); }
    .site-main { padding: var(--space-8) var(--space-4) 0; }
    .site-footer { margin-top: 150px; }
    .site-footer-grid { grid-template-columns: 1fr; }
  }
  @media (max-width: 460px) {
    .site-header > .site-bar { height: auto; min-height: 72px; flex-wrap: wrap; padding-block: var(--space-3); }
    .site-copyright > span:last-child { margin-inline-start: 0; }
  }
}
