/* ==========================================================================
   Explain8 order, checkout and billing screens (Operate mode).
   Builds on site.css and portal.css: suite title band, fills for panels,
   tabular numerals for every amount. Tokens only. Tables keep their lines.

   Contents
     1  Title band and step track
     2  Order layout and the running summary (suite panel)
     3  Order form: package presets, add-ons
     4  Review page: totals strip, seller, billing details
     5  Billing: orders table, extra work
     6  Receipt and print
   ========================================================================== */

/* 1 Title band and step track ------------------------------------------------- */

.order-head {
  padding-block: clamp(1.5rem, 3.2vw, 2.5rem) clamp(1.25rem, 2.6vw, 2rem);
}

.order-head .container {
  display: grid;
  gap: 0.35rem;
}

.order-head .lede {
  max-width: 46rem;
  margin: 0.5rem 0 0;
  font-size: var(--step-body);
  font-weight: 450;
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--on-suite);
}

.order-head .app-head-meta {
  color: var(--on-suite-soft);
}

/* The step strip is the timeline above the form: one bar per step, the playhead (amber) on the current one. */
.order-steps-nav {
  padding: 1rem 1.25rem 1.1rem;
  border-radius: var(--radius);
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.order-steps {
  display: flex;
}

.order-steps > li {
  display: flex;
  flex: 1 1 0;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--on-suite-soft);
  font-size: var(--step-small);
  font-weight: 650;
  line-height: 1.3;
}

.order-steps-number {
  font-variant-numeric: tabular-nums;
}

.order-steps > li.is-done {
  color: var(--on-suite);
}

.order-steps > li[aria-current="step"] {
  color: var(--paper);
  font-weight: 750;
}

/* On a phone only the current step keeps its label and gets the width; the bars still show progress. */
@media (max-width: 39.99rem) {
  .order-steps > li[aria-current="step"] {
    flex-grow: 3;
  }

  .order-steps > li:not([aria-current="step"]) .order-steps-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .order-steps > li:not([aria-current="step"]) .order-steps-number {
    display: none;
  }
}

.order-body {
  padding-block: clamp(1.5rem, 3.5vw, 2.5rem) clamp(2.5rem, 5vw, 4.5rem);
}

/* 2 Order layout and the running summary ------------------------------------------ */

.order-layout {
  display: grid;
  gap: clamp(1.25rem, 3vw, 2rem);
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.order-layout > .order-required {
  grid-column: 1 / -1;
  margin: 0;
}

@media (min-width: 62rem) {
  .order-layout {
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 24rem);
  }

  .order-layout > aside {
    position: sticky;
    top: calc(var(--header-h) + 1.5rem);
  }
}

/* The summary is the export dialog: a suite panel, the running total in display numerals. */
.order-summary {
  display: grid;
  gap: 1rem;
  align-content: start;
  padding: var(--panel-pad);
  border-radius: var(--radius);
}

.order-summary > * {
  margin: 0;
}

.order-summary .kv > div {
  grid-template-columns: minmax(6rem, 8rem) minmax(0, 1fr);
  gap: 0.1rem 1rem;
}

.order-lines {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.order-lines:empty {
  display: none;
}

.order-lines > li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  background: var(--suite-2);
}

.order-subtotal {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.25rem;
}

.order-subtotal > span {
  font-size: var(--step-small);
  font-weight: 650;
  color: var(--on-suite-soft);
}

.order-subtotal strong {
  font-family: var(--font-display);
  font-size: clamp(2rem, 1.6rem + 1.2vw, 2.5rem);
  font-stretch: 84%;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--paper);
}

/* 3 Order form: package presets, add-ons -------------------------------------------- */

.order-form {
  display: grid;
  gap: 1.25rem;
  min-width: 0;
}

.order-form > * {
  margin: 0;
}

.order-step {
  display: grid;
  gap: 1.25rem;
  align-content: start;
}

.order-step > * {
  margin: 0;
}

.order-step .field {
  margin-bottom: 0;
}

.order-step .field-row .field {
  margin-bottom: 1.35rem;
}

.order-step .field-row .field:last-child {
  margin-bottom: 0;
}

.order-nav,
.order-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin: 0;
}

/* A package is a preset: pick one, the chosen one becomes a filled suite panel. */
.package-options {
  display: grid;
  gap: 0.5rem;
}

.package-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0 1rem;
  margin: 0;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  background: var(--fog);
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--t-hover) ease, color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}

.package-option:active {
  transform: scale(0.99);
}

@media (hover: hover) {
  .package-option:hover {
    background: var(--fog-2);
  }

  .package-option:has(input:checked):hover {
    background: var(--suite);
  }
}

.package-option:has(input:checked) {
  background: var(--suite);
  color: var(--on-suite);
}

.package-option:has(input:focus-visible) {
  outline: 3px solid var(--signal);
  outline-offset: 3px;
}

.field.has-error .package-option {
  background: var(--bad-bg);
}

.package-option > input {
  appearance: none;
  width: 1.4rem;
  height: 1.4rem;
  margin: 0.15rem 0 0;
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: var(--paper);
  transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease, box-shadow var(--t-hover) ease;
}

.package-option > input:focus-visible {
  outline: none;
}

.package-option > input:checked {
  border-color: var(--signal-bright);
  background: var(--signal-bright);
  box-shadow: inset 0 0 0 0.25rem var(--suite);
}

