/* =========================================================================
   Explore page: planner + results on the left, map on the right.
   On phones the two take turns (see the .view-toggle button).
   ========================================================================= */

.page-explore { background: var(--cream); }

.explore {
  display: grid;
  grid-template-columns: minmax(390px, 480px) 1fr;
  height: calc(100dvh - var(--header-height));
}

.explore__panel {
  overflow-y: auto;
  padding: 1.75rem 1.5rem 4rem;
  border-right: 1px solid var(--line);
  scrollbar-gutter: stable;
}

/* ---------- Planner form ----------------------------------------------- */
.planner { display: grid; gap: 1.35rem; }

.planner__intro .eyebrow { margin-bottom: 0.5rem; }
.planner__title { font-size: clamp(1.6rem, 2.4vw, 2rem); margin: 0; }

.planner .field + .field { margin-top: 0; }

.fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.fieldset > legend { padding: 0; margin-bottom: 0.55rem; }
.label__optional { font-weight: 500; font-size: 0.8rem; color: var(--ink-soft); margin-left: 0.25rem; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }

.input-with-unit { position: relative; }
.input-with-unit .input { padding-right: 3.2rem; }
.input-with-unit span {
  position: absolute;
  top: 50%;
  right: 0.95rem;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: var(--ink-soft);
  pointer-events: none;
}

.chip-group--compact { gap: 0.4rem; margin-top: -0.6rem; }
.chip-group--compact .chip { padding: 0.3rem 0.75rem; font-size: 0.85rem; }

.button--large { min-height: 3.35rem; font-size: 1.05rem; }
.planner__note { margin-top: -0.6rem; text-align: center; }

/* Start-location search with suggestions */
.start-search { display: flex; gap: 0.6rem; align-items: stretch; }
.combobox { position: relative; flex: 1; min-width: 0; }
.combobox__icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  width: 1.1rem;
  height: 1.1rem;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}
.combobox__input { padding-left: 2.5rem; }

.locate-button { flex-shrink: 0; padding-inline: 0.95rem; }
.start-status:empty { display: none; }
.start-status[data-tone="good"] { color: var(--forest); font-weight: 500; }
.start-status[data-tone="error"] { color: var(--danger); font-weight: 500; }

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 20rem;
  overflow-y: auto;
}
.suggestions__option {
  display: grid;
  gap: 0.1rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
}
.suggestions__option:hover,
.suggestions__option[aria-selected="true"] { background: var(--sage-soft); }
.suggestions__main { font-weight: 600; color: var(--ink); }
.suggestions__secondary { font-size: 0.85rem; color: var(--ink-soft); }
.suggestions__attribution {
  padding: 0.4rem 0.75rem 0.2rem;
  text-align: right;
  font-family: Roboto, Arial, sans-serif;
  font-size: 0.75rem;
  color: #5F6368;
}

/* One-way / round trip */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.segmented__option { position: relative; cursor: pointer; }
.segmented__option input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__option > span {
  display: grid;
  gap: 0.1rem;
  height: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--sand);
  border-radius: var(--radius-sm);
  background: var(--paper);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.segmented__option strong { font-size: 0.95rem; color: var(--forest-deep); }
.segmented__option small { font-size: 0.8rem; color: var(--ink-soft); }
.segmented__option input:checked + span {
  border-color: var(--forest);
  background: #F3F5EC;
  box-shadow: inset 0 0 0 1px var(--forest);
}
.segmented__option input:focus-visible + span { outline: 3px solid var(--ember); outline-offset: 2px; }

/* Category tiles */
.category-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}
.category-tile { position: relative; cursor: pointer; }
.category-tile input { position: absolute; opacity: 0; pointer-events: none; }
.category-tile > span {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.4rem 0.6rem;
  border: 1px solid var(--sand);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.category-tile img { width: 100%; max-width: 92px; height: auto; border-radius: 8px; }
.category-tile:hover > span { transform: translateY(-1px); border-color: var(--sage); }
.category-tile input:checked + span {
  border-color: var(--forest);
  box-shadow: inset 0 0 0 1px var(--forest);
  background: #F3F5EC;
}
.category-tile input:focus-visible + span { outline: 3px solid var(--ember); outline-offset: 2px; }

.inferable-mark { color: var(--clay); }
.chip .inferable-mark { font-size: 0.75rem; }
.chip[aria-pressed="true"] .inferable-mark { color: #E9DFC9; }

/* ---------- Summary bar (after results) ------------------------------- */
.plan-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}
.plan-summary__label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ember-deep);
}
.plan-summary__text { margin: 0.1rem 0 0; font-weight: 600; color: var(--forest-deep); }

