/**
 * LocaLeaf Plant Catalogue — Responsive styles.
 *
 * Inherits all font-family and font-size from the theme.
 * Only overrides sizes for UI-specific elements (filter chips, badges).
 */

/* --- Layout Container --- */

.localeaf-catalogue {
    font-family: inherit;
    font-size: inherit;
}

/* --- Legend --- */

.localeaf-legend {
    margin-bottom: 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.localeaf-legend__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1rem;
    background: #f9f9f9;
    border: none;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    font-weight: 600;
}

.localeaf-legend__toggle:hover {
    background: #f0f0f0;
}

.localeaf-legend__content {
    padding: 0.75rem 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
}

.localeaf-legend__item {
    white-space: nowrap;
}

/* --- Catalogue Width — match header/footer via theme wide-size --- */

.localeaf-catalogue {
    max-width: var(--wp--style--global--wide-size, 1340px);
    margin-left: auto;
    margin-right: auto;
}

/* Match page title and intro text to catalogue width on the plant database page */
.page-id-8350 .wp-block-post-title,
.page-id-8350 .entry-content > :not(.localeaf-catalogue):not(.localeaf-catalogue__status),
.page-id-8352 .wp-block-post-title,
.page-id-8352 .entry-content > :not(.localeaf-catalogue):not(.localeaf-catalogue__status) {
    max-width: var(--wp--style--global--wide-size, 1340px);
    margin-left: auto;
    margin-right: auto;
}

/* --- Filters --- */

.localeaf-catalogue__filters {
    margin-bottom: 1.5rem;
}

/* --- Filter Toggle & Collapsible Panel --- */

.localeaf-filter-toggle {
    background: none;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    font-size: inherit;
    font-weight: 600;
    cursor: pointer;
    color: #333;
    white-space: nowrap;
}

.localeaf-filter-toggle:hover {
    border-color: #2e7d32;
    color: #2e7d32;
}

.localeaf-filter-toggle__count:not(:empty)::before {
    content: "(";
}

.localeaf-filter-toggle__count:not(:empty)::after {
    content: ")";
}

.localeaf-filter-panel {
    margin-bottom: 1rem;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    background: #fafafa;
}

.localeaf-filter-panel[hidden] {
    display: none;
}

.localeaf-filter-panel__actions {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #eee;
}

.localeaf-filter-reset {
    background: none;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 0.4rem 1rem;
    font-size: inherit;
    font-family: inherit;
    cursor: pointer;
    color: #666;
}

.localeaf-filter-reset:hover {
    border-color: #dc2626;
    color: #dc2626;
}

.localeaf-filter-panel__grid {
    display: flex;
    gap: 2.5rem;
}

.localeaf-filter-panel__col {
    flex: 1;
    min-width: 0;
}

@media (max-width: 768px) {
    .localeaf-filter-panel__grid {
        flex-direction: column;
        gap: 0;
    }
}

/* --- Filter Sections (S4 refactor) --- */

.localeaf-filter-section {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
}

.localeaf-filter-section:last-of-type {
    border-bottom: none;
}

.localeaf-filter-section__title {
    font-size: 0.85em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #444;
    margin: 0 0 0.5rem;
}

.localeaf-filter-section__body {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
}

/* --- Search Input (S3) --- */

.localeaf-search-input {
    padding: 0.4rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: inherit;
    min-width: 200px;
    max-width: 320px;
    width: 100%;
}

.localeaf-search-input:focus {
    outline: none;
    border-color: #2e7d32;
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.15);
}

/* Row 1: full-width chip filters (legacy compat) */
.localeaf-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

/* Row 2: compact controls bar */
.localeaf-catalogue__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    padding-top: 0.75rem;
}

.localeaf-catalogue__controls-right {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-left: auto;
}

