/* EXCAR homepage — the Trips section (Map / History / Detail), in EXCAR Mobile's Trips language:
   dark surfaces #1A1918 / #292827, hairline #2B2927, text #E9E4DC / #BDB7AE / #928D85, blue #3996EF, brand route
   #1E91FF; cards radius 20 / padding 16, panels radius 22 / padding 20, tiles radius 14; type 16/22 headline,
   14/20 subhead, 12/16 caption, 20/700 metric (TripCard.tsx, CloudTripDetail.tsx, theme/*). */
.home-v3-trips {
  --t-surface: #1a1918;
  --t-raised: #292827;
  --t-border: #2b2927;
  --t-canvas: #0d0c0c;
  --t-text: #e9e4dc;
  --t-muted: #bdb7ae;
  --t-quiet: #928d85;
  --t-blue: #3996ef;
  --t-green: #45d69a;
  --t-amber: #ffc56a;
}
.home-v3-trips__panel.v4t-panel-wrap { display: block; min-height: 0; }
.home-v3-trips__panel.v4t-panel-wrap[hidden] { display: none; }
.home-v3-trips .v4t-panel-wrap button { font-family: var(--font-body); }

/* ── Map tab: the map with the Recent Trips sheet beside it (below it on phones) ── */
.v4t-mapview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); min-height: 600px; }
.v4t-map { position: relative; overflow: hidden; background: var(--t-canvas); }
.v4t-map__canvas { position: absolute; inset: 0; }
.v4t-map__sketch {
  position: absolute; inset: 0; display: grid; place-items: center;
  background-color: var(--t-canvas);
  background-image: radial-gradient(circle, var(--t-border) .9px, transparent 1.2px);
  background-size: 18px 18px;
  transition: opacity .4s ease;
}
.v4t-map[data-state="ready"] .v4t-map__sketch { opacity: 0; pointer-events: none; }
.v4t-map__sketch svg { width: min(78%, 520px); height: auto; max-height: 86%; overflow: visible; }
.v4t-map__sketch .v4t-mini__line { stroke-width: 4; vector-effect: non-scaling-stroke; }
.v4t-map__sketch .v4t-mini__halo { stroke-width: 12; stroke-opacity: .18; vector-effect: non-scaling-stroke; }
.v4t-map__sketch circle { r: 1.3; }
.v4t-map__sketch .v4t-mini__start { stroke-width: .6; }

