/* ============================================================================
   Multi-level main menu — ТЗ §3.7
   ============================================================================

   Loaded AFTER css/style.css on every page. It only introduces new selectors;
   not one rule from style.css is redefined, so every existing page keeps its
   exact appearance. The only visible change to an existing element is a small
   caret on the top-level items that actually gained a submenu.

   Colours, radii, gaps and timings are taken from style.css rather than chosen:
   the dropdown reuses the panel of the language switcher (#2b3141, radius 8px,
   gap 1rem, padding 10px 5px) so it reads as the same component family.

   The desktop/mobile split uses `not all and (max-width: 63.75rem)` — the exact
   complement of the breakpoint style.css already uses for the burger menu, so
   there is no width at which both or neither applies.

   A mouse needs no JS to open a dropdown: hover and focus-within do it in CSS,
   per "минимум тяжёлых JS-библиотек, использовать CSS3 Transitions". A finger
   has no hover, so there a tap sets .nav__item--open (assets/menu.js).
   ========================================================================== */

.nav__item--has-children {
  position: relative;
}

/* Caret. Drawn from two borders instead of an icon file so it inherits
   currentColor and needs no extra request. */
.nav__item--has-children > .nav__link::after {
  content: "";
  display: inline-block;
  width: 0.375rem;
  height: 0.375rem;
  margin-left: 0.4rem;
  vertical-align: middle;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-0.125rem) rotate(45deg);
  transition: transform 0.35s ease;
}

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

.nav__subitem {
  display: block;
}

/* min-height, not just line-height: a 21px row is under the 24×24 CSS px that
   WCAG 2.2 asks of a control, and a submenu is a list of controls, not running
   text. The padding also gives the pointer somewhere to land between items. */
.nav__sublink {
  display: block;
  min-height: 24px;
  padding: 0.125rem 0;
  color: #ffffff;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.35;
  transition: color 0.35s ease;
}

.nav__sublink:hover,
.nav__sublink:focus-visible {
  color: #ed1a20;
  text-decoration: underline;
}

.nav__sublink--active {
  color: #ed1a20;
  font-weight: 600;
}

/* ТЗ §3.7: the current page and its parent are highlighted. The parent uses the
   site's own .nav__link--active; the submenu entry of the page being viewed
   carries .current-menu-item. */
.nav__sublink.current-menu-item {
  color: #ed1a20;
  font-weight: 600;
}

/* The accordion trigger exists only on mobile; on desktop hover opens the
   panel and an extra button would just be a focus trap. */
.nav__toggle {
  display: none;
}

/* --------------------------------------------------------- the city switch -- */
/* Two links that take a visitor between the cities from any page: the hero control
   exists on the two city homes only. The look of the language switcher next to it,
   white and 600 on the panel; the current city is the one with the site's red under
   it, because a red word would read as a third button beside «Купить». Rendered
   twice, see city_switch() in tools/gen_menu.py: each width shows its own copy. */
.city-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.city-switch--panel {
  display: none;
}

.city-switch__link {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  border-bottom: 2px solid transparent;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition:
    color 0.35s ease,
    border-color 0.35s ease;
}

.city-switch__link[aria-current] {
  border-bottom-color: #ed1a20;
  font-weight: 600;
}

.city-switch__link:hover,
.city-switch__link:focus-visible {
  color: #ed1a20;
}

/* A neutral page with Samarkand stored. The markup says Tashkent, and the head of
   the page has read the storage long before assets/menu.js moves aria-current:
   without these the mark would flip under the visitor's eyes. */
[data-stored-city="samarkand"] .city-switch__link:first-child {
  border-bottom-color: transparent;
  font-weight: 500;
}

[data-stored-city="samarkand"] .city-switch__link:last-child {
  border-bottom-color: #ed1a20;
  font-weight: 600;
}

/* On a city home the hero control offers the same choice: one of the two, for as
   long as the hero control is in view. visibility, so the row does not shift;
   the class comes from assets/menu.js and config/noscript-head.html undoes this. */
body:has(.hero-cities) .city-switch--bar:not(.city-switch--free) {
  visibility: hidden;
}

@media not all and (max-width: 63.75rem) {
  .city-switch--bar {
    flex-shrink: 0;
    gap: 0.5rem;
    margin-left: 0.75rem;
  }

  .city-switch--bar .city-switch__link {
    font-size: 0.8125rem;
  }

  .nav__label-full {
    display: none;
  }
}