.localeaf-filter-group--inline {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.localeaf-filter-group--inline label {
    white-space: nowrap;
    font-weight: 600;
}

.localeaf-filter-select,
.localeaf-catalogue__controls select {
    padding: 0.3rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: inherit;
}

.localeaf-filter-group {
    position: relative;
}

.localeaf-filter-group__label {
    display: block;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    margin-bottom: 0.25rem;
}

.localeaf-filter-group__options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.localeaf-filter-group__options label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.localeaf-filter-group__options label:hover {
    background: #f5f5f5;
}

.localeaf-filter-group__options input:checked + span,
.localeaf-filter-group__options label:has(input:checked) {
    background: #2e7d32;
    color: #fff;
    border-color: #2e7d32;
}

.localeaf-filter-group__options input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* --- Availability Toggle --- */

.localeaf-catalogue__available-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    white-space: nowrap;
    margin-left: 0.75rem;
}

.localeaf-catalogue__available-toggle input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: #2e7d32;
}

/* --- View Toggle --- */

.localeaf-catalogue__view-toggle {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.localeaf-view-btn {
    padding: 0.4rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 1.1em;
    line-height: 1;
    transition: background 0.15s, border-color 0.15s;
}

.localeaf-view-btn:hover {
    background: #f5f5f5;
}

.localeaf-view-btn--active {
    background: #2e7d32;
    color: #fff;
    border-color: #2e7d32;
}

/* --- Table View --- */

.localeaf-catalogue__table {
    width: 100%;
    border-collapse: collapse;
}

.localeaf-catalogue__table thead {
    border-bottom: 3px solid;
}

.localeaf-catalogue__table th {
    padding: 0.5em;
    text-align: left;
    font-weight: 700;
}

.localeaf-catalogue__table td {
    padding: 0.5em;
    border: 1px solid transparent;
}

.localeaf-catalogue__table tbody tr:nth-child(odd) {
    background-color: #f0f0f0;
}

.localeaf-catalogue__table tbody tr:hover {
    background-color: #e8f5e9;
}

.localeaf-catalogue__table td a {
    color: #2e7d32;
    text-decoration: none;
    font-weight: 500;
}

.localeaf-catalogue__table td a:hover {
    text-decoration: underline;
}

.localeaf-catalogue__table td em {
    color: #666;
}

/* --- Results Count & Loading --- */

.localeaf-catalogue__status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: #666;
}

.localeaf-catalogue__loading {
    display: none;
    color: #999;
}

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

.localeaf-catalogue__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

/* --- Group Headers --- */

.localeaf-catalogue__group {
    margin-bottom: 2rem;
}

.localeaf-catalogue__group-count {
    font-weight: 400;
    color: #888;
}

/* --- Plant Card --- */

.localeaf-plant-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.15s;
    background: #fff;
}

.localeaf-plant-card__image {
    aspect-ratio: 2 / 3;
    overflow: hidden;
    background: #f0f0f0;
}

.localeaf-plant-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.localeaf-plant-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.localeaf-plant-card__link,
.localeaf-plant-card__link:hover,
.localeaf-plant-card__link:focus,
.localeaf-plant-card__link:active {
    display: block;
    text-decoration: none !important;
    text-decoration-line: none !important;
    text-decoration-thickness: 0 !important;
    outline: none !important;
    outline-style: none !important;
    color: inherit;
}

.localeaf-plant-card__link:focus-visible {
    outline: 2px solid #2e7d32 !important;
    outline-offset: 2px;
    border-radius: 12px;
}

.localeaf-plant-card__name {
    padding: 0.75rem 1rem 0;
}

.localeaf-plant-card__latin,
.localeaf-plant-card__meta,
.localeaf-plant-card__details,
.localeaf-plant-card__link > .badge {
    padding-left: 1rem;
    padding-right: 0.5rem;
}

.localeaf-plant-card__link > .badge {
    margin-bottom: 0.75rem;
}

.localeaf-plant-card__name {
    margin: 0 0 0.25rem;
    line-height: 1.3;
}

.localeaf-plant-card__latin {
    margin: 0 0 0.5rem;
    color: #666;
}

.localeaf-plant-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.localeaf-plant-card__height,
.localeaf-plant-card__bloom {
    color: #888;
}

.localeaf-plant-card__details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #888;
    margin-top: 0.25rem;
}

.localeaf-plant-card__proximity {
    color: #888;
    padding-right: 1rem;
}

/* --- Badges --- */

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 600;
}

