@layer base, components, pages;

/* Key-value lists, fact lists, row lists, the order timeline and progress bar. */
@layer components {
  .facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-4); margin: 0 0 var(--space-6); }
  .facts dt { color: var(--muted); }
  .facts dd { margin: 0; }
  .kv { list-style: none; padding: 0; margin: 0; }
  .kv li { display: flex; justify-content: space-between; padding: var(--space-2) 0; border-bottom: 1px solid color-mix(in srgb, var(--fg) 8%, transparent); }
  .kv-wrap li { flex-wrap: wrap; gap: 0 var(--space-3); }
  .mono { font-family: var(--font-mono); font-size: var(--text-sm); overflow-wrap: anywhere; }
  .num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

  .rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid color-mix(in srgb, var(--fg) 10%, transparent); }
  .row-link { display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; padding: var(--space-3) var(--space-2); color: var(--fg); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--fg) 10%, transparent); }
  .row-link:hover, .row-link:focus-visible { background: color-mix(in srgb, var(--accent) 7%, transparent); }
  .row-main { display: grid; }
  .row-meta { display: flex; gap: var(--space-2); align-items: center; }
  .queue { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
  .queue-row { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); border: 1px solid color-mix(in srgb, var(--fg) 12%, transparent); color: var(--fg); text-decoration: none; flex-wrap: wrap; }
  .queue-row:hover { border-color: var(--accent); }
  .queue-main { display: grid; flex: 1; min-width: 10rem; }
  .visits { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
  .visits p { margin: var(--space-1) 0 0; }
  .checklist { padding-left: var(--space-6); }
  .checklist li { margin: var(--space-1) 0; }
  .checks { list-style: none; padding: 0; margin: 0 0 var(--space-4); display: grid; gap: var(--space-1); }
  .checks .ok span:first-child { color: var(--success); font-weight: 700; }
  .checks .bad span:first-child { color: var(--danger); font-weight: 700; }
  .checks .warn span:first-child { color: var(--warning); font-weight: 700; }
  .checks .todo span:first-child { color: var(--muted); }

  /* Order progress (T10). Screen readers get "done" and "step 3 of 8" as text (A27). */
  .progress { list-style: none; padding: 0; margin: var(--space-4) 0 var(--space-2); display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: var(--space-1); }
  .progress-step { display: grid; gap: var(--space-1); font-size: var(--text-xs); color: var(--muted); }
  .progress-bar { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--fg) 14%, transparent); }
  .progress-step.is-done .progress-bar, .progress-step.is-current .progress-bar { background: var(--accent); }
  .progress-step.is-current .progress-label { color: var(--fg); font-weight: 700; }
  @media (max-width: 40rem) { .progress { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: var(--space-3); } }
  .next-up { margin: 0; }

  .history { margin-top: var(--space-6); }
  .timeline { list-style: none; padding: 0 0 0 var(--space-4); margin: 0 0 var(--space-3); border-left: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); display: grid; gap: var(--space-4); }
  .timeline li { position: relative; }
  .timeline li::before { content: ""; position: absolute; left: calc(-1 * var(--space-4) - 6px); top: .45rem; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
  .timeline p { margin: 0; }
  .timeline-note { margin-top: var(--space-1) !important; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); background: color-mix(in srgb, var(--fg) 5%, var(--bg)); font-size: var(--text-sm); }

  /* Spinner and loading skeletons. */
  .spinner { width: 1.25rem; height: 1.25rem; flex: none; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); animation: spin .8s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes pulse { 50% { opacity: .45; } }
  @media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

  /* Stat tiles: the label is an eyebrow, the number is the headline (A33). */
  .stat h2 { text-transform: uppercase; letter-spacing: 0.08em; font: 600 var(--text-xs)/1.4 var(--font-body); color: var(--muted); margin: 0 0 var(--space-2); }
  .stat-num { font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 700; margin: 0 0 var(--space-2); font-variant-numeric: tabular-nums; }
  .big-rate { font: 700 var(--text-3xl)/1 var(--font-display); color: var(--accent); margin: 0; }
  .rates { display: flex; flex-wrap: wrap; gap: var(--space-8); margin-bottom: var(--space-6); }
}