/* ---------- Results ------------------------------------------------------ */
.results { margin-top: 1.5rem; }

.results__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.results__title { margin: 0; font-size: 1.45rem; }
.results__title:focus { outline: none; }

.sort { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; color: var(--ink-soft); }
.select--small { min-height: 2.3rem; padding: 0.35rem 2rem 0.35rem 0.75rem; width: auto; font-size: 0.9rem; }

.results .notice { margin-bottom: 1rem; }

.planner__defaults { margin-top: -0.75rem; text-align: center; }

.route-list { display: grid; gap: 1.1rem; }

.results__footer { margin-top: 1.5rem; font-size: 0.82rem; color: var(--ink-soft); }
.results__footer p { margin-bottom: 0.4rem; }
.results__attribution strong { font-family: Roboto, Arial, sans-serif; font-weight: 500; color: #5F6368; }

/* ---------- Route card -------------------------------------------------- */
.route-card {
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  animation: reveal 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.route-card:nth-child(2) { animation-delay: 0.05s; }
.route-card:nth-child(3) { animation-delay: 0.1s; }
.route-card:nth-child(4) { animation-delay: 0.15s; }
.route-card:nth-child(5) { animation-delay: 0.2s; }

.route-card--selected {
  border-color: var(--forest);
  box-shadow: 0 0 0 2px var(--forest), var(--shadow);
}

.route-card__media {
  position: relative;
  aspect-ratio: 16 / 8;
  background: var(--cream-deep);
}
.route-card__photo { width: 100%; height: 100%; object-fit: cover; }
.route-card--illustrated .route-card__photo { object-fit: contain; padding: 0.6rem; background: var(--cream-deep); }

.route-card__rank {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.94);
  color: var(--forest-deep);
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.route-card__photo-credit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 1.6rem 0.75rem 0.45rem;
  background: linear-gradient(transparent, rgba(20, 18, 14, 0.72));
  color: #F4F1EA;
  font-size: 0.72rem;
}
.route-card__photo-credit a { color: #fff; }

.route-card__body { padding: 1rem 1.15rem 1.15rem; }

.route-card__heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}
.route-card__name { margin: 0; font-size: 1.22rem; }
.route-card__type { margin: 0.15rem 0 0; font-size: 0.85rem; color: var(--ink-soft); }

.route-card__score-box {
  display: grid;
  justify-items: center;
  flex-shrink: 0;
  min-width: 3.4rem;
  margin: 0;
  padding: 0.35rem 0.5rem;
  border-radius: 12px;
  background: var(--sage-soft);
  line-height: 1;
}
.route-card__score { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; color: var(--forest-deep); }
.route-card__score-label { margin-top: 0.15rem; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--forest); }