.badge--available {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge--unavailable {
    background: #f5f5f5;
    color: #999;
}

.badge--layer {
    background: #e3f2fd;
    color: #1565c0;
}

/* --- Info Popup (D6) --- */

.localeaf-info-popup {
    display: inline;
    position: relative;
}

.localeaf-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3em;
    height: 1.3em;
    font-size: 0.8em;
    font-style: normal;
    border-radius: 50%;
    background: transparent;
    color: #555;
    cursor: pointer;
    vertical-align: middle;
    list-style: none;
}

.localeaf-info-btn::-webkit-details-marker {
    display: none;
}

.localeaf-info-btn:hover {
    background: #2e7d32;
    color: #fff;
}

.localeaf-info-popup__content {
    position: absolute;
    left: 0;
    top: 1.8em;
    z-index: 100;
    min-width: 280px;
    max-width: 360px;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    font-size: 0.9em;
    font-weight: 400;
    line-height: 1.5;
}

.localeaf-info-popup__content p {
    margin: 0 0 0.5rem;
}

.localeaf-info-popup__content a {
    color: #2e7d32;
    font-weight: 600;
    text-decoration: none;
}

.localeaf-info-popup__content a:hover {
    text-decoration: underline;
}

/* --- Hide french-name span if present on detail page (D3) --- */

.localeaf-plant-detail__french-name {
    display: none !important;
}

/* --- Hide theme-generated "Written by in" on single plant pages (D1) --- */

/* Classic themes */
.single-plant .entry-meta,
.single-plant .entry-subtitle,
.single-plant .flavor-subtitle,
.single-plant .ast-single-post-meta,
.single-plant .post-meta-wrapper {
    display: none !important;
}

/* Twenty Twenty-Five block theme: hidden-written-by pattern */
body.single-plant .wp-block-group.has-small-font-size {
    display: none !important;
}

/* --- Detail Page --- */

.localeaf-plant-detail {
    padding: 2rem 0;
}

/* Two-column layout: sidebar (image) + content */
.localeaf-plant-detail__columns {
    display: flex;
    gap: 2.5rem;
    align-items: flex-start;
}

.localeaf-plant-detail__sidebar {
    flex: 0 0 auto;
    width: 320px;
    max-width: 320px;
    position: sticky;
    top: 4rem;
}

.localeaf-plant-detail__content {
    flex: 1;
    min-width: 0;
}

@media (max-width: 768px) {
    .localeaf-plant-detail__columns {
        flex-direction: column;
        gap: 1.5rem;
    }

    .localeaf-plant-detail__sidebar {
        width: 100%;
        max-width: 400px;
        position: static;
    }
}

.localeaf-plant-detail__image {
    max-width: 100%;
    margin: 0 0 1rem;
}

.localeaf-plant-detail__image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.localeaf-plant-detail__image-placeholder {
    aspect-ratio: 2 / 3;
    background: #f0f0f0;
    border-radius: 8px;
}

