/* The animation shares the application's typography, rules and selection states.
   JavaScript owns the sequence and moving properties; this file owns geometry. */
.product-section.cinema-section {
  height: 100svh;
  min-height: 0;
  padding: 0;
}

.dispatch-cinema {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100svh;
  overflow: hidden;
  border-top: 1px solid var(--lw-line);
  background: var(--lw-ground);
  color: var(--lw-ink);
  font: 400 16px/1.4 var(--lw-font);
  font-variant-numeric: tabular-nums;
}

.algorithm-layout {
  --candidate-row-height: 96px;
  --candidate-columns: 148px minmax(0, 1fr) 104px 132px;
  --candidate-gap: 20px;
  width: min(1120px, calc(100% - 112px));
  min-width: 0;
  margin: 0 auto;
  padding-block: 28px;
}

.algorithm-heading {
  min-height: 39px;
  margin-bottom: 24px;
}

.algorithm-phase {
  display: block;
  font: 600 32px/1.2 var(--lw-font-display);
  text-transform: uppercase;
}

.request-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 84px;
  gap: 24px;
  margin-bottom: 24px;
  padding: 16px 20px;
  border: 1px solid var(--lw-line);
  border-left: 3px solid var(--lw-accent);
  border-radius: var(--lw-radius-sm);
}

.request-copy,
.request-spec {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 4px;
}

.request-copy strong,
.request-spec strong {
  font-size: 16px;
  font-weight: 500;
}

.request-copy span,
.request-spec span {
  color: var(--lw-muted);
  font-size: 14px;
}

.request-spec {
  flex-shrink: 0;
  text-align: right;
}

.comparison-head,
.option-row {
  display: grid;
  grid-template-columns: var(--candidate-columns);
  column-gap: var(--candidate-gap);
}

.comparison-head {
  align-items: center;
  height: 34px;
  padding: 0 18px;
  border-bottom: 1px solid var(--lw-line);
  color: var(--lw-muted);
  font-size: 13px;
}

.comparison-head > :nth-child(n + 3) {
  text-align: right;
}

.algorithm-rows {
  position: relative;
  height: calc(3 * var(--candidate-row-height));
  min-width: 0;
}

.option-row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  align-items: center;
  height: var(--candidate-row-height);
  min-width: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--lw-line);
  border-left: 2px solid transparent;
  background: var(--lw-ground);
}

.option-row.is-selected {
  z-index: 1;
  border-left-color: var(--lw-accent);
  background: var(--lw-selection);
}

.candidate-vehicle {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 5px;
}

.candidate-vehicle strong {
  font-size: 16px;
  font-weight: 500;
}

.candidate-vehicle span {
  color: var(--lw-muted);
  font-size: 12px;
  white-space: nowrap;
}

.candidate-schedule {
  position: relative;
  min-width: 0;
  height: 64px;
}

.schedule-axis {
  position: absolute;
  inset: 0 0 auto;
  height: 14px;
  color: var(--lw-muted);
  font-size: 10px;
  line-height: 1.2;
}

.schedule-axis > span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
}

.schedule-axis > span:first-child {
  transform: none;
}

.schedule-axis > span:last-child {
  transform: translateX(-100%);
}

.route-existing,
.insertion-preview {
  position: absolute;
  top: 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 40px;
  min-width: 0;
  overflow: hidden;
  gap: 2px;
  padding: 5px 8px;
  border-radius: var(--lw-radius-sm);
}

.route-existing {
  border: 1px solid var(--lw-line);
  background: var(--lw-surface);
  color: var(--lw-body);
}

.route-existing strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insertion-preview {
  border: 1px solid var(--lw-accent);
  background: var(--lw-ground);
  color: var(--lw-accent);
}

