/* TMS Autonomous Walkthrough — canonical Drop 1 presentation only.
   Session, checkpoint and control truth remains in TMSDriverWalkthrough. */
#tmsWalkthroughPlayer {
  position: fixed;
  inset: 0;
  z-index: var(--tms-z-modal, 4000000);
  box-sizing: border-box;
  overflow: auto;
  overscroll-behavior: contain;
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px
    max(12px, var(--tms-safe-bottom, 0px), var(--tms-kb-inset, 0px));
  color: #f8fafc;
  background:
    radial-gradient(circle at 82% 8%, rgba(37, 99, 235, .28), transparent 32%),
    linear-gradient(155deg, #050a15, #0b1730 55%, #061326);
  font-family: inherit;
}

#tmsWalkthroughPlayer * { box-sizing: border-box; }

.twp-shell {
  width: min(760px, 100%);
  min-height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
}

.twp-head,
.twp-progress-label,
.twp-partner {
  display: flex;
  align-items: center;
}

.twp-head { justify-content: space-between; gap: 14px; }
.twp-head > div { display: grid; gap: 2px; }
.twp-kicker { color: #7dd3fc; font-size: 11px; font-weight: 900; letter-spacing: .13em; }
.twp-head strong { font-size: 18px; }

.twp-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #25324b;
}

.twp-progress > i {
  display: block;
  width: 2%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  transition: width .25s ease;
}

.twp-progress-label { justify-content: space-between; color: #94a3b8; font-size: 12px; font-weight: 800; }

.twp-card {
  align-self: center;
  width: 100%;
  padding: clamp(22px, 6vw, 46px);
  border: 1px solid #334155;
  border-radius: 24px;
  background: rgba(15, 23, 42, .94);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .52);
}

