/* The Last-Mile Simulator — styles for the interactive stage injected by
   /assets/js/simulator.js into every [data-simulator-mount], plus the
   <noscript> diptych on /simulator/. Matches the M1 map language (mocks.css)
   and the FinMile token sheet. Animations here are decorative only — motion
   is driven by GSAP in simulator.js; the reduced-motion blanket in base.css
   kills the CSS keyframes automatically. */

/* ---------- Stage layout ---------- */
.sim { position: relative; }
.sim [hidden] { display: none !important; } /* beat display:flex/grid on [hidden] */
.sim-stage {
  display: grid;
  gap: var(--sp-6);
  justify-content: center;
  align-items: start;
}
@media (min-width: 900px) {
  .sim-stage { grid-template-columns: minmax(320px, 400px) 300px; }
}

.sim-phone-col { min-width: 0; }

/* ---------- Phone chrome: card <640px, bezel >=640px (same DOM) ---------- */
.sim-phone {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-raised);
  overflow: hidden;
  /* CLS 0: reserve the stage height before JS lays anything out */
  aspect-ratio: 9 / 15.5;
  max-height: 720px;
  margin-inline: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
}
@media (min-width: 640px) {
  .sim-phone {
    max-width: 380px;
    border: 10px solid var(--ink);
    border-radius: 40px;
    aspect-ratio: 9 / 16.5;
  }
  .sim-phone::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 104px; height: 20px;
    background: var(--ink);
    border-radius: 0 0 12px 12px;
    z-index: 6;
  }
}