@media (max-width: 63.75rem) {
  .nav__label-short {
    display: none;
  }
}

@media (max-width: 63.75rem) {
  .city-switch--bar {
    display: none;
  }

  /* First in the panel, and a thumb's 44px like the rows under it. */
  .city-switch--panel {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    width: 100%;
  }

  .city-switch--panel .city-switch__link {
    min-height: 2.75rem;
    font-size: 1rem;
  }
}

/* --------------------------------------------------------------- desktop -- */
@media not all and (max-width: 63.75rem) {
  .nav__submenu {
    position: absolute;
    top: calc(100% + 0.9rem);
    left: -0.9375rem;
    min-width: 13rem;
    /* Each panel is as wide as its own longest entry and no wider: «Информация»
       stays 184px, «Туры Узбекистан» takes the 499px its longest label needs.
       A 20rem cap was measured on staging as the reason the customer saw the
       dropdown «переносится»: seven entries broke onto two and three lines,
       «Классические туры (Ташкент — Самарканд — Бухара — Хива)» among them.
       The cap clears the longest label of «Пример структуры 2» in Inter at the
       site's size, in the 600 weight of the current page as well: 31.25rem held
       the 400 weight only, so on that tour's own page its entry wrapped. It never
       exceeds the window: a label longer than that (a future translation) wraps,
       which is still better than overflowing.
       tools/navfit_check.py measures every panel at 1021–1920px, all in 600. */
    width: max-content;
    max-width: min(33.75rem, calc(100vw - 2.5rem));
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: #2b3141;
    border-radius: 8px;
    padding: 10px 15px;
    box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.35);
    /* No max-height and no scrollbar.
       This used to cap the panel and scroll inside it, because the Маршруты
       branch carried 13 entries: 468px of panel in a 596px viewport, its own
       scrollbar, and a last item cut off mid-word. The stops now live on
       routes.html, where they were always going to be read, so the longest
       branch left is four blog categories — roughly 130px. A dropdown that
       needs a scrollbar is a page in a box; the fix is fewer entries, not a
       nicer scrollbar. tools/gen_menu.py fails the build if any branch grows
       past MAX_SUBMENU_ITEMS. */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    /* ТЗ: задержка скрытия 0,3 с, so the pointer can cross the gap to the panel.
       The fade itself is short on purpose. A neighbour opens after the same 0.3 s
       (below), so the two change places at that moment; a fade of 0.2 s left both
       on screen with their text crossing. */
    transition:
      opacity 0.1s ease 0.3s,
      transform 0.1s ease 0.3s,
      visibility 0s linear 0.4s;
    z-index: 10;
  }

  /* Invisible bridge over the 0.9rem gap between the item and the panel, so
     the hover is not lost on the way down. */
  .nav__submenu::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -0.9rem;
    height: 0.9rem;
  }

  /* Only where hover is real. A touch screen keeps :hover on whatever was last
     tapped: after turning a tablet from the burger to this layout, the panel under
     the finger stayed open over the page until the next tap.

     ТЗ §3.7: hover intent 0,3–0,5 с. A pointer on its way somewhere else opens
     nothing: leaving within the delay cancels the transition before it shows. */
  @media (hover: hover) {
    .nav__item--has-children:hover > .nav__submenu {
      opacity: 1;
      visibility: visible;
      transform: translateY(0);
      transition:
        opacity 0.2s ease 0.3s,
        transform 0.2s ease 0.3s,
        visibility 0s linear 0.3s;
    }

    .nav__item--has-children:hover > .nav__link::after {
      transform: translateY(0.0625rem) rotate(225deg);
    }
  }

  /* A tap is a decision, and there is no pointer to cross a gap with: the old panel
     goes at once, not 0.3 s into the new one. */
  @media (hover: none) {
    .nav__submenu {
      transition:
        opacity 0.1s ease,
        transform 0.1s ease,
        visibility 0s linear 0.1s;
    }
  }

  /* The keyboard and the finger have already chosen: no delay. After the :hover
     rule, because a hovered item can have focus as well. */
  .nav__item--has-children:focus-within > .nav__submenu,
  .nav__item--has-children.nav__item--open > .nav__submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition:
      opacity 0.2s ease 0s,
      transform 0.2s ease 0s,
      visibility 0s linear 0s;
  }

  .nav__item--has-children:focus-within > .nav__link::after,
  .nav__item--has-children.nav__item--open > .nav__link::after {
    transform: translateY(0.0625rem) rotate(225deg);
  }

  /* Esc over an open panel (assets/menu.js). No delay: the 0.3 s is there for a
     pointer crossing the gap, and this is a request to close. */
  .nav__item--has-children.nav__item--dismissed > .nav__submenu {
    opacity: 0;
    visibility: hidden;
    transition: none;
  }

  /* The last item sits next to the buy button: its panel opens leftwards so a
     20rem panel cannot run past the right edge of a 1024px screen. */
  .nav__item--has-children:last-child > .nav__submenu {
    left: auto;
    right: -0.9375rem;
  }
}

