/**
 * Abakan Online — compact / vertical organization card context.
 *
 * Scope is strictly .ao-home-organizations.
 * The shared .ao-company-card HTML is not changed.
 */

/* ---------- module grid ---------- */

.ao-home-organizations {
    --ao-home-card-text: #10182b;
    --ao-home-card-muted: #6b768c;
    --ao-home-card-border: #e3e9f1;
    --ao-home-card-green: #0a9a6a;
    width: 100%;
}

.ao-home-organizations,
.ao-home-organizations *,
.ao-home-organizations *::before,
.ao-home-organizations *::after {
    box-sizing: border-box;
}

.ao-home-organizations__grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

.ao-home-organizations__item {
    min-width: 0;
}

/* ---------- same shared card, compact presentation ---------- */

.ao-home-organizations .ao-company-card,
.ao-home-organizations .ao-company-card.ao-company-card--no-aside {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--ao-home-card-border);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 7px 22px rgba(31, 48, 86, .055);
    transform: none;
    transition:
        border-color .18s ease,
        box-shadow .18s ease,
        transform .18s ease;
}

.ao-home-organizations .ao-company-card:hover {
    border-color: #d4deeb;
    box-shadow: 0 11px 28px rgba(31, 48, 86, .09);
    transform: translateY(-2px);
}

/* ---------- image on top ---------- */

.ao-home-organizations .ao-company-card__media {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
    min-height: 0;
    margin: 0;
    overflow: hidden;
    border-radius: 0;
    background: #edf2f7;
}

.ao-home-organizations .ao-company-card__image-link {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 0;
    background: #edf2f7;
}

body.site .ao-home-organizations .ao-company-card__image {
    display: block;
    width: 100%;
    height: 100% !important;
    min-height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 0;
    transform: none;
}

/* ---------- favorite: same state logic, compact position ---------- */

.ao-home-organizations .ao-company-card__favorite {
    position: absolute;
    z-index: 5;
    top: 10px;
    right: 10px;
    left: auto;
    display: grid;
    width: 30px;
    height: 30px;
    padding: 0;
    place-items: center;
    border: 0 !important;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none !important;
    color: #fff !important;
    text-shadow: 0 1px 5px rgba(15, 23, 42, .62);
}

