/* Directions across pistes and lifts (A4). Uses the tokens in design/tokens.css and the shared .sheet, .btn, .grow
   and .hint styles in friends.css. */

.route-sheet #route-title { outline: none; }
.route-sheet .sheet-body { padding-top: var(--space-3); }
@media (max-width: 699px) {
  /* Short on phones, so the route on the map stays in view above it */
  .route-sheet { max-height: min(56vh, 540px); }
  /* Choosing a start or destination: a tall sheet, so the search results sit above the keyboard */
  .route-sheet.choosing { height: min(80vh, 660px); max-height: none; }
  /* "Choose on the map": the sheet drops to its header, leaving the map free to tap; tapping the header brings it back */
  .route-sheet.open.peek { transform: translateY(calc(100% - 66px - env(safe-area-inset-bottom))); }
  .route-sheet.peek .sheet-header { cursor: pointer; }
}

/* With the directions panel open on the left, a tapped piste's card sits next to it on wide screens.
   "Choose on the map" shrinks the panel to its header there. */
@media (min-width: 700px) {
  body:has(#route-sheet.open) .place-card { left: calc(var(--gutter) + 396px); margin-left: 0; }
  .route-sheet.peek .sheet-body { display: none; }
  .route-sheet.peek .sheet-header { border-bottom: 0; cursor: pointer; }
}

/* ---------- From and To: two tappable fields joined by a dotted line, with the swap button on the right ---------- */

.route-ends {
  position: relative;
  border-radius: var(--radius-sm);
  background: var(--fill);
}
.route-ends::before {
  content: ""; position: absolute;
  left: 18px; top: 30px; bottom: 30px;
  border-left: 2px dotted rgb(var(--navy-rgb) / .3);
  pointer-events: none;
}
.route-end {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; min-height: 52px; padding: 6px 52px 6px 12px;
  border: 0; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: none; color: var(--text);
  font: inherit; text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.route-end + .route-end { border-top: 1px solid var(--separator); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.route-end:hover { background: var(--fill); }
.route-end:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -3px; }
.route-end small { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.route-end strong { font-size: var(--text-base); font-weight: 600; white-space: nowrap; }
.route-end strong.empty { color: var(--accent); }   /* "Choose a start" reads as something to tap */
.route-dot {
  position: relative; z-index: 1; flex: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--piste-edge); border: 3px solid var(--accent);
}
.route-dot.to { background: var(--accent); border-color: var(--piste-edge); box-shadow: 0 0 0 1px var(--accent); }
.route-swap {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px;
  background: var(--glass-solid); color: var(--navy);
  box-shadow: 0 1px 3px var(--stroke);
}
.route-swap:disabled { opacity: .4; cursor: default; }
.route-swap svg { width: 17px; height: 17px; }

/* ---------- Options: one row of chips ---------- */

.route-prefs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-3); }
.route-pref {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid rgb(var(--navy-rgb) / .14); border-radius: 999px;
  background: var(--glass-solid); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.route-pref:hover { border-color: rgb(var(--navy-rgb) / .28); }
.route-pref[aria-pressed="true"] { border-color: transparent; background: rgb(var(--accent-rgb) / .13); color: var(--accent-hover); }
.route-pref svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.route-pref:focus-visible, .route-level:focus-within { outline: 3px solid var(--focus-ring); outline-offset: 1px; }
/* The piste level: a native select laid over the chip, so phones open their own picker */
.route-level { padding: 0 9px 0 11px; }
.route-level i { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px rgb(var(--navy-rgb) / .15); }
.route-level svg { stroke: var(--muted); }
.route-level select {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
  font-size: 16px;   /* no zoom on focus in iOS */
}

/* ---------- Result ---------- */

.route-result { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--separator); }
.route-result:empty { display: none; }
.route-status { display: flex; align-items: center; gap: 10px; margin: 4px 0 !important; color: var(--muted); }
.spinner {
  width: 16px; height: 16px; flex: none;
  border: 2px solid var(--fill-hover); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.route-head { display: flex; align-items: center; gap: var(--space-3); }
.route-summary {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 0; border: 0; background: none;
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
}
.route-summary strong { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.route-summary span { font-size: var(--text-sm); color: var(--muted); }
.route-summary:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; border-radius: 6px; }
.route-piste-dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; margin: 0 4px 0 2px; vertical-align: 1px; box-shadow: 0 0 0 1px rgb(255 255 255 / .9); }
.route-go { flex: none; min-width: 92px; height: 42px; border-radius: 999px; font-size: 16px; }

/* The route at a glance: each step's colour, as long as it takes */
.route-bar { display: flex; gap: 2px; height: 6px; margin: 10px 0 8px; border-radius: 3px; overflow: hidden; }
.route-bar i { min-width: 3px; }