/* Six top-level items and the city switch share what the logo, the buy button and
   the language leave of the 1180px container: about 650px, down to 470px just above
   the desktop breakpoint. Left alone, the browser broke every caret onto a second
   line — the customer saw it at 1440px with five items.

   So a label and its caret never break, and the spacing tightens in steps as the
   header narrows: first the gap, then, below 1200px, the size, and below 1100px
   the logo, which is what style.css does to it on a phone as well.
   tools/navfit_check.py measures every step in the real font, 1021–1920px.
   Only the caret and the city switch are ours. Every other step of the ladder
   corrects a rule of style.css, so it is in assets/fixes.css, the one sheet
   allowed to do that. */
@media not all and (max-width: 63.75rem) {
  .nav__item--has-children > .nav__link::after {
    margin-left: 0.35rem;
  }
}

@media (min-width: 63.8125rem) and (max-width: 75rem) {
  .city-switch--bar {
    margin-left: 0.5rem;
  }
}

@media (min-width: 63.8125rem) and (max-width: 68.75rem) {
  .nav__item--has-children > .nav__link::after {
    margin-left: 0.25rem;
  }
}

/* ---------------------------------------------------------------- mobile -- */
@media (max-width: 63.75rem) {
  /* No wrapper element is introduced: the link, the arrow and the submenu are
     laid out as flex children of the existing <li>, which keeps the node count
     close to production markup and the fidelity check meaningful. */
  .nav__item--has-children {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0 0.5rem;
    width: 100%;
  }

  /* On mobile the arrow button is the affordance, so the caret would be a
     duplicate. */
  .nav__item--has-children > .nav__link::after {
    display: none;
  }

  .nav__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    transition:
      border-color 0.35s ease,
      color 0.35s ease;
  }

  /* The circle stays 28px; the tappable area becomes 44px.
     A pseudo-element rather than padding, so the arrow does not move and the
     row's rhythm is unchanged. 28px is above the WCAG 2.2 AA floor of 24px but
     well under what a thumb expects. */
  .nav__toggle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2.75rem;
    height: 2.75rem;
    transform: translate(-50%, -50%);
  }

  .nav__toggle {
    position: relative;
  }

  .nav__toggle:hover,
  .nav__toggle:focus-visible {
    border-color: #ed1a20;
    color: #ed1a20;
  }

  .nav__toggle::before {
    content: "";
    width: 0.375rem;
    height: 0.375rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-0.0625rem) rotate(45deg);
    transition: transform 0.35s ease;
  }

  .nav__item--open > .nav__toggle::before {
    transform: translateY(0.0625rem) rotate(225deg);
  }

  .nav__submenu {
    flex-basis: 100%;
    display: flex;
    flex-direction: column;
    max-height: 0;
    overflow: hidden;
    /* max-height is animatable where height:auto is not; the value only has to
       be larger than any real submenu. */
    transition:
      max-height 0.35s ease,
      opacity 0.35s ease;
    opacity: 0;
  }

  /* Large enough for the longest branch (the route has 11 stops plus the city
     hub); max-height is animatable where height:auto is not. */
  .nav__item--open > .nav__submenu {
    max-height: 45rem;
    opacity: 1;
    padding-top: 0.25rem;
  }

  /* A thumb's 44px. The rows now touch instead of standing 12px apart, so the list
     stays about as tall as it was and a miss lands on the neighbouring row, not in
     a gap. The top-level links get the same in fixes.css: that selector is
     style.css's. */
  .nav__sublink {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
  }
}