.ao-home-organizations .ao-company-card__favorite svg {
    display: block;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ao-home-organizations .ao-company-card__favorite.is-active,
.ao-home-organizations .ao-company-card__favorite[aria-pressed="true"] {
    color: #ef4444 !important;
    text-shadow: 0 1px 4px rgba(15, 23, 42, .34);
}

.ao-home-organizations .ao-company-card__favorite.is-active svg,
.ao-home-organizations .ao-company-card__favorite[aria-pressed="true"] svg {
    fill: currentColor;
    stroke: currentColor;
}

/* ---------- information below image ---------- */

.ao-home-organizations .ao-company-card__main {
    display: flex;
    min-width: 0;
    flex-direction: column;
    padding: 12px 13px 14px;
}

/*
 * display:contents lets the existing shared heading children participate in
 * the compact vertical order without changing company-card.php markup.
 */
.ao-home-organizations .ao-company-card__heading {
    display: contents;
}

.ao-home-organizations .ao-company-card__title {
    order: 1;
    display: -webkit-box;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: var(--ao-home-card-text);
    font-size: 15.5px;
    font-weight: 650;
    line-height: 1.18;
    letter-spacing: -.015em;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.ao-home-organizations .ao-company-card__title > a,
.ao-home-organizations .ao-company-card__stretched-link {
    color: var(--ao-home-card-text) !important;
    text-decoration: none !important;
}

.ao-home-organizations .ao-company-card__category {
    order: 2;
    display: flex;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 4px;
    margin: 5px 0 0;
    overflow: hidden;
    color: var(--ao-home-card-muted);
    font-size: 11.5px;
    font-weight: 400;
    line-height: 1.25;
    white-space: nowrap;
}

.ao-home-organizations .ao-company-card__category a {
    overflow: hidden;
    color: var(--ao-home-card-muted) !important;
    text-decoration: none !important;
    text-overflow: ellipsis;
}

.ao-home-organizations .ao-company-card__rating {
    order: 3;
    display: inline-flex;
    width: max-content;
    max-width: 100%;
    align-items: center;
    gap: 3px;
    margin: 7px 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #667085 !important;
    font-size: 11.5px;
    font-weight: 400 !important;
    line-height: 1.2;
    text-decoration: none !important;
    white-space: nowrap;
}

.ao-home-organizations .ao-company-card__rating-star {
    color: #f59e0b !important;
    font-size: 12px;
    line-height: 1;
}

.ao-home-organizations .ao-company-card__rating-value {
    color: #344054 !important;
    font-weight: 400 !important;
}

.ao-home-organizations .ao-company-card__rating-separator,
.ao-home-organizations .ao-company-card__rating-count {
    color: #7a8795 !important;
    font-weight: 400 !important;
}

.ao-home-organizations .ao-company-card__open-state {
    order: 4;
    min-height: 15px;
    margin: 7px 0 0;
    color: #667085;
    font-size: 11.5px;
    font-weight: 400;
    line-height: 1.25;
}

.ao-home-organizations .ao-company-card__open-state.is-open {
    color: var(--ao-home-card-green);
}

/* Admin edit control remains in the shared markup but is not part of the card UX. */
.ao-home-organizations .ao-company-card__edit {
    order: 99;
}

/* ---------- compact defaults: hidden, but data/markup is retained ---------- */

.ao-home-organizations:not(.ao-home-organizations--show-address) .ao-company-card__address,
.ao-home-organizations:not(.ao-home-organizations--show-tags) .ao-company-card__tags,
.ao-home-organizations .ao-company-card__distance {
    display: none !important;
}

/*
 * Aside contains badges + phone + route.
 * By default it is hidden, but it can be enabled later through the module CSS
 * class without changing company-card.php.
 */
.ao-home-organizations .ao-company-card__aside {
    display: none !important;
}

.ao-home-organizations.ao-home-organizations--show-address .ao-company-card__address {
    order: 5;
    display: flex !important;
    margin: 7px 0 0;
    color: var(--ao-home-card-muted);
    font-size: 11.5px;
    line-height: 1.3;
}

.ao-home-organizations.ao-home-organizations--show-tags .ao-company-card__tags {
    order: 6;
    display: flex !important;
    margin-top: 8px;
}

.ao-home-organizations.ao-home-organizations--show-badges .ao-company-card__aside,
.ao-home-organizations.ao-home-organizations--show-actions .ao-company-card__aside {
    display: flex !important;
    min-height: 0;
    flex-direction: column;
    gap: 8px;
    padding: 0 13px 14px;
    border: 0;
}

.ao-home-organizations:not(.ao-home-organizations--show-badges) .ao-company-card__badges {
    display: none !important;
}

.ao-home-organizations:not(.ao-home-organizations--show-actions) .ao-company-card__contact {
    display: none !important;
}

/* ---------- tablet ---------- */

@media (max-width: 1199.98px) and (min-width: 992px) {
    .ao-home-organizations__grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 14px;
    }
}

@media (max-width: 991.98px) and (min-width: 768px) {
    .ao-home-organizations__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 14px;
    }
}

/* ---------- mobile: horizontal compact cards, image still on top ---------- */