.twp-partner { gap: 11px; margin-bottom: 22px; }
.twp-partner > span {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid #34d399;
  border-radius: 50%;
  background: #064e3b;
  color: #d1fae5;
  font-weight: 950;
}
.twp-partner > div { display: grid; }
.twp-partner small, .twp-step { color: #7dd3fc; font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.twp-card h1 { margin: 9px 0 14px; font-size: clamp(29px, 7vw, 50px); line-height: 1.04; }
.twp-body { margin: 0; color: #dbeafe; font-size: clamp(16px, 3.8vw, 19px); line-height: 1.55; }
.twp-isolation { margin: 20px 0 0; padding: 13px; border-left: 3px solid #34d399; color: #bbf7d0; background: rgba(6, 78, 59, .3); line-height: 1.45; }
.twp-status { min-height: 24px; margin-top: 16px; color: #fef3c7; font-weight: 800; }

.twp-controls {
  position: sticky;
  bottom: max(0px, var(--tms-kb-inset, 0px));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid #334155;
  border-radius: 18px;
  background: rgba(7, 16, 31, .97);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .28);
}

.twp-control {
  min-width: 0;
  min-height: 48px;
  padding: 9px 10px;
  border: 1px solid #475569;
  border-radius: 12px;
  color: #e2e8f0;
  background: #17233b;
  font: 800 14px/1.15 inherit;
  touch-action: manipulation;
}

.twp-control:focus-visible { outline: 3px solid #7dd3fc; outline-offset: 2px; }
.twp-control:disabled { opacity: .46; cursor: not-allowed; }
.twp-primary { border-color: #22c55e; color: #052e16; background: #22c55e; }
.twp-exit { min-width: 112px; border-color: #64748b; background: transparent; }

/* W1 and W2 live on the real FuelDesk document. The canonical player becomes a
   coaching layer instead of replacing the production surface. */
#tmsWalkthroughPlayer[data-checkpoint="W1"],
#tmsWalkthroughPlayer[data-checkpoint="W2"] {
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(2, 6, 23, .64), transparent 24%, transparent 72%, rgba(2, 6, 23, .7));
}
#tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-shell,
#tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-shell { pointer-events: auto; }
#tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-head,
#tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-head,
#tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-progress,
#tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-progress,
#tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-progress-label,
#tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-progress-label,
#tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-card,
#tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-card,
#tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-controls,
#tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-controls { pointer-events: auto; }
#tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-card,
#tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-card {
  align-self: start;
  width: min(540px, 100%);
  max-height: calc(100dvh - 245px);
  margin: 0 auto;
  overflow: auto;
  padding: 20px;
  border-color: #3b82f6;
  background: rgba(8, 17, 35, .97);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .56);
}
.twp-load,
.twp-result {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.twp-load > div,
.twp-result > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 11px;
  border: 1px solid #334155;
  border-radius: 12px;
  background: #101d34;
}
.twp-load small,
.twp-result small { color: #93c5fd; font-size: 10px; font-weight: 900; letter-spacing: .1em; }
.twp-load strong,
.twp-result strong { overflow-wrap: anywhere; font-size: 16px; }
.twp-load > div:nth-child(1),
.twp-load > div:nth-child(2),
.twp-load-offer,
.twp-result-hero { grid-column: 1 / -1; }
.twp-load-offer { border-color: #22c55e !important; background: rgba(6, 78, 59, .48) !important; }
.twp-load-offer strong { color: #86efac; font-size: 27px; }
.twp-result-hero { border-color: #fb923c !important; background: rgba(124, 45, 18, .35) !important; text-align: center; }
.twp-result-hero strong { color: #fdba74; font-size: clamp(31px, 8vw, 46px); }
.twp-result-hero span { color: #fed7aa; font-weight: 900; }
.twp-analyze {
  position: sticky;
  bottom: 0;
  z-index: 2;
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 14px;
  color: #052e16;
  background: #22c55e;
  font: 950 17px/1.1 inherit;
  touch-action: manipulation;
}
.twp-analyze:focus-visible { outline: 3px solid #7dd3fc; outline-offset: 3px; }
.twp-analyze:disabled { opacity: .62; }
.twp-green-context,
.twp-green-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 13px 0;
}
.twp-green-context > div,
.twp-green-compare > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid #334155;
  border-radius: 13px;
  background: #101d34;
  text-align: center;
}
.twp-green-context small,
.twp-green-compare small { color: #93c5fd; font-size: 10px; font-weight: 900; letter-spacing: .09em; }
.twp-green-context strong,
.twp-green-compare strong { font-size: clamp(23px, 7vw, 37px); overflow-wrap: anywhere; }
.twp-green-context span,
.twp-green-compare span { color: #cbd5e1; font-size: 11px; font-weight: 800; }
.twp-green-compare { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.twp-green-compare #twpGreenTarget { border-color: #22c55e; background: rgba(6, 78, 59, .5); }
.twp-green-compare #twpGreenTarget strong { color: #86efac; }
.twp-green-compare #twpGreenGap { border-color: #f59e0b; background: rgba(120, 53, 15, .36); }
.twp-green-compare #twpGreenGap strong { color: #fcd34d; }
.twp-green-rate { margin: 7px 0 12px; color: #bae6fd; text-align: center; }
.twp-green-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.twp-green-actions button {
  min-height: 46px;
  border: 1px solid #38bdf8;
  border-radius: 12px;
  color: #e0f2fe;
  background: rgba(3, 105, 161, .3);
  font: 850 14px/1.2 inherit;
}
body.tms-autonomous-w1 .fueldesk-wrap,
body.tms-autonomous-w2 .fueldesk-wrap { padding-bottom: 190px; }

/* The existing voice arbiter owns this Speaking/Stop surface. While it is
   active, reserve its measured top band so neither branding nor the always-
   available Exit control sits underneath it. */
body:has(#tmsVoiceState) #tmsWalkthroughPlayer .twp-head {
  margin-top: 68px;
}

@media (max-width: 520px) {
  #tmsWalkthroughPlayer { padding-inline: 9px; }
  .twp-card { padding: 22px 18px; }
  .twp-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .twp-control { min-height: 52px; }
  #tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-head strong,
  #tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-head strong { font-size: 14px; }
  #tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-card,
  #tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-card {
    max-height: calc(100dvh - 275px);
    padding: 15px;
    border-radius: 18px;
  }
  #tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-partner,
  #tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-partner { margin-bottom: 9px; }
  #tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-partner > span,
  #tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-partner > span { width: 38px; height: 38px; }
  #tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-card h1,
  #tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-card h1 { margin-block: 5px 9px; font-size: 24px; }
  #tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-body,
  #tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-body,
  #tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-isolation,
  #tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-isolation { font-size: 13px; line-height: 1.35; }
  #tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-isolation,
  #tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-isolation { margin-top: 9px; padding: 8px; }
  .twp-load, .twp-result { margin: 9px 0; gap: 6px; }
  .twp-load > div, .twp-result > div { padding: 8px; }
  .twp-analyze { min-height: 50px; }
  .twp-green-context, .twp-green-compare { margin: 8px 0; gap: 6px; }
  .twp-green-context > div, .twp-green-compare > div { padding: 8px 6px; }
  .twp-green-compare strong { font-size: clamp(21px, 7vw, 30px); }
  .twp-green-compare span { font-size: 10px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  #tmsWalkthroughPlayer { padding-block: 6px; }
  .twp-shell { height: 100%; min-height: 0; gap: 6px; grid-template-rows: auto auto auto minmax(0, 1fr) auto; }
  .twp-head strong { font-size: 15px; }
  .twp-card { align-self: stretch; min-height: 0; overflow: auto; padding: 15px 18px; }
  .twp-partner { margin-bottom: 8px; }
  .twp-partner > span { width: 38px; height: 38px; }
  .twp-card h1 { margin: 5px 0 8px; font-size: 25px; }
  .twp-body, .twp-isolation { font-size: 13px; line-height: 1.35; }
  .twp-isolation { margin-top: 8px; padding: 7px 10px; }
  .twp-status { min-height: 18px; margin-top: 6px; font-size: 12px; }
  .twp-controls { position: sticky; bottom: 0; grid-template-columns: repeat(6, minmax(0, 1fr)); padding: 6px; }
  .twp-control { min-height: 44px; padding: 6px; font-size: 12px; }
  body:has(#tmsVoiceState) #tmsWalkthroughPlayer .twp-head { margin-top: 62px; }
}

@media (prefers-reduced-motion: reduce) {
  #tmsWalkthroughPlayer *,
  #tmsWalkthroughPlayer *::before,
  #tmsWalkthroughPlayer *::after {
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* FIX-164 (2026-12-04, Jesse's report): on step W1/W2 the guide card always
   fits BETWEEN the header and the button bar, so "Analyze This Load" can never
   slide under Back/Pause — on any phone height or text size. The card scrolls
   inside its own space and Analyze stays pinned at its bottom. (The voice band
   above is now reserved the whole time the guide is open, so the guide no
   longer jumps down and up each time the Business Partner starts or stops
   talking.) */
#tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-shell,
#tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-shell { height: 100%; min-height: 0; }
#tmsWalkthroughPlayer[data-checkpoint="W1"] .twp-card,
#tmsWalkthroughPlayer[data-checkpoint="W2"] .twp-card { max-height: 100%; min-height: 0; }
.twp-w1-notice { margin: 10px 0; padding: 10px 12px; border: 1px solid #f59e0b; border-radius: 12px; color: #fef3c7; background: rgba(120, 53, 15, .45); font-weight: 800; line-height: 1.35; }
/* FIX-164: on a phone the card covers FuelDesk anyway, so the guide gets its
   own solid background — no app buttons or text showing through behind the
   header ("FuelDesk" under "Exit Walkthrough" in Jesse's screenshot). */
@media (max-width: 520px) {
  #tmsWalkthroughPlayer[data-checkpoint="W1"],
  #tmsWalkthroughPlayer[data-checkpoint="W2"] {
    background:
      radial-gradient(circle at 82% 8%, rgba(37, 99, 235, .28), transparent 32%),
      linear-gradient(155deg, #050a15, #0b1730 55%, #061326);
  }
}
