/**
 * Partners Grid — [partners_grid]
 *
 * Card grid modelled on the Team grid, plus a detail modal opened by the
 * Read More button. The modal is a native <dialog>, so it renders in the top
 * layer and is unaffected by any transformed or overflow-clipped ancestor.
 *
 * Colours come from the theme's palette presets, each with a literal fallback
 * so the grid still renders if the stylesheet loads before global styles.
 */

/* --- Grid ---------------------------------------------------------------- */

.hpg-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 32px 16px;
}

.hpg-card {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: calc((100% - (var(--hpg-columns, 3) - 1) * 16px) / var(--hpg-columns, 3));
    border: 1px solid #eaebec;
    border-radius: 12px;
    padding: 16px;
}

.hpg-card__photo {
    line-height: 0;
    border-radius: 12px;
    overflow: hidden;
}

.hpg-card__photo img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    object-position: top;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.hpg-card:hover .hpg-card__photo img {
    transform: scale(1.05);
}

.hpg-card__body {
    /* Fills the leftover height so Read More sits flush at the card's foot,
       keeping the buttons aligned across cards of differing text length. */
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 0 0;
}

.hpg-card__heading {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.hpg-card__name {
    margin: 0;
    font-family: var(--wp--preset--font-family--freight-text-pro, "FreightText Pro Book", Georgia, serif);
    font-size: 24px;
    font-weight: 400;
    line-height: 1.4;
    color: #19191b;
}

.hpg-card__designation {
    margin: 0 !important;
    font-size: 18px !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    color: #551c25 !important;
}

.hpg-card__excerpt {
    margin: 0 !important;
    font-size: 18px !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    color: #787a82 !important;
}

/* --- Read More ----------------------------------------------------------- */

.hpg-card__more {
    /* margin-top:auto pins the button to the bottom of .hpg-card__body;
       margin-right:auto keeps it from stretching to the full card width. */
    margin: auto auto 0 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 0;
    padding: 0;
    font-family: inherit;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.4;
    color: #538988;
    cursor: pointer;
    transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hpg-card__more:hover,
.hpg-card__more:focus-visible {
    color: #551c25;
}

/* The arrow has no colour of its own, so it follows the button's. */
.hpg-card__more-arrow {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hpg-card__more:hover .hpg-card__more-arrow,
.hpg-card__more:focus-visible .hpg-card__more-arrow {
    transform: translateX(4px);
}

.hpg-empty {
    margin: 0;
    color: var(--wp--preset--color--hang-neutral, #838484);
}

/* --- Modal --------------------------------------------------------------- */

/*
 * Centred on both axes: fixed with all four insets at 0 and auto margins,
 * which splits the leftover space evenly. height:fit-content is what makes
 * the vertical half work — with an auto height between top:0 and bottom:0 the
 * box would stretch to the full viewport and the auto margins collapse to 0.
 * Spelled out rather than left to the <dialog> UA defaults so the position
 * survives the non-modal fallback and any global dialog styling.
 */
.hpg-modal {
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    width: min(880px, calc(100vw - 32px));
    max-width: none;
    height: fit-content;
    max-height: calc(100vh - 64px);
    max-height: calc(100dvh - 64px);
    margin: auto;
    border: 0;
    border-radius: 16px;
    padding: 0;
    background: #fff;
    color: #19191b;
    overflow: hidden;
}

.hpg-modal::backdrop {
    background: rgba(25, 25, 27, 0.6);
}

.hpg-modal__dialog {
    position: relative;
    max-height: calc(100vh - 64px);
    max-height: calc(100dvh - 64px);
    padding: 32px;
    overflow-y: auto;
}

.hpg-modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid #eaebec;
    border-radius: 50%;
    padding: 0;
    background: #fff;
    font-size: 24px;
    line-height: 1;
    color: #19191b;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.hpg-modal__close:hover,
.hpg-modal__close:focus-visible {
    background: #f4f4f5;
}

/* Top section: photo | name + designation */
.hpg-modal__top {
    display: flex;
    align-items: center;
    gap: 24px;
    /* Clears the close button so a long name never runs underneath it. */
    padding-right: 44px;
}

.hpg-modal__photo {
    flex: 0 0 200px;
    line-height: 0;
    border-radius: 12px;
    overflow: hidden;
}

.hpg-modal__photo img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    object-position: top;
}

.hpg-modal__heading {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hpg-modal__name {
    margin: 0;
    font-family: var(--wp--preset--font-family--freight-text-pro, "FreightText Pro Book", Georgia, serif);
    font-size: 32px;
    font-weight: 400;
    line-height: 1.3;
    color: #19191b;
}

.hpg-modal__designation {
    margin: 0 !important;
    font-size: 18px !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    color: #551c25 !important;
}

/* Bottom section: full content */
.hpg-modal__content {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid #eaebec;
    font-size: 18px;
    line-height: 1.6;
    color: #787a82;
}

.hpg-modal__content > *:first-child {
    margin-top: 0;
}

.hpg-modal__content > *:last-child {
    margin-bottom: 0;
}

/* Set on <body> while a modal is open, so the page behind it cannot scroll. */
.hpg-modal-open {
    overflow: hidden;
}

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 767px) {
    .hpg-card {
        width: 100%;
    }

    .hpg-modal__dialog {
        padding: 24px;
    }

    .hpg-modal__top {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .hpg-modal__photo {
        flex: 0 0 auto;
        width: 140px;
    }

    .hpg-modal__name {
        font-size: 26px;
    }

    .hpg-modal__content {
        margin-top: 24px;
        padding-top: 24px;
    }
}
