/* ==========================================================================
   Tengri — Business Directory
   Page = page header + filter pills + (mobile toggle) + 2-col split (list + map)
   ========================================================================== */

.biz-page {
    color: var(--tengri-ink);
    display: flex;
    flex-direction: column;
    /* Use the dynamic header height plus a small allowance for the nav bar.
       Falls back to 210px on the rare load before sticky-offsets.js runs. */
    height: calc(100dvh - var(--header-offset, 210px));
    overflow: hidden;
}

/* The shared .page-header, kept to its own height inside the full-height layout */
.biz-page .page-header { flex-shrink: 0; margin-bottom: 0; }

/* ----- Filter pills ----- */
.biz-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--tengri-line);
    align-items: center;
    flex-shrink: 0;
}

.biz-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.8rem;
    min-height: 32px;
    background: transparent;
    color: var(--tengri-ink);
    border: 1px solid var(--tengri-line);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    font-family: var(--font-body);
    white-space: nowrap;
}

.biz-pill__count {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    opacity: 0.7;
}

.biz-pill:hover {
    border-color: var(--tengri-sky);
    color: var(--tengri-sky);
}

.biz-pill.is-active {
    background: var(--tengri-sky);
    color: var(--tengri-sun-soft);
    border-color: var(--tengri-sky);
}

.biz-pill.is-active .biz-pill__count { opacity: 0.9; }

/* ----- Mobile list/map toggle (hidden ≥ 900px) ----- */
.biz-toggle {
    display: none;
    gap: 0.4rem;
    padding: 0.6rem 0;
    background: var(--tengri-cream);
    border-bottom: 1px solid var(--tengri-line);
    flex-shrink: 0;
}

.biz-toggle__btn {
    flex: 1;
    padding: 0.6rem 0.75rem;
    min-height: var(--tap-target);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: transparent;
    color: var(--tengri-ink);
    border: 1px solid var(--tengri-line);
    border-radius: 999px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.biz-toggle__btn.is-active {
    background: var(--tengri-sky);
    color: var(--tengri-sun-soft);
    border-color: var(--tengri-sky);
}

.biz-toggle__icon { margin-right: 0.3rem; }

/* ----- Split (list + map) ----- */
.biz-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
}

.biz-list {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    border-right: 1px solid var(--tengri-line);
    background: var(--tengri-paper);
}

.biz-list__scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.biz-list .pagination {
    flex-shrink: 0;
    padding: 1rem;
    border-top: 1px solid var(--tengri-line);
    background: var(--tengri-paper);
}

/* ----- Card ----- */
.biz-card {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--tengri-line);
    background: var(--tengri-paper);
    align-items: flex-start;
    transition: background 0.18s ease;
}

.biz-card:hover { background: var(--tengri-cream); }
.biz-card.is-highlighted {
    background: #fff8ec;
    border-left: 4px solid #e67e22;
    padding-left: calc(1rem - 4px);
}
.biz-card.is-highlighted .biz-card__name {
    color: #e67e22;
}

.biz-card__name {
    cursor: pointer;
    transition: color 0.2s ease;
}
.biz-card__name:hover {
    color: var(--tengri-ember);
}

.biz-card__tile {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: var(--tengri-sky);
    color: var(--tengri-sun-soft);
    border: 1px solid var(--tengri-sun);
    border-radius: 4px;
    box-shadow: 2px 2px 0 var(--tengri-sun);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    line-height: 1;
}

.biz-card__body { flex: 1; min-width: 0; }

.biz-card__meta {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    margin-bottom: 0.15rem;
    flex-wrap: wrap;
}

.biz-card__cat {
    background: var(--tengri-sky);
    color: var(--tengri-sun-soft);
    font-family: var(--font-mono);
    font-size: 0.5625rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 0.15rem 0.55rem;
    text-transform: uppercase;
}

.biz-card__name {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--tengri-sky);
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0.1rem 0;
}

.biz-card__lines {
    margin: 0.2rem 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--tengri-ink);
}

.biz-card__addr { display: flex; gap: 0.4rem; align-items: baseline; opacity: 0.85; min-width: 0; }
.biz-card__addr > :last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.biz-card__pin  { flex-shrink: 0; }

