@layer components {
  /* The flow's pages: a step line, then one column on a phone and two on a
   * desktop. The mockups (../ops/flow-proposal-2026-11-03) are the reference. */
  .flow {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-block: 20px 56px;

    @media (min-width: 761px) {
      gap: 36px;
      padding-block: 40px 96px;
    }
  }

  .flow__columns {
    display: grid;
    gap: 28px;

    @media (min-width: 900px) {
      align-items: start;
      gap: 72px;
      grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    }
  }

  .flow__main,
  .flow__aside {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-inline-size: 0;
  }

  .flow__heading {
    display: flex;
    flex-direction: column;
    gap: 6px;

    h1:focus { outline: none; }
  }

  /* On a phone the heading is centred, as PhotoAiD sets it (founder's pick, 17 Nov 2026). */
  .flow__heading--centred {
    @media (max-width: 760px) {
      text-align: center;
    }
  }

  /* The step's main button. On a phone it stays at the bottom of the screen
   * while the page scrolls, as PhotoAiD's does; on a desktop it sits in the page. */
  .flow__bar {
    display: flex;
    flex-direction: column;
    gap: 8px;

    @media (max-width: 760px) {
      background: var(--color-ground);
      border-block-start: 1px solid var(--color-hairline);
      inset-block-end: 0;
      margin-inline: calc(-1 * var(--page-gutter));
      padding: 12px var(--page-gutter) calc(14px + env(safe-area-inset-bottom, 0px));
      position: sticky;
      z-index: 4;

      .flow__button { inline-size: 100%; }

      .flow__note { text-align: center; }
    }
  }

  .flow__lead {
    color: var(--color-muted);
    font: var(--text-lead);
  }

  .flow__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;

    @media (min-width: 761px) {
      align-items: flex-start;
    }
  }

  .flow__button {
    inline-size: 100%;

    @media (min-width: 761px) {
      inline-size: auto;
      min-inline-size: 320px;
    }
  }

  .flow__note {
    color: var(--color-muted);
    font: var(--text-caption);
  }

  /* A white card on the ground, for the one thing each step asks for. */
  .flow-card {
    background: var(--color-surface);
    border: 1px solid var(--color-hairline);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;

    @media (min-width: 761px) {
      padding: 24px;
    }
  }

  /* "Step 2 of 5 · Photo" and a thin bar under it. */
  .stepline {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-inline-size: 520px;
  }

  .stepline__row {
    display: flex;
    font: 500 12px/16px var(--font-mono);
    gap: 12px;
    justify-content: space-between;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .stepline__right {
    color: var(--color-muted);
  }

  .stepline__bar {
    background: linear-gradient(var(--color-ink), var(--color-ink)) 0 0 / calc(var(--step) * 20%) 100% no-repeat, var(--color-hairline);
    block-size: 3px;
    border-radius: 2px;
  }

  /* The document select: a <details> holding a search box and the list. */
  .doc-select {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
  }

  .doc-select__label {
    font-size: 15px;
    font-weight: 600;
    line-height: 22px;
  }

  .doc-select__current {
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-ink);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    font-size: 17px;
    font-weight: 600;
    justify-content: space-between;
    line-height: 22px;
    min-block-size: 54px;
    padding: 0 14px;

    &::after {
      background-color: currentColor;
      block-size: 22px;
      content: "";
      inline-size: 22px;
      mask: url("/assets/icons/chevron-down-30770c82.svg") center / contain no-repeat;
      transition: rotate 0.15s;
    }

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

  .doc-select__menu {
    background: var(--color-surface);
    border: 1px solid var(--color-hairline);
    border-radius: 12px;
    box-shadow: var(--shadow-float);
    display: flex;
    flex-direction: column;
    gap: 2px;
    inset-inline: 0;
    margin-block-start: 6px;
    padding: 8px;
    position: absolute;
    z-index: 2;
  }

  .doc-select__search {
    align-items: center;
    border: 1px solid var(--color-muted);
    border-radius: 8px;
    color: var(--color-muted);
    display: flex;
    gap: 10px;
    margin-block-end: 6px;
    min-block-size: 46px;
    padding: 0 12px;

    --icon-size: 20px;

    input {
      background: none;
      border: 0;
      color: var(--color-ink);
      flex: 1;
      font-size: 16px;
      min-inline-size: 0;
      outline: none;
    }

    &:focus-within {
      border-color: var(--color-ink);
      outline: var(--focus-ring-size) solid var(--focus-ring-color);
      outline-offset: var(--focus-ring-offset);
    }
  }

  .doc-select__link {
    align-items: center;
    border-radius: 8px;
    color: inherit;
    display: grid;
    gap: 12px;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    padding: 8px 10px;
    text-decoration: none;

    &:hover {
      background: var(--color-ground);
      color: inherit;
    }
  }

  .doc-select__link--current {
    background: var(--color-placeholder);
  }

  .doc-select__picture {
    block-size: 34px;
    border: 1px solid var(--color-hairline);
    border-radius: 3px;
    inline-size: 48px;
    object-fit: cover;
  }

  .doc-select__text {
    display: flex;
    flex-direction: column;
  }

  .doc-select__name {
    font-size: 16px;
    font-weight: 600;
    line-height: 21px;
  }

  .doc-select__description {
    color: var(--color-muted);
    font-size: 13px;
    line-height: 18px;
  }

  .doc-select__option--coming {
    .doc-select__name { color: var(--color-muted); }
    .doc-select__picture { opacity: 0.55; }
  }

  .doc-select__coming {
    color: var(--color-muted);
    font: 500 12px/16px var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .doc-select__empty,
  .doc-select__more {
    color: var(--color-muted);
    font: var(--text-caption);
    padding: 8px 10px 4px;
  }

  /* Step 1 (founder's pick, 17 Nov 2026, design-explorations/choose-document A): the select and
   * the document in one warm card, the example beside it, the button pinned on a phone. On a
   * desktop the button closes the card. */
  .doc-step {
    @media (min-width: 900px) {
      grid-template-areas: "main example" "bar example";
      grid-template-columns: repeat(2, minmax(0, 1fr));
      grid-template-rows: auto 1fr;
      row-gap: 0;

      .flow__main { grid-area: main; }
    }
  }

  .doc-step__card {
    background: var(--color-warm);
    border: 1px solid var(--color-hairline);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px 16px 18px;

    @media (min-width: 900px) {
      border-block-end: 0;
      border-end-end-radius: 0;
      border-end-start-radius: 0;
      gap: 20px;
      padding: 28px 24px 20px;
    }

    /* The label sits on the select's border. */
    .doc-select { gap: 0; }

    .doc-select__label {
      background: var(--color-surface);
      font-size: 13px;
      inset-block-start: -8px;
      inset-inline-start: 11px;
      line-height: 16px;
      padding: 0 4px;
      position: absolute;
      z-index: 1;
    }

    /* On a phone the open list stops above the pinned button and scrolls. */
    .doc-select__menu {
      @media (max-width: 760px) {
        max-block-size: 226px;
        overflow-y: auto;
      }
    }
  }

  .doc-step__example {
    gap: 12px;

    @media (min-width: 900px) {
      grid-area: example;
      padding-block-start: 6px;
    }
  }

  .doc-step__bar {
    @media (min-width: 900px) {
      align-self: start;
      grid-area: bar;
      background: var(--color-warm);
      border: 1px solid var(--color-hairline);
      border-block-start: 0;
      border-end-end-radius: 14px;
      border-end-start-radius: 14px;
      padding: 0 24px 22px;

      .flow__button { inline-size: 100%; }
      .flow__note { text-align: center; }
    }
  }

  /* The document itself, beside the three things it needs from the file. */
  .document-card {
    align-items: start;
    display: grid;
    gap: 16px;
    grid-template-columns: 104px minmax(0, 1fr);

    @media (min-width: 900px) {
      gap: 22px;
      grid-template-columns: 150px minmax(0, 1fr);
    }
  }

  /* The pictures are 3:2: the space is kept before the image loads. */
  .document-card__picture {
    aspect-ratio: 3 / 2;
    border: 1px solid var(--color-hairline);
    border-radius: 4px;
    inline-size: 100%;
    object-fit: cover;
  }

  .document-card__text {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .document-card__name {
    border-block-end: 1px solid color-mix(in srgb, var(--color-hairline), var(--color-ink) 8%);
    font-size: 17px;
    font-weight: 600;
    line-height: 24px;
    padding-block-end: 8px;
  }

  .document-card__source {
    color: var(--color-muted);
    font: var(--text-caption);
  }

  .document-card__spec {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding-block: 6px;

    div {
      display: flex;
      flex-wrap: wrap;
      font-size: 16px;
      gap: 0 8px;
      line-height: 22px;
    }

    dt { color: var(--color-muted); }
    dd { font-weight: 600; margin: 0; }
  }

  /* A photo as taken beside the same photo as delivered, the delivered one with its size
   * on two sides. Both keep room for the brackets, so the two photos line up. */
  .photo-pair {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-inline-size: 640px;

    @media (min-width: 900px) { gap: 10px; }
  }

  .photo-pair__item {
    margin: 0;
    padding: 24px 22px 0 0;
    position: relative;
  }

  .photo-pair__photo {
    aspect-ratio: 1;
    background: var(--color-placeholder);
    border: 1px solid var(--color-hairline);
    border-radius: 12px;
    overflow: hidden;

    img {
      block-size: 100%;
      inline-size: 100%;
      object-fit: cover;
    }
  }

  .photo-pair__tab {
    background: var(--color-ink);
    border-end-start-radius: 12px;
    border-start-end-radius: 8px;
    color: var(--color-on-ink);
    font: 500 11px/16px var(--font-mono);
    inset-block-end: 0;
    inset-inline-start: 0;
    letter-spacing: 0.06em;
    padding: 5px 10px;
    position: absolute;
    text-transform: uppercase;
  }

  .photo-pair__item--sized {
    &::before,
    &::after {
      content: "";
      position: absolute;
    }

    /* Over the photo, and down its side. */
    &::before {
      background: linear-gradient(var(--color-ink), var(--color-ink)) center / 100% 1.5px no-repeat;
      block-size: 11px;
      border-inline: 1.5px solid var(--color-ink);
      inset-block-start: 6px;
      inset-inline: 0 22px;
    }

    &::after {
      background: linear-gradient(var(--color-ink), var(--color-ink)) center / 1.5px 100% no-repeat;
      border-block: 1.5px solid var(--color-ink);
      inline-size: 11px;
      inset-block: 24px 0;
      inset-inline-end: 6px;
    }
  }

  .photo-pair__size {
    background: var(--color-ink);
    border-radius: 3px;
    color: var(--color-on-ink);
    font: 500 11px/14px var(--font-mono);
    letter-spacing: 0.04em;
    padding: 2px 5px;
    position: absolute;
    text-transform: uppercase;
    white-space: nowrap;
    z-index: 1;
  }

  .photo-pair__size--width {
    inset-block-start: 4px;
    inset-inline-start: calc(50% - 11px);
    translate: -50% 0;
  }

  .photo-pair__size--height {
    inset-block-start: calc(50% + 12px);
    inset-inline-end: 11px;
    rotate: 90deg;
    translate: 50% -50%;
  }
}
