/*
 * Design tokens from the Routific Website Figma file (variables on node 7166:92349).
 * Code components render inside Shadow DOM, so tokens are declared on :host as well as :root
 * (:root covers the local preview and Webflow's own page; :host covers the shadow tree).
 */
:host,
:host {
  /* Brand */
  --rt-indigo-100: #374cd2;
  --rt-indigo-200: #667afa;
  --rt-yellow-200: #ffad0a;
  --rt-yellow-border: #b97b01;
  --rt-turquoise: #45c4d7;
  --rt-primary-500: #326bfc;
  --rt-primary-600: #1750e3;
  --rt-hero-blue: #1f36a7;
  --rt-hero-lilac: #eceefb;

  /* Text */
  --rt-text-primary: #282828;
  --rt-text-secondary: #676d7e;
  --rt-text-tertiary: #9da1af;

  /* Route colours */
  --rt-route-violet: #7547bf;
  --rt-route-pink: #ff85a9;
  --rt-route-sky: #269ed1;
  --rt-route-lilac: #a770db;

  /* Type — Proxima Nova is expected to be loaded by the Webflow site (Adobe Fonts);
     Plus Jakarta Sans and Figtree are loaded from Google Fonts by useDocumentFonts(). */
  --rt-font-display: "Plus Jakarta Sans", system-ui, sans-serif;
  --rt-font-heading: "Figtree", system-ui, sans-serif;
  --rt-font-body: "proxima-nova", "Proxima Nova", "Figtree", system-ui, sans-serif;
  --rt-font-ui: "SF Pro Text", -apple-system, "Inter", system-ui, sans-serif;

  /* Radii */
  --rt-radius-md: 8px;
  --rt-radius-lg: 16px;

  /* Vector map (Hero/showcase/MapBase.tsx): Mapbox-light look of the current Routific UI */
  --map-land: #edeff3;
  --map-street: #fcfdfe;
  --map-park: #d3e9d1;
  --map-water: #b3caf3;
  --map-industrial: #f2e4c6;
  --map-highway: #aab3c7;
  --map-highway-edge: #fcfdfe;
}

/* ---------------------------------------------------------------------------
 * Section (Figma 7166:88632)
 * ------------------------------------------------------------------------- */
.rt-bi {
  position: relative;
  font-family: var(--rt-font-heading);
  color: var(--rt-text-primary);
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

.rt-bi *,
.rt-bi *::before,
.rt-bi *::after {
  box-sizing: border-box;
}

.rt-bi-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  width: 100%;
  max-width: calc(1113px + 2 * 24px);
  margin: 0 auto;
  padding: 120px 24px 100px;
}

.rt-bi-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 1030px;
  padding-bottom: 20px;
  text-align: center;
}

.rt-bi-h2 {
  margin: 0;
  font-family: var(--rt-font-display);
  font-weight: 700;
  font-size: clamp(2.25rem, 1rem + 3.5vw, 3.75rem);
  line-height: 1.2;
  text-wrap: balance;
}

.rt-bi-sub {
  margin: 0;
  font-size: clamp(1.0625rem, 0.9rem + 0.4vw, 1.25rem);
  line-height: 1.6;
  text-wrap: pretty;
}

/* ---- Cards: driver performance tall on the left, planned vs actuals + CSV short on the right ---- */
.rt-bi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 29px;
  width: 100%;
}

.rt-bi-col {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 32px;
}

.rt-bi-card {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  background: #f3f5ff;
}

.rt-bi-card-main {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  min-height: 458px;
  padding: 36px 30px 40px;
}

.rt-bi-card-small {
  min-height: 211px;
}

.rt-bi-copy {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.rt-bi-copy-small {
  position: relative;
  z-index: 1;
  max-width: 310px;
  padding: 50px 0 32px 29px;
}

.rt-bi-copy-planned {
  max-width: 47%;
  padding-top: 38px;
}

.rt-bi-copy-csv {
  max-width: 298px;
  padding-top: 38px;
}

.rt-bi-h3 {
  margin: 0;
  font-family: var(--rt-font-display);
  font-weight: 700;
  font-size: 23px;
  line-height: 27.4px;
  letter-spacing: 0.3px;
  color: #041527;
}

.rt-bi-h3-lg {
  font-size: clamp(1.625rem, 1.2rem + 1vw, 2rem);
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--rt-text-primary);
}