/* ---------- App bar (reskins per universe via .sim[data-mode]) ---------- */
.sim-appbar {
  padding: 24px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  flex: none;
  position: relative;
  z-index: 5;
  transition: background-color .5s;
}
.sim[data-mode="any"] .sim-appbar { background: #605C78; }
.sim[data-mode="fin"] .sim-appbar { background: var(--indigo); }
.sim-brand { display: flex; flex-direction: column; min-width: 0; }
.sim-brand b {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.sim-tagline {
  font-size: 10.5px;
  opacity: .75;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sim-track-no {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  background: rgba(255,255,255,.14);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  white-space: nowrap;
}
.sim-fin-tile {
  width: 28px; height: 28px;
  flex: none;
  border-radius: 8px;
  background: #fff;
  display: none;
  align-items: center;
  justify-content: center;
}
.sim-fin-tile svg { width: 16px; height: 16px; display: block; }
.sim[data-mode="fin"] .sim-fin-tile { display: inline-flex; }
.sim[data-mode="fin"] .sim-tagline { opacity: .85; }

/* ---------- Map ---------- */
.sim-map-wrap { position: relative; flex: none; }
.sim-map { width: 100%; height: auto; display: block; background: #F8F7FE; }
.sim-map .simb { fill: var(--lilac); stroke: #DDD9F6; stroke-width: 1; }
.sim-map .simb-park { fill: #E4F2E9; }
.sim-map .sim-river { fill: var(--lavender); opacity: .35; }
.sim-map .sim-route {
  fill: none;
  stroke: var(--indigo);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sim-map .sim-stop { fill: #fff; stroke: var(--indigo); stroke-width: 2; }
.sim-map .sim-stop-num { font: 700 7px var(--font-body); fill: var(--indigo); }
.sim-map .sim-depot { fill: var(--indigo); }
.sim-map .sim-pin-body { fill: var(--ink); }
.sim-map .sim-pin-dot { fill: var(--indigo); }
.sim-map .sim-courier-chip {
  fill: #8A86A3;
  filter: drop-shadow(0 2px 3px rgba(13,10,43,.25));
}
.sim[data-mode="fin"] .sim-map .sim-courier-chip { fill: var(--indigo); }
.sim-map .sim-trail { fill: #8A86A3; opacity: 0; }
.sim[data-mode="fin"] .sim-map .sim-trail { fill: var(--indigo); }
.sim-map .sim-blob { fill: var(--error); opacity: 0; }
.sim-map .sim-ripple { fill: none; stroke: var(--success); stroke-width: 2; opacity: 0; }

/* Re-optimise chip — one of the page's only lime uses */
.sim-remap-chip {
  position: absolute;
  top: 26%;
  right: 6%;
  background: var(--lime);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--r-pill);
  padding: 5px 11px;
  box-shadow: var(--shadow-raised);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
}

/* ---------- ETA pill (overlaid on the map) ---------- */
.sim-eta {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 4;
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-raised);
  padding: 7px 14px;
  font-size: 12px;
}
.sim-eta-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-40);
}
.sim-eta-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  overflow: hidden;
}
.sim-eta-num { display: inline-block; white-space: nowrap; }
.sim-eta-tick { font-size: 11px; font-weight: 800; display: none; }
.sim-eta[data-state="creep"] .sim-eta-num { color: var(--error); }
.sim-eta[data-state="creep"] .sim-eta-tick { display: inline; color: var(--error); }
.sim-eta[data-state="stale"] .sim-eta-num { color: var(--text-40); }
.sim-eta[data-state="live"] .sim-eta-num { color: var(--indigo); }
.sim-eta[data-state="improved"] .sim-eta-num { color: var(--indigo); }
.sim-eta[data-state="improved"] .sim-eta-tick {
  display: inline;
  color: var(--ink);
  background: var(--lime); /* lime: ETA improvement tick */
  border-radius: 4px;
  padding: 0 3px;
}
.sim-eta[data-state="done"] .sim-eta-num { color: var(--success); }

/* ---------- Status feed ---------- */
.sim-feed-wrap {
  flex: 1;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 12px;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}
.sim-feed-head {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-40);
  margin-bottom: 6px;
  flex: none;
}
.sim-feed-head.is-stale { color: var(--error); }
.sim-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  flex: 1;
  overflow: hidden;
}
.sim-bubble {
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.45;
  max-width: 94%;
  position: relative;
}
.sim-bubble--sys {
  background: var(--lilac);
  color: var(--ink);
  align-self: flex-start;
}
.sim-bubble--sms {
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-left: 3px solid var(--indigo);
  color: var(--ink);
  align-self: flex-start;
  padding-right: 40px;
}
.sim-sms-tag {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--indigo);
  background: var(--indigo-08);
  border-radius: 4px;
  padding: 1px 4px;
}
.sim-bubble.is-old { opacity: .45; }

/* ---------- Compose overlay ---------- */
.sim-compose {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 40px 16px 16px;
  overflow-y: auto;
}
.sim-compose-head {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}
.sim-presets { display: grid; gap: 8px; border: 0; margin: 0; padding: 0; }
.sim-preset { position: relative; display: block; }
.sim-preset input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}
.sim-preset span {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--ink-border);
  border-radius: var(--r-md);
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: border-color var(--dur-fast), background-color var(--dur-fast);
}
.sim-preset span::before {
  content: '';
  width: 16px; height: 16px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--lavender);
  background: #fff;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.sim-preset input:checked + span {
  border-color: var(--indigo);
  background: var(--indigo-08);
}
.sim-preset input:checked + span::before {
  border-color: var(--indigo);
  box-shadow: inset 0 0 0 4px var(--indigo);
}
.sim-preset input:focus-visible + span {
  box-shadow: 0 0 0 1px var(--indigo), 0 0 0 4px var(--indigo-16);
}
.sim-fixedrow {
  font-size: 12px;
  color: var(--text-60);
  background: var(--surface);
  border: 1px dashed var(--ink-border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  margin: 0;
}
.sim-fixedrow b { color: var(--ink); font-weight: 600; }
.sim-send { margin-top: auto; width: 100%; justify-content: center; }

/* ---------- Bottom sheet (slip / POD / end card) ---------- */
.sim-sheet {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 9;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 40px rgba(13,10,43,.18);
  padding: 16px 16px 18px;
  max-height: 88%;
  overflow-y: auto;
  transform: translateY(105%);
  visibility: hidden;
}
.sim-sheet.is-open { transform: none; visibility: visible; }
.sim-sheet:focus { outline: none; }
.sim-sheet-actions { display: grid; gap: 8px; margin-top: 12px; }
.sim-sheet-actions .btn { justify-content: center; font-size: 14px; padding: 13px 20px; }
.sim-caption {
  text-align: center;
  font-size: 12px;
  color: var(--text-60);
  margin: 8px 0 0;
}
.sim-btn-pulse { animation: simPulse 1.8s ease-in-out infinite; }
@keyframes simPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74,37,224,.35); }
  50% { box-shadow: 0 0 0 9px rgba(74,37,224,0); }
}

