/* Shipping block (shp-). Tokens only; controls are the base k- classes. Three variants: methods (the delivery step), tracking, policy.
   The authored moment is in methods: the chosen price ticks into the order total (the number is tweened in shipping's JS; the
   total's pop and the row's selected state are here). Everything else is a 150 to 200 ms transition or one 500 ms entrance. */
.shp { --shp-gap: clamp(24px, 4vw, 56px); padding-top: var(--section); padding-bottom: var(--section); }
.shp-wrap { display: flex; flex-direction: column; gap: 32px; }
.shp-head { display: flex; flex-direction: column; gap: 12px; max-width: var(--w-prose); }
.shp-hint { margin: 0; color: var(--muted); }
.shp-fine { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.shp-busy { margin: 0; display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 500; }
.shp-wa { gap: 8px; margin-left: 8px; }
.shp-retry { margin-top: 12px; }
.shp-note:empty { display: none; }
.shp-note .k-alert { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }

/* ---- methods: the questions and the choices on the left, the sum on the right ------------------------------------- */
.shp-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(300px, 4fr); gap: var(--shp-gap); align-items: start; }
.shp-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.shp-addr { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.shp-addr-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; }
.shp-addr .k-btn .k-spin { flex: none; }
.shp-options { margin: 0; padding: 0; border: 0; min-width: 0; }
.shp-list { display: flex; flex-direction: column; gap: 10px; }
.shp-skel { height: 76px; border-radius: var(--radius-sm); background: var(--placeholder); animation: shp-pulse 1.1s ease-in-out infinite alternate; }

.shp-opt { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center; min-height: 76px; padding: 14px 16px;
  border: 1px solid var(--field); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
  transition: border-color var(--d) var(--ease), background-color var(--d) var(--ease), box-shadow var(--d) var(--ease), opacity var(--d) ease; }
.shp-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.shp-input:disabled { cursor: not-allowed; }
.shp-opt:has(.shp-input:checked) { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: color-mix(in srgb, var(--brand-soft) 55%, var(--surface)); }
.shp-opt:has(.shp-input:focus-visible), .shp-pt:has(.shp-input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 3px; }
.shp-ico { width: 44px; height: 44px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--ground); color: var(--muted); transition: background-color var(--d) var(--ease), color var(--d) var(--ease); }
.shp-opt:has(.shp-input:checked) .shp-ico { background: var(--brand); color: var(--on-brand); }
.shp-opt-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.shp-opt-name { font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.shp-opt-meta { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.shp-opt-note { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.shp-price { padding: 6px 12px; border-radius: 999px; background: var(--ground); font-size: 18px; font-weight: 700; transition: background-color var(--d) var(--ease), color var(--d) var(--ease); }
.shp-price[data-free] { color: var(--brand); }
.shp-opt:has(.shp-input:checked) .shp-price { background: var(--brand); color: var(--on-brand); }
.shp[data-stale] .shp-list, .shp[data-stale] .shp-pick, .shp[data-stale] .shp-sum-body { opacity: .55; }

.shp-pick { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); animation: k-in var(--d-enter) var(--ease) both; }
.shp-pick-h { font-size: 20px; }
.shp-pick-none { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--muted); }
.shp-points { margin: 0; padding: 0 4px 0 0; border: 0; min-width: 0; max-height: 304px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; scrollbar-color: var(--field) transparent; overscroll-behavior: contain; }
.shp-pt { flex: none; position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 64px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color var(--d) var(--ease), background-color var(--d) var(--ease), box-shadow var(--d) var(--ease); }
.shp-pt:has(.shp-input:checked) { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: color-mix(in srgb, var(--brand-soft) 55%, var(--surface)); }
.shp-pt-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.shp-pt-name { font-weight: 600; overflow-wrap: anywhere; }
.shp-pt-addr, .shp-pt-hours, .shp-pt-dist { font-size: 14px; color: var(--muted); }
.shp-pt-addr { overflow-wrap: anywhere; }
.shp-pt-dist { white-space: nowrap; }

.shp-static h3 { font-size: 20px; margin-bottom: 12px; }
.shp-rates { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 0; max-width: 460px; }
.shp-rates li { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.shp-rates li span:last-child { text-align: right; color: var(--muted); }

.shp-sum { position: sticky; top: calc(var(--header-h) + 24px); display: flex; flex-direction: column; gap: 16px; padding: 24px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.shp-sum-h { font-size: 20px; }
.shp-sum-empty { margin: 0; color: var(--muted); }
.shp-sum-body { display: flex; flex-direction: column; gap: 16px; }
.shp-rows { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.shp-rows > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.shp-rows dt { color: var(--muted); font-weight: 500; }
.shp-rows dd { margin: 0; font-weight: 600; font-size: 17px; }
.shp-rows .shp-total { padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--line); }
.shp-total dt { color: var(--ink); font-weight: 600; }
.shp-total dd { font-size: clamp(26px, 3.4vw, 32px); font-weight: 700; letter-spacing: -0.02em; transform-origin: right center; }
.shp-eta { margin: 0; font-size: 15px; color: var(--muted); }
.shp-eta strong { color: var(--ink); font-weight: 600; }
.shp-need { margin: 0; font-size: 15px; font-weight: 600; color: var(--danger); }

/* ---- tracking ------------------------------------------------------------------------------------------------------- */
.shp-trk { display: flex; flex-direction: column; gap: 28px; }
.shp-ref { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; max-width: 560px; }
.shp-ref .k-field { flex: 1 1 240px; }
.shp-ref input { text-transform: uppercase; letter-spacing: .02em; }
.shp-trk-body { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); grid-template-rows: auto 1fr; column-gap: var(--shp-gap); row-gap: 16px; align-items: start; }
.shp-trk-body > p { grid-column: 1 / -1; }
.shp-now { grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 28px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); animation: k-in var(--d-enter) var(--ease) both; }
.shp-now-text { font-size: clamp(26px, 3.4vw, 40px); line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.shp-now-text.shp-none { font-size: 18px; font-weight: 500; line-height: 1.4; letter-spacing: 0; color: var(--muted); }
.shp-now-when { margin: 0; font-size: 17px; color: var(--muted); }
.shp-now-act { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.shp-now-act:empty { display: none; }
.shp-rail-h { font-size: 20px; align-self: end; }
.shp-rail { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.shp-step { --n: 0; position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 16px; padding-bottom: 26px; }
.shp-step:last-child { padding-bottom: 0; }
.shp-step:nth-child(2) { --n: 1; } .shp-step:nth-child(3) { --n: 2; } .shp-step:nth-child(4) { --n: 3; } .shp-step:nth-child(5) { --n: 4; } .shp-step:nth-child(6) { --n: 5; }
.shp-step:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); transform-origin: top; }
.shp-step[data-state="done"]:not(:last-child)::before { background: var(--brand); animation: shp-draw .5s calc(var(--n) * 90ms) var(--ease) backwards; }
.shp-dot { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); color: var(--on-brand); }
.shp-step[data-state="done"] .shp-dot { background: var(--brand); box-shadow: none; }
.shp-step[data-state="current"] .shp-dot { background: var(--brand); box-shadow: 0 0 0 6px var(--brand-soft); }
.shp-step[data-state="current"]:not([data-step="failed"]) .shp-dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--on-brand); }
.shp-step[data-step="failed"] .shp-dot { background: var(--danger); box-shadow: 0 0 0 6px var(--danger-soft); }
.shp-step-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding-top: 3px; }
.shp-step-name { font-size: 17px; font-weight: 600; line-height: 1.3; }
.shp-step[data-state="todo"] .shp-step-name { color: var(--muted); font-weight: 500; }
.shp-step[data-step="failed"] .shp-step-name { color: var(--danger); }
.shp-evs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.shp-evs li { display: flex; flex-wrap: wrap; gap: 0 12px; font-size: 15px; color: var(--muted); }
.shp-evs time { white-space: nowrap; }
.shp-evs span { overflow-wrap: anywhere; }
.shp-trk-foot { margin: 0; }

