/* Header search layout refinement
   Desktop: centered, contained modal with internal results scrolling.
   Mobile: top-aligned sheet with search field close to the top.
*/

.tt-header-search {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.tt-header-search__backdrop {
  position: absolute;
  inset: 0;
}

.tt-header-search__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(820px, calc(100vw - 48px));
  max-height: calc(100dvh - 64px);
  margin: 32px auto;
  overflow: hidden;
  border-radius: 24px;
}

.tt-header-search__head {
  flex: 0 0 auto;
}

.tt-header-search__panel > h2,
.tt-header-search__panel > p,
.tt-header-direct-search,
.tt-header-search__suggestions {
  flex: 0 0 auto;
}

.tt-header-direct-search {
  min-height: 0;
  margin-top: 20px;
}

.tt-header-search__field {
  position: relative;
  flex: 0 0 auto;
}

.tt-header-search__field .tt-header-direct-search__clear {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 34px;
  height: 34px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: #f3eee8;
  color: #66757a;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.tt-header-direct-search__status {
  flex: 0 0 auto;
  padding: 12px 2px 3px;
  color: #77858a;
  font-size: .82rem;
}

.tt-header-direct-search__results {
  min-height: 0;
  max-height: min(420px, calc(100dvh - 360px));
  margin-top: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid #ebe4dc;
  padding: 7px 4px 4px 0;
  scrollbar-width: thin;
}

.tt-header-direct-search__group-title {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 4px 8px 3px;
  padding: 7px 0 5px;
  background: #fffdf9;
  color: #8a969a;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.tt-header-direct-result {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 13px;
  border-radius: 12px;
  padding: 9px;
  color: #24353a;
  text-decoration: none;
  transition: background .18s ease;
}

.tt-header-direct-result:hover,
.tt-header-direct-result:focus {
  background: #f8f4ee;
  outline: none;
}

.tt-header-direct-result__image {
  display: block;
  overflow: hidden;
  width: 86px;
  height: 62px;
  border-radius: 9px;
  background: #ece7e0;
}

.tt-header-direct-result__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tt-header-direct-result__body {
  min-width: 0;
}

.tt-header-direct-result__body strong,
.tt-header-direct-result__route,
.tt-header-direct-result__body small {
  display: block;
}

.tt-header-direct-result__body strong {
  overflow: hidden;
  color: #1f3036;
  font-size: .92rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tt-header-direct-result__route {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 3px;
  color: #68777c;
  font-size: .74rem;
  line-height: 1.35;
  white-space: normal;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.tt-header-direct-result__body small {
  margin-top: 4px;
  color: #8a969a;
  font-size: .68rem;
  font-weight: 700;
}

.tt-header-direct-result__arrow {
  color: #d9644d;
  font-size: 1rem;
  font-weight: 800;
}

.tt-header-direct-result--landing {
  background: #fbf8f3;
}

.tt-header-direct-result--landing:hover,
.tt-header-direct-result--landing:focus {
  background: #f4eee6;
}

.tt-header-direct-result--landing .tt-header-direct-result__body small {
  color: #b25c49;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* When results are being searched, give the result list the space previously
   used by the quick links. */
.tt-header-search.has-query .tt-header-search__suggestions,
.tt-header-search__suggestions[hidden] {
  display: none !important;
}

@media (min-width: 768px) {
  .tt-header-search__panel {
    padding-bottom: 26px;
  }

  .tt-header-search.has-query .tt-header-direct-search__results {
    max-height: min(460px, calc(100dvh - 330px));
  }
}

@media (max-width: 767px) {
  .tt-header-search {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12px 10px;
  }

  .tt-header-search__panel {
    width: 100%;
    max-height: calc(100dvh - 24px);
    margin: 0;
    border-radius: 18px;
    padding: 18px 14px 16px;
  }

  .tt-header-search__head {
    margin-bottom: 10px;
  }

  .tt-header-search__panel > h2 {
    margin: 0 0 8px;
    font-size: clamp(1.65rem, 8vw, 2.2rem);
    line-height: 1.06;
  }

  .tt-header-search__panel > p {
    display: none;
  }

  .tt-header-direct-search {
    margin-top: 4px;
  }

  .tt-header-search__field {
    margin-top: 0;
  }

  .tt-header-search__field input {
    min-height: 52px;
    padding-block: 13px;
    font-size: .95rem;
  }

  .tt-header-direct-search__status {
    padding: 8px 2px 2px;
    font-size: .72rem;
  }

  .tt-header-search__suggestions {
    margin-top: 13px;
  }

  .tt-header-direct-search__results {
    max-height: calc(100dvh - 210px);
    margin-top: 6px;
    padding-right: 1px;
  }

  .tt-header-search.has-query .tt-header-direct-search__results {
    max-height: calc(100dvh - 172px);
  }

  .tt-header-direct-result {
    grid-template-columns: 64px minmax(0, 1fr) 18px;
    gap: 9px;
    padding: 7px 4px;
  }

  .tt-header-direct-result__image {
    width: 64px;
    height: 50px;
    border-radius: 8px;
  }

  .tt-header-direct-result__body strong {
    font-size: .84rem;
  }

  .tt-header-direct-result__route {
    font-size: .68rem;
  }

  .tt-header-direct-result__body small {
    font-size: .62rem;
  }

  .tt-header-direct-search__group-title {
    margin-inline: 4px;
    padding-top: 6px;
  }
}