/* ------------------------------------------------- sticky on scroll up ---- */
/* ТЗ §3.1: "sticky-header при скролле вверх". The header is already
   position:fixed in style.css; this adds hide-on-scroll-down. The transition that
   animates it extends a rule of style.css, so it is in assets/fixes.css. */
.header--hidden {
  transform: translateY(-100%);
}

/* A scroll that began before the burger opened can still have set the class.
   Focus and an open dropdown never let it be set: menuInUse() in assets/menu.js. */
.header--menu-open.header--hidden {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .nav__submenu,
  .nav__toggle::before,
  .nav__item--has-children > .nav__link::after {
    transition: none;
  }

  .header--hidden {
    transform: translateY(0);
  }
}

/* ------------------------------------------- content must not depend on motion */
/*
  style.css hides every animated block until JavaScript marks the body ready:

      body:not(.animations-ready) [data-animate-on-view]
          { opacity: 0; visibility: hidden }

  and there is no prefers-reduced-motion block anywhere in it. So a reader who
  asked the operating system for less motion still gets content that fades in,
  and a reader whose JavaScript failed gets a blank page — routes.html is 19
  such blocks, 17 of them invisible at any moment.

  Revealing them here costs nothing when animations do run: this rule only wins
  where the reader has explicitly asked for it. The no-JavaScript case is
  handled by a <noscript> block tools/gen_menu.py injects, since CSS alone
  cannot tell whether a script ran.

  The selectors are attribute-based and do not appear in style.css, so nothing
  there is redefined.
*/
@media (prefers-reduced-motion: reduce) {
  [data-animate-on-view] {
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
  }
}

/* ------------------------------------------------ routes.html cross-links -- */
/*
  The stop cards gained a link to the page built for each stop, and the two hub
  destinations that used to sit in the Маршруты dropdown moved onto the page.

  Both need styling here because menu.css is the only stylesheet the generator
  adds to the static pages. Neither selector exists in style.css.
*/

/* A heading that is also a link must still look like a heading: the browser
   default turns it blue and underlined, which reads as a foreign element
   dropped into the card. */
.route-card__link {
  color: inherit;
  text-decoration: none;
  transition: color 0.35s ease;
}

.route-card__link:hover,
.route-card__link:focus-visible {
  color: #ed1a20;
  text-decoration: none;
}

/* The card is not itself a link, so the affordance has to live on the title.
   An arrow rather than an underline: it says "this leads somewhere" without
   competing with "Показать на карте" lower in the same card.

   Visible at rest, not only on hover. A touch screen has no hover, so a title
   that looks exactly like the text around it gives a phone reader nothing to
   go on — and the phone is where this page is mostly read. */
.route-card__link::after {
  content: "→";
  margin-left: 0.4rem;
  display: inline-block;
  opacity: 0.45;
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
}

.route-card__link:hover::after,
.route-card__link:focus-visible::after {
  opacity: 1;
  transform: translateX(0.2rem);
}

.routes-hub {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  /* Under a centred heading and paragraph. */
  justify-content: center;
  margin: 0 auto 2.5rem;
  max-width: 75rem;
  padding: 0 0.625rem;
}

/* .button in style.css stretches to its container; these two sit side by side
   and are sized by their own text. */
.routes-hub__link {
  width: auto;
  flex: 0 0 auto;
  text-decoration: none;
}

.routes-hub__link:hover,
.routes-hub__link:focus-visible {
  text-decoration: none;
}

@media (max-width: 35rem) {
  .routes-hub__link {
    flex: 1 1 100%;
    justify-content: center;
  }
}

/* ---------------------------------------------- «Купить билет»: which city */
/* The chooser of menu.js. It is the site's own modal (.modal, .modal__window,
   .modal-option from style.css) — the same white window and grey options as
   the ticket modal it leads to; only the picture and the two lines are new. */
.city-pick__lead {
  margin: 0 0 1rem;
  text-align: center;
  color: #6f6f6f;
  line-height: 1.4;
}

.city-pick__option {
  width: 100%;
  flex-wrap: nowrap;
  border: 0;
  font: inherit;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  transition:
    color 0.35s ease,
    background-color 0.35s ease;
}

.city-pick__option:hover,
.city-pick__option:focus-visible {
  color: #151515;
  background-color: #d9d9d9;
}

.city-pick__option:focus-visible {
  outline: 2px solid #ed1a20;
  outline-offset: 2px;
}

