/* Компактная навигация главной и серверный справочник направлений. */
.directions-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.home-intro .header-home_app { display: block; }

/* Одинаковые промежутки 12 px между заголовком, типами недвижимости и счётчиками главной. */
.home-intro .header-home_app > h1 { margin-bottom: 12px; }
.home-intro .header-home_app > .help.title { padding: 0; margin: 0 0 12px; }

/* Высота обоих поисковых полей — 55 пикселей, включая рамку и внутренние отступы. */
.home-intro .header-home_info--search,
.home-intro #home-search-city-index { height: 55px; }

/* Счётчики выравниваем слева под строкой типов недвижимости; на узком экране разрешён перенос. */
.home-catalog-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    text-align: left;
    gap: 5px 22px;
    margin: 0 0 16px;
    /* Более тёмный текст счётчиков сохраняет читаемость рядом с заголовком. */
    color: #222;
    font-size: 15px;
    line-height: 1.5;
}

.home-city-tags {
    display: flex;
    flex-wrap: wrap;
    /* Центрируем и весь блок под поиском, и плитки в каждой перенесённой строке. */
    justify-content: center;
    gap: 8px;
    max-width: 1120px;
    margin: 20px auto 28px;
}

.home-city-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 13px;
    border: 1px solid #dbe6ec;
    border-radius: 6px;
    background: #fff;
    color: #18739e;
    font-size: 15px;
    line-height: 1.3;
    text-decoration: none;
    transition: border-color .15s, background-color .15s;
}

.home-city-tag:hover,
.home-city-tag:focus {
    border-color: #8ab6cb;
    background: #edf6fa;
    color: #125a7c;
    text-decoration: none;
}

.home-city-tag--all {
    gap: 6px;
    border-color: #b9d5e2;
    background: #eaf4f8;
    font-weight: 500;
}

.home-city-tag:focus-visible,
.directions-page a:focus-visible,
.directions-filter button:focus-visible {
    outline: 2px solid #168dc2;
    outline-offset: 3px;
}

/* Флаги остаются декором прежнего размера, но больше не являются отдельными img. */
.home-city-flag {
    display: inline-block;
    width: 18px;
    height: 14px;
    background: url('/img/flags/4x3/ru.svg') center / 100% 100% no-repeat;
    vertical-align: baseline;
}

