/*
 * MGN Property shortcodes. Colours, sizes and spacing follow the portal
 * (mgnproperty.my). Everything is scoped under .mgn so the theme's styles
 * don't leak in and ours don't leak out. Override the variables below in
 * your theme to restyle.
 */

.mgn {
    --mgn-font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --mgn-fg: #0a0a0a;
    --mgn-bg: #fff;
    --mgn-primary: #171717;
    --mgn-primary-fg: #fafafa;
    --mgn-muted: #f5f5f5;
    --mgn-muted-fg: #737373;
    --mgn-border: #ededed;
    --mgn-input: #e5e5e5;
    --mgn-radius: 8px;
    --mgn-amber: #fbbf24;
    --mgn-red: #f87171;
    --mgn-grey: #e5e7eb;
    --mgn-blue: #3b82f6;

    font-family: var(--mgn-font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--mgn-fg);
    margin-bottom: 32px;
}

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

.mgn .mgn-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.mgn .mgn-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mgn .mgn-section-title {
    font-family: var(--mgn-font);
    font-size: 24px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: normal;
    text-transform: none;
    color: var(--mgn-fg);
    margin: 0 0 16px;
}


/* Buttons */

.mgn .mgn-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    margin: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    font-family: var(--mgn-font);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}

.mgn .mgn-btn-primary {
    background: var(--mgn-primary);
    color: var(--mgn-primary-fg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

.mgn .mgn-btn-primary:hover,
.mgn .mgn-btn-primary:focus-visible {
    background: rgba(23, 23, 23, .9);
    color: var(--mgn-primary-fg);
}

.mgn .mgn-btn-outline {
    background: var(--mgn-bg);
    border-color: var(--mgn-input);
    color: var(--mgn-fg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

.mgn .mgn-btn-outline:hover,
.mgn .mgn-btn-outline:focus-visible {
    background: var(--mgn-muted);
    color: var(--mgn-fg);
}

.mgn .mgn-btn.is-disabled {
    opacity: .5;
    pointer-events: none;
}

.mgn .mgn-btn:focus-visible,
.mgn .mgn-category:focus-visible,
.mgn .mgn-carousel-nav:focus-visible,
.mgn .mgn-carousel-slide:focus-visible {
    outline: 2px solid var(--mgn-fg);
    outline-offset: 2px;
}


/* Selects (searchbar + filter popup) */

.mgn .mgn-select {
    position: relative;
    display: block;
}

.mgn .mgn-select select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 100%;
    min-height: 36px;
    margin: 0;
    padding: 0 36px 0 16px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-family: var(--mgn-font);
    font-size: 14px;
    line-height: 1.2;
    color: var(--mgn-fg);
    cursor: pointer;
}

.mgn .mgn-select select:focus {
    outline: none;
    background: var(--mgn-muted);
}

.mgn .mgn-select .mgn-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--mgn-muted-fg);
    pointer-events: none;
}


/* [mgn_searchbar] */

.mgn-searchbar {
    container: mgn-searchbar / inline-size;
    background: rgba(245, 245, 245, .5);
    border-radius: var(--mgn-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1);
    padding: 32px;
}

.mgn .mgn-searchbar-form {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.mgn .mgn-filter-toggle {
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 40px;
    padding: 0;
}

.mgn .mgn-filter-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--mgn-primary);
    color: var(--mgn-primary-fg);
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}

.mgn .mgn-searchbar-fields {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: stretch;
    height: 40px;
    background: var(--mgn-bg);
    border: 1px solid var(--mgn-input);
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
    overflow: hidden;
}

.mgn .mgn-searchbar-fields .mgn-select {
    flex: 0 0 170px;
    border-right: 1px solid var(--mgn-input);
}

.mgn .mgn-searchbar-input {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 0 16px;
    color: var(--mgn-muted-fg);
    cursor: text;
}

.mgn .mgn-searchbar-input input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    outline: none;
    font-family: var(--mgn-font);
    font-size: 14px;
    color: var(--mgn-fg);
}

.mgn .mgn-searchbar-input input::placeholder {
    color: var(--mgn-muted-fg);
    opacity: 1;
}

.mgn .mgn-searchbar-fields:focus-within {
    border-color: #a3a3a3;
}

.mgn .mgn-searchbar-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    width: 300px;
}

.mgn .mgn-searchbar-actions .mgn-btn {
    height: 40px;
}

.mgn .mgn-searchbar-submit {
    flex: 1 1 auto;
    padding: 0 32px;
}


/* Filter popup */

.mgn .mgn-dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 1px solid var(--mgn-border);
    border-radius: var(--mgn-radius);
    background: var(--mgn-bg);
    color: var(--mgn-fg);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -4px rgba(0, 0, 0, .1);
    font-family: var(--mgn-font);
}

.mgn .mgn-dialog::backdrop {
    background: rgba(0, 0, 0, .5);
}

.mgn .mgn-dialog-inner {
    padding: 24px;
}

