@layer components {
  .landing {
    display: flex;
    flex-direction: column;
    gap: var(--block-space);
    padding-block-end: var(--block-space-double);
  }

  /* What is said where the cards will be, while there are none. */
  .landing__lead {
    margin: 0;
  }

  .landing__rows {
    --rows-margin: var(--block-space-half) 0 0;

    .row__body {
      padding-block: 0.6em;
    }
  }

  .landing__icon {
    --icon-size: 1.5rem;

    margin-inline: 0.25em;
  }

  .landing__step-number {
    display: inline-grid;
    flex: none;
    place-items: center;
    block-size: 1.5rem;
    inline-size: 1.5rem;
    color: var(--color-ink-dark);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
  }

  .landing__step--done {
    color: var(--color-ink-dark);

    .row__title {
      font-weight: normal;
    }
  }

  /* Home: no sheet. The account's name over a card for each site, or each firm a person answers for, two abreast, in a tinted
     panel in the middle of the ground where there is room, with a greeting and what to start at its left. */
  @media screen {
    .sheet:has(> #main > .landing--home) {
      border-image: none;
      box-shadow: none;
      inline-size: auto;
      margin-inline: 0;

      > #main {
        padding-block: 0;
      }

      /* The row the top bar's field takes once the page scrolls is the ground's here. */
      &::before {
        background-color: var(--color-body);
      }
    }
  }

  .landing--home {
    --landing-column: 40rem;         /* 640px: the panel, and the cards' two columns without it */

    display: grid;
    gap: 1.25rem;                    /* 20px */
    grid-template-areas: "header" "aside" "body";
    grid-template-columns: minmax(0, 1fr);
    padding-block-start: 0.5rem;

    @media (min-width: 100ch) {
      --landing-column: 33.7rem;     /* 640px */

      gap: 1.05rem;
    }

    /* Three columns once the page is 944px wide, as in a 1024px window, and measured on the page so the open sidebar
       narrows it. The panel is as wide as leaves each side what the buttons take, and no narrower
       than 480px; short of that the buttons lean into the page's margin, and the activity keeps its width. */
    @container layout (width >= 944px) {
      --landing-column: clamp(25.26rem, 100cqi - 25.8rem, 33.7rem); /* 480px to 640px */

      align-items: start;
      column-gap: 1.7rem;            /* 32px */
      grid-template-areas: "aside panel activity";
      grid-template-columns: minmax(0, 1fr) var(--landing-column) minmax(10.37rem, 1fr); /* 197px */
    }
  }

  /* Beside the panel: a greeting over what to start from here, read towards the panel. Without the room, the actions alone, in a row between the account's name and the cards. */
  .landing__aside {
    grid-area: aside;

    @container layout (width >= 944px) {
      justify-self: end;
      padding-block-start: 3.8rem;   /* 72px, about level with the first card */
      text-align: end;
    }
  }

  .landing__greeting {
    display: none;
    font-size: var(--text-section);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0 0 0.85rem auto;        /* 16px under it */
    max-inline-size: 10rem;          /* 190px: the name goes under the greeting */
    overflow-wrap: anywhere;
    text-wrap: wrap;

    @container layout (width >= 944px) {
      display: block;
    }
  }

  .landing__actions {
    display: flex;
    flex-wrap: wrap;
    font-size: 1rem;                 /* 16px */
    gap: 0.625em;
    justify-content: center;

    @media (min-width: 100ch) {
      font-size: 0.842rem;           /* 16px */
    }

    @container layout (width >= 944px) {
      align-items: end;
      flex-direction: column;
    }
  }

  /* What is set up from here stands a little apart from what is done every day. */
  .landing__actions + .landing__actions {
    margin-block-start: 1em;         /* 16px */

    @container layout (width >= 944px) {
      margin-block-start: 1.375em;   /* 22px */
    }
  }

  .landing__action {
    --btn-border-color: var(--color-ink-lighter);
    --btn-gap: 0.5em;
    --btn-padding: 0 1em;
    --icon-size: 1.25em;

    font-weight: 500;
    min-block-size: 2.75em;          /* 44px */
    white-space: nowrap;

    .icon {
      color: var(--color-link);
    }
  }

  /* A count on a button is the button's small print. */
  .landing__action .count {
    font-size: 0.75em;               /* 12px */
  }

  /* The menu of inspections to do hangs from its button's middle, clear of both edges of a phone. Beside the panel it
     ends where the button does, towards the panel, and reads from the start as any menu, not from the aside's end. */
  .landing__owed .popup {
    inset-inline: 50% auto;
    max-inline-size: calc(100vw - 2rem);
    text-align: start;
    translate: -50%;

    @media (width >= 1024px) {
      inset-inline: auto 0;
      max-inline-size: 18rem;        /* 342px */
      translate: none;
    }
  }

  /* Without the room for three columns the panel is no box: its name and its cards are rows of the page, the actions between them. */
  .landing__panel {
    display: contents;

    @container layout (width >= 944px) {
      background-color: color-mix(in oklch, var(--color-ink) 3%, var(--color-body));
      border-radius: var(--radius-xl);
      display: block;
      grid-area: panel;
      padding: 0.85rem 0.85rem 1.05rem; /* 16px 16px 20px */
    }
  }

  /* The account's name and, where there is a keyboard, the key that opens the field in the top bar. */
  .landing__header {
    grid-area: header;
    text-align: center;

    @container layout (width >= 944px) {
      padding-block-end: 0.85rem;    /* 16px to the first card */
    }
  }

  .landing__body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;                     /* 8px */
    grid-area: body;
    inline-size: 100%;
    justify-self: center;
    max-inline-size: var(--landing-column);
    text-align: start;

    @media (min-width: 100ch) {
      gap: 0.42rem;
    }
  }

  .landing__account {
    font-size: 1.125rem;             /* 18px */
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.33;
    margin: 0;
    overflow-wrap: anywhere;
    text-wrap: balance;

    @media (min-width: 100ch) {
      font-size: 0.95rem;            /* 18px */
    }
  }

  .landing__hint {
    color: var(--color-text-subtle);
    font-size: var(--text-control);
    line-height: var(--leading-snug);
    margin: 0.25rem 0 0;
    text-wrap: balance;
  }

  /* The steps to get started are a card among the cards. */
  .landing__start {
    background-color: var(--color-canvas);
    border: 1px solid var(--color-ink-lighter);
    border-radius: var(--radius-lg);
    padding: var(--block-space) calc(var(--block-space) * 1.25);
  }

  /* The gate's search is what its keeper comes for: a card over the sites, a little apart from them. */
  .landing__gate {
    background-color: var(--color-canvas);
    border: 1px solid var(--color-ink-lighter);
    border-radius: var(--radius-lg);
    margin-block-end: 0.5rem;        /* 16px to the first site */
    padding: 1rem;                   /* 16px */

    @media (min-width: 100ch) {
      margin-block-end: 0.42rem;
      padding: 0.85rem;
    }
  }

  .landing__cards {
    display: grid;
    gap: inherit;
    grid-template-columns: minmax(0, 1fr);
    list-style: none;
    margin: 0;
    padding: 0;

    @media (width >= 480px) {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .landing__card {
    background-color: var(--color-canvas);
    border: 1px solid var(--color-ink-lighter);
    border-radius: var(--radius-lg);
    display: flex;
    outline: none;
    position: relative;

    /* A card on its own takes the panel's width, and so does our own company's, above the sites. */
    &:only-child,
    &.landing__card--ours,
    .landing__card--ours + &:last-child {
      grid-column: 1 / -1;
    }

    /* Under the pointer a card gets a ring, with no lift, and at home a small round mark at its foot. */
    @media (any-hover: hover) {
      &:hover {
        box-shadow: 0 0 0 2px var(--color-ink-medium);
      }

      .landing__cards > &:hover::after {
        block-size: 1rem;            /* 16px */
        border: 2px solid var(--color-ink-light);
        border-radius: 50%;
        content: "";
        inline-size: 1rem;
        inset-block-end: 0.75rem;    /* 12px */
        inset-inline-end: 1.875rem;  /* 30px */
        pointer-events: none;
        position: absolute;

        @media (min-width: 100ch) {
          block-size: 0.842rem;
          inline-size: 0.842rem;
          inset-block-end: 0.63rem;
          inset-inline-end: 1.58rem;
        }
      }
    }

    /* The list picks its first card as the page loads, which is no one's doing: the pick shows once the keys move it,
       and Shift held for the key caps moves nothing. */
    &:is(:focus-visible:not([data-shift-alone] *), :has(:focus-visible)) {
      outline: var(--focus-ring);
      outline-offset: var(--focus-ring-offset);
    }
  }

  /* The name at the top, how the site is doing under it, and who is on it at the bottom. */
  .landing__card-link,
  .landing__card-body {
    border-radius: inherit;
    color: inherit;
    display: flex;
    flex: 1;
    flex-direction: column;
    outline: none;
    padding: 1rem;                   /* 16px */
    text-decoration: none;

    @media (min-width: 100ch) {
      padding: 0.85rem;
    }
  }

  /* Where a figure on the card is a link of its own, the name's link covers the rest of the card. */
  .landing__card-cover {
    color: inherit;
    text-decoration: none;

    &::after {
      border-radius: var(--radius-lg);
      content: "";
      inset: 0;
      position: absolute;
    }
  }

  /* The name, and under it how the site stands. */
  .landing__card-head {
    align-items: start;
    display: flex;
    flex-direction: column;

    .status {
      font-size: var(--text-control);
      line-height: var(--leading-snug);
    }
  }

  /* A site someone said how it is going shows that at the right of its name, a dot and a word. */
  .landing__card-head:has(.landing__card-needle) {
    column-gap: var(--inline-space);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;

    > :not(.landing__card-needle) {
      grid-column: 1;
    }
  }

  .landing__card-needle {
    align-self: center;
    grid-column: 2;
    grid-row: 1 / span 2;
    font-size: var(--text-control);
  }

  .landing__card-name {
    font-size: 1.125rem;             /* 18px */
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.33;
    overflow-wrap: anywhere;

    @media (min-width: 100ch) {
      font-size: 0.95rem;            /* 18px */
    }
  }

  .landing__card-line {
    color: var(--color-meta);
    font-size: 0.95rem;              /* 15px */
    line-height: var(--leading-snug);

    @media (min-width: 100ch) {
      font-size: 0.76rem;            /* 14.4px */
    }
  }

  /* How the site is doing: each number large over a small label, a pair as "8 of 9". */
  .landing__figures {
    display: grid;
    gap: 0.875rem 0.75rem;           /* 14px 12px */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-block-start: 0.75rem;     /* 12px */

    @media (min-width: 100ch) {
      gap: 0.74rem 0.63rem;
      margin-block-start: 0.63rem;
    }
  }

  .landing__figure {
    display: flex;
    flex-direction: column;
  }

  .landing__figure-number {
    font-size: 1.75rem;              /* 28px */
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;

    @media (min-width: 100ch) {
      font-size: 1.474rem;           /* 28px */
    }
  }

  .landing__figure-of {
    color: var(--color-meta);
    font-size: 0.57em;               /* 16px */
    font-weight: 700;
    letter-spacing: 0;
  }

  .landing__figure-label {
    color: var(--color-meta);
    font-size: 0.8125rem;            /* 13px */
    line-height: var(--leading-snug);

    @media (min-width: 100ch) {
      font-size: 0.684rem;           /* 13px */
    }
  }

  .landing__card-people {
    --avatar-size: 2rem;             /* 32px */

    font-size: var(--text-control);
    margin-block-start: auto;
    padding-block-start: var(--block-space);

    @media (min-width: 100ch) {
      --avatar-size: 1.7rem;         /* 32px */
    }

    /* The round mark shows at this row's end under the pointer, so the avatars wrap short of it. */
    @media (any-hover: hover) {
      padding-inline-end: 3rem;      /* 48px */

      @media (min-width: 100ch) {
        padding-inline-end: 2.53rem;
      }
    }
  }

  /* Our own company's faces stay on one row, the rest said as a count after them, and with nobody the row goes. */
  .landing__card--ours .landing__card-people:not(:has(*)) {
    display: none;
  }

  .landing__card-more {
    color: var(--color-meta);
    font-size: var(--text-small);
    margin-inline-start: var(--inline-space);
  }

  /* Beside the panel at its other side: what people did lately. */
  .landing__activity {
    display: none;
    grid-area: activity;

    @container layout (width >= 944px) {
      display: block;
      max-inline-size: 15.5rem;      /* 295px */
      padding-block-start: 3.8rem;   /* 72px, level with the greeting */
      text-align: start;
    }
  }

  /* Its heading is the greeting's twin, with the way to the whole log beside it or under it. */
  .landing__activity-header {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.5rem;
    margin-block-end: 0.85rem;       /* 16px, as under the greeting */
  }

  .landing__activity-title {
    font-size: var(--text-section);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0;
  }

  .landing__activity-all {
    color: var(--color-text-subtle);
    font-size: var(--text-control);
    text-decoration: underline;
  }

  .landing__activity-blank {
    color: var(--color-text-subtle);
    font-size: var(--text-control);
    margin: 0;
  }

  .landing__events {
    display: grid;
    font-size: var(--text-control);
    gap: 1em;
    line-height: 1.45;
    list-style: none;
    margin: 0;
    padding: 0;
  }

  /* Who did it at the left, how long ago over what they did. */
  .landing__event {
    column-gap: 0.6em;
    display: grid;
    grid-template-areas: "who time" "who body";
    grid-template-columns: max-content minmax(0, 1fr);
  }

  .landing__event-avatar {
    --avatar-size: 1.26rem;          /* 24px */

    font-size: var(--text-xx-small);
    grid-area: who;
  }

  .landing__event-time {
    color: var(--color-meta);
    font-size: 0.93em;               /* 13px */
    grid-area: time;
  }

  /* A long sentence stops at four lines; the log has the rest. */
  .landing__event-body {
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    display: -webkit-box;
    grid-area: body;
    margin: 0;
    overflow: hidden;
    overflow-wrap: anywhere;

    a {
      color: inherit;
      text-decoration: underline;
      text-decoration-color: var(--color-ink-light);

      @media (any-hover: hover) {
        &:hover {
          text-decoration-color: currentcolor;
        }
      }
    }
  }
}
