/* EDH Business Directory — front-end and editor styles. Colours inherit from the theme. */

:root {
    --edhbd-gap: 1rem;
    --edhbd-radius: 8px;
    --edhbd-border: rgba(0, 0, 0, 0.12);
    --edhbd-muted: rgba(0, 0, 0, 0.6);
}

/* Filter bar */
.edhbd-filter-bar__form {
    display: flex;
    flex-wrap: wrap;
    gap: var(--edhbd-gap);
    align-items: flex-end;
    margin: 0 0 calc(var(--edhbd-gap) * 1.5);
}

.edhbd-filter-bar__field,
.edhbd-filter-bar__actions {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: 0;
    min-width: 12rem;
    flex: 1 1 12rem;
}

.edhbd-filter-bar__actions {
    flex-direction: row;
    align-items: center;
    gap: var(--edhbd-gap);
    flex: 0 0 auto;
}

.edhbd-filter-bar__field label {
    font-size: 0.875em;
    font-weight: 600;
}

.edhbd-filter-bar__field select {
    width: 100%;
    padding: 0.5em 0.75em;
    border: 1px solid var(--edhbd-border);
    border-radius: var(--edhbd-radius);
    font: inherit;
    background: transparent;
}

.edhbd-filter-bar__submit {
    cursor: pointer;
}

/* Map */
.edhbd-map {
    width: 100%;
    min-height: 200px;
    border-radius: var(--edhbd-radius);
    overflow: hidden;
    margin-bottom: calc(var(--edhbd-gap) * 1.5);
    background: #e9e9e9;
    z-index: 0;
}

.edhbd-map--greyscale .leaflet-tile-pane {
    filter: grayscale(1);
}

.edhbd-pin {
    background: none;
    border: 0;
}

.edhbd-pin svg {
    display: block;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}

.edhbd-map .leaflet-popup-content {
    line-height: 1.4;
}

/* Card */
.edhbd-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid var(--edhbd-border);
    border-radius: var(--edhbd-radius);
    overflow: hidden;
}

/* Fixed-ratio box; the image is positioned inside it so theme rules such as
   img { height: auto !important } cannot change the card height. */
.edhbd-card__logo {
    display: block;
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #fff;
    border-bottom: 1px solid var(--edhbd-border);
}

.edhbd-card__logo img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
    padding: 0.75rem;
    box-sizing: border-box;
}

.edhbd-card__body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: var(--edhbd-gap);
}

.edhbd-card__title {
    margin: 0;
    font-size: 1.125em;
}

.edhbd-card__title a {
    text-decoration: none;
}

.edhbd-card__sectors,
.edhbd-details__sectors {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.edhbd-card__sectors li a,
.edhbd-details__sectors li a {
    display: inline-block;
    padding: 0.125em 0.625em;
    border: 1px solid var(--edhbd-border);
    border-radius: 999px;
    font-size: 0.75em;
    text-decoration: none;
}

.edhbd-card__address,
.edhbd-card__short-description,
.edhbd-card__email {
    margin: 0;
    color: var(--edhbd-muted);
    font-size: 0.9em;
    font-style: normal;
    line-height: 1.5;
}

.edhbd-card__email a {
    word-break: break-word;
}

/* Footer buttons: Website | Phone, 50/50 (full width if only one). */
.edhbd-card__footer {
    display: flex;
    margin-top: auto;
    border-top: 1px solid var(--edhbd-border);
}

.edhbd-card__button {
    flex: 1 1 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 0.5rem;
    font-size: 0.9em;
    font-weight: 600;
    text-decoration: none;
    min-width: 0;
    transition: filter 0.15s;
}

.edhbd-card__button + .edhbd-card__button {
    border-left: 1px solid rgba(255, 255, 255, 0.25);
}

.edhbd-card__button:hover,
.edhbd-card__button:focus-visible {
    filter: brightness(1.15);
    text-decoration: none;
}

.edhbd-card__button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edhbd-card__button-icon {
    flex: none;
}

/* Listings grid. Core's layout CSS for the Post Template grid is not emitted
   in editor previews, so declare the columns explicitly here. */
.edhbd-listings .wp-block-post-template {
    display: grid;
    gap: var(--edhbd-gap);
    grid-template-columns: repeat(1, minmax(0, 1fr));
    list-style: none;
    margin: 0;
    padding: 0;
}

@media (min-width: 600px) {
    .edhbd-listings .wp-block-post-template.columns-2,
    .edhbd-listings .wp-block-post-template.columns-3,
    .edhbd-listings .wp-block-post-template.columns-4,
    .edhbd-listings .wp-block-post-template.columns-5,
    .edhbd-listings .wp-block-post-template.columns-6 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 782px) {
    .edhbd-listings .wp-block-post-template.columns-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .edhbd-listings .wp-block-post-template.columns-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .edhbd-listings .wp-block-post-template.columns-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .edhbd-listings .wp-block-post-template.columns-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.edhbd-listings .wp-block-post-template > li {
    margin: 0;
}

/* Details (single): a container of Business Field / Business Map blocks */
.edhbd-details {
    margin-bottom: calc(var(--edhbd-gap) * 2);
}

.edhbd-details > * + * {
    margin-top: var(--edhbd-gap);
}

.edhbd-details__columns {
    width: 100%;
}

.edhbd-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem 1rem;
}

@media (min-width: 600px) {
    .edhbd-field:not(.edhbd-field--logo):not(.edhbd-field--sectors):not(.edhbd-field--short_description):not(.edhbd-field--back_link) {
        grid-template-columns: 8rem minmax(0, 1fr);
    }
}

.edhbd-field__label {
    font-weight: 600;
}

.edhbd-field__value > p,
.edhbd-field__value > address {
    margin: 0;
}

.edhbd-field--logo img {
    max-width: 240px;
    height: auto;
}

.edhbd-details__address {
    font-style: normal;
}

.edhbd-details__map {
    margin-bottom: 0;
}

/* Default two-column layout: the map fills its column's height. */
.edhbd-details__columns > .wp-block-column:has(> .edhbd-details__map) {
    display: flex;
}

.edhbd-details__columns > .wp-block-column > .edhbd-details__map {
    flex: 1;
    min-height: 300px;
}

/* Classic-theme templates: fill the theme's content area (some themes lay
   out #primary in a flex row and only size their own .content-area class). */
.edhbd-classic-template {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
}

/* Editor */
.edhbd-map-editor-placeholder {
    display: flex;
}

.edhbd-map-editor-placeholder .components-placeholder {
    flex: 1;
}

.edhbd-editor-preview .edhbd-filter-bar__form {
    pointer-events: none;
}

.edhbd-field--back_link {
    margin-top: 25px;
}