@media (max-width: 767.98px) {
    .ao-home-organizations {
        width: auto;
        margin-inline: -14px;
    }

    .ao-home-organizations__grid {
        display: flex;
        width: 100%;
        max-width: 100%;
        gap: 9px;
        padding: 2px 14px 10px;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        scroll-padding-inline: 14px;
        touch-action: pan-x;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .ao-home-organizations__grid::-webkit-scrollbar {
        display: none;
    }

    .ao-home-organizations__item {
        flex: 0 0 156px;
        width: 156px;
        scroll-snap-align: start;
    }

    .ao-home-organizations__item,
    .ao-home-organizations .ao-company-card,
    .ao-home-organizations .ao-company-card__image-link,
    .ao-home-organizations .ao-company-card__image {
        touch-action: pan-x;
    }

    .ao-home-organizations .ao-company-card__image {
        -webkit-user-drag: none;
        user-select: none;
    }

    .ao-home-organizations .ao-company-card,
    .ao-home-organizations .ao-company-card.ao-company-card--no-aside {
        min-height: 0;
        border-radius: 15px;
        box-shadow: 0 5px 16px rgba(31, 48, 86, .05);
    }

    .ao-home-organizations .ao-company-card:hover {
        transform: none;
    }

    .ao-home-organizations .ao-company-card__image-link {
        aspect-ratio: 4 / 3;
    }

    .ao-home-organizations .ao-company-card__main {
        padding: 9px 10px 11px;
    }

    .ao-home-organizations .ao-company-card__title {
        font-size: 12.5px;
        line-height: 1.16;
    }

    .ao-home-organizations .ao-company-card__category {
        margin-top: 4px;
        font-size: 9.75px;
    }

    .ao-home-organizations .ao-company-card__rating {
        margin-top: 5px;
        font-size: 10px;
    }

    .ao-home-organizations .ao-company-card__rating-star {
        font-size: 10.5px;
    }

    .ao-home-organizations .ao-company-card__open-state {
        min-height: 13px;
        margin-top: 5px;
        font-size: 10px;
    }

    .ao-home-organizations .ao-company-card__favorite {
        top: 7px;
        right: 7px;
        width: 27px;
        height: 27px;
    }

    .ao-home-organizations .ao-company-card__favorite svg {
        width: 18px;
        height: 18px;
    }

    .ao-home-organizations.ao-home-organizations--show-address .ao-company-card__address {
        margin-top: 5px;
        font-size: 9.75px;
    }

    .ao-home-organizations.ao-home-organizations--show-badges .ao-company-card__aside,
    .ao-home-organizations.ao-home-organizations--show-actions .ao-company-card__aside {
        padding: 0 10px 11px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ao-home-organizations .ao-company-card,
    .ao-home-organizations .ao-company-card * {
        transition: none !important;
    }
}

/* ==========================================================
   POPULAR / NEW SHELL
   ========================================================== */

.ao-home-tabs {
    width: 100%;
    margin: 34px 0 48px;
    padding: 24px;
    border: 1px solid #e3e9f1;
    border-radius: 24px;
    background: #f8faff;
}

.ao-home-tabs,
.ao-home-tabs *,
.ao-home-tabs *::before,
.ao-home-tabs *::after {
    box-sizing: border-box;
}

.ao-home-tabs__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: 0 0 18px;
}

.ao-home-tabs__nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ao-home-tabs__tab {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    color: #687086;
    font: inherit;
    font-size: 17px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition:
        background-color .18s ease,
        color .18s ease;
}

.ao-home-tabs__tab:hover,
.ao-home-tabs__tab:focus-visible {
    color: #182033;
}

.ao-home-tabs__tab:focus-visible {
    outline: 3px solid rgba(39, 87, 215, .16);
    outline-offset: 2px;
}

.ao-home-tabs__tab.active {
    background: #edf2ff;
    color: #182033;
    font-weight: 600;
}

.ao-home-tabs__all {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 4px;
    color: #2757d7 !important;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none !important;
}

.ao-home-tabs__all svg {
    display: block;
    width: 16px;
    height: 16px;
    transition: transform .18s ease;
}

.ao-home-tabs__all:hover svg,
.ao-home-tabs__all:focus-visible svg {
    transform: translateX(2px);
}

.ao-home-tabs__panel {
    min-width: 0;
}

.ao-home-tabs__content {
    min-width: 0;
}


/* Mobile prototype: no outer card, compact tab row, horizontal cards below */
@media (max-width: 767.98px) {
    .ao-home-tabs {
        margin: 22px 0 28px;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    .ao-home-tabs__head {
        margin-bottom: 10px;
    }

    .ao-home-tabs__nav {
        gap: 6px;
    }

    .ao-home-tabs__tab {
        min-height: 38px;
        padding: 0 12px;
        border-radius: 12px;
        font-size: 14px;
    }

    .ao-home-tabs__all {
        gap: 2px;
        font-size: 11.5px;
    }

    .ao-home-tabs__all svg {
        width: 14px;
        height: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ao-home-tabs__tab,
    .ao-home-tabs__all svg {
        transition: none;
    }
}