.localeaf-plant-detail__gallery {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.localeaf-plant-detail__gallery-item {
    width: 120px;
    margin: 0;
}

.localeaf-plant-detail__gallery-item img {
    width: 100%;
    height: auto;
    border-radius: 6px;
}

/* --- Lightbox --- */

.localeaf-lightbox[open] {
    border: none;
    background: transparent;
    padding: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.localeaf-lightbox::backdrop {
    background: rgba(0, 0, 0, 0.8);
}

.localeaf-lightbox img {
    max-width: 85vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
}

.localeaf-lightbox__close {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.localeaf-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.4);
}

.localeaf-plant-detail__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.localeaf-plant-detail__title {
    margin: 0;
}

.localeaf-plant-detail__back {
    flex-shrink: 0;
}

.localeaf-plant-detail__back a {
    color: #2e7d32;
    text-decoration: none;
    white-space: nowrap;
}

.localeaf-plant-detail__back a:hover {
    text-decoration: underline;
}

.localeaf-plant-detail__latin {
    color: #666;
    margin-top: 0.25rem;
}

.localeaf-plant-detail__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.localeaf-plant-detail__section {
    margin-bottom: 2rem;
}

.localeaf-plant-detail__section h2 {
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.localeaf-plant-detail__dl {
    display: grid;
    grid-template-columns: minmax(120px, auto) 1fr;
    gap: 0.5rem 1rem;
}

.localeaf-plant-detail__dl dt {
    font-weight: 600;
    color: #555;
}

.localeaf-plant-detail__dl dd {
    margin: 0;
}

/* --- Empty State (no results) --- */

.localeaf-empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #555;
}

.localeaf-empty-state__message {
    font-size: 1.1em;
    margin: 0 0 1.25rem;
    line-height: 1.6;
}

.localeaf-empty-state__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.localeaf-empty__btn {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 0.5rem 1.25rem;
    font-size: inherit;
    font-family: inherit;
    cursor: pointer;
    color: #555;
    transition: border-color 0.15s, color 0.15s;
}

.localeaf-empty__btn:hover {
    border-color: #2e7d32;
    color: #2e7d32;
}

.localeaf-empty__btn--primary {
    background: #2e7d32;
    color: #fff;
    border-color: #2e7d32;
}

.localeaf-empty__btn--primary:hover {
    background: #1b5e20;
    border-color: #1b5e20;
    color: #fff;
}

/* --- Ecology Sub-sections (R1) --- */

.localeaf-ecology-subsection {
    margin-bottom: 1.5rem;
}

.localeaf-ecology-subsection:last-child {
    margin-bottom: 0;
}

.localeaf-ecology-subsection h4 {
    font-size: 0.85em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #2e7d32;
    margin: 0 0 0.75rem;
}

/* --- Responsive --- */

/* Tablet */
@media (max-width: 768px) {
    .localeaf-catalogue__grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .localeaf-catalogue__toolbar {
        flex-direction: column;
    }

    .localeaf-plant-detail__dl {
        grid-template-columns: 1fr;
    }

    .localeaf-plant-detail__dl dt {
        margin-top: 0.5rem;
    }

    .localeaf-catalogue__table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* #37/38: Prevent proximity label + dropdown from breaking viewport width */
    .localeaf-filter-group--inline {
        flex-wrap: wrap;
    }

    .localeaf-filter-group--inline label {
        white-space: normal;
    }

    .localeaf-filter-select,
    .localeaf-filter-group--inline select {
        max-width: 100%;
    }

    /* Controls bar: stack left/right on narrow screens */
    .localeaf-catalogue__controls-right {
        margin-left: 0;
        flex-wrap: wrap;
        width: 100%;
    }

    .localeaf-catalogue__controls {
        gap: 0.75rem;
    }
}

/* --- Toxicity Callout Box (D4) --- */

.localeaf-plant-detail__toxicity-callout {
    padding: 1.25rem 1.5rem;
    border-radius: 8px;
    border-left: 5px solid;
}

.localeaf-plant-detail__toxicity-callout--high {
    background: #fef2f2;
    border-left-color: #dc2626;
}

.localeaf-plant-detail__toxicity-callout--med {
    background: #fffbeb;
    border-left-color: #f59e0b;
}

.localeaf-plant-detail__toxicity-callout--low {
    background: #fefce8;
    border-left-color: #eab308;
}

.localeaf-plant-detail__toxicity-callout-header {
    margin-bottom: 0.5rem;
}

.localeaf-plant-detail__toxicity-callout-header .badge {
    font-size: 1em;
}

.localeaf-plant-detail__toxicity-callout-details {
    margin: 0;
    color: #333;
}

/* --- Toxicity Badges (10.1) --- */

.toxicity-badge--high {
    background: #dc2626;
    color: #fff;
}

.toxicity-badge--med {
    background: #f59e0b;
    color: #1a1a1a;
}

.toxicity-badge--low {
    background: #fbbf24;
    color: #1a1a1a;
}

/* --- Edibility Warning (10.2) --- */

.localeaf-plant-detail__warning {
    background: #fef2f2;
    border-left: 3px solid #dc2626;
    padding: 0.5rem 0.75rem;
    border-radius: 0 4px 4px 0;
    color: #991b1b;
}

/* Mobile */
@media (max-width: 480px) {
    .localeaf-catalogue__grid {
        grid-template-columns: 1fr;
    }

    .localeaf-legend__content {
        flex-direction: column;
        gap: 0.5rem;
    }

    .localeaf-filter-group__options {
        flex-direction: column;
    }
}
