/**
 * Global Member Directory — Responsive styles.
 *
 * Loaded AFTER public.css, directory.css and organization.css so that
 * these rules win the cascade. Handles all breakpoints for every
 * frontend GMD view:
 *   - member directory (grid + list)
 *   - filter bar
 *   - member cards
 *   - pagination
 *   - member profile
 *   - self-submit registration form
 *   - organization directory (committees + forums)
 *   - single organization
 *   - smart modal
 *
 * Breakpoints:
 *   ≥ 1101px  desktop (default)
 *   ≤ 1100px  small desktop   (4 → 3 columns)
 *   ≤  900px  tablet          (3 → 2 columns, stack sidebar)
 *   ≤  782px  small tablet    (filter bar stacks, cards shrink)
 *   ≤  560px  mobile          (1 column)
 *   ≤  400px  small mobile    (tight paddings)
 *
 * @package GlobalMemberDirectory
 */


/* =========================================================================
 * 1. SMALL DESKTOP — ≤ 1100px
 *
 * Grid: 4 → 3 columns.
 * Filter bar: wraps.
 * ====================================================================== */

@media (max-width: 1100px) {
    /* Member directory: 4 → 3 columns */
    .gmd-members--grid,
    .gmd-members--cols-4 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    /* Filter bar wraps more aggressively */
    .gmd-filter-bar {
        padding: 12px;
        gap: 8px;
    }
    .gmd-filter-bar__field {
        flex: 1 1 150px;
        min-width: 130px;
    }
    .gmd-filter-bar__field--search {
        flex: 1 1 100%;
    }
}


/* =========================================================================
 * 2. TABLET — ≤ 900px
 *
 * Grid: 3 → 2 columns.
 * Org single: sidebar stacks under main.
 * ====================================================================== */

@media (max-width: 900px) {
    /* Member directory: 3 → 2 columns */
    .gmd-members--grid,
    .gmd-members--cols-3,
    .gmd-members--cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }
    /* Org single: main + sidebar stack */
    .gmd-org-single__body {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    /* Org single: member grid drops to 2 columns */
    .gmd-org-single .gmd-members--grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    /* Org directory: single column */
    .gmd-org-directory__columns--2 {
        grid-template-columns: 1fr;
    }
    /* Org card grid: 3 → 2 */
    .gmd-orgs-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    /* Member profile: shrink hero photo */
    .gmd-profile__hero {
        grid-template-columns: 140px 1fr;
        gap: 24px;
        padding: 24px;
    }
    .gmd-profile__name {
        font-size: 24px;
    }
    .gmd-profile__body {
        padding: 24px;
    }
}


/* =========================================================================
 * 3. SMALL TABLET — ≤ 782px
 *
 * Filter bar stacks vertically.
 * Directory header stacks.
 * Registration grid becomes 1 column.
 * ====================================================================== */

