/* The routes' pages (#510): /routes and /routes/<slug>. A route's page borrows the terminal pages' layout and parts
   (terminal.css), with its day from each terminal side by side, and its sailings' stops in order. */

.route-marks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
}

.route-marks:empty {
  display: none;
}

.route-title {
  margin-bottom: var(--space-6);
}

/* A long name on a narrow line breaks with a hyphen where the browser knows one, not inside a word anywhere (#562); at
   200% on a phone, the title steps down so a name as long as "Fauntleroy" fits a line of its own. In rem, so it follows
   the zoom: the text is as large as ever, and only the title is smaller beside it. */
.route-title h1 {
  -webkit-hyphens: auto;
  hyphens: auto;
}

@media (max-width: 18rem) {
  .route-title h1 {
    font-size: var(--step-2);
  }
}

.route-map-link {
  margin: 0;
  padding: var(--space-2) var(--space-4) var(--space-3);
}

.route-map-link a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
}

.route-note {
  margin-bottom: var(--space-5);
  border-color: var(--kelp);
}

.route-note-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: var(--step-1-display);
}

.route-note .caption {
  margin: var(--space-1) 0 0;
}

.route-today h2 {
  margin-top: 0;
}

/* The way you're going, on a phone: one terminal's day at a time. */
.route-switch {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.route-switch .pill {
  background: var(--paper);
  color: var(--sound);
  font: inherit;
  font-family: var(--display);
  font-weight: 700;
  cursor: pointer;
}

.route-switch .pill[aria-pressed="true"] {
  background: var(--sound);
  color: var(--paper);
}

.route-sides {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
  gap: var(--space-5);
  align-items: start;
}

.route-side h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--step-2);
}

/* Its terminal's page, under the heading (#565). */
.route-side-page {
  margin: calc(-1 * var(--space-2)) 0 var(--space-2);
}

.route-side-page a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
}

/* Vehicle reservations recommended (#548), before the side's sailings: its words and link are terminal.css's. */
.route-reservations {
  margin-bottom: var(--space-2);
}

.route-earlier summary {
  min-height: 36px;
  color: var(--sound);
  font-weight: 600;
  cursor: pointer;
}

/* A sailing's stops in order, as the app's stop line draws them: a dot for each, the water between. */
.route-stops {
  flex-basis: 100%;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--step--1);
}

/* A stop's time wraps under its name when there's no room beside it, and neither breaks inside a word (#545). */
.route-stops li {
  position: relative;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-1);
  padding-inline-start: calc(0.6em + var(--space-1));
}

/* Beside the first line, so a time that wraps lines up under the name. */
.route-stops li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: calc(0.5lh - 0.3em);
  box-sizing: border-box;
  width: 0.6em;
  height: 0.6em;
  border: 2px solid var(--sound);
  border-radius: 50%;
}

/* Each breaks inside a word only when it doesn't fit a line of its own, at the very largest text. */
.route-stop-name,
.route-stop-time {
  min-width: 0;
  overflow-wrap: break-word;
}

.route-stop-name {
  font-weight: 600;
}

.route-stop-time {
  color: var(--ink-2);
}

.route-later-title {
  margin: var(--space-4) 0 var(--space-1);
  color: var(--ink-2);
  font-family: var(--body);
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* In columns where there's room, read down each one, so the day runs in order (#545). */
.route-later {
  columns: 11rem;
  column-gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Each read as a row is (#562), smaller and always stacked, so every one in a column has the same shape: the time,
   the boat or where it goes, then where and how under it. */
.route-later > li {
  break-inside: avoid;
  flex-direction: column;
  /* Each part as wide as the column, so a stop's name wraps in it at the largest text: one line, since a wrapping
     column is as wide as its widest part. */
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 2px;
  padding-block: var(--space-2);
  border-top: 1px solid color-mix(in srgb, var(--ink-2) 30%, transparent);
}

.route-later .departure-time {
  flex: none;
  font-size: inherit;
  font-weight: 700;
}

.route-later .departure-body {
  flex: none;
  width: 100%;
}

/* One under another, in every later row, so the column keeps one shape (#562): on one flex line, as wide as the
   column, so a long name wraps in it. */
.route-later .route-stops {
  flex-direction: column;
  flex-wrap: nowrap;
  margin-top: 0;
}

.route-last {
  margin: var(--space-3) 0 0;
}

/* Under the day (#547): the small map, the boats on the route and WSF's news. */
.route-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: var(--space-5);
  align-items: start;
  margin-top: var(--space-5);
}

.route-body > * {
  min-width: 0;
}

/* ── /routes ───────────────────────────────────────────────────────────── */

.route-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
  gap: var(--space-5);
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}

.route-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.route-card h3 {
  margin: 0;
  font-size: var(--step-1-display);
}

.route-card h3 a {
  color: var(--ink);
  text-decoration: none;
}

.route-card h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.route-card h3 a:hover {
  text-decoration: underline;
}

/* Whose route it is, and another operator's between the same places (#666). */
.route-owner {
  margin: 0;
}

.route-others ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.route-others li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