.route-steps { list-style: none; margin: 0; padding: 0; }
.route-steps li { position: relative; }
/* A thin line down the step icons, like a transit timeline */
.route-steps li:not(:last-child)::after {
  content: ""; position: absolute; left: 15px; top: 40px; bottom: -8px;
  border-left: 2px solid var(--separator);
}
.route-step {
  display: flex; align-items: center; gap: var(--space-3);
  width: calc(100% + 2 * var(--space-2)); min-height: 52px;
  margin: 0 calc(-1 * var(--space-2)); padding: 7px var(--space-2);
  border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text);
  font: inherit; text-align: left;
}
button.route-step { cursor: pointer; transition: background var(--dur-fast) var(--ease); }
button.route-step:hover { background: var(--fill); }
button.route-step:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -3px; }
.route-step strong { font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.route-step .grow strong { white-space: normal; }
.route-step-icon {
  position: relative; z-index: 1; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--fill-2); color: var(--navy);
}
.route-step-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.route-step-icon.run { background: var(--c); color: #fff; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--stroke); }
.route-step-icon.lift { background: var(--lift); color: #fff; }
.route-step-icon.end { background: var(--accent); color: var(--on-accent); }
.route-step-icon.food { background: var(--poi-food); color: #fff; }
.route-step-icon.parking { background: var(--poi-parking); color: #fff; font-size: 14px; font-weight: 800; font-style: normal; }
.route-step-icon.junction { background: #fff; color: var(--poi-junction); box-shadow: inset 0 0 0 2px var(--poi-junction); }
.route-step-icon.quick { background: rgb(var(--accent-rgb) / .12); color: var(--accent); }
.route-steps li.done { opacity: .45; }
.route-steps li[aria-current="step"] .route-step, button.route-step.focused { background: rgb(var(--accent-rgb) / .1); }

/* The pistes of a "Ski to…" step, in order */
.route-step .route-pistes, .route-now .route-pistes {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px;
  margin: 3px 0 2px;
  font-size: 13px; font-weight: 500; color: var(--text);
  overflow: visible;
}
.route-pistes > span { display: inline-flex; align-items: center; white-space: nowrap; }
.route-pistes > span + span::before { content: "›"; margin: 0 4px 0 0; color: var(--muted); font-weight: 600; }

.route-error { padding: 10px 12px; border-radius: var(--radius-sm); background: rgb(var(--navy-rgb) / .05); }
.route-error p { margin: 0 0 8px !important; }
.route-error p:last-child { margin: 0 !important; }
.route-note { margin: var(--space-4) 0 0 !important; font-size: 12px; }

/* ---------- Following the route: the current step in large type ---------- */

.route-now { display: flex; align-items: flex-start; gap: var(--space-3); }
.route-now > .route-step-icon { width: 46px; height: 46px; }
.route-now > .route-step-icon svg { width: 23px; height: 23px; }
.route-now .grow small:first-child { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.route-now .grow strong { margin: 1px 0; font-family: var(--font-display); font-size: 21px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; white-space: normal; }
.route-then {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 0 0 !important; padding: 8px 10px;
  border-radius: var(--radius-sm); background: var(--fill);
}
.route-then > span { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.route-then .route-step-icon { width: 24px; height: 24px; }
.route-then .route-step-icon.run { border-width: 1.5px; }
.route-then .route-step-icon svg { width: 13px; height: 13px; }
.route-then strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.route-nav-foot { display: flex; align-items: center; gap: 8px; margin-top: var(--space-3); }
.route-left { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.route-left strong { color: var(--text); }

/* ---------- Choosing a start or destination ---------- */

.route-search { position: relative; }
.route-search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round;
  pointer-events: none;
}
.route-search input {
  width: 100%; height: 42px; padding: 0 12px 0 38px;
  border: 0; border-radius: var(--radius-sm);
  background: var(--fill-2); color: var(--text);
  font: inherit; font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
.route-search input::placeholder { color: var(--muted); }
.route-search input:focus { outline: none; background: #fff; box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / .3); }
.route-choices { list-style: none; margin: 8px 0 0; padding: 0; }
.route-choices li + li { border-top: 1px solid var(--separator-soft); }
.route-choice {
  display: flex; align-items: center; gap: var(--space-3);
  width: calc(100% + 2 * var(--space-2)); min-height: 52px;
  margin: 0 calc(-1 * var(--space-2)); padding: 6px var(--space-2);
  border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.route-choice:hover { background: var(--fill); }
.route-choice:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: -3px; }
.route-choice strong { font-size: 15px; font-weight: 600; }
.route-found { margin-top: 4px; }
.route-found > .hint, .route-found > .route-status { margin: 10px 0 0 !important; }
.route-found .route-choices { margin-top: 0; padding-top: 4px; border-top: 1px solid var(--separator); }
.route-found-head { margin: 16px 0 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.route-found-head + .route-choices { padding-top: 0; border-top: 0; }

/* ---------- Choosing on the map ---------- */

.chip.route-pick {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--on-accent); background: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.chip.route-pick u { text-decoration-color: rgba(255, 255, 255, .6); text-underline-offset: 2px; }
.chip.route-pick:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
body:has(.chip.route-pick:not([hidden])) .maplibregl-canvas { cursor: crosshair; }

/* Restaurant and car park card badges (select.js) */
.place-badge.food { background: var(--poi-food); color: #fff; }
.place-badge.parking { background: var(--poi-parking); color: #fff; font-size: 19px; font-weight: 800; }

/* Directions in a card keeps its full label; Centre and the resort or website button share the rest */
.place-actions .btn[data-action="route-to"] { flex: none; }
.place-actions .btn:first-child:nth-last-child(3) ~ .btn { padding: 0 8px; }
