/* ══════════════════════════════════════════════
   Order Pages
   ══════════════════════════════════════════════ */

.order-page h1,
.order-detail-page h1,
.order-list-page h1 {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

/* Order Form Layout */
.order-layout {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-lg);
  align-items: start;
}

@media (max-width: 768px) {
  .order-layout {
    grid-template-columns: 1fr;
  }
}

.order-summary-card,
.order-form-card {
  padding: var(--space-lg);
}

.order-details-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-xs) var(--space-md);
}

.order-details-list dt {
  color: var(--text-secondary);
  font-weight: 500;
}

.order-details-list dd {
  margin: 0;
}

.order-total-label {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: -0.005em;
  padding-top: 0.85rem;
  margin-top: 0.4rem;
  border-top: 1px solid var(--mp-color-divider);
  color: var(--text-primary);
}

.order-total-value {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.5rem;
  padding-top: 0.85rem;
  margin-top: 0.4rem;
  border-top: 1px solid var(--mp-color-divider);
  color: var(--mp-color-accent);
  letter-spacing: -0.01em;
  line-height: 1;
}

.order-details-list {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
}

.order-details-list dt {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 0.9375rem;
}

.order-details-list dd {
  color: var(--text-primary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.order-address {
  font-style: normal;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text-primary);
}

.order-address strong {
  font-weight: 600;
  color: var(--text-primary);
}

.order-eta {
  margin: 0 0 0.4rem;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-style: italic;
  color: var(--mp-color-accent);
  line-height: 1.1;
}

.order-eta strong { font-weight: 400; }

.order-eta-hint {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.order-book-link {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.125rem;
  color: var(--mp-color-accent);
  font-weight: 400;
  border-bottom: 1px solid rgba(181, 87, 58, 0.3);
  text-decoration: none;
}

.order-book-link:hover {
  color: var(--mp-color-accent-dark);
  border-bottom-color: var(--mp-color-accent-dark);
  text-decoration: none;
}

.order-cancel-section {
  margin-top: 2rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--mp-color-divider);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

/* Order Form */
.order-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.form-row {
  display: flex;
  flex-direction: column;
}

.form-row-2col {
  flex-direction: row;
  gap: var(--space-md);
}

.form-row-2col .form-group {
  flex: 1;
}

@media (max-width: 480px) {
  .form-row-2col {
    flex-direction: column;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.form-group label {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.form-group .required {
  color: var(--color-danger);
}

.form-group input,
.form-group select {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--surface-primary);
  color: var(--text-primary);
  font-size: 0.9375rem;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.order-submit {
  text-align: center;
  padding-top: var(--space-md);
}

.order-note {
  margin-top: var(--space-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Order Detail */
.order-status-section {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.rpi-status {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.order-timeline-card {
  padding: 2rem 2.25rem;
  margin-bottom: 2rem;
  background: var(--mp-color-surface);
  border: 1px solid var(--mp-color-divider);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(42, 31, 26, 0.04);
}

.order-timeline-card h2 {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  margin: 0 0 0.5rem;
  color: var(--text-primary);
}

.order-timeline {
  display: flex;
  justify-content: space-between;
  position: relative;
  padding: var(--space-lg) 0 var(--space-md);
}

.order-timeline::before {
  content: '';
  position: absolute;
  top: calc(var(--space-lg) + 11px);
  left: 8%;
  right: 8%;
  height: 2px;
  background: var(--border-default);
}

/* Compact 2-step layout for cancelled/error */
.order-timeline--short {
  max-width: 260px;
  margin: 0 auto;
}

.order-timeline--short::before {
  left: 25%;
  right: 25%;
}

.timeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  z-index: 1;
  flex: 1;
}

.timeline-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--border-default);
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.timeline-step.active .timeline-dot {
  background: var(--mp-color-accent);
  border-color: var(--mp-color-accent);
  box-shadow: 0 0 0 4px rgba(181, 87, 58, 0.18);
}

.timeline-step.done .timeline-dot {
  background: var(--mp-color-accent);
  border-color: var(--mp-color-accent);
  opacity: 0.65;
}

.timeline-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 72px;
  line-height: 1.3;
}

.timeline-step.active .timeline-label {
  color: var(--mp-color-accent-dark);
  font-weight: 600;
}

.timeline-step.done .timeline-label {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Per-step timestamp ("Apr 28") under the label, plus the inline tracking
   link / number on the Shipped step. Both render only when the data is
   present (template guards), so most steps just have the label. */
.timeline-when {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.timeline-tracking,
.timeline-tracking-num {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
}

.timeline-tracking {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: underline;
}

.timeline-tracking-num code {
  font-size: inherit;
  word-break: break-all;
}

/* Wrapper around label/timestamp/tracking inside each step. On desktop it
   should be visually transparent so the existing centered column layout
   (dot → label → when) is unchanged. The mobile @media block below
   overrides this to a flex column so the text stacks next to the dot. */
.timeline-step-text {
  display: contents;
}

/* ── Mobile: vertical timeline stack ──
   At ≤600px the horizontal timeline becomes unreadable (7 steps × 50px
   each, labels clamped to 72px wrapping into illegible columns). Switch
   to a vertical stack: dot on the left, text on the right, connecting
   line running down the left gutter through the dot centers. */
@media (max-width: 600px) {
  .order-timeline-card {
    padding: 1.25rem;
  }

  .order-timeline {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  /* Flip the connecting line from horizontal to vertical. The line sits
     at x = 10px (half of the 22px dot) so it passes through dot centers.
     `bottom: var(--space-md)` lets the line terminate at the last dot
     since the flex column ends at the last child. */
  .order-timeline::before {
    top: calc(var(--space-lg) + 11px);
    bottom: var(--space-md);
    left: 10px;
    right: auto;
    width: 2px;
    height: auto;
  }

  /* Cancelled-order 2-step variant: drop the desktop `max-width: 260px;
     margin: 0 auto;` centering and the `left/right: 25%` line inset so
     the vertical layout matches the regular variant. */
  .order-timeline--short {
    max-width: none;
    margin: 0;
  }

  .order-timeline--short::before {
    left: 10px;
    right: auto;
  }

  .timeline-step {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    flex: 0 0 auto;
  }

  /* Activate the wrapper as a real flex column so label/when/tracking
     stack vertically next to the dot. */
  .timeline-step-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
  }

  .timeline-label {
    max-width: none;
    text-align: left;
  }

  .timeline-when {
    margin-top: 0;
  }

  .timeline-tracking,
  .timeline-tracking-num {
    margin-top: 2px;
    text-align: left;
  }

  /* 44px tappable target for the tracking link (codebase mobile touch
     convention). `inline-block` so it doesn't stretch the full row. */
  .timeline-tracking {
    display: inline-block;
    min-height: 44px;
    line-height: 44px;
    font-size: 0.8125rem;
  }
}

/* "What's next" note — sits between the timeline and the detail grid,
   icon + one-line copy. Mirrors the existing toast-style banner without
   the dismiss affordance. */
.order-whats-next {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 1.25rem 0 2rem;
  padding: 0.7rem 1rem;
  border-radius: 4px;
  background: var(--mp-color-surface-warm);
  border: 1px solid var(--mp-color-divider);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.order-whats-next svg {
  flex-shrink: 0;
  color: var(--mp-color-accent);
}

.order-eta {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.order-eta-hint {
  margin: 0;
  font-size: 0.8rem;
}

.order-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.order-detail-grid .card {
  padding: var(--space-lg);
}

.order-address {
  font-style: normal;
  line-height: 1.6;
}

.order-actions {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

/* Order List */
.order-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
}

.order-table th,
.order-table td {
  padding: 1rem 1.5rem;
  text-align: left;
  border-bottom: 1px solid var(--mp-color-divider);
}

.order-table tbody tr:last-child td {
  border-bottom: none;
}

.order-table th {
  font-weight: 600;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: var(--mp-color-surface-warm);
  border-bottom: 1px solid var(--mp-color-divider);
}

.order-table tbody tr {
  transition: background 160ms ease;
}

.order-table tbody tr:hover {
  background: rgba(181, 87, 58, 0.03);
}

.order-table .order-cell-total {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text-primary);
}

.order-table .order-cell-date {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.order-id-link {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--mp-color-accent);
  font-weight: 400;
  text-decoration: none;
  border-bottom: 1px solid rgba(181, 87, 58, 0.3);
}

.order-id-link:hover {
  color: var(--mp-color-accent-dark);
  border-bottom-color: var(--mp-color-accent-dark);
  text-decoration: none;
}

.order-cell-view {
  font-size: 0.875rem;
  white-space: nowrap;
}

/* "Complete checkout" + "Cancel order" pair shown on pending+unpaid
   orders. Lives in two places: the table action cell on /orders and
   the resume banner on /orders/{id}. Both consume the same button
   styles so the pair always reads as a matched set.

   Why a custom button system here (instead of mp-cta + mp-cta-
   secondary): the page-level mp-cta is a chunky, full-bleed action
   meant for primary calls-to-action, and mp-cta-secondary is a thin
   underlined text link. Pairing them produced a giant filled button
   beside a tiny text link with mismatched heights. We need a compact
   pair that scales with the row/banner and sits side-by-side. */
.order-action-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* The cancel button is wrapped in a <form> for the POST. Make the
   form transparent to the flex layout so the button aligns with the
   adjacent anchor instead of dropping to the next row. */
.order-action-pair form {
  display: contents;
}

/* Shared base for both buttons: identical height, padding, font, and
   shape so they look like a matched pair of pills. Subclasses below
   add the filled vs. outlined treatment. */
.order-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 2.25rem;
  padding: 0 1.1rem;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  line-height: 1;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

/* Primary — filled terracotta. */
.order-action-btn--primary {
  background: var(--mp-color-accent);
  border-color: var(--mp-color-accent);
  color: var(--mp-color-bg);
}

.order-action-btn--primary:hover {
  background: var(--mp-color-accent-dark);
  border-color: var(--mp-color-accent-dark);
  color: var(--mp-color-bg);
  text-decoration: none;
}

.order-action-btn--primary:focus-visible {
  outline: 2px solid var(--mp-color-accent-dark);
  outline-offset: 2px;
}

/* Secondary — outlined, picks up the accent border on hover. Reads
   as the quieter sibling next to the primary fill while staying the
   same physical size. */
.order-action-btn--secondary {
  background: transparent;
  border-color: var(--mp-color-divider);
  color: var(--text-secondary);
}

.order-action-btn--secondary:hover {
  border-color: var(--mp-color-accent);
  color: var(--mp-color-accent);
  background: var(--mp-color-accent-soft);
  text-decoration: none;
}

.order-action-btn--secondary:focus-visible {
  outline: 2px solid var(--mp-color-accent);
  outline-offset: 2px;
}

/* ── Mobile: stacked-card order list ──
   At ≤600px the 6-column .order-table crushes columns into ~60px
   illegible strips (or forces horizontal page scroll), which is the
   first thing a customer sees when they tap an order link in a
   shipping email on their phone. Convert each <tr> into a stacked
   card: Order ID + status pill on top, book name on a second row,
   date + total side-by-side, then full-width action button(s) at the
   bottom. The <thead> is hidden (we synthesize per-cell labels via
   `td::before { content: attr(data-label) }` instead). Markup keeps
   the semantic table on desktop and at screen readers — display
   reflow only kicks in at ≤600px. */
@media (max-width: 600px) {
  /* Strip table chrome so we can lay each row out as a grid card. */
  .order-table,
  .order-table thead,
  .order-table tbody,
  .order-table tr,
  .order-table td {
    display: block;
    width: 100%;
  }

  /* Hide the desktop column headers visually but leave them in the
     accessibility tree by leaning on the existing .sr-only-esque
     pattern. We use the standard visually-hidden trick directly. */
  .order-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Each row becomes a 2-col grid card: order/status on row 1, book
     title on row 2, date + total side-by-side on row 3, actions
     spanning the bottom. The wrapping .order-list .mp-card--flush
     already paints the outer border, so we paint inter-card dividers
     instead. */
  .order-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "order   status"
      "book    book"
      "date    total"
      "actions actions";
    gap: 0.5rem 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--mp-color-divider);
  }

  .order-table tbody tr:last-child {
    border-bottom: none;
  }

  /* Hover affordance off on mobile — touch devices don't hover, and
     the subtle background tint adds noise when the card is tapped. */
  .order-table tbody tr:hover {
    background: transparent;
  }

  /* Cells: drop the cell border/padding (the row owns padding now). */
  .order-table td {
    padding: 0;
    border-bottom: none;
  }

  /* Cell label injected via data-label — small uppercase eyebrow that
     reads as the column name for the value below. Suppressed below
     for cells where the value is self-explanatory (Order ID, Status,
     Book), so only Date + Total carry labels. */
  .order-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.15rem;
  }

  /* Order ID — top-left. */
  .order-table td[data-label="Order"] {
    grid-area: order;
    align-self: center;
  }
  .order-table td[data-label="Order"]::before {
    display: none;
  }
  .order-table td[data-label="Order"] .order-id-link {
    font-size: 1.05rem;
  }

  /* Status pill — top-right. */
  .order-table td.order-cell-status {
    grid-area: status;
    align-self: center;
    justify-self: end;
  }
  .order-table td.order-cell-status::before {
    display: none;
  }

  /* Book title — second row, spans both columns, bumped a touch so
     it reads as the primary identifier of the card. */
  .order-table td.order-cell-book {
    grid-area: book;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
  }
  .order-table td.order-cell-book::before {
    display: none;
  }

  /* Date + Total — third row, side-by-side. Date left-aligned with
     its small eyebrow, total right-aligned with its eyebrow. */
  .order-table td.order-cell-date {
    grid-area: date;
    font-size: 0.875rem;
    text-align: left;
  }
  .order-table td.order-cell-total {
    grid-area: total;
    justify-self: end;
    text-align: right;
    font-size: 0.875rem;
  }
  .order-table td.order-cell-total::before {
    text-align: right;
  }

  /* Actions cell — full-width footer of the card. The button-pair
     wraps to its own row when both buttons are present (pending +
     unpaid), and the lone "View →" anchor goes full-width too. */
  .order-table td.order-cell-actions {
    grid-area: actions;
    margin-top: 0.25rem;
  }
  .order-table td.order-cell-actions::before {
    display: none;
  }

  /* Primary CTA gets its own row + fills the width. The Cancel
     button sits below it (still its own pill, not full-width, so it
     reads as the quieter option). 44px tall hits the codebase mobile
     touch-target convention. */
  .order-action-pair {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .order-action-pair .order-action-btn {
    height: 2.75rem;
    width: 100%;
  }

  /* Lone "View →" link — present on every non-pending-unpaid order.
     Promote it to a full-width pill so it has a tappable footprint
     (the desktop text-link form is too small for a thumb). */
  .order-cell-actions .order-cell-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.75rem;
    padding: 0 1rem;
    border-radius: 4px;
    border: 1px solid var(--mp-color-divider);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    width: 100%;
  }
  .order-cell-actions .order-cell-view:hover {
    border-color: var(--mp-color-accent);
    color: var(--mp-color-accent);
    background: var(--mp-color-accent-soft);
    text-decoration: none;
  }

  /* Hover affordance off on mobile — touch devices don't hover, and
     the subtle background tint adds noise when the card is tapped. */
  .order-table tbody tr:hover {
    background: transparent;
  }
}

/* Prominent "Your order isn't paid yet" banner on the order detail
   page. Pairs the Complete-checkout CTA and the Cancel-order button
   so the customer can finish (or kill) a stuck pending order. */
.order-resume-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem;
}

.order-resume-banner h2 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0 0 0.25rem;
}

.order-resume-banner p {
  margin: 0;
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.empty-state-icon {
  color: var(--mp-color-divider);
  margin-bottom: 0.5rem;
}

.empty-state h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  margin: 0;
  color: var(--text-primary);
}

.empty-state p {
  font-family: var(--font-sans);
  color: var(--text-secondary);
  font-size: 1rem;
  margin: 0 0 1rem;
  max-width: 40ch;
}

/* Toast variants */
.toast-warning {
  background: var(--color-primary-subtle);
  color: var(--color-warning);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.toast-success {
  background: var(--color-success-subtle);
  color: var(--color-success);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.toast-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: inherit;
  opacity: 0.7;
}

.toast-dismiss:hover {
  opacity: 1;
}

/* Error/cancelled timeline state */
.order-timeline-error::before {
  background: var(--color-danger);
}

.timeline-step-error .timeline-dot {
  background: var(--color-danger);
  border-color: var(--color-danger);
  box-shadow: 0 0 0 4px var(--color-danger-subtle);
}

.timeline-step-error .timeline-dot::after {
  content: '✕';
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--text-inverse);
  line-height: 1;
}

.timeline-step-error .timeline-label {
  color: var(--color-danger);
  font-weight: 600;
}

.timeline-step.done .timeline-dot::after {
  content: '✓';
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--mp-color-bg);
  line-height: 1;
}

.timeline-step.active .timeline-dot::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mp-color-bg);
  display: block;
}

/* Toast success icon alignment */
.toast-success {
  gap: var(--space-sm);
}

.toast-success svg {
  flex-shrink: 0;
}

/* Order Print Section (on book detail page) */
.order-print-section {
  text-align: center;
  padding: var(--space-md) 0 var(--space-lg);
}

/* Call-to-action button */
.btn-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--color-primary);
  color: var(--text-inverse);
  padding: var(--space-sm) var(--space-xl);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 2px 8px var(--color-primary-ring);
}