.city-pick__img {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}

.city-pick__name {
  display: block;
  font-size: 1.125rem;
  color: #151515;
}

.city-pick__note {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.city-pick__arrow {
  font-size: 1.25rem;
  color: #ed1a20;
}

/* ------------------------------------------------------- skip link (WCAG 2.4.1)
 * The first Tab stop of every page. Out of sight until it has focus: a mouse
 * user never needs it, a keyboard user otherwise walks the whole menu. */
.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 200;
  padding: 1rem 0.9375rem;
  border-radius: 10px;
  background-color: #ed1a20;
  color: #ffffff;
  font-weight: 500;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform 0.35s ease;
}

.skip-link:focus {
  transform: none;
}

/* A click on the link lands here by script-free focus: the outline of the whole
   page says nothing. */
main:focus {
  outline: none;
}

/* ------------------------------------------------------------- breadcrumbs
 * Here rather than in blog.css because the static pages have them too and do
 * not load blog.css. */
/* The width caps are what lets the last crumb's ellipsis work at all. Its
   nowrap text is the trail's min-content; where the trail sits in a column
   flex with align-items: flex-start (tour hero) or is inline-flex (location
   hero with a photo), that min-content became the trail's width, the
   document grew past the phone screen and the header's buy button and
   burger slid off its right edge. Capped, the trail is never wider than its
   container, so the crumb shrinks and is cut instead. */
.breadcrumbs {
  font-size: 0.875rem;
  max-width: 100%;
  min-width: 0;
}

.breadcrumbs__list {
  max-width: 100%;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.breadcrumbs__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.6);
}

/* The slash closes the crumb before it rather than opening the next one: when
   the trail wraps, the break falls after it, so no line begins with «/». */
.breadcrumbs__item:not(:last-child)::after {
  content: "/";
  color: rgba(255, 255, 255, 0.3);
}

/* The last crumb is the page's own name and repeats the H1 just below it (ТЗ
   §3.2). On a phone the whole title took two or three lines of the trail. It
   now keeps to one line and is cut with an ellipsis: on the line of the other
   crumbs when at least 5rem is left there, otherwise on a line of its own.
   Basis 0 with min-width is what decides that: a line breaks on the
   hypothetical size, 5rem, not on the full title, and the crumb then grows into
   what is left of the line. A short name is never cut. The full name stays in
   the markup, for screen readers and for the BreadcrumbList. */
.breadcrumbs__item:last-child {
  flex: 1 1 0;
  min-width: 5rem;
}

.breadcrumbs__current {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumbs__link {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: color 0.35s ease;
}

.breadcrumbs__link:hover,
.breadcrumbs__link:focus-visible {
  color: #ed1a20;
  text-decoration: underline;
}

/* A word in a strip: the target grows into the strip, the strip stays as it is. */
@media (max-width: 48rem) {
  .breadcrumbs__link {
    display: inline-block;
    margin: -0.875rem 0;
    padding: 0.875rem 0;
  }
}

/* 0.6, not 0.5: below AA on the panel colour, and the static pages have it now. */
.breadcrumbs__current {
  color: rgba(255, 255, 255, 0.6);
}

/* The strip they sit on on the static pages: the colour of the hero panel of the
   PHP pages, so the two read as the same place on the page. */
.page-crumbs {
  padding: 0.75rem 0;
  background-color: #2b3141;
}

/* ------------------------------------------------- without JavaScript only */
.nojs-note {
  padding: 0.75rem 0;
  background-color: #2b3141;
  font-size: 0.875rem;
  line-height: 1.4;
}

.nojs-note a {
  color: #ffffff;
  font-weight: 500;
}

/* A language without a flag: contract 2.2 rules out new icons, so the code stands
   alone. It keeps the height and the text column of an entry with a flag (35 px
   and 0.4rem from style.css), or the list would jump between lines. */
.lang-switcher__item--text a {
  min-height: 35px;
  padding-left: calc(35px + 0.4rem);
}

/* 04.11.2026, the user: the city pair goes from the header — next to «Купить» on a
   desktop, at the top of the burger panel on a phone. The choice stays on the two
   city homes (.hero-cities), and «Маршрут» still follows the city of the page.
   The element stays in the markup: assets/menu.js reads data-city-nav from it. */
.city-switch--bar,
.city-switch--panel {
  display: none !important;
}