.package-option-body {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.package-option-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.15rem 1rem;
}

.package-option-name,
.package-option-price {
  font-family: var(--font-display);
  font-size: var(--step-h3);
  font-stretch: 86%;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.package-option-price {
  font-variant-numeric: tabular-nums;
}

.package-option-copy {
  color: var(--slate);
  line-height: 1.5;
}

.package-option-runtime {
  font-weight: 700;
  color: var(--ink);
}

.package-option:has(input:checked) .package-option-copy {
  color: var(--on-suite-soft);
}

.package-option:has(input:checked) .package-option-runtime {
  color: var(--paper);
}

.order-addon {
  display: grid;
  gap: 1rem;
}

.order-addon > * {
  margin: 0;
}

.order-addon h3 {
  margin-bottom: 0;
}

.order-addon .check {
  margin: 0;
}

.order-addon:has(input[data-order-guided]:checked) {
  background: var(--wash);
}

.order-addon.has-error {
  background: var(--bad-bg);
}

.order-form input[readonly] {
  background-color: var(--fog);
  color: var(--slate);
  cursor: default;
}

/* 4 Review page: totals strip, seller, billing details --------------------------------- */

.order-page-stack {
  min-width: 0;
}

.order-lines-table th[scope="row"],
.statement-lines th[scope="row"] {
  min-width: 9rem;
}

/* Four short columns fit a phone without a scrolling frame. */
.table-wrap > .order-lines-table,
.table-wrap > .statement-lines {
  min-width: 0;
}

@media (max-width: 39.99rem) {
  .order-lines-table :is(th, td),
  .statement-lines :is(th, td) {
    padding-inline: 0.6rem;
  }
}

/* The totals read like the bar at the bottom of an edit: a suite strip, the amount due in display numerals. */
.order-totals {
  gap: 0.15rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
}

.order-totals > div,
.order-totals > div:first-child,
.order-totals > div:last-child {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.15rem 1rem;
  padding: 0.3rem 0;
}

.order-totals dt {
  font-size: var(--step-body);
  font-weight: 600;
}

.order-totals dd {
  margin-left: auto;
  color: var(--on-suite);
}

.order-totals .muted {
  display: block;
}

.order-totals > div.order-total-row {
  margin-top: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  background: var(--suite-2);
}

.order-total-row dt {
  color: var(--on-suite);
  font-weight: 700;
}

.order-total-row dd strong {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 1.4rem + 1vw, 2.25rem);
  font-stretch: 84%;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--paper);
}

.order-seller {
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  background: var(--fog);
}

.order-seller h3 {
  margin: 0 0 0.35rem;
}

.order-seller p {
  margin: 0;
}

.order-seller p + p {
  margin-top: 0.6rem;
}

.order-billing {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.order-billing > * {
  margin: 0;
}

.billing-pair {
  display: grid;
  gap: clamp(1.25rem, 3vw, 2rem);
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

@media (min-width: 56rem) {
  .billing-pair {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  }
}

/* 5 Billing: orders table, extra work ------------------------------------------------- */

.billing-table {
  min-width: 52rem;
}

.billing-table tbody th[scope="row"] {
  white-space: nowrap;
}

/* The order number stays in view while the rest of a wide table scrolls inside its frame. */
.billing-table thead th:first-child,
.billing-table tbody th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
}

.billing-table tbody th:first-child {
  background: var(--paper);
}

.billing-table thead th:first-child {
  background: var(--fog-2);
}

.billing-table tbody td:nth-child(3) {
  white-space: nowrap;
}

@media (hover: hover) {
  .billing-table tbody tr:hover > * {
    background: var(--fog);
  }
}

.billing-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.billing-actions a {
  white-space: nowrap;
}

.billing-extra {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.billing-extra > li {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  background: var(--fog);
}

.billing-extra p {
  margin: 0;
}

.billing-extra .actions {
  margin-top: 0.25rem;
}

/* 6 Receipt and print ---------------------------------------------------------------- */

.statement {
  max-width: 44rem;
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
}

.statement-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: clamp(1.25rem, 3vw, 1.75rem) clamp(1.25rem, 3vw, 2rem);
}

.statement-head h1 {
  font-size: var(--app-h1);
}

.statement-body {
  padding: clamp(1.25rem, 3vw, 2rem);
}

.statement-ref {
  margin: 0;
}

.statement-ref dt {
  font-size: var(--step-small);
  font-weight: 650;
  color: var(--muted);
}

.statement-ref dd {
  margin: 0.1rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.4rem);
  font-stretch: 84%;
  font-weight: 800;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.statement-reference {
  overflow-wrap: anywhere;
}

.statement-parties {
  display: grid;
  gap: 1.25rem 2rem;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 40rem) {
  .statement-parties {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.statement-subhead {
  margin: 0;
  font-family: var(--font-text);
  font-size: var(--step-small);
  font-stretch: 100%;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--muted);
}

@media print {
  .order-steps-nav,
  .app-back,
  .sidebar {
    display: none !important;
  }

  .portal-layout {
    display: block;
    padding: 0;
  }

  .statement {
    max-width: none;
  }

  .statement-head,
  .order-totals {
    background: none;
    color: black;
  }

  .statement-head {
    border-bottom: 2px solid black;
  }

  .order-totals dd,
  .order-total-row dt,
  .order-total-row dd strong {
    color: black;
  }
}