.rt-bi-h3-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.rt-bi-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: #e2e6ff;
  font-family: var(--rt-font-heading);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.2px;
  color: #374cd2;
  white-space: nowrap;
}

.rt-bi-text {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
}

/* ---- Driver leaderboard ---- */
.rt-bi-board {
  align-self: center;
  width: 100%;
  max-width: 470px;
  padding: 20px 22px 12px;
  border: 1px solid #e4e5ed;
  border-radius: 20px;
  background: #fff;
  font-family: var(--rt-font-body);
  box-shadow: 0 10px 30px rgba(31, 54, 167, 0.06);
}

.rt-bi-board-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.rt-bi-board-title {
  font-weight: 600;
  font-size: 16px;
  line-height: 24px;
}

.rt-bi-board-range {
  font-size: 13px;
  color: #6b7280;
}

.rt-bi-board-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px 52px 64px;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  line-height: 20px;
  font-variant-numeric: tabular-nums;
}

.rt-bi-board-head {
  padding-bottom: 8px;
  border-bottom: 1px solid #eef0f6;
  font-size: 12px;
  color: #6b7280;
}

.rt-bi-driver {
  padding: 10px 0;
  border-bottom: 1px solid #eef0f6;
}

.rt-bi-driver:last-child {
  border-bottom: 0;
}

.rt-bi-num {
  text-align: right;
}

.rt-bi-driver-name {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-weight: 500;
}

.rt-bi-driver-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-bi-avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
}

.rt-bi-coach {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fff1d6;
  font-weight: 600;
  font-size: 11px;
  line-height: 16px;
  color: #b06a00;
}

.rt-bi-narrow {
  display: none;
}

