/* ============================================================
   SC Cargo Pro — Responsive Primitives
   Mobile-first shared components. No media queries.
   Consumed by mobile + tablet; safe at desktop (nothing forced).
   Namespace: .rsp-*
   ============================================================ */

/* ── Tap-target sizer ─────────────────────────────────────── */
.rsp-tap {
  min-width: var(--tap);
  min-height: var(--tap);
}

/* ── Bottom sheet ─────────────────────────────────────────── */
.rsp-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.rsp-sheet[aria-hidden="false"] { pointer-events: auto; }

.rsp-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: var(--sheet-backdrop);
  -webkit-backdrop-filter: blur(2px);
          backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--t-mid);
}
.rsp-sheet[aria-hidden="false"] .rsp-sheet-backdrop { opacity: 1; }

.rsp-sheet-panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: var(--sheet-max);
  background: var(--bg-2);
  border-top-left-radius: var(--sheet-radius);
  border-top-right-radius: var(--sheet-radius);
  box-shadow: var(--shadow-modal);
  transform: translateY(100%);
  transition: transform var(--t-mid);
  padding-bottom: var(--sa-bottom);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  will-change: transform;
}
.rsp-sheet[aria-hidden="false"] .rsp-sheet-panel { transform: translateY(0); }

.rsp-sheet-handle {
  width: 44px;
  height: 4px;
  margin: 10px auto 6px;
  border-radius: 999px;
  background: var(--line-3);
  flex-shrink: 0;
}

.rsp-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 16px 12px;
  border-bottom: 1px solid var(--line-1);
  flex-shrink: 0;
}
.rsp-sheet-title {
  font: 600 16px var(--font-ui);
  color: var(--text-0);
  margin: 0;
}
.rsp-sheet-close {
  width: var(--tap);
  height: var(--tap);
  border: 0;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rsp-sheet-close:hover { background: var(--bg-4); color: var(--text-0); }

.rsp-sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 18px;
  flex: 1;
}

/* ── Segmented control ────────────────────────────────────── */
.rsp-segmented {
  display: inline-flex;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 3px;
  gap: 2px;
}
.rsp-segmented-item {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: 500 13px var(--font-ui);
  padding: 7px 14px;
  border-radius: calc(var(--r-lg) - 3px);
  cursor: pointer;
  min-height: 34px;
  transition: background var(--t-fast), color var(--t-fast);
}
.rsp-segmented-item[aria-selected="true"] {
  background: var(--bg-1);
  color: var(--text-0);
  box-shadow: var(--shadow-card);
}

