/* The home list. Sizes here are deliberate. The row is tuned to fit a phone
   screen's worth of resorts above the fold. */

.masthead__account-link[hidden] {
  display: none;
}

/* Signed in, the alerts link's slot is held unseen until the overview fills it. */
[data-account-reserved] .masthead__account-link[data-alerts-target="mastheadAccount"][hidden] {
  display: inline-flex;
  visibility: hidden;
}

.window-chip {
  display: inline-block;
  margin: 12px 0 6px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-bright);
  font-size: 11.5px;
}

.location-line {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-size: .75rem;
  line-height: 1.5;
}

.sortbar {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.sortbar__button {
  min-width: 44px;
  min-height: 44px;
  padding: 5px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .75rem;
  cursor: pointer;
}

/* The bottom cue marks the active sort without relying on the fill alone. */
.sortbar__button.is-active {
  background: var(--raised);
  box-shadow: inset 0 -2px var(--accent-bright);
  color: var(--ink);
}

/* The shared focus shadow would otherwise replace the active cue. */
button.sortbar__button.is-active:focus-visible {
  box-shadow: inset 0 -2px var(--accent-bright), 0 0 0 2px var(--focus-gap);
}

.sortbar__button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Region groups ---------------------------------------------------------- */

.group {
  margin-top: 22px;
}

.group[hidden] {
  display: none;
}

.group__header {
  display: flex;
  justify-content: space-between;
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  line-height: 1.5;
  text-transform: uppercase;
}

.group__distance {
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0;
}

/* Favorites stay pinned, but read as one card once they gain an account
   summary. The same surface and radius are already used by expanded panels. */
.group--bookmarks {
  margin-top: 18px;
  padding: 10px 12px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.group--bookmarks .group__header {
  text-transform: none;
}

.favorites-card__empty {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.favorites-card__empty-title,
.favorites-card__empty-hint {
  margin: 0;
}

.favorites-card__empty-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.favorites-card__empty-hint {
  margin-top: 3px;
  color: var(--muted);
  font-size: .75rem;
}

/* Hidden takes no space. Showing or hiding grows or shrinks the card, because a
   grid row animates between 0fr and 1fr where height can't reach auto. */
.favorites-card__footer {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 200ms ease, margin-top 200ms ease;
}

/* .panel__read loads later in panel.css and sets the footer's own size. */
.group--bookmarks .favorites-card__footer {
  font-size: .75rem;
}

/* Visibility waits out the collapse, so the content stays readable while it shrinks.
   The top margin animates from .panel__read's. */
.favorites-card__footer[hidden] {
  grid-template-rows: 0fr;
  margin-top: 0;
  visibility: hidden;
  pointer-events: none;
  transition: grid-template-rows 200ms ease, margin-top 200ms ease, visibility 0s 200ms;
}

.favorites-card__footer-body {
  display: flex;
  min-height: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: opacity 150ms ease 100ms;
}

/* Clipped only while hidden, so the shown action's focus ring isn't cut off. Opening
   it fades in as the row grows, so the unclipped content never spills visibly. */
.favorites-card__footer[hidden] .favorites-card__footer-body {
  overflow: hidden;
  opacity: 0;
  transition: opacity 120ms ease;
}

.favorites-card__message {
  min-width: 0;
  flex: 1;
  border-radius: 5px;
}

.favorites-card__message.is-highlighted {
  animation: favorites-card-highlight 700ms ease-out;
}

.favorites-card__bell {
  color: currentcolor;
}

.favorites-card__action {
  display: inline-flex;
  min-height: 44px;
  flex: 0 0 auto;
  align-items: center;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.favorites-card__action[hidden] {
  display: none;
}

.favorites-card__locked {
  margin-top: 10px;
}

.favorites-card__locked[hidden] {
  display: none;
}

.favorites-card__locked .cta {
  margin-top: 14px;
}

@keyframes favorites-card-highlight {
  0% { background: var(--raised); }
  100% { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .favorites-card__message.is-highlighted {
    animation: none;
  }
}

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A row ------------------------------------------------------------------ */

/* The bottom padding keeps the bar's projecting tick clear of the divider. */
.row {
  display: block;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.row__main {
  display: grid;
  position: relative;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 44px;
}

/* A signed-in card holds the bell column before its bells arrive. */
.row__main.row__main--bell,
[data-account-reserved] .group--bookmarks .row__main {
  grid-template-columns: 44px minmax(0, 1fr) 44px;
}

/* The whole row except the star is one tap target. */
.row__open {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max(52px, 3.25rem) max(22px, 1.0625rem);
  align-items: center;
  gap: 0 6px;
  min-height: 44px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.row--open .row__title {
  color: var(--accent-bright);
}

.row__star {
  display: grid;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  place-items: center;
  cursor: pointer;
}

.row__star.is-on {
  color: var(--accent-bright);
}

.row__bell {
  display: grid;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  place-items: center;
  cursor: pointer;
}

.row__bell:disabled {
  cursor: default;
}

.row__bell[data-alerts-behavior="locked"] {
  font-size: 13px;
  line-height: 1;
}

.row__bell-control {
  display: grid;
  width: 44px;
  min-height: 44px;
  place-items: center;
}

.row__bell.is-on {
  color: var(--accent-bright);
}

.bell {
  display: inline-block;
  vertical-align: -1px;
}

/* Names wrap normally and grow the row. Anywhere only reaches strings with no
   other break. */
.row__name {
  display: flex;
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
  overflow-wrap: anywhere;
}

.row__title {
  display: block;
  color: var(--ink);
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.4;
}

.row__meta {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.5;
}

/* The bar shares the amount's track, along its bottom edge. */
.row__bar {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  height: 4px;
  margin-bottom: 1px;
  line-height: 0;
}

.bar {
  display: block;
  position: relative;
  height: 4px;
  border-radius: 4px;
  outline: 1px solid var(--muted);
  background: var(--bar-track);
}

.bar__fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--bar);
}

/* At 50 cm the bar is full, so it changes colour rather than growing. */
.bar__fill--pegged {
  background: var(--accent-bright);
}

/* The "worth driving" line at 20 cm. */
.bar__tick {
  position: absolute;
  top: -1px;
  left: 40%;
  width: 2px;
  height: 10px;
  background: var(--ink-soft);
  box-shadow: 0 0 0 1px var(--bg);
}

/* Center both parts of the quantity on the same axis as the row indicators. */
.row__median {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  color: var(--ink-soft);
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.row__unit {
  margin-left: 2px;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 400;
}

.row__dash {
  color: var(--muted);
}

.row__grade {
  display: flex;
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  justify-content: center;
}

/* Letters carry the meaning. Colour only reinforces it. Rem, so the box grows
   with its letter. */
.grade {
  display: grid;
  width: 1.0625rem;
  height: 1.0625rem;
  border: 1px solid currentcolor;
  border-radius: 5px;
  font-size: .625rem;
  font-weight: 800;
  place-items: center;
}

.grade--a { color: var(--grade-a); }
.grade--b { color: var(--grade-b); }
.grade--c { color: var(--grade-c); }

/* Em follows the reader's text size, so enlarged text puts the full name above
   one row of indicators. The open button shares the row's tracks via subgrid. */
@media (width < 20em) {
  .row__main {
    grid-template-rows: auto minmax(44px, auto);
    padding-block: 6px;
  }

  .row__star {
    grid-column: 1;
    grid-row: 2;
  }

  .row__bell-control {
    grid-column: 3;
    grid-row: 2;
  }

  .row__open {
    grid-column: 2;
    grid-row: 1 / 3;
    grid-template-rows: subgrid;
    gap: 6px;
    padding: 0;
  }

  .row__name {
    grid-column: 1 / -1;
  }

  .row__bar {
    grid-column: 1;
    grid-row: 2;
    align-self: center;
    margin-bottom: 0;
  }

  .row__median,
  .row__grade {
    grid-row: 2;
  }
}

/* Forced colors drop the track and fill backgrounds, so the bar keeps an edge
   and a solid fill. Grade boxes already keep their currentcolor border. */
@media (forced-colors: active) {
  .bar {
    border: 1px solid ButtonText;
  }

  .bar__fill {
    background: CanvasText;
  }
}

.legend {
  margin: 22px 0 0;
  color: var(--ink-soft);
  font-size: .75rem;
  line-height: 1.5;
}
