/*
 * Центральная колонка первого экрана: «Выберите направление», мозаика плиток + «Ещё»
 * и каталог всех услуг в <dialog>. Сетку колонок задаёт /assets/css/index-services-hero.css.
 */

.rbz-sh {
    --rbz-sh-ink: #111a2b;
    --rbz-sh-line: #dfe6ef;
    --rbz-sh-muted: #66758a;
    --rbz-sh-accent: #1759d5;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    color: var(--rbz-sh-ink);
    line-height: 1.3;
}

.rbz-sh *,
.rbz-sh *::before,
.rbz-sh *::after {
    box-sizing: border-box;
}

.rbz-sh__head {
    height: 47px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

/* template_styles.css шаблона задаёт h2 размер и регистр с !important — перебиваем только их. */
.rbz-sh .rbz-sh__title {
    margin: 0;
    padding: 0;
    color: #6f7d91;
    font-family: inherit;
    font-size: 12px !important;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: .02em;
    text-transform: uppercase !important;
}

.rbz-sh__index {
    color: #b3bdca;
    font-size: 12px;
}

/* --- мозаика ------------------------------------------------------------------ */

/*
 * Ряд — 12 колонок, ширину плитки в колонках задаёт --rbz-sh-span (result_modifier.php:
 * свойство WIDTH или авто). Рядов сколько угодно: три заполняют 320 px, как в макете,
 * дальше колонка растёт вниз.
 */
.rbz-sh__mosaic {
    flex: 0 0 auto;
    min-height: 320px;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-rows: minmax(100px, 1fr);
    gap: 8px;
}

.rbz-sh__mosaic > .rbz-sh__card {
    grid-column: span var(--rbz-sh-span, 4);
}

/* --- плитка ------------------------------------------------------------------- */

.rbz-sh__card {
    --rbz-sh-hover: #dfeeff;
    --rbz-sh-hover-fg: #13233b;
    --rbz-sh-hover-muted: rgba(19, 35, 59, .68);
    position: relative;
    min-width: 0;
    display: grid;
    grid-template-columns: 35px minmax(0, 1fr) 24px;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 13px;
    border: 1px solid var(--rbz-sh-line);
    border-radius: 14px;
    background: #f8fafc;
    color: var(--rbz-sh-ink);
    font: inherit;
    text-align: left;
    text-decoration: none;
    overflow: hidden;
    cursor: pointer;
    transition: background-color .2s, border-color .2s, color .2s, transform .2s, box-shadow .2s;
}

.rbz-sh__card:hover,
.rbz-sh__card:focus {
    color: var(--rbz-sh-hover-fg);
    text-decoration: none;
}

.rbz-sh__card:hover {
    border-color: transparent;
    background: var(--rbz-sh-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(24, 44, 75, .1);
}

.rbz-sh__card:focus-visible,
.rbz-sh__extra:focus-visible,
.rbz-sh__dialog-close:focus-visible {
    outline: 3px solid #91b8f4;
    outline-offset: 2px;
}

/* Цвет наведения: по умолчанию чередуется по позиции, свойство STYLE задаёт его явно. */
.rbz-sh__mosaic > .rbz-sh__card:nth-child(6n+1) { --rbz-sh-hover: #117be5; --rbz-sh-hover-fg: #fff; --rbz-sh-hover-muted: rgba(255, 255, 255, .75); }
.rbz-sh__mosaic > .rbz-sh__card:nth-child(6n+2) { --rbz-sh-hover: #1b2029; --rbz-sh-hover-fg: #fff; --rbz-sh-hover-muted: rgba(255, 255, 255, .68); }
.rbz-sh__mosaic > .rbz-sh__card:nth-child(6n+3) { --rbz-sh-hover: #dceaff; }
.rbz-sh__mosaic > .rbz-sh__card:nth-child(6n+4) { --rbz-sh-hover: #ffd4ae; }
.rbz-sh__mosaic > .rbz-sh__card:nth-child(6n+5) { --rbz-sh-hover: #f6dce8; }
.rbz-sh__mosaic > .rbz-sh__card:nth-child(6n+6) { --rbz-sh-hover: #0f396c; --rbz-sh-hover-fg: #fff; --rbz-sh-hover-muted: rgba(255, 255, 255, .7); }

.rbz-sh .rbz-sh__card--light { --rbz-sh-hover: #dceaff; --rbz-sh-hover-fg: #13233b; --rbz-sh-hover-muted: rgba(19, 35, 59, .68); }
.rbz-sh .rbz-sh__card--blue { --rbz-sh-hover: #117be5; --rbz-sh-hover-fg: #fff; --rbz-sh-hover-muted: rgba(255, 255, 255, .75); }
.rbz-sh .rbz-sh__card--orange { --rbz-sh-hover: #ffd4ae; --rbz-sh-hover-fg: #13233b; --rbz-sh-hover-muted: rgba(19, 35, 59, .68); }
.rbz-sh .rbz-sh__card--pink { --rbz-sh-hover: #f6dce8; --rbz-sh-hover-fg: #13233b; --rbz-sh-hover-muted: rgba(19, 35, 59, .68); }
.rbz-sh .rbz-sh__card--dark { --rbz-sh-hover: #0f396c; --rbz-sh-hover-fg: #fff; --rbz-sh-hover-muted: rgba(255, 255, 255, .7); }
.rbz-sh .rbz-sh__card--black { --rbz-sh-hover: #1b2029; --rbz-sh-hover-fg: #fff; --rbz-sh-hover-muted: rgba(255, 255, 255, .68); }

.rbz-sh__icon,
.rbz-sh__extra-icon {
    display: grid;
    place-items: center;
    background: #e8f1ff;
    color: var(--rbz-sh-accent);
}

.rbz-sh__icon {
    width: 35px;
    height: 35px;
    border-radius: 10px;
    font-weight: 800;
    letter-spacing: -.05em;
}

.rbz-sh__card:hover .rbz-sh__icon {
    background: rgba(255, 255, 255, .85);
}

.rbz-sh__icon svg,
.rbz-sh__extra-icon svg {
    display: block;
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 4.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.rbz-sh__copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.rbz-sh__copy strong,
.rbz-sh__copy small {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/*
 * При плотном line-height overflow: hidden у line-clamp срезает надстрочные знаки первой
 * строки (кратка «Й» в Safari) — запас сверху внутри блока, компенсированный отступом.
 */
.rbz-sh__copy strong {
    margin-top: -.15em;
    padding-top: .15em;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.15;
}

.rbz-sh__copy small {
    color: var(--rbz-sh-muted);
    font-size: 11px;
    line-height: 1.25;
}

.rbz-sh__card:hover .rbz-sh__copy small {
    color: var(--rbz-sh-hover-muted);
}

.rbz-sh__arrow {
    display: grid;
    place-items: center;
    color: #8b98aa;
}

.rbz-sh__card:hover .rbz-sh__arrow {
    color: inherit;
}

/* Размер плитки — по фактической ширине, на мобильной не действует. */
@media (min-width: 761px) {
    /* От 8 колонок — крупная, как первая плитка макета. */
    .rbz-sh__card--wide {
        grid-template-columns: 42px minmax(0, 1fr) 28px;
        padding: 17px;
    }

    .rbz-sh__card--wide .rbz-sh__icon {
        width: 42px;
        height: 42px;
    }

    .rbz-sh__card--wide .rbz-sh__copy strong {
        font-size: 20px;
    }

    .rbz-sh__card--wide .rbz-sh__copy small {
        font-size: 12px;
    }

    /*
     * До 5 колонок: иконка и стрелка сверху, текст на всю ширину.
     * Реальные названия услуг длиннее, чем в макете, и в один ряд с иконкой не читаются.
     */
    .rbz-sh__card--narrow {
        grid-template-columns: minmax(0, 1fr) 16px;
        grid-template-rows: 28px minmax(0, 1fr);
        align-items: start;
        gap: 6px;
        padding: 10px;
    }

    .rbz-sh__card--narrow .rbz-sh__icon {
        grid-column: 1;
        grid-row: 1;
        width: 28px;
        height: 28px;
        border-radius: 8px;
    }

    .rbz-sh__card--narrow .rbz-sh__icon svg {
        width: 18px;
        height: 18px;
    }

    .rbz-sh__card--narrow .rbz-sh__arrow {
        grid-column: 2;
        grid-row: 1;
        align-self: center;
    }

    .rbz-sh__card--narrow .rbz-sh__copy {
        grid-column: 1 / -1;
        grid-row: 2;
        gap: 2px;
    }

    .rbz-sh__card--narrow .rbz-sh__copy strong {
        font-size: 12px;
    }

    .rbz-sh__card--narrow .rbz-sh__copy small {
        -webkit-line-clamp: 1;
    }
}

.rbz-sh__copy strong {
    overflow-wrap: anywhere;
}

/* Плитка «Ещё». */
.rbz-sh__more,
.rbz-sh__more:hover {
    border-color: #1b2029;
    background: #1b2029;
    color: #fff;
    box-shadow: none;
}

.rbz-sh__more .rbz-sh__icon,
.rbz-sh__more:hover .rbz-sh__icon {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.rbz-sh__more .rbz-sh__copy small,
.rbz-sh__more:hover .rbz-sh__copy small {
    color: rgba(255, 255, 255, .7);
}

.rbz-sh__more-count {
    position: absolute;
    top: 9px;
    right: 10px;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
}

/* --- каталог -------------------------------------------------------------------- */

.rbz-sh__dialog {
    width: min(720px, calc(100vw - 30px));
    max-width: none;
    max-height: calc(100vh - 30px);
    margin: auto;
    padding: 0;
    border: 1px solid var(--rbz-sh-line);
    border-radius: 18px;
    background: #fff;
    color: var(--rbz-sh-ink);
    box-shadow: 0 24px 70px rgba(20, 37, 64, .25);
    overflow: auto;
    overscroll-behavior: contain;
}

.rbz-sh__dialog::backdrop {
    background: rgba(12, 19, 31, .45);
}

/* Немодальный режим (панель администратора): окно поверх страницы без top layer. */
.rbz-sh__dialog[open]:not(:modal) {
    position: fixed;
    z-index: 1000;
    inset: 15px;
}

.rbz-sh__dialog-inner {
    padding: 0 18px 18px;
}

.rbz-sh__dialog-head {
    position: sticky;
    z-index: 3;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 -18px 14px;
    padding: 18px 18px 12px;
    border-bottom: 1px solid #e8edf4;
    background: #fff;
}

.rbz-sh .rbz-sh__dialog-title {
    margin: 0;
    padding: 0;
    color: inherit;
    font-family: inherit;
    font-size: 18px !important;
    font-weight: 800;
    line-height: 1.2;
    text-transform: none !important;
}

.rbz-sh__dialog-close {
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--rbz-sh-ink);
    font: inherit;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.rbz-sh__dialog-close:hover {
    background: #edf3fb;
}

.rbz-sh__group + .rbz-sh__group {
    margin-top: 16px;
}

.rbz-sh .rbz-sh__group-title {
    margin: 0 0 8px;
    padding: 0;
    color: #66758a;
    font-family: inherit;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.rbz-sh__extras {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.rbz-sh__extra {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--rbz-sh-line);
    border-radius: 11px;
    background: #f8fafc;
    color: var(--rbz-sh-ink);
    text-decoration: none;
}

.rbz-sh__extra:hover,
.rbz-sh__extra:focus {
    border-color: #9fc6ff;
    background: #edf5ff;
    color: var(--rbz-sh-ink);
    text-decoration: none;
}

.rbz-sh__extra-icon {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 9px;
}

.rbz-sh__extra-icon:empty {
    display: none;
}

.rbz-sh__extra-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.rbz-sh__extra-copy b {
    font-size: 13px;
    line-height: 1.25;
}

.rbz-sh__extra-copy small {
    color: var(--rbz-sh-muted);
    font-size: 11px;
    line-height: 1.3;
}

/* --- мобильная ------------------------------------------------------------------ */

@media (max-width: 760px) {
    .rbz-sh__head {
        height: 40px;
    }

    .rbz-sh__mosaic {
        flex: none;
        min-height: 0;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: minmax(90px, auto);
        gap: 8px;
    }

    .rbz-sh__mosaic > .rbz-sh__card {
        grid-column: auto;
        grid-template-columns: 32px minmax(0, 1fr) 18px;
        gap: 8px;
        min-height: 90px;
        padding: 10px;
    }

    /* Порядок плиток не меняется: во всю ширину — широкие и узкие без пары (result_modifier.php). */
    .rbz-sh__mosaic > .rbz-sh__card--mfull {
        grid-column: 1 / -1;
    }

    .rbz-sh__mosaic .rbz-sh__icon {
        width: 32px;
        height: 32px;
        border-radius: 9px;
    }

    .rbz-sh__mosaic .rbz-sh__copy strong {
        font-size: 14px;
    }

    .rbz-sh__mosaic .rbz-sh__copy small {
        font-size: 11px;
    }

    .rbz-sh__arrow {
        font-size: 17px;
    }

    /* Каталог — нижний лист. */
    .rbz-sh__dialog,
    .rbz-sh__dialog[open]:not(:modal) {
        inset: auto 0 0;
        width: 100vw;
        height: min(82dvh, 720px);
        max-height: 82dvh;
        margin: auto 0 0;
        border: 0;
        border-radius: 24px 24px 0 0;
        background: linear-gradient(160deg, #202734 0%, #171c25 100%);
        color: #fff;
        box-shadow: 0 -18px 50px rgba(7, 15, 28, .3);
    }

    .rbz-sh__dialog-inner {
        padding: 0 14px 22px;
    }

    .rbz-sh__dialog-head {
        margin: 0 -14px 8px;
        padding: 19px 18px 15px;
        border-color: rgba(255, 255, 255, .1);
        background: #1c222d;
        color: #fff;
    }

    .rbz-sh__dialog-head::before {
        content: "";
        position: absolute;
        top: 7px;
        left: 50%;
        width: 30px;
        height: 3px;
        border-radius: 999px;
        background: #91a0b5;
        transform: translateX(-50%);
    }

    .rbz-sh__dialog-close {
        flex-basis: 32px;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: #f1f5fb;
        color: #5b6678;
        font-size: 22px;
    }

    .rbz-sh__dialog-close:hover {
        background: #fff;
    }

    .rbz-sh__group + .rbz-sh__group {
        margin-top: 18px;
    }

    .rbz-sh .rbz-sh__group-title {
        margin-bottom: 10px;
        color: #91b8ff;
    }

    .rbz-sh__extras {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px 8px;
    }

    .rbz-sh__extra,
    .rbz-sh__extra:hover,
    .rbz-sh__extra:focus {
        min-height: 104px;
        flex-direction: column;
        justify-content: flex-start;
        gap: 6px;
        padding: 11px 5px;
        border: 0;
        border-radius: 16px;
        background: #0d131c;
        color: #fff;
        text-align: center;
    }

    .rbz-sh__extra:hover {
        background: #111925;
    }

    .rbz-sh__extra-icon,
    .rbz-sh__extra-icon:empty {
        display: grid;
        flex: 0 0 48px;
        width: 48px;
        height: 48px;
        border-radius: 14px;
        background: linear-gradient(145deg, #177ee5, #72c8ff);
        color: #fff;
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 7px 16px rgba(19, 118, 215, .18);
    }

    .rbz-sh__extra-icon svg {
        width: 28px;
        height: 28px;
    }

    .rbz-sh__extra-copy {
        align-items: center;
    }

    .rbz-sh__extra-copy b {
        display: -webkit-box;
        overflow: hidden;
        color: #f7f9fc;
        font-size: 12px;
        line-height: 1.2;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
    }

    .rbz-sh__extra-copy small {
        display: none;
    }
}

@media (max-width: 360px) {
    .rbz-sh__mosaic {
        grid-auto-rows: minmax(94px, auto);
        gap: 7px;
    }

    .rbz-sh__mosaic > .rbz-sh__card {
        grid-template-columns: minmax(0, 1fr) 15px;
        grid-template-rows: 28px minmax(0, 1fr);
        align-items: start;
        gap: 5px 6px;
        min-height: 94px;
        padding: 9px;
    }

    .rbz-sh__mosaic > .rbz-sh__card .rbz-sh__icon {
        grid-column: 1;
        grid-row: 1;
        width: 28px;
        height: 28px;
    }

    .rbz-sh__mosaic > .rbz-sh__card .rbz-sh__copy {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .rbz-sh__mosaic > .rbz-sh__card .rbz-sh__arrow {
        grid-column: 2;
        grid-row: 1;
        align-self: center;
    }

    .rbz-sh__mosaic > .rbz-sh__card--mfull {
        grid-template-columns: 28px minmax(0, 1fr) 15px;
        grid-template-rows: auto;
        align-items: center;
    }

    .rbz-sh__mosaic > .rbz-sh__card--mfull .rbz-sh__copy {
        grid-column: 2;
        grid-row: 1;
    }

    .rbz-sh__mosaic > .rbz-sh__card--mfull .rbz-sh__arrow {
        grid-column: 3;
        grid-row: 1;
    }

    .rbz-sh__mosaic .rbz-sh__icon svg {
        width: 18px;
        height: 18px;
    }

    .rbz-sh__mosaic .rbz-sh__copy strong {
        font-size: 13px;
    }

    .rbz-sh__more-count {
        top: 7px;
        right: 8px;
    }

    .rbz-sh__extras {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
