@layer components {
  /* "Choose your document", step 1 of the flow, as ../landing/pages/choose-document/design.html draws it
   * (approved 27 Nov 2026), on the flow's two sides (.flow-page, flow.css): left, the search field and the
   * list under the step line and the headline; right, the example, a raised card that stays in view while
   * the list scrolls. Under 1024px one column, with the example after the list. */

  /* The search field: sand with a hairline and 10px corners, so it reads as a field on the warm white side.
   * Where the group above is not kept, the field alone stays at the top of the window while the list
   * scrolls under it. */
  .doc-search {
    background: var(--color-ground);
    inset-block-start: 0;
    margin-block-start: 12px;
    padding-block: 12px;
    position: sticky;
    z-index: 5;

    &::after {
      background: linear-gradient(var(--color-ground), transparent);
      block-size: 10px;
      content: "";
      inset-block-start: 100%;
      inset-inline: 0;
      pointer-events: none;
      position: absolute;
    }

    @media (max-width: 600px) {
      margin-block-start: 6px;
    }

    /* Inside the kept group on a computer it is no longer kept on its own: it moves with the group. */
    .flow-page__head & {
      @media (min-width: 1024px) and (min-height: 620px) {
        inset-block-start: auto;
        position: relative;
      }
    }
  }

  .doc-search__field {
    align-items: center;
    background: var(--color-surface);
    block-size: 50px;
    border: 1px solid var(--color-hairline);
    border-radius: var(--rounded-md);
    display: flex;
    position: relative;

    &:focus-within {
      background: var(--color-ground);
      border-color: var(--color-ink);
      box-shadow: 0 0 0 1px var(--color-ink);
    }
  }

  .doc-search__icon {
    --icon-size: 18px;

    color: var(--color-muted);
    inset-inline-start: 15px;
    pointer-events: none;
    position: absolute;
  }

  .doc-search__input {
    appearance: none;
    background: transparent;
    block-size: 100%;
    border: 0;
    border-radius: inherit;
    color: var(--color-ink);
    flex: 1;
    font-size: 16px;
    font-weight: 500;
    line-height: normal;
    min-inline-size: 0;
    outline: none;
    padding: 0 46px 0 44px;

    &::placeholder {
      color: var(--color-muted);
      font-weight: 400;
      opacity: 1;
    }

    &::-webkit-search-cancel-button {
      display: none;
    }
  }

  /* The key that takes you to the field, "/", while the field is empty and not in use, on a computer. */
  .doc-search__key {
    background: var(--color-ground);
    block-size: 24px;
    border: 1px solid var(--color-hairline);
    border-radius: var(--rounded-sm);
    color: var(--color-muted);
    display: grid;
    font: 600 12px/1 var(--font-sans);
    inset-inline-end: 12px;
    min-inline-size: 24px;
    padding: 0 6px;
    place-items: center;
    pointer-events: none;
    position: absolute;

    .doc-search__field:focus-within &,
    .doc-search__field--filled & {
      display: none;
    }

    @media (max-width: 1023px) {
      display: none;
    }
  }

  .doc-search__clear {
    --icon-size: 16px;

    background: none;
    block-size: 36px;
    border: 0;
    border-radius: var(--rounded-sm);
    color: var(--color-muted);
    cursor: pointer;
    display: grid;
    inline-size: 36px;
    inset-inline-end: 7px;
    padding: 0;
    place-items: center;
    position: absolute;

    &:hover { color: var(--color-ink); }
  }

  /* The list: a small grey line in capitals for each group, then one row for each document on sale. */
  .doc-list {
    margin-block-start: 6px;
  }

  .doc-list__group + .doc-list__group {
    margin-block-start: 24px;
  }

  .doc-list__name {
    color: var(--color-muted);
    font: var(--text-label);
    letter-spacing: 0.02em;
    margin-block-end: 10px;
    text-transform: uppercase;
  }

  .doc-list__rows {
    display: grid;
    gap: 8px;
  }

  /* A row is one link: the picture of the document in a sand tile, the name, one grey line and the arrow.
   * It is the homepage's Documents card, one across: warm white, hairline, 16px corners, flat. Under the
   * mouse the hairline turns charcoal and the arrow moves 3px. */
  .doc-row {
    align-items: center;
    background: var(--color-ground);
    border: 1px solid var(--color-hairline);
    border-radius: var(--rounded-lg);
    color: var(--color-ink);
    cursor: pointer;
    display: flex;
    gap: 14px;
    inline-size: 100%;
    min-block-size: 68px;
    padding: 7px 16px 7px 8px;
    position: relative;
    scroll-margin: 96px 0 24px;
    text-align: start;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;

    /* The arrow, drawn here and not in the markup, approved on 27 Nov 2026 as the homepage cards' was. */
    &::after {
      background-color: currentColor;
      block-size: 18px;
      content: "";
      flex: none;
      inline-size: 18px;
      mask: url("/assets/icons/arrow-right-4195434d.svg") center / contain no-repeat;
    }

    &:hover {
      border-color: var(--color-ink);
      color: var(--color-ink);

      &::after { translate: 3px 0; }
    }

    @media (min-width: 1024px) and (min-height: 620px) {
      scroll-margin-block-start: 340px;
    }

    /* A low window (a small laptop): lower rows, so the popular documents and the start of the next group
     * are on the first screen at 1280 by 720. */
    @media (min-width: 1024px) and (max-height: 780px) {
      min-block-size: 62px;
      padding-block: 6px;
    }

    @media (max-width: 600px) {
      gap: 11px;
      min-block-size: 64px;
      padding: 7px 13px 7px 7px;
    }
  }

  /* The picture is the document's own, a passport's cover upright or a visa sticker on its side, whole and
   * never cut. A document whose picture is a stand-in shows the homepage's drawing of its kind. The tile
   * turns pale mint under the mouse, and stays so on the row the example shows. */
  .doc-row__tile {
    background: var(--color-surface);
    block-size: 52px;
    border-radius: var(--rounded-md);
    display: grid;
    flex: none;
    inline-size: 52px;
    place-items: center;

    .doc-row:not(.doc-row--coming):hover &,
    .doc-row--shown & {
      background: var(--color-accent-soft);
    }

    @media (min-width: 1024px) and (max-height: 780px) {
      block-size: 48px;
      inline-size: 48px;
    }

    @media (max-width: 600px) {
      block-size: 48px;
      inline-size: 48px;
    }
  }

  .doc-row__picture {
    block-size: auto;
    border-radius: 3px;
    inline-size: auto;
    max-block-size: 48px;
    max-inline-size: 48px;
    outline: 1px solid color-mix(in srgb, var(--color-ink) 14%, transparent);
    outline-offset: -1px;

    @media (min-width: 1024px) and (max-height: 780px) {
      max-block-size: 44px;
      max-inline-size: 44px;
    }

    @media (max-width: 600px) {
      max-block-size: 42px;
      max-inline-size: 42px;
    }
  }

  /* A standard size shows the example photo, smaller than a cover. */
  .doc-row__tile--photo .doc-row__picture {
    max-block-size: 38px;
    max-inline-size: 38px;

    @media (min-width: 1024px) and (max-height: 780px) {
      max-block-size: 36px;
      max-inline-size: 36px;
    }

    @media (max-width: 600px) {
      max-block-size: 36px;
      max-inline-size: 36px;
    }
  }

  .doc-row__drawing {
    block-size: 36px;
    color: var(--color-ink);
    display: block;
    inline-size: 27px;

    * { vector-effect: non-scaling-stroke; }
  }

  .doc-row__text {
    flex: 1;
    min-inline-size: 0;
  }

  .doc-row__name {
    display: block;
    font: 600 16px/1.3 var(--font-sans);
    letter-spacing: -0.01em;

    @media (max-width: 600px) {
      font-size: 15.5px;
    }
  }

  .doc-row__line {
    color: var(--color-muted);
    display: block;
    font: 400 14px/1.4 var(--font-sans);
    margin-block-start: 1px;
    text-wrap: pretty;

    @media (max-width: 600px) {
      font-size: 13.5px;
    }
  }

  /* A document that is not on sale shows only in the search's results: no fill, a dashed hairline, grey
   * words and a tag in place of the arrow. */
  .doc-row--coming {
    background: transparent;
    border-style: dashed;
    cursor: default;

    &::after { content: none; }

    &:hover { border-color: var(--color-hairline); }

    .doc-row__tile { background: transparent; }

    .doc-row__drawing,
    .doc-row__picture {
      opacity: 0.45;
    }

    .doc-row__name {
      color: var(--color-muted);
      font-weight: 500;
    }
  }

  .doc-row__tag {
    background: var(--color-surface);
    border: 1px solid var(--color-hairline);
    border-radius: var(--rounded-full);
    color: var(--color-muted);
    flex: none;
    font: 500 12px/1.4 var(--font-sans);
    padding: 3px 10px;
    white-space: nowrap;
  }

  /* What the search says when it finds nothing, with a way back to the list and a way to ask for the document. */
  .doc-none {
    border: 1px dashed var(--color-hairline);
    border-radius: var(--rounded-lg);
    padding: 20px 18px;
  }

  .doc-none__text {
    color: var(--color-muted);
    font: 400 15px/1.5 var(--font-sans);
    text-wrap: pretty;
  }

  .doc-none__query {
    color: var(--color-ink);
    font-weight: 600;
    overflow-wrap: anywhere;
  }

  .doc-none__links {
    display: flex;
    flex-wrap: wrap;
    font: 400 15px/1.5 var(--font-sans);
    gap: 10px 22px;
    margin-block-start: 14px;
  }

  /* The brand's text link: charcoal, semibold, underlined, with a finger's reach above and below. */
  .doc-none__link {
    background: none;
    border: 0;
    color: var(--color-ink);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    padding: 0;
    position: relative;
    text-decoration: underline;
    text-underline-offset: 4px;

    &::after {
      content: "";
      inset: -13px 0;
      position: absolute;
    }

    &:hover { text-decoration-thickness: 2px; }

    &:where(button) { line-height: normal; }
  }

  /* The documents that are coming: one closed line with a dashed hairline at the end of the list, which
   * opens to their names. */
  .doc-coming {
    border: 1px dashed var(--color-hairline);
    border-radius: var(--rounded-lg);
    margin-block-start: 24px;
  }

  .doc-coming__summary {
    align-items: center;
    border-radius: var(--rounded-lg);
    cursor: pointer;
    display: flex;
    font: 600 15px/1.3 var(--font-sans);
    gap: 12px;
    justify-content: space-between;
    min-block-size: 54px;
    padding: 0 16px 0 18px;

    &::after {
      background-color: var(--color-muted);
      block-size: 16px;
      content: "";
      flex: none;
      inline-size: 16px;
      mask: url("/assets/icons/disclosure-4055d0eb.svg") center / contain no-repeat;
    }

    .doc-coming[open] &::after {
      rotate: 180deg;
    }
  }

  .doc-coming__body {
    padding: 0 18px 18px;
  }

  .doc-coming__note {
    color: var(--color-muted);
    font: 400 14px/1.5 var(--font-sans);
  }

  .doc-coming__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-block-start: 12px;
  }

  .doc-coming__chip {
    background: var(--color-surface);
    border: 1px solid var(--color-hairline);
    border-radius: var(--rounded-full);
    color: var(--color-muted);
    font: 400 13px/1.4 var(--font-sans);
    padding: 4px 10px;
  }

  /* The example: a raised card on the sand side, a flat sand card under 1024px, where it floats over
   * nothing. Its height doesn't change from one document to the next: the facts and the last line keep
   * their room. --doc-max-w and --doc-max-h are the largest photo; the script fits each document's shape
   * into them. Until a document is shown on a phone or a tablet, it shows only the two photos. */
  .doc-example {
    --doc-max-w: 216px;
    --doc-max-h: 232px;

    background: var(--color-ground);
    border: 1px solid var(--color-hairline);
    border-radius: var(--rounded-xl);
    box-shadow: var(--shadow-raised);
    inline-size: 100%;
    max-inline-size: 404px;
    padding: 20px 24px 18px;

    &:not(.doc-example--filled) .doc-example__value { display: none; }

    /* A lower window still: a smaller photo, so the card and its sentence still fit. */
    @media (min-width: 1024px) and (max-height: 700px) {
      --doc-max-w: 176px;
      --doc-max-h: 190px;

      padding-block: 16px 14px;
    }

    @media (max-width: 1023px) {
      background: var(--color-surface);
      border-radius: var(--rounded-lg);
      box-shadow: none;
      max-inline-size: none;

      &:not(.doc-example--filled) {
        padding-block-end: 20px;

        .doc-example__facts,
        .doc-example__source {
          display: none;
        }

        .doc-example__stage {
          grid-template-rows: var(--doc-max-w) auto;
          margin-block-start: 16px;
        }

        .doc-example__after { padding-inline-end: 0; }
      }
    }

    @media (max-width: 600px) {
      --doc-max-w: 188px;
      --doc-max-h: 202px;

      padding-inline: 18px;
    }

    @media (max-width: 379px) {
      --doc-max-w: 168px;
      --doc-max-h: 180px;

      padding-inline: 14px;
    }
  }

  .doc-example__head {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    min-block-size: 28px;
  }

  .doc-example__title {
    font: 700 17px/1.3 var(--font-sans);
    letter-spacing: -0.01em;
    text-wrap: wrap;
  }

  .doc-example__tag {
    background: var(--color-accent-soft);
    border-radius: var(--rounded-full);
    color: var(--color-ink);
    flex: none;
    font: var(--text-label);
    letter-spacing: 0.02em;
    padding: 3px 12px;
  }

  /* The pictures: her photo as taken, small, an arrow, and the photo IDshot makes, in the document's shape,
   * on one line. The two rules with the size hang on the large photo and move with it. */
  .doc-example__stage {
    display: grid;
    grid-template-columns: 66px 30px minmax(0, 1fr);
    grid-template-rows: calc(var(--doc-max-h) + 30px) auto;
    margin: 10px auto 0;
    max-inline-size: 356px;

    @media (max-width: 379px) {
      grid-template-columns: 58px 24px minmax(0, 1fr);
    }
  }

  .doc-example__before {
    align-self: end;
    block-size: 88px;
    border: 1px solid var(--color-hairline);
    border-radius: 8px;
    grid-area: 1 / 1;
    inline-size: 66px;
    overflow: hidden;

    @media (max-width: 379px) {
      block-size: 77px;
      inline-size: 58px;
    }
  }

  .doc-example__selfie {
    block-size: 100%;
    inline-size: 100%;
    object-fit: cover;
  }

  .doc-example__before-caption {
    color: var(--color-muted);
    font: 500 12px/1.4 var(--font-sans);
    grid-area: 2 / 1 / 3 / 3;
    margin-block-start: 6px;
    white-space: nowrap;
  }

  .doc-example__arrow {
    align-self: end;
    background-color: var(--color-ink);
    block-size: 16px;
    grid-area: 1 / 2;
    inline-size: 16px;
    justify-self: center;
    margin-block-end: 36px;
    mask: url("/assets/icons/arrow-right-long-17d3401e.svg") center / contain no-repeat;
    opacity: 0.45;

    @media (max-width: 379px) {
      margin-block-end: 30px;
    }
  }

  .doc-example__after {
    align-items: flex-end;
    display: flex;
    grid-area: 1 / 3;
    justify-content: center;
    padding-inline-end: 26px;
  }

  .doc-example__frame {
    block-size: var(--doc-fh, var(--doc-max-w));
    flex: none;
    inline-size: var(--doc-fw, var(--doc-max-w));
    position: relative;
  }

  .doc-example__paper {
    background: var(--doc-paper, white);
    border: 1px solid var(--color-hairline);
    border-radius: 8px;
    inset: 0;
    overflow: hidden;
    position: absolute;
  }

  /* The photo is the check's real 600 by 600 file. For another shape the script places it by the
   * document's own framing (documents.yml), so the example is cut as the file is. */
  .doc-example__photo {
    aspect-ratio: 1;
    block-size: auto;
    inline-size: var(--doc-pw, 100%);
    inset-block-start: var(--doc-py, 0%);
    inset-inline-start: var(--doc-px, 0%);
    max-inline-size: none;
    position: absolute;
  }

  .doc-example__raw,
  .doc-example__crop {
    display: none;
  }

  .doc-example__dim {
    opacity: 0;
    pointer-events: none;
    position: absolute;

    &::before,
    &::after {
      border: 0 solid var(--color-ink);
      content: "";
      position: absolute;
    }

    .doc-example--filled & { opacity: 1; }
  }

  .doc-example__dim--width {
    block-size: 11px;
    inset-block-start: -20px;
    inset-inline: 0;

    &::before {
      border-block-start-width: 1px;
      inset-block-start: 5px;
      inset-inline: 0;
    }

    &::after {
      border-inline-width: 1px;
      inset: 0;
    }
  }

  .doc-example__dim--height {
    inline-size: 11px;
    inset-block: 0;
    inset-inline-end: -20px;

    &::before {
      border-inline-start-width: 1px;
      inset-block: 0;
      inset-inline-start: 5px;
    }

    &::after {
      border-block-width: 1px;
      inset: 0;
    }

    .doc-example__size { transform: translate(-50%, -50%) rotate(90deg); }
  }

  .doc-example__size {
    background: var(--color-accent-soft);
    border-radius: var(--rounded-full);
    color: var(--color-ink);
    font: 600 11.5px/1.5 var(--font-sans);
    inset-block-start: 50%;
    inset-inline-start: 50%;
    padding: 1px 8px;
    position: absolute;
    transform: translate(-50%, -50%);
    white-space: nowrap;
  }

  /* The three facts. Before a document is shown each one is a grey bar. */
  .doc-example__facts {
    margin: 14px 0 0;
    min-block-size: 131px;
  }

  .doc-example__fact {
    align-items: baseline;
    border-block-start: 1px solid var(--color-hairline);
    display: grid;
    font: 400 14px/1.4 var(--font-sans);
    gap: 8px;
    grid-template-columns: 92px minmax(0, 1fr);
    padding-block: 8px;

    dt { color: var(--color-muted); }

    dd {
      color: var(--color-ink);
      font-weight: 600;
      margin: 0;
      text-wrap: pretty;
    }
  }

  .doc-example__bar {
    background: var(--color-hairline);
    block-size: 8px;
    border-radius: var(--rounded-full);
    display: block;
    margin-block: 6px 5.6px;

    .doc-example--filled & { display: none; }
  }

  .doc-example__source {
    border-block-start: 1px solid var(--color-hairline);
    color: var(--color-muted);
    font: 400 12.5px/1.45 var(--font-sans);
    min-block-size: calc(10px + 2 * 1.45em);
    padding-block-start: 10px;
    text-wrap: pretty;
  }

  /* Movement, only with motion allowed. Hover states change in 150ms. The page comes in from the top down
   * (.flow-page, flow.css). The large photo takes the next document's shape in 280ms, and the words that
   * change with it fade in. On a full load her photo stands in the frame as taken on its dark wall, a mint
   * line marks the cut, and the wall turns into the white of the real file: one time, done in 1.7 seconds.
   * The two wall colours are the photo's own. Without a script, or with reduced motion, nothing moves and
   * the page is whole. */
  @media screen and (prefers-reduced-motion: no-preference) {
    .doc-row {
      transition: border-color 150ms ease, box-shadow 150ms ease;

      &::after { transition: translate 150ms ease; }

      &:not(.doc-row--coming):active { scale: 0.995; }
    }

    .doc-row__tile {
      transition: background-color 150ms ease;
    }

    .doc-example__frame {
      transition: inline-size 280ms cubic-bezier(0.22, 1, 0.36, 1), block-size 280ms cubic-bezier(0.22, 1, 0.36, 1);
    }

    .doc-example__photo {
      transition:
        inset-inline-start 280ms cubic-bezier(0.22, 1, 0.36, 1),
        inset-block-start 280ms cubic-bezier(0.22, 1, 0.36, 1),
        inline-size 280ms cubic-bezier(0.22, 1, 0.36, 1);
    }

    .doc-example__dim {
      transition: opacity 200ms ease;
    }

    .doc-example--swap {
      .doc-example__title,
      .doc-example__value,
      .doc-example__source,
      .doc-example__size {
        animation: doc-example-swap 220ms ease both;
      }
    }

    .js-motion .doc-example--intro {
      .doc-example__paper {
        background: linear-gradient(90deg, #133E43, #295863); /* the wall, behind the two thin strips her photo doesn't reach */
      }

      .doc-example__raw {
        block-size: 116.966%;
        display: block;
        inline-size: 87.725%;
        inset-block-start: -9.651%;
        inset-inline-start: 6.371%;
        max-inline-size: none;
        position: absolute;
        rotate: 0.9deg;
        transform-origin: 49.734% 50.998%;
      }

      .doc-example__photo {
        animation: doc-example-wall 700ms ease 950ms both paused;
      }

      .doc-example__crop {
        animation: doc-example-crop 500ms cubic-bezier(0.22, 1, 0.36, 1) 400ms both paused, doc-example-crop-out 300ms ease 1400ms forwards paused;
        border: 2px solid var(--color-accent); /* the cut's mint line, the page's one other mint (AGENTS.md, Brand) */
        border-radius: 8px;
        display: block;
        inset: 0;
        position: absolute;
      }

      &.doc-example--play {
        .doc-example__photo,
        .doc-example__crop {
          animation-play-state: running;
        }
      }
    }
  }

  @keyframes doc-example-swap {
    from { opacity: 0; }
  }

  @keyframes doc-example-wall {
    from { opacity: 0; }
  }

  @keyframes doc-example-crop {
    from { opacity: 0; scale: 1.06; }
  }

  @keyframes doc-example-crop-out {
    to { opacity: 0; }
  }
}