/* ---- policy ----------------------------------------------------------------------------------------------------------- */
.shp-ledger { margin: 0; max-width: 880px; display: flex; flex-direction: column; }
.shp-ledger > div { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 8px 32px; padding: 22px 0; border-top: 1px solid var(--line); }
.shp-ledger > div:last-child { border-bottom: 1px solid var(--line); }
.shp-ledger dt { font-weight: 600; }
.shp-ledger dd { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.shp-ledger dd p { max-width: var(--w-prose); }

@media (hover: hover) and (pointer: fine) {
  .shp-opt:hover:not(:has(.shp-input:checked)):not(:has(.shp-input:disabled)), .shp-pt:hover:not(:has(.shp-input:checked)) { border-color: var(--brand); }
}

@keyframes shp-pulse { from { opacity: .55; } to { opacity: 1; } }
@keyframes shp-draw { from { transform: scaleY(0); } }

@media (max-width: 720px) {
  .shp-grid { grid-template-columns: minmax(0, 1fr); }
  .shp-sum { position: static; padding: 20px; }
  .shp-addr-grid { grid-template-columns: minmax(0, 1fr); }
  .shp-addr .k-btn { width: 100%; }
  .shp-opt { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; padding: 12px 14px; }
  .shp-ico { width: 40px; height: 40px; }
  .shp-price { font-size: 16px; padding: 5px 10px; }
  .shp-pick { padding: 16px; }
  .shp-trk-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .shp-now { grid-row: auto; padding: 22px; }
  .shp-rail-h { margin-top: 12px; }
  .shp-ledger > div { grid-template-columns: minmax(0, 1fr); padding: 18px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .shp-skel { animation: none; }
  .shp-pick, .shp-now { animation: k-fade .3s ease both; }
  .shp-step[data-state="done"]:not(:last-child)::before { animation: none; }
}