.mgn .mgn-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.mgn .mgn-dialog-title {
    font-family: var(--mgn-font);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    color: var(--mgn-fg);
}

.mgn .mgn-dialog-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--mgn-muted-fg);
    cursor: pointer;
}

.mgn .mgn-dialog-close:hover {
    background: var(--mgn-muted);
    color: var(--mgn-fg);
}

.mgn .mgn-dialog-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.mgn .mgn-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}

.mgn .mgn-field-label {
    font-size: 14px;
    font-weight: 500;
}

.mgn .mgn-field .mgn-select {
    height: 36px;
    border: 1px solid var(--mgn-input);
    border-radius: 6px;
    overflow: hidden;
}

.mgn .mgn-dialog-foot {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
}


/* [mgn_featured_carousel] */

.mgn-carousel {
    position: relative;
}

.mgn .mgn-carousel-track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    border-radius: var(--mgn-radius);
    scrollbar-width: none;
}

.mgn .mgn-carousel-track::-webkit-scrollbar {
    display: none;
}

.mgn .mgn-carousel-slide {
    position: relative;
    flex: 0 0 100%;
    display: block;
    height: var(--mgn-carousel-height, 320px);
    overflow: hidden;
    border-radius: var(--mgn-radius);
    scroll-snap-align: start;
    text-decoration: none;
}

.mgn .mgn-carousel-slide img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    transition: transform .3s;
}

.mgn .mgn-carousel-slide:hover img {
    transform: scale(1.05);
}

.mgn .mgn-carousel-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #e5e7eb;
    color: #d1d5db;
}

.mgn .mgn-carousel-empty .mgn-icon {
    width: 64px;
    height: 64px;
}

.mgn .mgn-carousel-caption {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 16px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, .6), transparent);
}

.mgn .mgn-carousel-tag {
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--mgn-bg);
    color: var(--mgn-fg);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
}

.mgn .mgn-carousel-title {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
}

.mgn .mgn-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--mgn-input);
    border-radius: 999px;
    background: var(--mgn-bg);
    color: var(--mgn-fg);
    opacity: .5;
    cursor: pointer;
    transition: opacity .15s;
}

.mgn .mgn-carousel-nav:hover,
.mgn .mgn-carousel-nav:focus-visible {
    opacity: 1;
}

.mgn .mgn-carousel-prev {
    left: 16px;
}

.mgn .mgn-carousel-next {
    right: 16px;
}


/* [mgn_categories] */

.mgn .mgn-categories-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 16px;
    scroll-snap-type: x mandatory;
}

.mgn .mgn-category {
    flex: 0 0 auto;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 2px solid #f9fafb;
    border-radius: 6px;
    background: #f9fafb;
    text-align: center;
    text-decoration: none;
    scroll-snap-align: start;
    transition: background-color .15s, border-color .15s, box-shadow .15s;
}

.mgn .mgn-category .mgn-icon {
    width: 24px;
    height: 24px;
    color: #d1d5db;
}

.mgn .mgn-category span {
    font-size: 14px;
    color: #6b7280;
}

.mgn .mgn-category:hover {
    background: #eff6ff;
    border-color: #dbeafe;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1);
}

.mgn .mgn-category:hover .mgn-icon,
.mgn .mgn-category:hover span {
    color: var(--mgn-blue);
}

.mgn .mgn-category.is-active {
    background: #dbeafe;
    border-color: #93c5fd;
}

.mgn .mgn-category.is-active .mgn-icon {
    color: var(--mgn-blue);
}

.mgn .mgn-category.is-active span {
    color: #2563eb;
    font-weight: 500;
}


/* [mgn_search_results] + [mgn_featured_properties] */

.mgn .mgn-results-count {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 24px;
    font-weight: 500;
}

.mgn .mgn-results-count .mgn-icon {
    color: var(--mgn-muted-fg);
}

.mgn .mgn-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.mgn .mgn-section-head .mgn-section-title {
    margin: 0;
}

.mgn .mgn-section-head .mgn-btn {
    margin-left: auto;
}

.mgn .mgn-list-row {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    padding: 2px 2px 16px;
    scroll-snap-type: x mandatory;
}

.mgn .mgn-list-row > .mgn-card {
    flex: 0 0 300px;
    scroll-snap-align: start;
}

.mgn .mgn-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.mgn .mgn-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px 16px;
    border-radius: var(--mgn-radius);
    background: rgba(245, 245, 245, .5);
    text-align: center;
}

.mgn .mgn-empty .mgn-icon {
    width: 64px;
    height: 64px;
    color: var(--mgn-muted-fg);
}

.mgn .mgn-empty p {
    margin: 0;
    font-size: 18px;
    color: var(--mgn-muted-fg);
}

.mgn .mgn-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

.mgn .mgn-pagination-status {
    font-size: 14px;
    color: var(--mgn-muted-fg);
}


/* Property card */