.insertion-preview strong,
.insertion-preview span {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insertion-preview strong {
  font-weight: 500;
}

.insertion-preview span {
  font-size: 11px;
}

.insertion-preview.is-inserted {
  border-color: var(--lw-accent);
  background: var(--lw-accent);
  color: var(--lw-inverse);
}

.candidate-detour,
.candidate-contribution {
  min-width: 0;
  text-align: right;
}

.metric-label {
  display: none;
}

.candidate-detour strong,
.candidate-contribution strong {
  display: inline-block;
  font-size: 16px;
  font-weight: 400;
  white-space: nowrap;
}

.candidate-contribution strong {
  padding: 4px 6px;
  margin-right: -6px;
}

.candidate-contribution.is-selected strong {
  background: var(--lw-signal);
  color: var(--lw-ink);
  font-weight: 500;
}

.chosen-route {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 20px;
  min-height: 100px;
  margin-top: 28px;
  padding: 18px;
  border-top: 1px solid var(--lw-line);
}

.route-caption {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.route-caption strong {
  font-size: 16px;
  font-weight: 500;
}

.route-caption span {
  color: var(--lw-muted);
  font-size: 12px;
}

.route-stops {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}

.route-stops::before {
  content: '';
  position: absolute;
  top: 5px;
  right: 25%;
  left: 4px;
  height: 1px;
  background: var(--lw-line);
}

.route-stop {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 3px;
  padding-top: 20px;
}

.route-stop::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 0;
  width: 7px;
  height: 7px;
  border: 1px solid var(--lw-control);
  border-radius: 50%;
  background: var(--lw-ground);
}

.route-stop time {
  font-size: 12px;
}

.route-stop strong {
  font-size: 14px;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.route-stop.is-added {
  color: var(--lw-accent);
}

.route-stop.is-added::before {
  border-color: var(--lw-accent);
  background: var(--lw-accent);
}

@media (max-width: 1100px) and (min-width: 761px) {
  .algorithm-layout {
    --candidate-columns: 112px minmax(0, 1fr) 80px 96px;
    --candidate-gap: 12px;
    width: calc(100% - 64px);
  }

  .chosen-route {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 12px;
  }
}

@media (max-width: 760px) {
  .algorithm-layout {
    --candidate-row-height: 112px;
    width: calc(100% - 40px);
    padding-block: 20px;
  }

  .algorithm-heading {
    margin-bottom: 20px;
  }

  .algorithm-phase {
    font-size: 30px;
  }

  .request-strip {
    min-height: 84px;
    gap: 12px;
    margin-bottom: 20px;
    padding: 14px 12px;
  }

  .request-copy strong,
  .request-spec strong {
    font-size: 14px;
  }

  .request-copy span,
  .request-spec span {
    font-size: 11px;
  }

  .request-copy span {
    max-width: 180px;
  }

  .comparison-head {
    display: none;
  }

  .option-row {
    grid-template-columns: minmax(0, 1fr) 78px 92px;
    grid-template-rows: 36px 50px;
    column-gap: 8px;
    row-gap: 4px;
    align-items: center;
    padding: 10px 10px;
  }

  .candidate-vehicle {
    gap: 1px;
  }

  .candidate-vehicle strong {
    font-size: 14px;
  }

  .candidate-vehicle span {
    font-size: 10px;
  }

  .candidate-schedule {
    grid-column: 1 / -1;
    grid-row: 2;
    height: 50px;
  }

  .candidate-detour {
    grid-column: 2;
    grid-row: 1;
  }

  .candidate-contribution {
    grid-column: 3;
    grid-row: 1;
  }

  .metric-label {
    display: block;
    margin-bottom: 1px;
    color: var(--lw-muted);
    font-size: 10px;
    line-height: 1.1;
  }

  .candidate-detour strong,
  .candidate-contribution strong {
    font-size: 15px;
    line-height: 1.15;
  }

  .candidate-contribution strong {
    padding: 3px 4px;
    margin-right: -4px;
  }

  .schedule-axis {
    font-size: 9px;
  }

  .route-existing,
  .insertion-preview {
    top: 17px;
    height: 32px;
    padding: 3px 5px;
    gap: 1px;
  }

  .route-existing strong {
    font-size: 11px;
  }

  .insertion-preview strong {
    font-size: 11px;
  }

  .insertion-preview span {
    font-size: 10px;
  }

  .chosen-route {
    grid-template-columns: minmax(0, 1fr);
    min-height: 112px;
    gap: 14px;
    margin-top: 22px;
    padding: 14px 0 0;
  }

  .route-caption {
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
  }

  .route-caption strong {
    font-size: 14px;
  }

  .route-stops {
    gap: 8px;
  }

  .route-stop {
    gap: 2px;
    padding-top: 17px;
  }

  .route-stop time {
    font-size: 11px;
  }

  .route-stop strong {
    font-size: 12px;
    line-height: 1.2;
  }
}

/* Keep a complete composition on laptop and short mobile viewports. */
@media (max-height: 740px) and (min-width: 761px) {
  .algorithm-layout {
    --candidate-row-height: 82px;
    padding-block: 18px;
  }

  .algorithm-heading {
    min-height: 34px;
    margin-bottom: 16px;
  }

  .algorithm-phase {
    font-size: 28px;
  }

  .request-strip {
    min-height: 72px;
    margin-bottom: 16px;
    padding-block: 12px;
  }

  .chosen-route {
    min-height: 88px;
    margin-top: 18px;
    padding-block: 14px;
  }
}

@media (max-height: 740px) and (max-width: 760px) {
  .algorithm-layout {
    --candidate-row-height: 102px;
    padding-block: 12px;
  }

  .algorithm-heading {
    min-height: 32px;
    margin-bottom: 12px;
  }

  .algorithm-phase {
    font-size: 27px;
  }

  .request-strip {
    min-height: 70px;
    margin-bottom: 12px;
    padding-block: 10px;
  }

  .option-row {
    grid-template-rows: 32px 46px;
    padding-block: 8px;
  }

  .candidate-schedule {
    height: 46px;
  }

  .chosen-route {
    min-height: 100px;
    gap: 10px;
    margin-top: 16px;
    padding-top: 10px;
  }
}