.v4t-sheet { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 18px 20px 20px; border-left: 1px solid var(--t-border); background: var(--t-surface); }
.v4t-sheet__handle { display: none; }
.v4t-sheet__head { display: flex; align-items: center; justify-content: space-between; min-height: 40px; }
.v4t-sheet__head h3, .v4t-history__head h3 { margin: 0; color: var(--t-text); font: 600 16px/22px var(--font-body); }
.v4t-link { padding: 6px 0; border: 0; color: var(--t-blue); background: none; font: 400 14px/20px var(--font-body); cursor: pointer; }
.v4t-link:hover { text-decoration: underline; }
.v4t-more { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 16px; border: 1px solid var(--t-border); border-radius: 20px; color: var(--t-text); background: transparent; text-align: left; cursor: pointer; transition: background-color .2s ease; }
.v4t-more:hover { background: var(--t-raised); }
.v4t-more span { display: grid; }
.v4t-more b { font: 600 16px/22px var(--font-body); }
.v4t-more small { color: var(--t-muted); font: 400 14px/20px var(--font-body); }
.v4t-more svg, .v4t-card__chev, .v4t-back svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: var(--t-quiet); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Trip card (TripCard.tsx) ── */
.v4t-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.v4t-card {
  display: flex; align-items: center; gap: 16px; width: 100%; min-width: 0; padding: 16px;
  border: 1px solid var(--t-border); border-radius: 20px; color: var(--t-text); background: var(--t-surface);
  text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color .2s ease, border-color .2s ease;
}
.v4t-sheet .v4t-card { background: #201f1e; }
@media (hover: hover) { .v4t-card:hover { background: var(--t-raised); } }
.v4t-card:active { background: var(--t-raised); }
.v4t-card.is-selected { border-color: rgba(57, 150, 239, .55); box-shadow: inset 0 0 0 1px rgba(57, 150, 239, .25); }
.v4t-card:focus-visible, .v4t-more:focus-visible, .v4t-link:focus-visible, .v4t-back:focus-visible, .v4t-fit:focus-visible { outline: 2px solid #8fd5ff; outline-offset: 2px; }
.v4t-card__text { display: grid; gap: 8px; flex: 1; min-width: 0; }
.v4t-card__top { display: flex; align-items: center; gap: 4px; }
.v4t-card__when { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 600 16px/22px var(--font-body); }
.v4t-card__score { font: 600 16px/22px var(--font-body); font-variant-numeric: tabular-nums; white-space: nowrap; }
.v4t-card__places { color: var(--t-muted); font: 400 14px/20px var(--font-body); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.v4t-card__metrics { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.v4t-metric { display: grid; gap: 1px; min-width: 64px; }
.v4t-metric small { display: flex; align-items: center; gap: 4px; color: var(--t-quiet); font: 500 12px/16px var(--font-body); white-space: nowrap; }
.v4t-metric small svg { width: 11px; height: 11px; fill: none; stroke: var(--t-blue); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.v4t-metric b { font: 600 16px/22px var(--font-body); font-variant-numeric: tabular-nums; white-space: nowrap; }
.v4t-card__mini { flex: 0 0 auto; width: 76px; height: 76px; overflow: hidden; border: 1px solid var(--t-border); border-radius: 14px; background: var(--t-canvas); }
.v4t-mini { display: block; width: 100%; height: 100%; }
.v4t-mini__halo, .v4t-mini__line { fill: none; stroke: var(--t-blue); stroke-linecap: round; stroke-linejoin: round; }
.v4t-mini__halo { stroke-opacity: .2; stroke-width: 6; }
.v4t-mini__line { stroke-width: 2.25; }
.v4t-mini__start { fill: var(--t-surface); stroke: var(--t-green); stroke-width: 2; }
.v4t-mini__end { fill: var(--t-text); }

/* ── History tab ── */
.v4t-history { padding: clamp(20px, 3vw, 32px); background: radial-gradient(90% 60% at 0% 0%, rgba(30, 113, 207, .1), transparent 70%); }
.v4t-history__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.v4t-history__head h3 { font: 700 28px/34px var(--font-body); letter-spacing: -.6px; }
.v4t-history__head p { margin: 0; color: var(--t-quiet); font: 400 13px/18px var(--font-body); }
.v4t-overline { margin: 0 0 8px 4px; color: var(--t-quiet); font: 700 11px/14px var(--font-body); letter-spacing: 1.4px; }
.v4t-list--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ── Detail tab (CloudTripDetail.tsx) ── */
/* Two balanced rows under the heading: Route | Trip details, then Trip score | Fuel. */
.v4t-detail {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, 1fr);
  grid-template-areas: "head head" "route details" "score fuel";
  align-items: stretch; gap: 16px 20px; padding: clamp(20px, 3vw, 32px);
}
.v4t-detail__main, .v4t-detail__side { display: contents; }
.v4t-head { grid-area: head; display: grid; gap: 6px; }
.v4t-detail .v4t-block[aria-label="Route"] { grid-area: route; grid-template-rows: auto minmax(240px, 1fr) auto auto; }
.v4t-detail .v4t-block[aria-label="Trip details"] { grid-area: details; }
.v4t-detail .v4t-block[aria-label="Trip score"] { grid-area: score; grid-template-rows: auto auto auto auto 1fr; }
.v4t-detail .v4t-block[aria-label="Fuel"] { grid-area: fuel; align-content: start; }
.v4t-back { display: inline-flex; align-items: center; gap: 2px; justify-self: start; padding: 4px 6px 4px 0; border: 0; color: var(--t-blue); background: none; font: 400 14px/20px var(--font-body); cursor: pointer; }
.v4t-back svg { stroke: var(--t-blue); }
.v4t-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.v4t-heading h3 { margin: 0; color: var(--t-text); font: 700 28px/34px var(--font-body); letter-spacing: -.6px; }
.v4t-heading p, .v4t-places, .v4t-badges { margin: 0; }
.v4t-heading p { color: var(--t-muted); font: 400 14px/20px var(--font-body); font-variant-numeric: tabular-nums; }
.v4t-places { margin-top: 0; color: var(--t-text); font: 600 16px/22px var(--font-body); }
.v4t-badges { display: flex; gap: 8px; margin-top: 4px; }
.v4t-badge { display: inline-flex; align-items: center; justify-self: start; min-height: 24px; padding: 0 10px; border-radius: 999px; font: 700 12px/16px var(--font-body); }
.v4t-badge.is-info { color: var(--t-blue); background: #13263a; }
.v4t-badge.is-caution { color: var(--t-amber); background: #3d2e14; }
.v4t-block { display: grid; gap: 12px; padding: 20px; border: 1px solid var(--t-border); border-radius: 22px; background: var(--t-surface); }
.v4t-h { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--t-text); font: 700 20px/26px var(--font-body); }
.v4t-h svg { width: 18px; height: 18px; fill: none; stroke: var(--t-quiet); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.v4t-map--detail { height: 100%; min-height: 240px; border: 1px solid var(--t-border); border-radius: 16px; }
.v4t-fit { position: absolute; z-index: 2; top: 10px; right: 10px; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--t-border); border-radius: 50%; color: var(--t-text); background: rgba(26, 25, 24, .92); cursor: pointer; }
.v4t-fit svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.v4t-legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.v4t-legend li { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border-radius: 999px; color: var(--t-muted); background: var(--t-raised); font: 500 12px/16px var(--font-body); }
.v4t-legend li::before { content: ''; width: 9px; height: 9px; border-radius: 50%; box-sizing: border-box; }
.v4t-legend .is-start::before { border: 2px solid var(--t-green); }
.v4t-legend .is-end::before { background: var(--t-text); }
.v4t-note, .v4t-foot { margin: 0; color: var(--t-quiet); font: 400 13px/18px var(--font-body); }
.v4t-foot { color: var(--t-muted); }
.v4t-score { margin: 0; color: var(--t-text); font: 700 28px/32px var(--font-body); font-variant-numeric: tabular-nums; letter-spacing: -.4px; }
.v4t-line { margin: -4px 0 0; color: var(--t-text); font: 400 14px/20px var(--font-body); }
.v4t-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.v4t-tiles--events { margin-top: auto; padding-top: 4px; }
.v4t-tile { display: grid; gap: 2px; padding: 14px 16px; border-radius: 14px; background: var(--t-raised); }
.v4t-tile small { color: var(--t-quiet); font: 600 12px/16px var(--font-body); }
.v4t-tile b { color: var(--t-text); font: 700 20px/26px var(--font-body); font-variant-numeric: tabular-nums; }
.v4t-tile span { color: var(--t-quiet); font: 500 12px/16px var(--font-body); }
.v4t-label { margin: 4px 0 0; color: var(--t-quiet); font: 600 12px/16px var(--font-body); }
.v4t-numeral { margin: -6px 0 0; color: var(--t-text); font: 800 34px/40px var(--font-body); font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.v4t-rows { display: grid; margin: 0; }
.v4t-rows div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--t-border); }
.v4t-rows dt { color: var(--t-quiet); font: 400 13px/18px var(--font-body); }
.v4t-rows dd { margin: 0; color: var(--t-text); font: 500 13px/18px var(--font-body); font-variant-numeric: tabular-nums; text-align: right; }
/* Map markers (TripRouteMap.tsx): green start ring, white end dot. */
.v4t-dot { display: block; border-radius: 50%; box-sizing: border-box; transform: translateY(50%); }
.v4t-dot--start { width: 15px; height: 15px; border: 3.5px solid var(--t-green); background: var(--t-surface); }
.v4t-dot--end { width: 14px; height: 14px; border: 2.5px solid var(--t-surface); background: var(--t-text); }

/* ── Tablet ── */
/* The Recent Trips sheet is narrow beside the map: a slightly tighter card. */
@media (min-width: 900px) {
  .v4t-sheet .v4t-card { gap: 12px; padding: 14px; }
  .v4t-sheet .v4t-card__mini { width: 64px; height: 64px; }
  .v4t-sheet .v4t-card__metrics { gap: 4px 16px; }
  .v4t-sheet .v4t-metric { min-width: 0; }
  .v4t-sheet .v4t-card__when { font-size: 15px; }
}
/* One column: the app's order — Route, Trip score, Trip details, Fuel. */
@media (max-width: 1080px) {
  .v4t-detail { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "route" "score" "details" "fuel"; }
  .v4t-detail .v4t-block[aria-label="Route"] { grid-template-rows: auto auto auto auto; }
  .v4t-map--detail { height: clamp(240px, 60vw, 360px); }
}
@media (max-width: 899px) {
  .v4t-mapview { grid-template-columns: 1fr; min-height: 0; }
  .v4t-map--overview { height: clamp(300px, 62vw, 440px); }
  .v4t-sheet { position: relative; z-index: 1; margin-top: -28px; padding: 8px 16px 18px; border-left: 0; border-top: 1px solid var(--t-border); border-radius: 28px 28px 0 0; }
  .v4t-sheet__handle { display: block; justify-self: center; align-self: center; width: 40px; height: 4px; margin-bottom: 2px; border-radius: 99px; background: var(--t-border); }
  .v4t-list--grid { grid-template-columns: 1fr; }
}
/* ── Phones ── */
@media (max-width: 600px) {
  .v4t-history { padding: 18px 12px; }
  .v4t-history__head { display: block; }
  .v4t-history__head p { margin-top: 2px; }
  .v4t-detail { padding: 16px 12px 20px; gap: 16px; }
  .v4t-block { padding: 16px; }
  .v4t-card { gap: 12px; padding: 14px; }
  .v4t-card__mini { width: 64px; height: 64px; }
  .v4t-card__metrics { gap: 4px 16px; }
  .v4t-metric { min-width: 0; }
  .v4t-card__when { font-size: 15px; }
  .v4t-heading h3 { font-size: 24px; line-height: 30px; }
}
@media (prefers-reduced-motion: reduce) { .v4t-card, .v4t-more, .v4t-map__sketch { transition: none; } }
/* Google refused the key: keep the recorded-path sketch instead of Google's error tile. */
[data-v4t][data-maps="failed"] .v4t-map__canvas, [data-v4t][data-maps="failed"] .v4t-fit { visibility: hidden; }
[data-v4t][data-maps="failed"] .v4t-map__sketch { opacity: 1; }