.route-card__stats {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 0.5rem;
  margin: 0.9rem 0 0.6rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--cream);
}
.route-card__stats div { min-width: 0; }
.route-card__stats dt { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.route-card__stats dd { margin: 0.1rem 0 0; font-weight: 600; font-size: 0.95rem; color: var(--ink); }

.diff { display: inline-block; margin-top: 0.15rem; padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.diff--good { background: var(--sage-soft); color: var(--forest-deep); }
.diff--ok { background: #F1E6D2; color: #6B5639; }
.diff--far { background: var(--ember-soft); color: var(--ember-deep); }

.route-card__shape,
.route-card__hours { margin: 0.25rem 0 0; font-size: 0.88rem; }
.route-card__shape { color: var(--ink-soft); }
.route-card__hours::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: var(--sand);
  vertical-align: 0.05rem;
}
.route-card__hours[data-tone="good"]::before { background: #5E8C52; }
.route-card__hours[data-tone="bad"]::before { background: var(--danger); }

.route-card__features {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
}
.route-card__features .badge { cursor: help; }

.route-card__reasons { margin: 0.8rem 0 0; font-size: 0.9rem; color: var(--ink-soft); }

.route-card__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

/* Loading placeholders shaped like cards */
.skeleton-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}
.skeleton-card__media { aspect-ratio: 16 / 8; border-radius: 0; }
.skeleton-card__body { display: grid; gap: 0.6rem; padding: 1rem 1.15rem 1.25rem; }
.skeleton-line { height: 0.85rem; }
.skeleton-line--title { height: 1.2rem; width: 60%; }
.skeleton-line--short { width: 40%; }

.loading-message {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  font-weight: 600;
  color: var(--forest);
}

.empty-state {
  padding: 1.75rem;
  border: 1px dashed var(--sand);
  border-radius: var(--radius);
  text-align: center;
  color: var(--ink-soft);
}

/* ---------- Map --------------------------------------------------------- */
.explore__map { position: relative; background: #E8E2D4; }
.map { position: absolute; inset: 0; }

.map-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.75rem;
  padding: 2rem;
  text-align: center;
  color: var(--ink-soft);
  background:
    radial-gradient(circle at 30% 30%, rgba(163, 177, 138, 0.25), transparent 50%),
    var(--cream-deep);
}
.map-placeholder p { max-width: 26rem; margin: 0; }

.map-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
}
.map-control {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--forest-deep);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.map-control svg { width: 1.05rem; height: 1.05rem; }
.map-control[aria-pressed="true"] { background: var(--forest); border-color: var(--forest); color: #fff; }

/* Custom markers (HTML elements placed on the map by maps.js) */
.map-pin { cursor: pointer; }
.map-pin--start {
  width: 22px;
  height: 22px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--forest);
  box-shadow: 0 0 0 6px rgba(47, 79, 58, 0.22), 0 2px 6px rgba(0, 0, 0, 0.3);
  transform: translateY(50%); /* markers hang from their bottom edge; center the dot instead */
}
.map-pin--destination { filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.3)); }
.map-pin--waypoint {
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--sage-deep);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transform: translateY(50%);
}
.map-pin--other {
  width: 12px;
  height: 12px;
  border: 2px solid var(--forest);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transform: translateY(50%);
}

.map-pin--station {
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 4px;
  background: #3E5C76;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transform: translateY(50%);
}

.map-info { max-width: 15rem; font-family: var(--font-body); font-size: 0.88rem; color: var(--ink); }
.map-info strong { display: block; margin-bottom: 0.15rem; font-size: 0.95rem; }

/* ---------- Phone layout: list OR map ----------------------------------- */
.view-toggle { display: none; }

@media (max-width: 900px) {
  .explore { display: block; height: auto; }
  .explore__panel { overflow: visible; border-right: 0; padding: 1.25rem 1.1rem 6rem; }

  /* The map covers the screen below the header, but stays invisible until shown,
     so Google can measure its size correctly. */
  .explore__map {
    position: fixed;
    inset: var(--header-height) 0 0 0;
    z-index: 20;
    visibility: hidden;
  }
  body[data-view="map"] .explore__map { visibility: visible; }
  body[data-view="map"] .explore__panel { visibility: hidden; height: 0; overflow: hidden; padding: 0; }

  .view-toggle {
    position: fixed;
    left: 50%;
    bottom: 1.1rem;
    z-index: 40;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.3rem;
    border: 0;
    border-radius: 999px;
    background: var(--forest-deep);
    color: #fff;
    font: inherit;
    font-weight: 600;
    box-shadow: 0 12px 28px -10px rgba(31, 53, 40, 0.7);
    transform: translateX(-50%);
    cursor: pointer;
  }
  .view-toggle svg { width: 1.15rem; height: 1.15rem; }
  .view-toggle[hidden] { display: none; }
}

@media (max-width: 420px) {
  .start-search { flex-direction: column; }
  .locate-button { justify-content: center; }
  .category-picker { grid-template-columns: repeat(2, 1fr); }
  .route-card__stats { grid-template-columns: 1fr 1fr; }
  .route-card__stats div:first-child { grid-column: 1 / -1; }
}