/* ── Stepper accordion ────────────────────────────────────── */
.rsp-stepper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rsp-stepper-item {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.rsp-stepper-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
  min-height: var(--tap);
  font: inherit;
}
.rsp-stepper-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-4);
  color: var(--text-1);
  font: 600 12px var(--font-mono);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rsp-stepper-item[data-complete="true"] .rsp-stepper-num {
  background: var(--accent);
  color: var(--bg-0);
}
.rsp-stepper-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.rsp-stepper-title {
  font: 600 14px var(--font-ui);
  color: var(--text-0);
  line-height: 1.2;
}
.rsp-stepper-value {
  font: 400 12px var(--font-ui);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rsp-stepper-chev {
  color: var(--text-2);
  transition: transform var(--t-fast);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.rsp-stepper-item[aria-expanded="true"] .rsp-stepper-chev {
  transform: rotate(90deg);
}
.rsp-stepper-body {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--line-1);
}
.rsp-stepper-item[aria-expanded="false"] .rsp-stepper-body {
  display: none;
}

/* ── Persistent rail (for tablets) ────────────────────────── */
.rsp-rail {
  display: none; /* opt-in via body.has-tablet-rail in tablet.css */
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--rail-w-tablet);
  background: var(--bg-1);
  border-right: 1px solid var(--line-2);
  z-index: 60;
  padding: calc(var(--sa-top) + 8px) 0 calc(var(--sa-bottom) + 8px);
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.rsp-rail-item {
  width: calc(var(--rail-w-tablet) - 10px);
  min-height: 52px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.rsp-rail-item:hover   { background: var(--bg-4); color: var(--text-0); }
.rsp-rail-item[aria-selected="true"] {
  color: var(--accent);
  background: var(--accent-tint);
}
.rsp-rail-item-icon { width: 22px; height: 22px; display: block; }
.rsp-rail-item-label {
  font: 500 10px var(--font-ui);
  letter-spacing: 0.02em;
}

/* ── Generic mobile card ──────────────────────────────────── */
.rsp-card {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}

/* ── Swipe action row ─────────────────────────────────────── */
.rsp-swipe-row {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
  /* The visual chrome (border, bg, padding) lives on .rsp-swipe-content
     so the slide animation reveals the .rsp-swipe-action behind. The
     row itself stays transparent. */
  background: transparent;
}
.rsp-swipe-content {
  position: relative;
  z-index: 2;
  transition: transform var(--t-fast);
  will-change: transform;
  /* Inherit any background the consumer applied to .rsp-swipe-row */
  background: inherit;
}
.rsp-swipe-action {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  color: white;
  font: 600 13px var(--font-ui);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.rsp-swipe-action--delete   { right: 0; width: 96px; background: var(--bad); }
.rsp-swipe-action--complete { left:  0; width: 96px; background: var(--good); }
/* "Armed" state: when dragged past the commit threshold, expand the
   action panel for clearer commit feedback. */
.rsp-swipe-row.is-armed .rsp-swipe-action--delete   { width: 100%; justify-content: flex-end; padding-right: 22px; }
.rsp-swipe-row.is-armed .rsp-swipe-action--complete { width: 100%; justify-content: flex-start; padding-left: 22px; }

/* Mission cards adopt the swipe-row pattern. Visual chrome moves to
   the inner .rsp-swipe-content so the card slides left as one piece. */
.mission-item.rsp-swipe-row {
  background: transparent;
  border: none;
  padding: 0;
}
.mission-item.rsp-swipe-row .rsp-swipe-content {
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-left: 2px solid var(--accent);
  padding: 10px 12px;
  transition: transform var(--t-fast), border-color 0.15s;
}
.mission-item.rsp-swipe-row:hover .rsp-swipe-content {
  border-color: var(--accent-tint);
}

/* ── Pull-to-refresh indicator ────────────────────────────── */
.rsp-ptr {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  overflow: hidden;
  pointer-events: none;
  transition: height var(--t-fast);
}
.rsp-ptr[data-state="pulling"],
.rsp-ptr[data-state="armed"],
.rsp-ptr[data-state="refreshing"] { height: 44px; }
.rsp-ptr-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: rsp-spin 0.8s linear infinite;
}
@keyframes rsp-spin { to { transform: rotate(360deg); } }

/* ── Focus ring for keyboard users ────────────────────────── */
.rsp-sheet-panel :focus-visible,
.rsp-rail-item:focus-visible,
.rsp-segmented-item:focus-visible,
.rsp-stepper-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── POI sheet (mobile/tablet POI tap target) ────────────── */
.poi-sheet-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.poi-sheet-type {
  font: 500 12px var(--font-mono);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.poi-sheet-jurisdiction {
  font: 500 13px var(--font-ui);
  color: var(--text-1);
}
.poi-sheet-label {
  display: inline-block;
  font: 500 10px var(--font-mono);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 6px;
}
.poi-sheet-desc {
  font: 400 13px var(--font-ui);
  color: var(--text-1);
  line-height: 1.45;
  margin: 4px 0 0;
}
.poi-sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.poi-sheet-actions .btn {
  min-height: var(--tap);
  justify-content: center;
}

/* ── Skip-to-content link ─────────────────────────────────── */
/* Visually hidden until focused (Tab from page top). When focused,
   slides into view at the top-left as a clearly-styled link. */
.skip-link {
  position: fixed;
  top: -40px;
  left: 8px;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--bg-0);
  font: 600 13px var(--font-ui);
  text-decoration: none;
  border-radius: var(--r-md);
  transition: top var(--t-fast);
}
.skip-link:focus {
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  outline: 2px solid var(--text-0);
  outline-offset: 2px;
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .rsp-sheet-panel,
  .rsp-sheet-backdrop,
  .rsp-stepper-chev,
  .rsp-swipe-content,
  .rsp-ptr,
  .skip-link { transition: none !important; }
  .rsp-ptr-spinner { animation: none !important; }
  /* Pulsing route-chip dot is decorative — calm it down */
  .mobile-route-chip-dot { animation: none !important; }
}
