/* ==========================================================================
   MKH - Numbering
   Visual language from the Claude Design project.
   Requires tokens.css, base.css, components.css and layout.css.

   The Numbering tab of Settings: three running numbers, each built from a few
   short parts. The parts are small and the preview is the point, so the layout
   puts the fields on one line and gives the result its own block underneath.
   ========================================================================== */

/* --------------------------------------------------------------------------
   The parts of a number
   -------------------------------------------------------------------------- */

/* Reads left to right in the order the number is built: starts with, year,
   then, digits, ends with. auto-fit so the row breaks where it must rather
   than at a width guessed here. */
.seq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-3) var(--sp-4);
  align-items: start;
}

/* The reset choice and the counter, which are about where the series stands
   rather than how it looks. Given room because the checkbox carries a
   sentence. */
.seq-grid--foot {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
}

.seq-grid .field { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   What it produces
   -------------------------------------------------------------------------- */

/* The answer to the only question this screen asks, so it is given its own
   block rather than a note under a field. Tinted, because it is a result and
   not another input. */
.seq-preview {
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

/* Over sixteen characters an invoice number is not legal, so the block says so
   in the same way a field does. */
.seq-preview.is-over { border-color: var(--bad); }

.seq-preview__main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
}

.seq-preview__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--txt-3);
}

.seq-preview__value {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--txt);
  word-break: break-all;
}

.seq-preview__meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-3);
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--txt-3);
}

/* The character count, which is half the answer for an invoice number. */
.seq-preview__count { white-space: nowrap; }
.seq-preview__count.is-over { color: var(--bad-fg); font-weight: var(--fw-semibold); }

/* Each sequence saves on its own, so the buttons belong to the card and sit in
   its footer, pushed to the trailing edge. */
.seq-foot { justify-content: flex-end; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Narrowing
   -------------------------------------------------------------------------- */

@container content (max-width: 620px) {
  /* The checkbox sentence and the counter stop sharing a line comfortably. */
  .seq-grid--foot { grid-template-columns: minmax(0, 1fr); }

  /* Label above value rather than beside it, so a long number keeps the width. */
  .seq-preview__main { display: block; }
  .seq-preview__label { display: block; margin-bottom: 4px; }
  .seq-preview__meta { flex-direction: column; }
}

@supports not (container-type: inline-size) {
  @media (max-width: 900px) {
    .seq-grid--foot { grid-template-columns: minmax(0, 1fr); }
    .seq-preview__main { display: block; }
    .seq-preview__label { display: block; margin-bottom: 4px; }
    .seq-preview__meta { flex-direction: column; }
  }
}
