/* Passenger mode (docs/passenger-page.md): one centred column, and the map
   out of the way until it's asked for. Driver mode keeps the form beside
   the map (style.css). */
body[data-mode="passenger"] main {
  display: block;
  overflow-y: auto;
}

body[data-mode="passenger"] .panel {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  border-right: none;
  background: transparent;
  overflow: visible;
}

/* On the page's grey, cards are white. */
body[data-mode="passenger"] .drive-card,
body[data-mode="passenger"] .match-card {
  background: var(--panel);
}

/* The map keeps its size while hidden, so routes can be drawn and framed on
   it (app.js: openMap); shown, it lies over the page. */
body[data-mode="passenger"] #map {
  position: fixed;
  inset: 5vh 5vw;
  width: auto;
  height: auto;
  z-index: 1500;
  visibility: hidden;
  pointer-events: none;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
}

body[data-mode="passenger"].map-open #map {
  visibility: visible;
  pointer-events: auto;
}

#map-backdrop, #map-close, #map-hint { display: none; }

body[data-mode="passenger"].map-open #map-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: rgba(0, 0, 0, 0.4);
}

body[data-mode="passenger"].map-open #map-close {
  display: block;
  position: fixed;
  top: calc(5vh + 12px);
  right: calc(5vw + 12px);
  z-index: 1600;
  width: auto;
  margin: 0;
  padding: 8px 14px;
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* While a place is being picked on it, the map says what to do. */
body[data-mode="passenger"].map-open.map-picking #map-hint {
  display: block;
  position: fixed;
  bottom: calc(5vh + 28px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1600;
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  font-size: 14px;
  white-space: nowrap;
}

/* The passenger page: the trip card straight on the page. */
#page-ride .page-title { margin-bottom: 12px; font-size: 22px; }

/* One sentence under the title says what the service is, until a search
   shows its results. */
.ride-pitch {
  margin: -6px 0 14px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--muted);
}
#page-ride:has(#ride-results:not([hidden])) .ride-pitch { display: none; }
/* Nor does it come back between two searches, when the form is changed. */
#page-ride.trip-searched .ride-pitch { display: none; }