.btn-cta:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 4px 12px var(--color-primary-glow);
}

/* nav-orders-link styles live in layout.css */

/* ── Multi-step order flow (address → shipping → checkout) ──────────────── */

.order-step-help {
  color: var(--text-secondary, #666);
  font-size: 0.95rem;
  margin: -0.25rem 0 1rem;
}

.shipping-production-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted, #888);
  margin: 0 0 1rem;
}

.shipping-production-note svg {
  flex-shrink: 0;
  color: var(--text-secondary, #666);
}

.muted {
  color: var(--text-muted, #888);
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-primary, #2563eb);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
}

.ship-address-form .form-row,
.ship-address-form .form-row-2col,
.ship-address-form .form-row-3col {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

/* Explicit row direction. Needed because `.form-row` (defined in the
 * shared form section earlier in this file) hard-sets flex-direction
 * to column for the single-field rows. `.form-row-2col` then re-sets
 * it to row in the shared block, but there was no equivalent rule for
 * `.form-row-3col`, so City / State / ZIP silently stacked even at
 * desktop width. Setting it here keeps the cascade explicit. */
.ship-address-form .form-row-2col,
.ship-address-form .form-row-3col {
  flex-direction: row;
}

.ship-address-form .form-row > label {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--text-secondary, #555);
}

.ship-address-form .form-row-2col > label {
  flex: 1 1 calc(50% - 0.5rem);
}

.ship-address-form .form-row-3col > label {
  flex: 1 1 calc(33% - 0.5rem);
}

/* Inputs / selects default their intrinsic-min width to the rendered
 * width of their `size=20` attribute (roughly 200px), and labels in a
 * flex container default min-width: auto, which propagates that
 * content min up the tree. When the form sits inside a CSS grid
 * track narrower than that (e.g. the order page at 375px viewport
 * where the grid track shrinks to ~344px), the grid item refuses to
 * compress below the input's min-content and the whole form overflows
 * the viewport. Forcing min-width: 0 on the fields + labels lets the
 * flex parents shrink them so the form stays inside the card, and
 * keeps the 3-up row at desktop from wrapping when the State select's
 * intrinsic content (e.g. "Massachusetts") exceeds the 33% basis. */
.ship-address-form input,
.ship-address-form select,
.ship-address-form .form-row > label,
.ship-address-form .form-row-2col > label,
.ship-address-form .form-row-3col > label {
  min-width: 0;
}

/* Mobile: collapse City / State / ZIP and Email / Phone to a single
 * column so each field gets the full row width (City names like
 * "San Francisco" no longer get clipped at 375–414px) and stays
 * comfortably tappable. The action row also flips to a stacked
 * column so the "Continue to shipping →" button doesn't push the
 * form past the viewport (the two anchors can't both fit at ~200px
 * intrinsic min on a 375px screen). Matches the project
 * `@media (max-width: 600px)` convention used by the order list,
 * preview, and shipping option layouts (PRs #155, #156, #158). */
@media (max-width: 600px) {
  .ship-address-form .form-row-2col,
  .ship-address-form .form-row-3col {
    flex-direction: column;
  }
  .ship-address-form .form-row-2col > label,
  .ship-address-form .form-row-3col > label {
    flex: 1 1 100%;
  }
  .ship-address-form .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .ship-address-form .form-actions > .btn {
    width: 100%;
    text-align: center;
  }
}

.ship-address-form input[type="text"],
.ship-address-form input[type="email"],
.ship-address-form input[type="tel"],
.ship-address-form select {
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border-default, #ccc);
  border-radius: var(--radius-sm, 4px);
  font-size: 1rem;
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #111);
}

.ship-address-form input:focus,
.ship-address-form select:focus {
  outline: none;
  border-color: var(--border-focus, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* ── Shipping picker ───────────────────────────────────────────────────── */

.shipping-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.shipping-options {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.shipping-option {
  /* Three-column grid: radio, body (name + class), price.
   * `minmax(0, 1fr)` on the body cell lets text-overflow apply
   * inside it without blowing out the row width. */
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  border: 1.5px solid var(--border-default, #ccc);
  border-radius: var(--radius-md, 6px);
  background: var(--bg-primary, #fff);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.shipping-option:hover {
  border-color: var(--color-primary, #2563eb);
}

.shipping-option:has(input[type="radio"]:checked) {
  border-color: var(--color-primary, #2563eb);
  background: var(--bg-tertiary, #f5f7ff);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.shipping-option input[type="radio"] {
  margin: 0;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.shipping-option-body {
  /* Vertical stack of name (top, bold) and class (bottom, muted).
   * minmax(0, …) on the column above is what keeps the ellipsis working. */
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.shipping-option-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shipping-option-class {
  font-size: 0.8125rem;
  text-transform: capitalize;
  color: var(--text-muted, #6b6b6b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shipping-option-price {
  flex: 0 0 auto;
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--text-primary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums; /* keep digits aligned across rows */
}

.shipping-option-price--free {
  color: var(--color-success, #15803d);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.875rem;
}

/* "Shipping to <address>" banner that sits between the page heading and the
 * picker. Lays the address out in one row that ellipses on small viewports
 * so the address never wraps the picker layout. */
.ship-to-banner {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  margin-bottom: 1rem;
  background: var(--bg-tertiary, #f5f7ff);
  border: 1px solid var(--border-default, #e5e7eb);
  border-radius: var(--radius-md, 6px);
  font-size: 0.9375rem;
}

.ship-to-banner-label {
  font-weight: 600;
  color: var(--text-secondary, #555);
  flex: 0 0 auto;
}

.ship-to-banner-addr {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ship-to-summary {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-default, #ddd);
  font-size: 0.875rem;
  line-height: 1.45;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 600px) {
  .shipping-option {
    /* Tighter padding so prices don't get bumped to a second line on
     * narrow screens. The grid layout stays single-row. */
    padding: 0.75rem;
    gap: 0.625rem;
  }
  .ship-to-banner {
    flex-wrap: wrap;
  }
  .ship-to-banner-addr {
    flex: 1 1 100%;
  }
}

/* ── Checkout summary tweaks ──────────────────────────────────────────── */

/* Allow the summary list to flex without long shipping labels squeezing
 * the price column. Each dt+dd pair lays out as a row, and the dt cell
 * itself gets min-width: 0 + word-break so the method name wraps cleanly
 * if it's long instead of forcing a horizontal scroll. */
.checkout-summary-list dt {
  min-width: 0;
}
.checkout-summary-list dd {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* "Shipping" + method-name on a stacked label so the price column stays
 * aligned regardless of method name length. */
.checkout-summary-shipping-row {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.checkout-summary-shipping-method {
  font-size: 0.8125rem;
  color: var(--text-muted, #6b6b6b);
  font-weight: 400;
}

.checkout-summary-free {
  display: inline-block;
  color: var(--color-success, #15803d);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  font-size: 0.875rem;
}

/* Total row gets a top border to visually separate from the line items. */
.checkout-summary-total-row {
  margin-top: 0.5rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--border-default, #ddd);
}

/* ── Order status / return pages ──
   Centered single-column layout used by /orders/return and similar
   short status pages. */

.order-page--centered {
  text-align: center;
  padding: var(--space-xl);
}

.order-page-icon {
  color: var(--color-primary);
  margin-bottom: 1rem;
}

.order-page-actions {
  margin-top: 1rem;
}

.order-page-redirect {
  margin-top: 1rem;
  color: var(--color-muted);
}

/* "Read our terms" links beneath the place-order CTA. */
.checkout-legal-links {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}
.checkout-legal-links a {
  color: var(--text-muted);
  text-decoration: underline;
}

/* Order-detail "loading" status row — the icon vertically aligns with
   the first line of body text instead of centering on the wrapper. */
.order-status-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

/* Single-line book row inside the order-detail Book card — overrides
   the default <p> bottom margin so the card content fits one line. */
.order-book-paragraph {
  margin: 0;
}

/* Order-list mp-card variant — the table rows already paint their
   own padding, so we strip the card's interior padding and rely on
   border-radius + overflow:hidden to clip the table corners. */
.mp-card--flush {
  padding: 0;
  overflow: hidden;
}

/* Admin-only dev callout — bright orange so it's never confused with
   a customer-facing affordance. Only renders in DevMode. */
.dev-callout {
  margin-top: 1rem;
  border: 2px dashed var(--color-warning);
  padding: 1rem;
}
.dev-callout .btn-dev {
  background: var(--color-warning);
  color: #fff;
  border: none;
}
.dev-callout .order-note {
  color: var(--color-warning);
}

/* Standalone dev note — same accent as .dev-callout but without the
   wrapper border, used for inline admin hints between cards. */
.dev-note {
  margin-top: 1rem;
  color: var(--color-warning);
}

/* Toast embedded above a form (warning + form error) — its container
   already has a margin-bottom, but the inline toast wants its own
   bottom padding so it doesn't sit flush with the next card. */
.toast--inline {
  margin-bottom: 1rem;
}

/* "Preparing your book" status card — narrow, centered. */
.order-prepare-card {
  max-width: 600px;
  margin: 0 auto;
}

/* Log of generation events — scrolls inside the card. */
.generation-log--prepare {
  margin-top: 1rem;
  max-height: 300px;
  overflow-y: auto;
}

/* Hidden by default; JS toggles display:block on error. */
.order-prepare-error {
  display: none;
}

/* Retry button has a margin-top so it sits below the error message. */
.order-prepare-retry {
  margin-top: 1rem;
}

/* Price-quote card sits below the address card with breathing room. */
.order-quote-card {
  margin-top: 1.5rem;
}

/* The "Confirm & pay with Stripe" form wants a tight gap above the
   Stripe button so the dl/form pair reads as one block. */
.order-confirm-form {
  margin-top: 1.25rem;
}
