@layer components {
  /* A flat sand card with a hairline: the contact page's card (pages/contact). */
  .flow-card {
    background: var(--color-surface);
    border: 1px solid var(--color-hairline);
    border-radius: var(--rounded-lg);
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;

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

  /* The flow's steps on two sides, each the full height of the window, as the landing course draws them:
   * "Choose your document" (step 1, documents/index, ../landing/pages/choose-document/design.html) and the
   * photo state of "Add your photo" (step 2, checks/_photo, ../landing/pages/add-photo/design.html), both
   * approved 27 Nov 2026, then the check and its result (step 3), the checkout (step 4) and the order once
   * paid (step 5). Left, on warm white, the logo row, the step line, the headline and the step's work; right,
   * on sand with a hairline on its left, a raised card that stays in view while the left side scrolls. Under
   * 1024px one column, the card after the work. No site header and no footer: the page provides :bare. Only
   * .flow-page__top, .flow-page__column and .flow-page__aside set side padding, and the steps' pinned bars
   * (.add-bar and .check-actions in check.css, .pay-bar and .done-actions in order.css) take the same
   * --flow-gutter. Step 1's values are the block's; .flow-page--add, --check, --pay and --done hold where
   * steps 2 to 5 differ. */
  .flow-page {
    --flow-gutter: 40px;
    --flow-column: 560px;
    --flow-head-top: calc(44px + clamp(28px, 7vh, 60px)); /* where the kept top stands: the logo row and the space under it */

    display: grid;
    grid-template-columns: minmax(0, 54fr) minmax(0, 46fr);
    min-block-size: 100vh;
    min-block-size: 100dvh;

    @media (min-width: 1024px) and (max-height: 780px) {
      --flow-head-top: 62px;
    }

    /* From 1024px to 1180px the two sides are narrower: less space at the sides of the left one. */
    @media (min-width: 1024px) and (max-width: 1180px) {
      --flow-gutter: 32px;
    }

    @media (max-width: 1023px) {
      --flow-gutter: 32px;
      --flow-column: 640px;

      display: flex;
      flex-direction: column;
    }

    @media (max-width: 600px) {
      --flow-gutter: 20px;
    }
  }

  .flow-page__main {
    display: flex;
    flex-direction: column;
    min-inline-size: 0;

    /* One column: the logo, the step's work, then the card. */
    @media (max-width: 1023px) {
      display: contents;
    }
  }

  .flow-page__top,
  .flow-page__column {
    padding-inline: var(--flow-gutter);
  }

  /* The logo, and on step 2 the chosen document at the right end of the row. */
  .flow-page__top {
    align-items: flex-end;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding-block: 22px 0;

    .logo {
      display: flex;
      flex: none;
    }

    @media (min-width: 1024px) and (min-height: 620px) {
      inset-block-start: 0;
      position: sticky;
      z-index: 7;
    }

    @media (min-width: 1024px) and (max-height: 780px) {
      padding-block-start: 18px;
    }

    @media (max-width: 1023px) {
      order: 1;
      padding-block-start: 18px;
    }

    @media (max-width: 600px) {
      padding-block-start: 16px;
    }
  }

  .flow-page__column {
    flex: 1;
    inline-size: 100%;
    margin-inline: auto;
    max-inline-size: calc(var(--flow-column) + 2 * var(--flow-gutter));
    padding-block: clamp(28px, 7vh, 60px) 36px;

    @media (min-width: 1024px) and (max-height: 780px) {
      padding-block-start: 22px;
    }

    @media (max-width: 1023px) {
      flex: none;
      order: 2;
      padding-block: 22px 28px;
    }

    @media (max-width: 600px) {
      padding-block-start: 18px;
    }
  }

  /* The top of the left side, the step line and the headline (and on step 1 the search field), is one
   * group. On a computer it stays where it is with the logo, and only what follows scrolls under them (the
   * founder's question of 27 Nov 2026). The window still scrolls, so the wheel works with the mouse anywhere
   * and the left side has no scrollbar of its own. On a phone, a tablet or a low window the group would
   * take too much of the screen, so it is no box at all (and on step 1 only the search field stays). */
  .flow-page__head {
    display: contents;

    @media (min-width: 1024px) and (min-height: 620px) {
      background: var(--color-ground);
      display: block;
      inset-block-start: var(--flow-head-top);
      margin-inline: -8px;
      padding-inline: 8px;
      position: sticky;
      z-index: 5;

      /* The warm white above the group, up to the top of the window. */
      &::before {
        background: var(--color-ground);
        block-size: 160px;
        content: "";
        inset-block-end: 100%;
        inset-inline: 0;
        position: absolute;
      }
    }
  }

  /* The step line: five short bars, the steps reached in charcoal, and "Step 1 of 5" under them. */
  .flow-page__steps {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .flow-page__bar {
    background: var(--color-hairline);
    block-size: 4px;
    border-radius: var(--rounded-full);
  }

  .flow-page__bar--done {
    background: var(--color-ink);
  }

  .flow-page__step {
    color: var(--color-muted);
    font: var(--text-label);
    font-weight: 600;
    margin-block-start: 22px;

    @media (min-width: 1024px) and (max-height: 780px) {
      margin-block-start: 16px;
    }

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

  /* The brand's display, 30px from 600px down. */
  .flow-page__title {
    font-size: 40px;
    line-height: 1.08;
    margin-block-start: 6px;

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

  /* The mint marker under "your document", "your photo" or "again": the headlines of the two sides are the
   * ones the brand allows it on (AGENTS.md, Brand). */
  .flow-page__mark {
    position: relative;
    white-space: nowrap;
    z-index: 0;

    &::after {
      background: var(--color-accent);
      block-size: 0.34em;
      border-radius: 0.55em 0.2em 0.6em 0.3em / 0.35em 0.6em 0.3em 0.5em;
      content: "";
      inset-block-end: 0.02em;
      inset-inline: -0.08em -0.06em;
      position: absolute;
      rotate: -1.5deg;
      z-index: -1;
    }
  }

  /* The card's side: sand, with dots in the hairline colour 22px apart. */
  .flow-page__aside {
    align-items: center;
    align-self: start;
    background-color: var(--color-surface);
    background-image: radial-gradient(var(--color-hairline) 1px, transparent 1.5px);
    background-size: 22px 22px;
    block-size: 100vh;
    block-size: 100dvh;
    border-inline-start: 1px solid var(--color-hairline);
    display: flex;
    flex-direction: column;
    gap: 18px;
    inset-block-start: 0;
    justify-content: center;
    overflow: hidden;
    padding: 28px 24px;
    position: sticky;

    @media (min-width: 1024px) and (max-height: 700px) {
      gap: 14px;
      padding-block: 18px;
    }

    @media (max-width: 1023px) {
      background: none;
      block-size: auto;
      border-inline-start: 0;
      inline-size: 100%;
      margin-inline: auto;
      max-inline-size: calc(var(--flow-column) + 2 * var(--flow-gutter));
      order: 3;
      overflow: visible;
      padding-block: 0 40px;
      padding-inline: var(--flow-gutter);
      position: static;
    }
  }

  .flow-page__caption {
    color: var(--color-muted);
    font: 400 14px/1.55 var(--font-sans);
    max-inline-size: 396px;
    text-align: center;
    text-wrap: pretty;

    @media (min-width: 1024px) and (max-height: 700px) {
      font-size: 13px;
    }

    @media (min-width: 1024px) and (max-height: 600px) {
      display: none;
    }

    @media (max-width: 1023px) {
      max-inline-size: 46ch;
    }
  }

  .flow-page__title:focus {
    outline: none; /* the check page moves the focus here when it comes back to its photo state */
  }

  /* "Add your photo", step 2: its left side ends with its work and no room under it, followed on a touch
   * screen by its one button; its kept group has a little warm white under the headline; its card's side
   * is tighter from 780px tall down, with more room above the card in one column; its caption keeps its
   * size and goes from 660px tall down. */
  .flow-page--add {
    .flow-page__column {
      flex: none;
      padding-block-end: 32px;

      @media (pointer: coarse) {
        padding-block-end: 22px;
      }

      @media (max-width: 1023px) {
        padding-block-end: 0;
      }
    }

    .flow-page__head {
      @media (min-width: 1024px) and (min-height: 620px) {
        padding-block-end: 4px;
      }
    }

    .flow-page__aside {
      @media (min-width: 1024px) and (max-height: 780px) {
        gap: 14px;
        padding-block: 18px;
      }

      @media (max-width: 1023px) {
        padding-block: 22px 32px;
      }

      @media (max-width: 600px) {
        padding-block-start: 18px;
      }
    }

    .flow-page__caption {
      @media (min-width: 1024px) and (max-height: 700px) {
        font-size: 14px;
      }

      @media (min-width: 1024px) and (max-height: 660px) {
        display: none;
      }
    }
  }

  /* The check running and its result, step 3 (checks/_check, ../landing/pages/check-result/design.html):
   * its left side ends with its work, followed by the result's main button (.check-actions, check.css); its
   * kept group has a little warm white under the headline. Under 1024px the photo comes before the details:
   * the left side is no box, so its parts and the card stand in one column, the headline and its sentence,
   * the card, then the details (the stages, or the six checks and the link), and the main button pinned to
   * the bottom of the screen. Each part takes the column's width and gutters there. */
  .flow-page--check {
    .flow-page__column {
      flex: none;
      padding-block-end: 0;

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

    .flow-page__head {
      @media (min-width: 1024px) and (min-height: 620px) {
        padding-block-end: 4px;
      }
    }

    .flow-page__aside {
      @media (max-width: 1023px) {
        padding-block: 20px 0;
      }

      @media (max-width: 600px) {
        padding-block-start: 16px;
      }
    }

    @media (max-width: 1023px) {
      .flow-page__head > *,
      .flow-page__column > * {
        inline-size: 100%;
        margin-inline: auto;
        max-inline-size: calc(var(--flow-column) + 2 * var(--flow-gutter));
        order: 2;
        padding-inline: var(--flow-gutter);
      }

      .flow-page__column > .flow-page__details {
        order: 4;
      }

      .flow-page__steps {
        margin-block-start: 22px;

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

  /* The checkout, step 4 (orders/states/_unpaid and _confirming, ../landing/pages/checkout/design.html): its
   * left side ends with the payment and the line under it, and its kept group has a little warm white under
   * the headline; Paddle's form is tall, so on a computer the left side scrolls under the kept top. Under
   * 1024px one column, in the order the checkout had: the headline, the photo and its name, the payment, the
   * line, the rest of the order and the total pinned to the bottom of the screen. The left side, the card's
   * side and the card (.pay-card, order.css) are no boxes there, so their parts stand in one column, each as
   * wide as the column, in the order its own block gives it (order.css). */
  .flow-page--pay {
    .flow-page__head {
      @media (min-width: 1024px) and (min-height: 620px) {
        padding-block-end: 4px;
      }
    }

    @media (max-width: 1023px) {
      .flow-page__column,
      .flow-page__aside {
        display: contents;
      }

      .flow-page__head > *,
      .flow-page__column > :not(.flow-page__head) {
        inline-size: calc(100% - 2 * var(--flow-gutter));
        margin-inline: auto;
        max-inline-size: var(--flow-column);
      }

      .flow-page__head > * {
        order: 2;
      }

      .flow-page__steps {
        margin-block-start: 22px;

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

  /* The order once paid, step 5 (orders/_paid, ../landing/pages/order-page/design.html): nothing here is long,
   * so on a computer the top of the left side doesn't stay in place and the page scrolls as one. On "Retake
   * needed", "Refunded" and "Closed" there are no bars and the step line, the order, comes first. Under 1024px
   * one column, the photo before the details: the left side is no box, so its parts and the card stand in one
   * column, each as wide as the column, in this order: the headline, its line and the flash alert (2), the
   * card "Your photo" (3), the sheet, the list and the boxes (4), the card "Your order" (5), the last lines
   * (6), room to end the page on (8) and the main button pinned to the bottom of the screen (9, .done-actions
   * in order.css). */
  .flow-page--done {
    .flow-page__top {
      @media (min-width: 1024px) and (min-height: 620px) {
        position: static;
      }
    }

    .flow-page__column {
      @media (min-width: 1024px) and (max-height: 780px) {
        padding-block: 20px 16px;
      }

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

    .flow-page__head {
      @media (min-width: 1024px) and (min-height: 620px) {
        background: none;
        margin-inline: 0;
        padding-inline: 0;
        position: static;

        &::before { content: none; }
      }
    }

    .flow-page__step:first-child {
      @media (min-width: 1024px) {
        margin-block-start: 0;
      }
    }

    .flow-page__aside {
      @media (max-width: 1023px) {
        margin-block-start: 20px;
        padding-block: 0;
      }

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

      /* The card "Your order" comes after the list. */
      &:has(.pay-card) {
        @media (max-width: 1023px) {
          margin-block-start: 24px;
          order: 5;
        }
      }
    }

    @media (max-width: 1023px) {
      .flow-page__head > *,
      .flow-page__column > :not(.flow-page__head, .done-actions) {
        inline-size: calc(100% - 2 * var(--flow-gutter));
        margin-inline: auto;
        max-inline-size: var(--flow-column);
        order: 2;
      }

      .flow-page__column > :is(.done-sheet, .done-track, .done-hint, .done-notice:not([role="alert"])) {
        order: 4;
      }

      .flow-page__column > .done-hint {
        margin-block-start: 16px;
      }

      .flow-page__column > :is(.done-again, .done-note) {
        order: 6;
      }

      .flow-page__steps {
        margin-block-start: 22px;

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

      &::after {
        block-size: 28px;
        content: "";
        flex: none;
        order: 8;
      }
    }
  }

  /* The load effect, only with motion allowed, on the steps and on the pages where the flow stops (.stop,
   * order.css): once the page is shown, each item fades in and rises, after its own delay, from the top down
   * (reveal_controller.js), on a full load only: html.js-motion holds the start state. Without a script, or
   * with reduced motion, nothing moves and the page is whole. The transition is a default (:where), so an
   * item with a transition of its own (step 2's drop area) can add to it. */
  @media screen and (prefers-reduced-motion: no-preference) {
    .js-motion :is(.flow-page, .stop) [data-reveal-target~="item"]:not([data-revealed]) {
      opacity: 0;
      translate: 0 16px;
    }

    :where(:is(.flow-page, .stop) [data-revealed]) {
      transition:
        opacity 500ms cubic-bezier(0.2, 0.7, 0.2, 1) var(--reveal-delay, 0ms),
        translate 500ms cubic-bezier(0.2, 0.7, 0.2, 1) var(--reveal-delay, 0ms);
    }
  }
}