.biz-card__contact {
    display: inline-flex;
    gap: 0.85rem;
    flex-wrap: wrap;
    margin: 0.3rem 0.75rem 0 0;
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

.biz-card__contact-link {
    color: var(--tengri-sky);
    text-decoration: none;
    border-bottom: 1px dotted var(--tengri-sky);
}

.biz-card__contact-link:hover { color: var(--tengri-ember); border-color: var(--tengri-ember); }

.biz-card__actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.3rem;
    flex-wrap: wrap;
    align-items: center;
}

.biz-favorite-form {
    display: inline-flex;
}

/* Rarely used, so kept quiet and away from the main buttons */
.biz-card__report { margin-left: auto; opacity: 0.55; }
.biz-card__report:hover, .biz-card__report:focus-visible { opacity: 1; }

.biz-card__report,
.biz-favorite-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
    padding: 0.2rem;
    color: var(--tengri-ink-soft);
    transition: color 0.15s ease, transform 0.1s ease;
}

.biz-favorite-btn:hover {
    color: var(--tengri-ember);
    transform: scale(1.15);
}

.biz-favorite-btn.is-favorited {
    color: var(--tengri-ember);
}

.button--facebook { background: #1877F2; color: #fff; }
.button--facebook:hover { background: #145DBF; }

/* ----- Map ----- */
.biz-map {
    position: relative;
    background: linear-gradient(135deg, var(--tengri-cream) 0%, var(--tengri-cream-dark) 100%);
    min-height: 0;
    overflow: hidden;
}

.biz-map__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.biz-map__legend {
    position: absolute;
    bottom: 1.25rem;
    left: 1.25rem;
    background: var(--tengri-sky);
    color: var(--tengri-sun-soft);
    padding: 0.65rem 0.9rem;
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: 0.1em;
    z-index: 5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.biz-map__legend-title { font-weight: 700; }
.biz-map__legend-sub { opacity: 0.75; margin-top: 0.15rem; }

/* ----- Empty ----- */
.biz-empty {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--tengri-ink-soft);
    font-style: italic;
}

/* ----- Google Maps info window ----- */
.info-window__title { margin: 0; font-family: var(--font-heading); font-size: 0.95rem; font-weight: 700; color: var(--tengri-sky); }
.info-window { min-width: 200px; font-family: var(--font-body); font-size: 0.8125rem; color: var(--tengri-ink-soft); line-height: 1.4; }
.info-window p { margin: 0 0 0.3rem; }
.info-window__links { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; margin-top: 0.4rem; }
.info-window a { color: var(--tengri-sky); text-decoration: none; border-bottom: 1px dotted var(--tengri-sky); font-weight: 600; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
    /* Mobile shows one panel at a time, but we still want the clamped-height
       pattern so the visible panel fills the remaining viewport cleanly. */
    .biz-toggle { display: flex; }
    .biz-split {
        grid-template-columns: 1fr;
    }
    .biz-list { border-right: none; }

    /* mobile view switch */
    .biz-page[data-mobile-view="list"] .biz-map { display: none; }
    .biz-page[data-mobile-view="map"] .biz-list { display: none; }
}

@media (max-width: 900px) {
    /* List view scrolls with the page (one scroll, not a box inside the page);
       only the map view keeps the full-height clamp. The list/map switch stays
       pinned under the header. */
    .biz-page[data-mobile-view="list"] { height: auto; overflow: visible; }
    .biz-page[data-mobile-view="list"] .biz-split,
    .biz-page[data-mobile-view="list"] .biz-list,
    .biz-page[data-mobile-view="list"] .biz-list__scroll { overflow: visible; }
    .biz-toggle {
        position: sticky;
        top: var(--header-offset);
        z-index: 5;
    }
}

@media (max-width: 768px) {
    /* Pills: one swipeable row (see base.css), still thumb-sized */
    .biz-pill { min-height: var(--tap-target-sm); padding: 0.3rem 0.85rem; }
    /* Addresses wrap to two lines instead of being cut off */
    .biz-card__addr > :last-child {
        white-space: normal;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }
    .biz-card__report { width: var(--tap-target); height: var(--tap-target); }
}

@media (max-width: 540px) {
    .biz-card { padding: 0.7rem 0.9rem; gap: 0.65rem; }
    .biz-card.is-highlighted { padding-left: calc(0.9rem - 4px); }
    .biz-card__tile { width: 36px; height: 36px; font-size: 1.1rem; }
    .biz-card__name { font-size: 1rem; }
}

/* ----- Places vs. services (no fixed location) ----- */
.biz-tabs { display: flex; gap: 0.25rem; padding-top: 0.5rem; border-bottom: 1px solid var(--tengri-line); flex-shrink: 0; }
.biz-tab { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.9rem; margin-bottom: -1px; border: 1px solid transparent; border-radius: 8px 8px 0 0; color: var(--tengri-ink-soft); font-weight: 600; font-size: 0.92rem; text-decoration: none; }
.biz-tab:hover { color: var(--tengri-sky); }
.biz-tab.is-active { background: var(--tengri-paper); border-color: var(--tengri-line); border-bottom-color: var(--tengri-paper); color: var(--tengri-sky); }

.biz-page--services { height: auto; overflow: visible; }
.biz-services { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 0.75rem; padding: 1rem 0 2rem; }
.biz-service { display: flex; gap: 0.75rem; padding: 0.9rem 1rem; border: 1px solid var(--tengri-line); border-radius: 8px; background: var(--tengri-paper); }
.biz-service__area { margin: 0.2rem 0 0; font-size: 0.88rem; color: var(--tengri-ink-soft); }

/* Up to 5 photos under a business; each opens full size */
.biz-photos { display: flex; gap: 0.35rem; margin: 0.45rem 0 0.2rem; overflow-x: auto; }
.biz-photos img { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; border: 1px solid var(--tengri-line); display: block; }

/* Phones: the map view fills the screen between the top and the tab bar */
@media (max-width: 768px) {
    .biz-page[data-mobile-view="map"] {
        height: calc(100dvh - var(--header-offset) - var(--tabbar-h, 0px));
    }
}

/* Phones: both switches (places/services, list/map) become segmented controls:
   a muted track with the chosen side raised. */
@media (max-width: 768px) {
    .biz-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
        margin-top: 0.75rem;
        padding: 4px;
        border: none;
        border-radius: var(--radius);
        background: var(--tengri-cream-dark);
    }
    .biz-tab {
        justify-content: center;
        min-height: var(--tap-target-sm);
        margin: 0;
        padding: 0.35rem 0.5rem;
        border: none;
        border-radius: var(--radius-sm);
        font-size: 0.82rem;
        line-height: 1.2;
        text-align: center;
    }
    .biz-tab.is-active {
        background: var(--color-surface);
        box-shadow: 0 1px 2px rgba(27, 42, 87, 0.12);
    }

    .biz-toggle { padding: 0.5rem 0; background: var(--tengri-paper); }
    .biz-toggle.container { width: 100%; padding-inline: var(--gutter); }
    .biz-toggle__btn {
        min-height: var(--tap-target-sm);
        padding: 0.35rem 0.5rem;
        border-radius: var(--radius-sm);
        letter-spacing: 0;
    }
    .biz-filters { border-bottom: none; }
}

/* Filtering hides cards with [hidden]; a card's own display must not win */
.biz-page [hidden] { display: none !important; }

/* ☆ save (this browser only) */
.biz-save {
    min-width: var(--tap-target-sm);
    min-height: var(--tap-target-sm);
    padding: 0;
    border: none;
    background: none;
    color: var(--tengri-ink-soft);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}
.biz-save.is-on { color: var(--tengri-sun); }

/* «✓ Эзэн нь хөтөлдөг»: staff checked the business keeps its own page up */
/* Confirmed closed: kept for a month, greyed and listed last, then removed (ClosedBusinessCleanupTask) */
.biz-closed { display: inline-block; margin-left: 0.35rem; font-size: 0.7rem; font-weight: 700; color: var(--color-danger, #b91c1c); white-space: nowrap; }
.biz-card.is-closed, .biz-service.is-closed { opacity: 0.6; }
.biz-card.is-closed .biz-card__tile, .biz-service.is-closed .biz-card__tile { filter: grayscale(1); }
.biz-card.is-closed .biz-card__name, .biz-service.is-closed .biz-card__name { text-decoration: line-through; text-decoration-thickness: 1px; }
.biz-owner { display: inline-block; margin-left: 0.35rem; font-size: 0.7rem; font-weight: 600; color: var(--color-success, #2e7d32); white-space: nowrap; }
