/* =========================================================================
   The purchase order form's own piece: the order lines.

   Everything else on the page is form.css - this is only the repeating line
   editor, which no other form has. A line is product, quantity, its own money,
   and a way to drop it; on a narrow screen it stacks rather than squeezing a
   select into a third of a phone.
   ========================================================================= */

.po-lines__label {
  font-size: .78rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft);
}
.po-lines__note {
  margin: .25rem 0 .7rem; font-size: .8rem; color: var(--ink-faint);
}
.po-lines__empty {
  margin: 0; padding: .9rem 1rem; font-size: .88rem; color: var(--ink-soft);
  border: 1px dashed var(--hairline); border-radius: var(--radius);
}

.po-lines { display: flex; flex-direction: column; gap: .55rem; }

.po-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7rem 5.5rem 2rem;
  gap: .6rem; align-items: end;
  padding: .7rem .8rem;
  border: 1px solid var(--hairline); border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper-warm) 55%, transparent);
}

.po-line__label {
  display: block; margin-bottom: .25rem;
  font-size: .68rem; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--ink-faint);
}

/* Matching form.css's fields rather than inheriting them: `.field input` is
   scoped to `.field`, and a line is not one. */
.po-line__sku,
.po-line__n {
  width: 100%;
  font: inherit; font-size: .92rem;
  padding: .5rem .6rem;
  border: 1px solid var(--hairline); border-radius: 6px;
  background: var(--paper); color: var(--ink);
}
.po-line__sku:focus,
.po-line__n:focus { outline: 2px solid var(--green); outline-offset: 1px; }

.po-line__sum {
  margin: 0 0 .5rem; text-align: right;
  font-family: var(--mono); font-size: .85rem; color: var(--ink-soft);
  white-space: nowrap;
}

.po-line__drop {
  margin-bottom: .35rem;
  width: 1.8rem; height: 1.8rem; padding: 0;
  font-size: 1.1rem; line-height: 1;
  color: var(--ink-faint); background: none;
  border: 1px solid var(--hairline); border-radius: 6px;
  cursor: pointer; transition: color .15s, border-color .15s;
}
.po-line__drop:hover:not(:disabled) { color: var(--terracotta); border-color: var(--terracotta); }
.po-line__drop:disabled { opacity: .3; cursor: default; }

.po-lines__foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-top: .8rem;
}
.po-total {
  margin: 0; font-family: var(--mono); font-size: .82rem;
  letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint);
}
.po-total strong {
  font-size: 1.05rem; color: var(--ink); margin-left: .4rem;
  letter-spacing: 0; text-transform: none;
}

@media (max-width: 620px) {
  .po-line {
    grid-template-columns: minmax(0, 1fr) 2rem;
    align-items: start;
  }
  .po-line__product { grid-column: 1; }
  .po-line__qty { grid-column: 1; }
  .po-line__sum { grid-column: 1; text-align: left; margin-bottom: 0; }
  .po-line__drop { grid-column: 2; grid-row: 1; margin-bottom: 0; }
}

/* =========================================================================
   "Flow responded with:" - the answer to a blocking call.

   A blocking call is the one where the learner waits, so the answer is the
   event of the page and it gets the screen. A non-blocking call answers with a
   receipt instead, which stays in the status line under the form where it
   belongs. Hidden with the `hidden` attribute, which site.css enforces with
   `!important`, so there is no display rule here to fight it.
   ========================================================================= */

.po-modal {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
}
.po-modal__scrim {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--ink) 58%, transparent);
  backdrop-filter: blur(2px);
}

.po-modal__card {
  position: relative;
  display: flex; flex-direction: column;
  width: min(48rem, 100%); max-height: min(80vh, 44rem);
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0,0,0,.34);
  animation: po-modal-in .16s ease-out;
}
@keyframes po-modal-in {
  from { opacity: 0; transform: translateY(.6rem) scale(.99); }
}
@media (prefers-reduced-motion: reduce) {
  .po-modal__card { animation: none; }
}

.po-modal__head { padding: 1.1rem 1.3rem .8rem; border-bottom: 1px solid var(--hairline); }
.po-modal__eyebrow {
  margin: 0 0 .3rem; font-family: var(--mono); font-size: .68rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint);
}
.po-modal__title { margin: 0; font-size: 1.25rem; }

/* The answer itself: monospace, scrolls in both directions rather than forcing
   the dialog wider than the screen. */
.po-modal__body {
  margin: 0; padding: 1.1rem 1.3rem;
  overflow: auto; flex: 1 1 auto;
  font-family: var(--mono); font-size: .82rem; line-height: 1.6;
  white-space: pre; tab-size: 2;
  background: color-mix(in srgb, var(--paper-warm) 60%, transparent);
}
.po-modal__body:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }

.po-modal__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 1.3rem; border-top: 1px solid var(--hairline);
}
.po-modal__note { margin: 0; font-size: .8rem; color: var(--ink-faint); max-width: 44ch; }

/* An answer that is not a 2xx is still an answer, and still worth reading - it
   is marked, not hidden away in an error state. */
.po-modal[data-kind='error'] .po-modal__card { border-top: 3px solid var(--terracotta); }
.po-modal[data-kind='ok'] .po-modal__card { border-top: 3px solid var(--green); }