.mgn .mgn-card {
    /* Keeps the hidden screen-reader text inside the card; without it, cards
       scrolled out of view in a row push the whole page wider. */
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    padding: 24px;
    background: var(--mgn-bg);
    border: 1px solid var(--mgn-border);
    border-radius: var(--mgn-radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
    overflow: hidden;
    transition: box-shadow .15s;
}

.mgn .mgn-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1);
}

/* Promotion colours, same as the portal */
.mgn .mgn-card.is-featured,
.mgn .mgn-card.is-highlight {
    border: 2px solid var(--mgn-amber);
}

.mgn .mgn-card.is-urgent {
    border: 2px solid var(--mgn-red);
}

.mgn .mgn-card.is-bump {
    border: 2px solid var(--mgn-grey);
}

.mgn .mgn-gallery {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-radius: var(--mgn-radius);
    overflow: hidden;
    text-decoration: none;
}

.mgn .mgn-gallery img {
    display: block;
    width: 100%;
    max-width: none;
    object-fit: cover;
    border-radius: 0;
}

.mgn .mgn-gallery .mgn-gallery-main {
    height: 208px;
}

.mgn .mgn-gallery-thumbs {
    display: grid;
    grid-template-columns: repeat(var(--mgn-thumbs, 3), 1fr);
    gap: 4px;
}

.mgn .mgn-gallery-thumbs img {
    height: 80px;
}

.mgn .mgn-gallery-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 208px;
    background: var(--mgn-muted);
    color: var(--mgn-muted-fg);
}

.mgn .mgn-gallery-empty .mgn-icon {
    width: 40px;
    height: 40px;
    padding: 6px;
    border: 2px solid currentColor;
    border-radius: 999px;
    box-sizing: content-box;
}

.mgn .mgn-gallery-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--mgn-amber);
    color: #111827;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: .05em;
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

.mgn .mgn-gallery-badge.is-urgent {
    background: var(--mgn-red);
}

.mgn .mgn-gallery-badge.is-bump {
    background: var(--mgn-grey);
}

.mgn .mgn-card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.mgn .mgn-badge {
    align-self: flex-start;
    padding: 4px 8px;
    border: 1px solid var(--mgn-amber);
    border-radius: 999px;
    background: #fef3c7;
    color: #b45309;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
}

.mgn .mgn-card-price {
    font-size: 14px;
    color: var(--mgn-muted-fg);
}

.mgn .mgn-card-title {
    margin: 0;
    font-family: var(--mgn-font);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: normal;
    text-transform: none;
    color: var(--mgn-fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mgn .mgn-card-desc {
    margin: 0;
    font-size: 14px;
    color: var(--mgn-muted-fg);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mgn .mgn-card-specs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.mgn .mgn-spec {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
}

.mgn .mgn-spec .mgn-icon {
    width: 20px;
    height: 20px;
    color: #4b5563;
}

.mgn .mgn-card-actions {
    margin-top: auto;
    display: flex;
    gap: 8px;
}


/* Notice shown when the API can't be reached */

.mgn-notice {
    padding: 16px;
    border: 1px solid var(--mgn-border);
    border-radius: var(--mgn-radius);
    background: var(--mgn-muted);
    color: var(--mgn-muted-fg);
    font-size: 14px;
}


/* Phones and small tablets */

@media (max-width: 767px) {

    .mgn-searchbar {
        padding: 12px;
    }

    .mgn .mgn-dialog-grid {
        grid-template-columns: 1fr;
    }

    .mgn .mgn-category {
        min-width: 90px;
    }

    .mgn .mgn-list-row > .mgn-card {
        flex-basis: 85%;
    }

    .mgn .mgn-list-grid {
        grid-template-columns: 1fr;
    }

    .mgn .mgn-carousel-nav {
        display: none;
    }

}

/*
 * The searchbar reacts to its own width, not the screen's, because page
 * builders often put it in a narrow column on a wide screen. One row needs
 * about 900px; below that the buttons move under the fields, and below
 * 560px the fields stack too.
 */

@container mgn-searchbar (max-width: 900px) {

    .mgn .mgn-searchbar-form {
        flex-wrap: wrap;
    }

    .mgn .mgn-searchbar-fields {
        order: -1;
        flex: 1 1 100%;
    }

    .mgn .mgn-searchbar-actions {
        flex: 1 1 0;
        width: auto;
    }

}

@container mgn-searchbar (max-width: 560px) {

    .mgn .mgn-searchbar-fields {
        flex-direction: column;
        height: auto;
    }

    .mgn .mgn-searchbar-fields .mgn-select {
        flex: 0 0 40px;
        border-right: 0;
        border-bottom: 1px solid var(--mgn-input);
    }

    .mgn .mgn-searchbar-input {
        height: 40px;
    }

}

@media (prefers-reduced-motion: reduce) {

    .mgn .mgn-carousel-track {
        scroll-behavior: auto;
    }

    .mgn .mgn-carousel-slide img {
        transition: none;
    }

}
