@layer base {
html {
  font-family: var(--font-body);
  font-size: 100%;
  background: var(--c-ground);
  color: var(--c-ink);
  accent-color: var(--c-pine);
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  /* An automatic column is as wide as the widest thing that will not wrap, and a long address in the header's chip
     made that wider than a phone. The column is the page's width and nothing inside it may say otherwise. */
  grid-template-columns: minmax(0, 1fr);
  /* The inline-size container a full-bleed band measures itself against (100cqi is the viewport less its scrollbar). */
  container-type: inline-size;
  font-size: var(--text-m);
  line-height: var(--leading-body);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: var(--leading-tight);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 {
  font-size: var(--text-2xl);
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-l);
}

p + p,
p + h2,
p + h3,
ul + p,
h1 + p,
h2 + p,
h3 + p {
  margin-block-start: var(--space-4);
}

a {
  color: var(--c-pine);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.15em;

  &:hover {
    color: var(--c-pine-hover);
  }
}

code {
  font-family: var(--font-data);
  font-size: 0.9em;
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-s);
}

/* A heading the script moves focus to, so a screen reader starts there, is not a control and draws no ring. */
:is(h1, h2)[tabindex="-1"]:focus-visible {
  outline: none;
}

::selection {
  background: var(--c-lantern-tint);
}

/* The header: paper with a slate rule in daylight, the roofline in the dark, with the mark and the wordmark on it */
.site-header {
  background: light-dark(var(--c-paper), var(--c-roof));
  color: light-dark(var(--c-ink), var(--c-on-roof));
  border-block-end: 2px solid light-dark(var(--c-contour), var(--c-on-roof-line));
}

.site-header__inner {
  inline-size: min(100%, var(--page-max));
  margin-inline: auto;
  padding-inline: var(--gutter);
  min-block-size: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--space-2) var(--space-5);
}

.wordmark {
  margin-inline-end: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 700;
  font-stretch: 90%;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: light-dark(var(--c-ink), var(--c-on-roof));
}

.mark {
  inline-size: 1.75rem;
  block-size: 1.75rem;
  flex: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-5);

  & a {
    text-decoration: none;
    font-weight: 500;
    color: light-dark(var(--c-ink), var(--c-on-roof));

    &:hover {
      color: light-dark(var(--c-pine), var(--c-on-roof-link));
    }

    /* The page being read: a line under its link, as the desk's tabs have. */
    &[aria-current="page"] {
      box-shadow: 0 3px 0 light-dark(var(--c-pine), var(--c-on-roof-link));
    }
  }
}

/* Where "Sign in" would be: a chip that says there is no account to make, and where the plan is kept. */
.keep-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-block-size: 2.5rem;
  /* Without this the chip's own minimum is its words at full length, and a long address widens a phone's page. */
  min-inline-size: 0;
  padding: var(--space-1) var(--space-3);
  border: 1px solid light-dark(var(--c-contour), var(--c-on-roof-line));
  border-radius: 999px;
  font-size: var(--text-s);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  color: light-dark(var(--c-ink), var(--c-on-roof));

  &:hover {
    border-color: light-dark(var(--c-pine), var(--c-on-roof-link));
    color: light-dark(var(--c-pine), var(--c-on-roof-link));
  }

  & .mark-icon {
    inline-size: 1.1rem;
    block-size: 1.1rem;
    flex: none;
  }
}

/* "Signed in as" and the address: the address gives way first, so a long one never widens the header. */
.keep-chip [data-keep-label="account"] {
  display: inline-flex;
  gap: 0.35em;
  min-inline-size: 0;
}

.keep-chip__who {
  max-inline-size: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 44rem) {
  /* On a phone there is no room beside the links, so the chip takes a line of its own under them. */
  .site-header__inner {
    flex-wrap: wrap;
    padding-block-end: var(--space-2);
  }

  .site-nav {
    min-block-size: var(--header-height);
  }

  .keep-chip {
    flex: 1 0 100%;
    justify-content: center;
    min-block-size: 2.25rem;
  }
}

.site-main {
  inline-size: min(100%, var(--page-max));
  margin-inline: auto;
  padding-block: var(--space-6) var(--space-8);
  padding-inline: var(--gutter);
}

/* The footer matches the header, so in the dark the page is held between two slates */
.site-footer {
  background: light-dark(var(--c-paper), var(--c-roof));
  color: light-dark(var(--c-ink-muted), var(--c-on-roof-muted));
  border-block-start: 2px solid light-dark(var(--c-contour), transparent);
  font-size: var(--text-s);
}

.site-footer__inner {
  inline-size: min(100%, var(--page-max));
  margin-inline: auto;
  padding-block: var(--space-7);
  padding-inline: var(--gutter);
  display: grid;
  gap: var(--space-4);

  & p {
    max-inline-size: var(--measure);
  }

  & a {
    color: light-dark(var(--c-pine), var(--c-on-roof-link));
  }

  & .button--quiet {
    color: light-dark(var(--c-pine), var(--c-on-roof-link));
  }
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
}

/* A button, because it does something, drawn as the links beside it are. */
.site-footer__install {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: light-dark(var(--c-pine), var(--c-on-roof-link));
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

.site-footer__made {
  padding-block-start: var(--space-4);
  border-block-start: 1px solid light-dark(var(--c-contour), var(--c-on-roof-line));
}

.skip-link {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--c-paper);
  border-radius: var(--radius-s);
  translate: 0 -200%;

  &:focus {
    translate: 0 0;
  }
}
}