@media (max-width: 782px) {
    /* --------------------- Directory header -------------------- */
    .gmd-directory__header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .gmd-directory__tools {
        justify-content: space-between;
        width: 100%;
    }
    .gmd-directory__title {
        font-size: 20px;
    }
    /* --------------------- Filter bar -------------------------- */
    .gmd-filter-bar {
        flex-direction: column;
        padding: 12px;
    }
    .gmd-filter-bar__field {
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
    }
    .gmd-filter-bar__field--search {
        flex: 1 1 auto;
    }
    .gmd-filter-bar__field--actions {
        display: flex;
        justify-content: flex-end;
    }
    /* --------------------- Member cards ------------------------ */
    .gmd-member-card--grid .gmd-member-card__initials {
        font-size: 36px;
    }
    .gmd-member-card__body {
        padding: 14px 16px 16px;
    }
    .gmd-member-card__name {
        font-size: 15px;
    }
    .gmd-member-card__designation {
        font-size: 12.5px;
    }
    /* --------------------- Profile ----------------------------- */
    .gmd-profile__hero {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px;
        text-align: center;
    }
    .gmd-profile__photo {
        max-width: 160px;
        margin: 0 auto;
    }
    .gmd-profile__name {
        font-size: 22px;
    }
    .gmd-profile__designation {
        font-size: 15px;
    }
    .gmd-profile__organization,
    .gmd-profile__country,
    .gmd-profile__categories,
    .gmd-profile__socials {
        justify-content: center;
    }
    .gmd-profile__body {
        padding: 20px;
    }
    .gmd-profile__section-title {
        font-size: 16px;
    }
    /* --------------------- Registration form ------------------- */
    .gmd-registration__form .gmd-grid--2 {
        grid-template-columns: 1fr;
    }
    .gmd-registration__title {
        font-size: 22px;
    }
    .gmd-registration__section {
        padding: 16px;
    }
    /* --------------------- Org directory ----------------------- */
    .gmd-org-directory__header {
        padding: 36px 16px 32px;
    }
    .gmd-org-directory__emblem {
        width: 56px;
        height: 56px;
        font-size: 1.8rem;
    }
    .gmd-org-directory__title {
        font-size: 1.5rem;
    }
    .gmd-org-directory__flags {
        width: auto;
        padding: 10px 12px;
    }
    .gmd-org-directory__name {
        padding: 10px 12px;
    }
    .gmd-org-directory__name a,
    .gmd-org-directory__name span {
        font-size: 0.95rem;
    }
    /* --------------------- Org single -------------------------- */
    .gmd-org-single__hero {
        padding: 40px 16px 36px;
    }
    .gmd-org-single__flags img {
        height: 32px;
    }
    .gmd-org-single__title {
        font-size: 1.5rem;
    }
    .gmd-org-single__logo {
        height: 48px;
        max-width: 90px;
    }
    .gmd-org-single__section {
        padding: 18px;
    }
    /* --------------------- Pagination -------------------------- */
    .gmd-pagination a,
    .gmd-pagination button,
    .gmd-page-current,
    .gmd-page-disabled {
        min-width: 32px;
        height: 32px;
        font-size: 12.5px;
        padding: 0 8px;
    }
}


/* =========================================================================
 * 4. MOBILE — ≤ 560px
 *
 * Everything is 1 column.
 * ====================================================================== */