.rt-bi-rate {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rt-bi-rate-track {
  flex: 1;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: #eef0f6;
}

.rt-bi-rate-bar {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: #326bfc;
  transform-origin: left;
}

.is-coach .rt-bi-rate-bar {
  background: #ffa928;
}

.rt-bi-rate-val {
  width: 34px;
  text-align: right;
}

/* ---- Planned vs actuals: one route's planned vs actual day, on the right of the short card ---- */
.rt-bi-pva {
  position: absolute;
  top: 50%;
  right: 22px;
  left: 50%;
  translate: 0 -50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 14px 14px 16px;
  border: 1px solid #e4e5ed;
  border-radius: 16px;
  background: #fff;
  font-family: var(--rt-font-body);
  box-shadow: 0 10px 30px rgba(31, 54, 167, 0.06);
}

.rt-bi-pva-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rt-bi-pva-route {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  line-height: 18px;
  white-space: nowrap;
}

.rt-bi-pva-route i {
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: #a770db;
}

.rt-bi-pva-chip {
  padding: 1px 8px;
  border-radius: 999px;
  background: #fff1d6;
  font-weight: 700;
  font-size: 11.5px;
  line-height: 18px;
  color: #b06a00;
  white-space: nowrap;
}

.rt-bi-tl {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.rt-bi-tl-k {
  font-family: var(--rt-font-body);
  font-size: 9.5px;
  fill: #6b7280;
}

.rt-bi-tl-end {
  font-family: var(--rt-font-body);
  font-weight: 600;
  font-size: 9.5px;
  fill: var(--rt-text-primary);
  font-variant-numeric: tabular-nums;
}

.rt-bi-tl-late {
  fill: #b06a00;
}

.rt-bi-tl-bar {
  transform-box: fill-box;
  transform-origin: left center;
}

/* ---- Spreadsheet (Figma "Excel"): tilted, bleeding off the card's right and bottom edges ---- */
.rt-bi-sheet {
  position: absolute;
  left: 54.13%;
  top: 12.39%;
  right: -15.36%;
  bottom: -24.95%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.rt-bi-sheet-svg {
  display: block;
  width: 94.5%;
  height: auto;
  border-radius: 10.4px;
  rotate: 5.41deg;
  box-shadow: 0 2.6px 18.2px rgba(0, 0, 0, 0.15);
}

.rt-bi-cell {
  font-family: var(--rt-font-body);
  font-size: 7.8px;
  fill: var(--rt-text-primary);
}

/* ---------------------------------------------------------------------------
 * Responsive (only the 1440 layout exists in Figma)
 * ------------------------------------------------------------------------- */
@media (max-width: 991px) {
  .rt-bi-grid {
    grid-template-columns: 1fr;
  }
  .rt-bi-card-main {
    min-height: 0;
  }
  .rt-bi-col {
    grid-template-rows: auto;
    gap: 29px;
  }
  /* planned vs actuals: the route card sits in the flow beside the copy (it grows with its width) */
  .rt-bi-card-planned {
    display: flex;
    align-items: center;
  }
  .rt-bi-pva {
    position: relative;
    inset: auto;
    translate: none;
    flex: none;
    width: min(340px, 50%);
    margin: 22px 22px 22px auto;
  }
}

@media (max-width: 599px) {
  .rt-bi-inner {
    padding: 88px 16px 72px;
  }
  .rt-bi-card-main {
    gap: 24px;
    padding: 28px 20px 24px;
  }
  .rt-bi-board {
    padding: 16px 14px 6px;
  }
  .rt-bi-board-row {
    grid-template-columns: minmax(0, 1fr) 72px 44px 58px;
    gap: 8px;
    font-size: 13px;
  }
  /* success rate: the bar sits under the percentage */
  .rt-bi-rate {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 3px;
  }
  .rt-bi-rate-val {
    width: auto;
    text-align: left;
  }
  .rt-bi-rate-track {
    flex: none;
  }
  .rt-bi-wide {
    display: none;
  }
  .rt-bi-narrow {
    display: inline;
  }
  .rt-bi-avatar {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }
  .rt-bi-coach {
    display: none;
  }
  /* planned vs actuals: the route card moves under the copy */
  .rt-bi-card-planned {
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
  }
  .rt-bi-copy-planned {
    max-width: none;
  }
  .rt-bi-pva {
    position: relative;
    inset: auto;
    translate: none;
    width: auto;
    margin: 0 20px;
  }
  .rt-bi-copy-small {
    padding: 28px 20px 24px;
  }
  /* The spreadsheet moves under the copy instead of beside it */
  .rt-bi-card-csv {
    display: flex;
    flex-direction: column;
  }
  .rt-bi-sheet {
    position: relative;
    inset: auto;
    height: 150px;
    margin: 0 -24px -24px 40px;
    align-items: flex-start;
  }
  .rt-bi-sheet-svg {
    width: 320px;
    flex: none;
  }
}

/* ---------------------------------------------------------------------------
 * Motion: when the cards scroll into view the planned then actual bars grow,
 * the actual finish is flagged, and the spreadsheet fills in row by row. Base styles = final state.
 * ------------------------------------------------------------------------- */
@keyframes rt-bi-up {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
@keyframes rt-bi-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes rt-bi-grow {
  from { transform: scaleX(0); }
  to { transform: none; }
}
@keyframes rt-bi-sheet-in {
  from { opacity: 0; transform: translate(24px, 30px); }
  to { opacity: 1; transform: none; }
}

.rt-bi-animate.is-inview .rt-bi-card {
  animation: rt-bi-up 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.rt-bi-animate.is-inview .rt-bi-col .rt-bi-card:nth-child(1) { animation-delay: 120ms; }
.rt-bi-animate.is-inview .rt-bi-col .rt-bi-card:nth-child(2) { animation-delay: 240ms; }

.rt-bi-animate.is-inview .rt-bi-tl-bar {
  animation: rt-bi-grow 900ms cubic-bezier(0.65, 0, 0.35, 1) both;
}
.rt-bi-animate.is-inview .rt-bi-tl-link,
.rt-bi-animate.is-inview .rt-bi-tl-flag {
  animation: rt-bi-fade 400ms ease-out both;
}

.rt-bi-animate.is-inview .rt-bi-driver {
  animation: rt-bi-up 600ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.rt-bi-animate.is-inview .rt-bi-rate-bar {
  animation: rt-bi-grow 900ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.rt-bi-animate.is-inview .rt-bi-sheet {
  animation: rt-bi-sheet-in 900ms 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.rt-bi-animate.is-inview .rt-bi-row {
  animation: rt-bi-fade 350ms ease-out both;
}

@media (prefers-reduced-motion: reduce) {
  .rt-bi *,
  .rt-bi *::before,
  .rt-bi *::after {
    animation: none !important;
  }
}