.trip-card {
  position: relative;
  padding: 2px 60px 2px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.trip-field {
  display: flex;
  align-items: center;
  gap: 12px;
}
.trip-field + .trip-field { border-top: 1px solid var(--border); }
.trip-field:focus-within { box-shadow: inset 0 -2px 0 var(--accent); }

/* The colours of the two pins on the map. */
.trip-dot {
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 3px solid #1a7f37;
}
.trip-field + .trip-field .trip-dot { border-color: #d8232a; }

.trip-card input[type=text] {
  width: 100%;
  padding: 16px 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 17px;
}

.trip-swap {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.trip-swap:hover { background: var(--bg); }
.trip-swap svg { display: block; margin: auto; }

/* A field's own entries (pick on the map), after the places found. */
.autocomplete-list li.action {
  border-top: 1px solid var(--border);
  color: var(--accent-dark);
  font-weight: 600;
}
.autocomplete-list li.action:first-child { border-top: none; }

/* Leave at / Arrive by, the date and the time: on one line where they fit,
   the date and time below otherwise. */
.ride-when {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 16px;
}
.ride-when[hidden] { display: none; }
.ride-when .datetime { flex: 1 1 260px; min-width: 0; }

/* The Search button: under the form, as wide as it. */
.ride-search { margin-top: 16px; padding: 13px; font-size: 16px; border-radius: 10px; }
.ride-search svg { display: none; }

/* Wide screens: one bar, From, To and when, wider than the column of
   results below it. The time is there from the start (it is for now). */
@media (min-width: 980px) {
  body[data-mode="passenger"] #page-ride { --bar-out: 150px; }
  body[data-mode="passenger"] #page-ride .page-title,
  body[data-mode="passenger"] #page-ride .ride-pitch { margin-left: calc(4px - var(--bar-out)); }
  body[data-mode="passenger"] .trip-bar {
    display: flex;
    align-items: center;
    margin: 0 calc(-1 * var(--bar-out));
    padding: 4px 10px 4px 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  }
  body[data-mode="passenger"] .trip-bar .trip-card {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }
  body[data-mode="passenger"] .trip-bar .trip-field { flex: 1 1 0; min-width: 0; }
  body[data-mode="passenger"] .trip-bar .trip-field + .trip-field { order: 3; border-top: none; }
  body[data-mode="passenger"] .trip-bar .trip-swap {
    position: static;
    order: 2;
    flex: none;
    margin: 0 12px;
    transform: none;
  }
  body[data-mode="passenger"] .trip-bar .trip-swap svg { transform: rotate(90deg); }
  body[data-mode="passenger"] .trip-bar .ride-when,
  body[data-mode="passenger"] .trip-bar .ride-when[hidden] {
    display: flex;
    flex: none;
    flex-wrap: nowrap;
    gap: 4px;
    margin: 0 0 0 12px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
  }
  body[data-mode="passenger"] .trip-bar .ride-when .datetime { flex: none; }
  body[data-mode="passenger"] .trip-bar .ride-when .datetime input[type=date] { flex: none; width: auto; }
  /* Part of the bar: no boxes of their own until pointed at. */
  body[data-mode="passenger"] .trip-bar .ride-when select,
  body[data-mode="passenger"] .trip-bar .ride-when input {
    border-color: transparent;
    background-color: transparent;
  }
  body[data-mode="passenger"] .trip-bar .ride-when select:hover,
  body[data-mode="passenger"] .trip-bar .ride-when input:hover { background-color: var(--bg); }
  /* The button ends the bar. */
  body[data-mode="passenger"] .trip-bar .ride-search {
    flex: none;
    width: auto;
    margin: 0 0 0 10px;
    padding: 11px 20px;
    font-size: 15px;
  }
}
/* Where the bar is at its narrowest the button is a magnifying glass, and
   the places keep their room. Its word stays its name for a screen reader. */
@media (min-width: 980px) and (max-width: 1099px) {
  body[data-mode="passenger"] .trip-bar .ride-search { padding: 10px 13px; }
  body[data-mode="passenger"] .trip-bar .ride-search svg { display: block; }
  body[data-mode="passenger"] .trip-bar .ride-search span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
@media (min-width: 1100px) {
  body[data-mode="passenger"] #page-ride { --bar-out: 200px; }
}

/* A match: the passenger's trip first, as a timetable shows a connection
   (its times, how long it takes, its price), then how it goes, then who
   drives; the rest in its details. A card is something to choose: pointing
   at it outlines it, and the arrow at the end of its first line says it
   opens. */
.match-card.open { box-shadow: 0 1px 6px rgba(0, 0, 0, 0.14); }
.match-card.clickable:hover,
.match-card.open { border-color: var(--accent); }
.trip-line {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
/* On a narrow card, how long it takes goes under the times. */
.trip-when {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 10px;
  min-width: 0;
}
.trip-times { font-size: 20px; font-weight: 700; line-height: 1.25; white-space: nowrap; }
.trip-duration { font-size: 14px; color: var(--muted); white-space: nowrap; }
/* The day a trip ends on, when it isn't the one it starts on: after the times. */
.trip-day { font-size: 14px; color: var(--muted); white-space: nowrap; }
/* The day it starts on, when it isn't the day searched: a line of its own
   above the times, as a timetable heads the connections of the next day. */
.trip-start-day { flex-basis: 100%; font-size: 13px; font-weight: 700; }
.trip-price {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  align-items: flex-end;
  max-width: 58%;
  text-align: right;
}
.trip-amount { font-size: 17px; font-weight: 700; line-height: 1.45; white-space: nowrap; }
.trip-price-note { font-size: 11px; color: var(--muted); }
.trip-price-note span { white-space: nowrap; }
.match-card.clickable .trip-line::after {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  margin: 5px 4px 0 0;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s;
}
.match-card.clickable:hover .trip-line::after { border-color: var(--accent); }
.match-card.open .trip-line::after { margin-top: 10px; transform: rotate(-135deg); }
/* On a phone the times and the price don't always fit next to each other:
   they are a little smaller there, and a price that still doesn't fit goes
   under the times, on the right, instead of the times running over it. The
   arrow keeps its corner. */
@media (max-width: 400px) {
  .trip-line { position: relative; flex-wrap: wrap; gap: 2px 8px; }
  .trip-when { flex: 1 1 0; min-width: min-content; }
  .trip-times { font-size: 18px; }
  .trip-price { width: min-content; max-width: none; margin-left: auto; }
  .trip-amount { font-size: 16px; }
  .match-card.clickable .trip-line { padding-right: 21px; }
  .match-card.clickable .trip-line::after { position: absolute; top: 0; right: 0; }
}
/* How the trip goes, its parts in order, one a line, as a small journey:
   the sign of what the passenger rides in a circle (the car in the site's
   colour, public transport in grey), joined to the next by a line, and a
   few words: who drives them (their small circle, their name in bold), or
   public transport to where. */
.trip-how {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.35;
}
.trip-part {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.trip-part > span:last-child { padding-top: 4px; }
.trip-part:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 28px;
  bottom: -8px;
  left: 13px;
  width: 2px;
  background: var(--border);
}
.trip-icon {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef0f3;
  color: var(--muted);
}
.trip-icon.car { background: var(--accent-soft); color: var(--accent-dark); }
.trip-part .avatar {
  display: inline-flex;
  width: 20px;
  height: 20px;
  margin: -3px 6px -3px 0;
  vertical-align: middle;
  font-size: 11px;
}
.trip-icon .pt-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.match-name { font-weight: 700; }
/* Beyond a short walk, how far the car passes from the passenger's own start
   or destination. */
.trip-gap { margin: 4px 0 0 38px; font-size: 12px; color: var(--muted); }
/* Asking for a seat is what a card is for: the filled button. */
.match-card .booking-box .submit-btn { padding: 9px 16px; }
/* A demo ride has no such button: where it would be, the card says what it
   is (app.js: demoNote). */
.demo-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--demo-text);
}
.demo-note .badge { flex: none; margin-left: 0; }
.avatar {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 700;
}
.avatar svg { width: 26px; height: 26px; fill: currentColor; opacity: 0.7; }
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Asking the drivers for this ride, under the rides found: a panel of its
   own, a question as its title and the filled button. */
.ask-box {
  margin: 20px 0 8px;
  padding: 16px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--accent-soft);
}
.ask-title { font-size: 16px; font-weight: 700; }
.ask-box .hint { font-size: 13px; line-height: 1.45; color: var(--text); }
.ask-box .submit-btn {
  margin-top: 12px;
  padding: 13px;
  border-radius: 10px;
  font-size: 15px;
}

/* No ride found: a picture, a sentence, and asking the drivers straight on
   the page, without the question (app.js: renderMatches). */
.no-rides { padding: 20px 0 4px; text-align: center; }
.no-rides img { display: block; margin: 0 auto 12px; }
.no-rides-text { font-size: 16px; font-weight: 600; }
#ride-results.no-matches .matches-title { display: none; }
#ride-results.no-matches .ask-box {
  margin: 4px 0 20px;
  padding: 0;
  border: none;
  background: none;
  text-align: center;
}
#ride-results.no-matches .ask-title { display: none; }
#ride-results.no-matches .ask-box .hint { color: var(--muted); }
#ride-results.no-matches .ask-box .submit-btn { margin-top: 14px; }
#ride-results.no-matches .ask-box .status-msg { text-align: left; }
#ride-transit { margin-top: 14px; }
.match-details {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.match-more, .match-on-map { color: var(--accent-dark); font-size: 13px; }
.match-more { display: block; margin-top: 10px; }
.match-card.open .match-more { font-weight: 600; }
.match-on-map { display: block; margin-top: 10px; }

/* Phones: the map takes the whole screen. */
@media (max-width: 760px) {
  body[data-mode="passenger"] .panel { padding: 16px 16px 32px; }
  body[data-mode="passenger"] #map {
    inset: 0;
    min-height: 0;
    max-height: none;
    border-bottom: none;
    border-radius: 0;
  }
  body[data-mode="passenger"].map-open #map-close { top: 12px; right: 12px; }
  body[data-mode="passenger"].map-open.map-picking #map-hint { bottom: 40px; }
}