.home-countries .countries-box_list .home-country-flag {
    width: 52px;
    height: 40px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

.home-popular { margin-top: 12px; }
.home-popular .popular-box__item { overflow: hidden; border-radius: 5px; }
/* Уменьшенные JPEG имеют прежнюю пропорцию 947:520; фиксируем область фото до его загрузки. */
.home-popular .popular-box__item-img { padding-top: 54.91024287%; }
.home-popular .popular-box__item-img img {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    /* В общем CSS у .img-responsive задано height:auto!important; ограничиваем переопределение этими карточками. */
    height: 100% !important;
    object-fit: cover;
}

/* Открытые авторские подписи в подвале главной, без раскрытия через JavaScript. */
.home-photo-footer { padding-bottom: 20px; }
.home-photo-credits { margin-top: 22px; padding-top: 16px; border-top: 1px solid #dbe6ec; font-size: 12px; line-height: 1.5; }
.home-photo-credits h2 { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.home-photo-credits ul { margin: 0; padding: 0; list-style: none; }
.home-photo-credits li { margin: 4px 0; overflow-wrap: anywhere; }
.home-photo-credits p { margin: 8px 0 0; }
.home-photo-credits a { text-decoration: underline; }

/* Ссылка на всю карточку работает и на сенсорном экране, без обязательного hover. */
.home-popular .popular-box__item-link { z-index: 2; }
.home-popular .popular-box__item-link .btn { opacity: 0; }
.home-popular .popular-box__item:hover .popular-box__item-link,
.home-popular .popular-box__item:focus-within .popular-box__item-link { z-index: 5; }
.home-popular .popular-box__item:hover .popular-box__item-link .btn,
.home-popular .popular-box__item-link:focus .btn { opacity: 1; }
.home-countries { margin-top: 28px; }
.home-countries .countries-box_caption { color: #263b49; margin-top: 24px; }
.home-countries .countries-box_list a { color: #18739e; }
.home-countries .countries-box_list a.selected { color: #18739e; background-color: #e1edf3; }
.home-directions-more { margin: 18px 0 0; font-size: 16px; }

.directions-page { padding-top: 22px; padding-bottom: 40px; }
.directions-breadcrumbs { margin-bottom: 22px; color: #6b7c87; font-size: 14px; }
.directions-page h1 {
    margin: 0 0 12px;
    color: #263b49;
    font-size: 30px;
    line-height: 1.25;
    font-weight: 500;
}
.directions-intro { margin: 0 0 22px; color: #536b7a; font-size: 16px; line-height: 1.5; }
.directions-filter { max-width: 700px; margin-bottom: 24px; }
.directions-filter label { display: block; margin-bottom: 8px; color: #263b49; font-size: 15px; font-weight: 500; }
.directions-filter__controls { display: flex; gap: 10px; }
.directions-filter input {
    box-sizing: border-box;
    flex: 1;
    min-width: 0;
    width: 100%;
    height: 55px;
    min-height: 55px;
    padding: 10px 12px;
    border: 1px solid #bed2de;
    border-radius: 5px;
    background: #fff;
    color: #263b49;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
}
.directions-filter input:focus { border-color: #168dc2; outline: 2px solid #c9e5f1; outline-offset: 1px; }
.directions-filter button {
    padding: 8px 12px;
    border: 1px solid #c9dce6;
    border-radius: 5px;
    background: #edf5f9;
    color: #18739e;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
}
#directions-filter-result { margin: 8px 0 0; color: #536b7a; font-size: 14px; line-height: 1.45; }
.directions-country-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 30px; }
.directions-country-nav a {
    padding: 6px 10px;
    border-radius: 5px;
    background: #e8f1f6;
    color: #18739e;
    font-size: 14px;
    line-height: 1.35;
    text-decoration: none;
}
.directions-country-nav a:hover { background: #dcebf3; }
.directions-country { margin-bottom: 32px; scroll-margin-top: 20px; }
.directions-country h2 {
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #dce7ed;
    font-size: 25px;
    line-height: 1.25;
    font-weight: 500;
    color: #263b49;
}
.directions-country h2 a,
.directions-region h3 a { color: #18739e; text-decoration: none; }
.directions-country h2 a:hover,
.directions-region h3 a:hover,
.directions-city-list a:hover { color: #125a7c; text-decoration: underline; }
.directions-region { margin-bottom: 24px; }
.directions-region h3 { margin: 0 0 10px; font-size: 19px; line-height: 1.4; font-weight: 500; color: #263b49; }
.directions-city-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px 24px;
    padding: 0;
    margin: 0;
    list-style: none;
}
.directions-city-list li { min-width: 0; padding: 0; margin: 0; }
.directions-city-list a {
    display: inline-block;
    padding: 5px 0;
    color: #217ba5;
    font-size: 16px;
    line-height: 1.4;
    overflow-wrap: anywhere;
    text-decoration: none;
}

/* Фильтрация доступна только пользователю; исходный HTML содержит весь справочник. */
.directions-page [hidden] { display: none !important; }

@media (max-width: 960px) {
    .home-countries .countries-box_list .home-country-flag { width: 33px; height: 25px; }
    .directions-city-list { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 18px; }
}
@media (max-width: 620px) {
    .home-city-tags { gap: 7px; margin-top: 16px; margin-bottom: 20px; }
    .home-city-tag { min-height: 36px; padding: 7px 10px; font-size: 14px; }
    .directions-page h1 { font-size: 25px; }
    .directions-country h2 { font-size: 23px; }
    .directions-region h3 { font-size: 18px; }
    .directions-city-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; }
    .directions-city-list a { padding: 7px 0; font-size: 15px; }
}
@media (max-width: 380px) {
    .directions-filter__controls { flex-wrap: wrap; }
    .directions-filter__controls input { flex-basis: 100%; }
}