@media (max-width: 560px) {
    /* --------------------- Directory --------------------------- */
    .gmd-directory__header {
        gap: 10px;
    }
    .gmd-directory__title {
        font-size: 18px;
    }
    .gmd-directory__tools {
        flex-wrap: wrap;
        gap: 8px;
    }
    .gmd-directory__tools .gmd-btn {
        flex: 1 1 auto;
    }
    /* --------------------- Grid: 1 column --------------------- */
    .gmd-members--grid,
    .gmd-members--cols-2,
    .gmd-members--cols-3,
    .gmd-members--cols-4,
    .gmd-org-single .gmd-members--grid {
        grid-template-columns: 1fr;
    }
    /* --------------------- Member cards ----------------------- */
    .gmd-member-card--grid .gmd-member-card__media {
        aspect-ratio: 4 / 3;
    }
    .gmd-member-card__body {
        padding: 14px;
    }
    .gmd-member-card__name {
        font-size: 15px;
    }
    /* --------------------- Filter chips ----------------------- */
    .gmd-filter-chips {
        gap: 6px;
    }
    .gmd-chip {
        font-size: 12px;
        padding: 3px 6px 3px 10px;
    }
    /* --------------------- Profile ---------------------------- */
    .gmd-profile__photo {
        max-width: 120px;
    }
    .gmd-profile__name {
        font-size: 20px;
    }
    .gmd-profile__body {
        padding: 16px;
    }
    .gmd-profile__footer {
        flex-direction: column;
        align-items: stretch;
    }
    .gmd-profile__footer .gmd-btn {
        width: 100%;
        justify-content: center;
    }
    /* --------------------- Registration ----------------------- */
    .gmd-registration__header {
        text-align: center;
    }
    .gmd-registration__title {
        font-size: 20px;
    }
    .gmd-registration__section {
        padding: 14px;
    }
    .gmd-registration__legend {
        font-size: 15px;
    }
    .gmd-registration__actions {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    .gmd-registration__actions .gmd-btn {
        width: 100%;
        justify-content: center;
    }
    .gmd-registration__privacy {
        text-align: center;
    }
    /* --------------------- Org directory ----------------------- */
    .gmd-org-directory__header {
        padding: 28px 14px 24px;
    }
    .gmd-org-directory__title {
        font-size: 1.25rem;
    }
    .gmd-org-directory__ornament span {
        width: 32px;
    }
    .gmd-org-directory__ornament span:nth-child(2) {
        width: 48px;
    }
    /* --------------------- Org single ------------------------- */
    .gmd-org-single__hero {
        padding: 32px 14px;
    }
    .gmd-org-single__flags {
        gap: 10px;
    }
    .gmd-org-single__flags img {
        height: 26px;
    }
    .gmd-org-single__title {
        font-size: 1.25rem;
    }
    .gmd-org-single__excerpt {
        font-size: 0.9rem;
    }
    .gmd-org-single__section {
        padding: 14px;
    }
    .gmd-org-single__section-title {
        font-size: 1rem;
    }
    .gmd-org-single__footer {
        flex-direction: column;
        align-items: stretch;
    }
    .gmd-org-single__footer .gmd-btn {
        width: 100%;
        justify-content: center;
    }
    /* --------------------- Org cards -------------------------- */
    .gmd-orgs-grid {
        grid-template-columns: 1fr;
    }
    /* --------------------- Pagination ------------------------- */
    .gmd-pagination {
        gap: 3px;
    }
    .gmd-pagination a,
    .gmd-pagination button,
    .gmd-page-current,
    .gmd-page-disabled {
        min-width: 30px;
        height: 30px;
        font-size: 12px;
        padding: 0 6px;
    }
    .gmd-pagination-summary {
        font-size: 12px;
    }
    /* --------------------- Modal ------------------------------ */
    .gmd-modal__dialog {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
        margin-top: auto;
    }
}


/* =========================================================================
 * 5. SMALL MOBILE — ≤ 400px
 *
 * Tightest paddings.
 * ====================================================================== */

@media (max-width: 400px) {
    .gmd-directory__title {
        font-size: 17px;
    }
    .gmd-filter-bar {
        padding: 10px;
    }
    .gmd-member-card__body {
        padding: 12px;
    }
    .gmd-profile__name {
        font-size: 18px;
    }
    .gmd-profile__body {
        padding: 14px;
    }
    .gmd-registration__title {
        font-size: 18px;
    }
    .gmd-registration__section {
        padding: 12px;
    }
    .gmd-org-directory__title {
        font-size: 1.15rem;
    }
    .gmd-org-single__title {
        font-size: 1.15rem;
    }
    .gmd-org-single__hero {
        padding: 24px 12px;
    }
    .gmd-pagination a,
    .gmd-pagination button,
    .gmd-page-current {
        min-width: 28px;
        height: 28px;
        padding: 0 4px;
    }
}


/* =========================================================================
 * 6. LANDSCAPE PHONES — max-height: 500px
 *
 * Shrink modal and hero paddings.
 * ====================================================================== */

@media (max-height: 500px) and (orientation: landscape) {
    .gmd-org-single__hero {
        padding: 24px 16px;
    }
    .gmd-profile__hero {
        padding: 16px;
    }
    .gmd-modal__dialog {
        max-height: 100vh;
    }
}


/* =========================================================================
 * 7. REDUCED MOTION
 *
 * Respect user preference for less animation.
 * ====================================================================== */

@media (prefers-reduced-motion: reduce) {
    .gmd-member-card,
    .gmd-org-card,
    .gmd-btn,
    .gmd-layout-toggle__btn,
    .gmd-profile__social,
    .gmd-modal__dialog {
        transition: none !important;
        animation: none !important;
    }
    .gmd-member-card:hover,
    .gmd-org-card:hover,
    .gmd-profile__social:hover {
        transform: none !important;
    }
}


/* =========================================================================
 * 8. PRINT
 *
 * Keep the directory printable.
 * ====================================================================== */

@media print {
    .gmd-filter-bar,
    .gmd-directory__tools,
    .gmd-pagination,
    .gmd-directory__pagination,
    .gmd-profile__socials,
    .gmd-profile__footer,
    .gmd-org-single__footer,
    .gmd-modal,
    .gmd-directory__overlay {
        display: none !important;
    }
    .gmd-member-card,
    .gmd-org-card,
    .gmd-profile__hero,
    .gmd-profile__body,
    .gmd-org-single__hero,
    .gmd-org-single__section {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }
    .gmd-members--grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}