/* Slip card — the dreaded physical "we missed you" slip */
.sim-slip {
  border: 2px dashed var(--ink-40);
  border-radius: var(--r-sm);
  padding: 14px;
  background: #FFFDF6;
  color: var(--ink);
  position: relative;
  overflow: hidden;
}
.sim-slip-head {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.01em;
  margin: 0 0 10px;
  text-transform: uppercase;
}
.sim-slip ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 7px; }
.sim-slip li { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; line-height: 1.4; }
.sim-cb {
  flex: none;
  width: 14px; height: 14px;
  margin-top: 2px;
  border: 1.5px solid var(--ink-60);
  border-radius: 3px;
  background: #fff;
  position: relative;
}
.sim-cb.is-checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}
.sim-slip-note {
  font-size: 12px;
  font-style: italic;
  color: var(--ink-80);
  border-top: 1px dashed var(--ink-40);
  padding-top: 8px;
  margin: 0 0 6px;
}
.sim-slip-window { font-size: 12px; margin: 0; font-weight: 600; }
.sim-watermark {
  position: absolute;
  right: -8px;
  bottom: 6px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
  opacity: .08;
  transform: rotate(-8deg);
  pointer-events: none;
  white-space: nowrap;
}

/* POD card */
.sim-pod { text-align: center; }
.sim-pod-art {
  width: 150px;
  margin: 0 auto 8px;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--ink-border);
}
.sim-pod-art svg { width: 100%; height: auto; display: block; }
.sim-pod-cap { font-size: 12.5px; color: var(--text-60); margin: 0 0 2px; }
.sim-pod-time { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--success); margin: 0; }

/* End card */
.sim-end { text-align: center; }
.sim-tick-ring {
  width: 62px; height: 62px;
  margin: 2px auto 10px;
  border-radius: 50%;
  background: var(--lilac);
  color: var(--indigo);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sim-tick-ring svg { width: 28px; height: 28px; stroke-width: 2.5; }
.sim-end-head {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .02em;
  margin: 0;
}
.sim-end-sub { font-size: 13px; color: var(--text-60); margin: 2px 0 10px; }
.sim-end-meta { font-size: 12px; font-weight: 600; margin: 0 0 6px; }
.sim-zeros {
  font-size: 11.5px;
  color: var(--text-60);
  background: var(--bg);
  border-radius: var(--r-md);
  padding: 8px 10px;
  margin: 0 0 6px;
}
.sim-count { font-size: 12px; color: var(--text-60); margin: 0; }
.sim-end-link {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 4px;
}

/* ---------- Controls row ---------- */
.sim-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-top: var(--sp-4);
  min-height: 42px;
}
.sim-speed, .sim-skip, .sim-next {
  font: 600 13px var(--font-body);
  color: var(--ink-80);
  background: var(--surface);
  border: 1.5px solid var(--ink-border);
  border-radius: var(--r-pill);
  padding: 8px 16px;
  cursor: pointer;
  transition: border-color var(--dur-fast), background-color var(--dur-fast), color var(--dur-fast);
}
.sim-speed[aria-pressed="true"] {
  background: var(--indigo);
  border-color: var(--indigo);
  color: #fff;
}
.sim-skip { display: none; }
.sim-skip.is-on { display: inline-block; }
.sim-next { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.sim-next:hover { background: var(--indigo-deep); }
.sim-speed:hover, .sim-skip:hover { border-color: var(--indigo); color: var(--indigo); }

/* Universe toggle (segmented radiogroup, unlocks in FREEPLAY) */
.sim-toggle {
  display: inline-flex;
  border: 0;
  margin: 0;
  padding: 3px;
  background: var(--surface);
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1.5px var(--ink-border);
  position: relative;
  overflow: hidden;
}
.sim-toggle.is-locked { opacity: .45; }
.sim-toggle label { position: relative; display: inline-block; }
.sim-toggle input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.sim-toggle input:disabled { cursor: not-allowed; }
.sim-toggle span {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-80);
  border-radius: var(--r-pill);
  padding: 7px 13px;
  white-space: nowrap;
  transition: background-color var(--dur-fast), color var(--dur-fast);
}
.sim-toggle input:checked + span { background: var(--indigo); color: #fff; }
.sim-toggle input:focus-visible + span { box-shadow: 0 0 0 2px var(--indigo-16); }
.sim-toggle .sim-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(255,255,255,.85) 50%, transparent 62%);
  transform: translateX(-110%);
  pointer-events: none;
}
.sim-toggle.is-unlocking .sim-shine { animation: simShine .9s var(--ease-out) 2; }
@keyframes simShine { to { transform: translateX(110%); } }

/* ---------- Confetti (pooled spans; exactly 4 lime) ---------- */
.sim-confetti {
  position: absolute;
  z-index: 5;
  width: 0; height: 0;
  pointer-events: none;
}
.sim-confetti i {
  position: absolute;
  width: 7px; height: 10px;
  border-radius: 2px;
  background: var(--indigo);
  opacity: 0;
  will-change: transform, opacity;
}
.sim-confetti i:nth-child(3n) { background: var(--lavender); }
.sim-confetti i:nth-child(3n+2) { background: #fff; border: 1px solid var(--ink-border); }
.sim-confetti i.is-lime { background: var(--lime); border: 0; } /* the only other lime */

/* ---------- Ops panel (desktop only) ---------- */
.sim-ops { display: none; }
@media (min-width: 900px) {
  .sim-ops {
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-rest);
    padding: var(--sp-5);
    min-height: 380px;
    position: sticky;
    top: 100px;
  }
}
.sim-ops-head {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 var(--sp-4);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sim-ops-head::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--lavender);
}
.sim[data-mode="fin"] .sim-ops-head::before { background: var(--success); }
.sim-ops-dead {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: var(--text-40);
  font-size: 14px;
}
.sim-ops-dead .sim-ops-refresh {
  font: 600 12.5px var(--font-body);
  color: var(--text-60);
  background: none;
  border: 1.5px solid var(--ink-border);
  border-radius: var(--r-pill);
  padding: 8px 16px;
  cursor: not-allowed;
}
.sim-ops-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; flex: 1; align-content: start; }
.sim-ops-log li {
  display: flex;
  gap: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-80);
  border-left: 2px solid var(--lilac);
  padding-left: 9px;
}
.sim-ops-log li time {
  flex: none;
  font-variant-numeric: tabular-nums;
  color: var(--text-40);
  font-weight: 600;
}
.sim-kpis {
  border-top: 1px solid var(--ink-border);
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  opacity: 0;
}
.sim-kpis.is-on { opacity: 1; transition: opacity .5s; }

/* ---------- Static diptych (noscript / no-GSAP fallback) ---------- */
.sim-diptych { display: grid; gap: var(--sp-5); margin-top: var(--sp-6); }
@media (min-width: 720px) { .sim-diptych { grid-template-columns: 1fr 1fr; align-items: stretch; } }
.sim-diptych .sim-slip, .sim-diptych .sim-delivered { height: 100%; }
.sim-delivered {
  background: var(--surface);
  border: 1px solid var(--ink-border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  text-align: center;
  box-shadow: var(--shadow-rest);
}
.sim-diptych-label {
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-40);
  margin: 0 0 var(--sp-3);
  text-align: center;
}

/* Fallback teaser card (visible until JS swaps it, and for no-JS) */
.sim-fallback-card {
  background: var(--lilac);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  text-align: center;
}
