/* AirLoop filter controls — inherits Divi design tokens where available */

/* Numbered pagination bar */
.al-pagination-numbered {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 24px;
    margin-bottom: 8px;
}

.al-page-btn {
    min-width: 36px;
    padding: 6px 10px;
    border: 1px solid var(--et-color-border, #ddd);
    background: var(--et-color-white, #fff);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
    color: inherit;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.al-page-btn:hover:not(:disabled) {
    background: var(--et-color-off-white, #f3f4f6);
    border-color: var(--et-color-primary, #2271b1);
}

.al-page-btn.al-page-current {
    background: var(--et-color-primary, #2271b1);
    color: #fff;
    border-color: var(--et-color-primary, #2271b1);
    cursor: default;
}

.al-page-btn.al-page-prev,
.al-page-btn.al-page-next {
    font-size: 18px;
    padding: 4px 10px;
}

.al-page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.al-page-ellipsis {
    padding: 6px 4px;
    line-height: 1.4;
    color: #888;
    pointer-events: none;
    user-select: none;
}

.airloop-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--et-gap-row, 14px) var(--et-gap-column, 14px);
    align-items: flex-end;
    margin-bottom: var(--et-gap-row, 20px);
}

/* The grey card framing only makes sense when there are text/date/number search
   inputs to group. A pills-only filter renders as a clean, label-less bar like
   the reference example — no card chrome. */
.airloop-filters:has(.airloop-filter-field:not(.airloop-filter-field--pills)) {
    padding: 18px 20px;
    background: var(--et-color-off-white, #f9fafb);
    border: 1px solid var(--et-color-border, #e5e7eb);
    border-radius: 10px;
}

/* Pills-only filter: lay out as one wrapping bar so boolean toggle pills flow
   together like the reference example. (When a non-pill search field is present,
   the grid layout above applies instead.) */
.airloop-filters:not(:has(.airloop-filter-field:not(.airloop-filter-field--pills))) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.airloop-filter-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 160px;
    width: 100%;
    box-sizing: border-box;
}

.airloop-filter-field label {
    font-family: var(--et-font-body, inherit);
    font-size: 11px;
    font-weight: 700;
    color: var(--et-color-body-text, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.airloop-filter-field input,
.airloop-filter-field select {
    font-family: var(--et-font-body, inherit);
    font-size: 13.5px;
    color: var(--et-color-body-text, #111827);
    background: var(--et-color-white, #fff);
    border: 1.5px solid var(--et-color-border, #e5e7eb);
    border-radius: 8px;
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
}

.airloop-filter-field input::placeholder {
    color: var(--et-color-body-text, #9ca3af);
    opacity: 1;
}

.airloop-filter-field input:focus,
.airloop-filter-field select:focus {
    border-color: var(--et-color-primary, #F95E00);
    outline: none;
    box-shadow:
        0 0 0 3px color-mix(in srgb, var(--et-color-primary, #F95E00) 15%, transparent),
        0 1px 3px rgba(0,0,0,0.06);
}

.airloop-filters--loading .airloop-filter-field input,
.airloop-filters--loading .airloop-filter-field select {
    opacity: 0.5;
    cursor: wait;
}

/* =======================================
   Pill filter controls
   Choice fields (select / checkbox) render as a row of pills instead of a
   dropdown. Self-contained styles here so the filter looks right even when
   the grid theme stylesheet (shortcode-themes.css) isn't loaded — e.g. the
   standalone Divi Filter Module.
   ======================================= */
.airloop-filter-field--pills {
    /* Multi-value pill bars read best full-width rather than squeezed into a grid
       column. Lay the field label inline, to the left of its pills.
       flex-direction:row is explicit because the base .airloop-filter-field rule
       sets column — without this the label stacks above the pills and centres. */
    grid-column: 1 / -1;
    flex: 1 1 100%;
    min-width: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 10px 14px;
}

/* Boolean toggle field: a single self-labelling pill that packs inline with its
   siblings, so several booleans render as one bar instead of stacked rows. */
.airloop-filter-field--toggle {
    grid-column: auto;
    flex: 0 0 auto;
    width: auto;
    gap: 0;
}

.airloop-pill-group-label {
    font-family: var(--et-font-body, inherit);
    font-size: 14px;
    font-weight: 600;
    color: var(--et-color-body-text, #374151);
    /* Reserve a consistent column so stacked filter rows line their pills up. */
    flex: 0 0 auto;
    min-width: 140px;
}

.al-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.al-filter-pills .al-filter-pill {
    font-family: var(--et-font-body, inherit);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    padding: 10px 18px;
    border: 1.5px solid var(--et-color-border, #e5e7eb);
    border-radius: 999px;
    /* --al-choice-bg/--al-choice-text are set inline per pill when the value
       matches an Airtable choice colour (select-colour-sync); theme colours
       remain the fallback when absent or the toggle is off. */
    background: var(--al-choice-bg, var(--et-color-white, #fff));
    color: var(--al-choice-text, var(--et-color-body-text, #374151));
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.al-filter-pills .al-filter-pill.is-active {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.al-filter-pills .al-filter-pill:hover {
    border-color: var(--et-color-primary, #F95E00);
    color: var(--et-color-primary, #F95E00);
}

.al-filter-pills .al-filter-pill.is-active {
    background: var(--et-color-primary, #F95E00);
    border-color: var(--et-color-primary, #F95E00);
    color: #fff;
}

.al-filter-pills .al-filter-pill:focus-visible {
    outline: 2px solid var(--et-color-primary, #F95E00);
    outline-offset: 2px;
}

/* Boolean toggle on/off colours. Booleans carry yes/no meaning, so the toggle
   gets its own semantic palette instead of inheriting the generic pill greys:
   off is a clearly neutral chip, on is the same green used by boolean yes
   badges (FieldRenderer::render_bool_badge). Scoped to --toggle so select-field
   pills keep their Airtable choice colours. */
.airloop-filter-field--toggle .al-filter-pill {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #6b7280;
}

.airloop-filter-field--toggle .al-filter-pill:hover {
    background: #e5e7eb;
    border-color: #16a34a;
    color: #166534;
}

.airloop-filter-field--toggle .al-filter-pill.is-active {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

.airloop-filter-field--toggle .al-filter-pill:focus-visible {
    outline-color: #16a34a;
}

.airloop-filters--loading .al-filter-pills .al-filter-pill {
    opacity: 0.5;
    cursor: wait;
}

/* =======================================
   Pro-locked placeholder
   ======================================= */
.airloop-pro-locked {
    font-size: 12.5px;
    color: var(--et-color-body-text, #6b7280);
    background: var(--et-color-off-white, #f9fafb);
    border: 1px dashed var(--et-color-border, #d1d5db);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 0;
    line-height: 1.5;
}

.airloop-pro-locked a {
    color: var(--et-color-primary, #F95E00);
    text-decoration: none;
    font-weight: 600;
}
.airloop-pro-locked a:hover {
    text-decoration: underline;
}

/* =======================================
   Custom Chevrons for Dropdowns
   ======================================= */
.al-select-wrapper {
    position: relative;
    width: 100%;
}
.al-select-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 34px !important;
    cursor: pointer;
}
.al-select-wrapper::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 6px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
    transition: transform 0.18s ease;
}

/* =======================================
   Clear Filters Button
   ======================================= */
.airloop-filter-actions {
    display: flex;
    align-items: flex-end;
}
.airloop-clear-filters {
    background: transparent;
    border: 1.5px solid var(--et-color-border, #e5e7eb);
    border-radius: 8px;
    color: var(--et-color-body-text, #374151);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease;
    width: 100%;
    height: 38px;
    box-sizing: border-box;
    letter-spacing: 0.01em;
}
.airloop-clear-filters:hover {
    background: var(--et-color-off-white, #f3f4f6);
    border-color: var(--et-color-primary, #F95E00);
    color: var(--et-color-primary, #F95E00);
}
.airloop-clear-filters:focus-visible {
    outline: 2px solid var(--et-color-primary, #F95E00);
    outline-offset: 2px;
}

/* =======================================
   Skeleton Shimmer Loading Placeholders
   ======================================= */
@keyframes al-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.al-skeleton-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 20px 0;
    width: 100%;
}
.al-skeleton-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    box-sizing: border-box;
    list-style: none;
}
.al-skeleton-media {
    width: 100%;
    aspect-ratio: 16/9;
    background: linear-gradient(90deg, #f3f4f6 25%, #fafafa 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: al-shimmer 1.6s ease-in-out infinite;
    border-radius: 6px;
    margin-bottom: 14px;
}
.al-skeleton-text {
    height: 13px;
    background: linear-gradient(90deg, #f3f4f6 25%, #fafafa 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: al-shimmer 1.6s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 9px;
}
.al-skeleton-text.al-skeleton-title {
    height: 19px;
    width: 65%;
    margin-bottom: 13px;
}
.al-skeleton-text.al-skeleton-desc {
    width: 90%;
}
.al-skeleton-text.al-skeleton-badge {
    height: 16px;
    width: 28%;
    display: inline-block;
    border-radius: 20px;
    margin-right: 6px;
}

@media (prefers-reduced-motion: reduce) {
    .al-skeleton-media,
    .al-skeleton-text {
        animation: none;
    }
}

/* =======================================
   Touch targets: ensure 44px min on coarse pointers
   ======================================= */
@media (pointer: coarse) {
    .airloop-filter-field input,
    .airloop-filter-field select,
    .airloop-clear-filters {
        min-height: 44px;
    }
    .al-filter-pills .al-filter-pill {
        min-height: 44px;
    }
}

/* -------------------------------------------------------------------------
 * Grid reflow (FLIP) — survivors glide to their new positions when a filter
 * changes the visible set, instead of jump-cutting. The `al-reflowing` class
 * is added to the .airloop-filtered-set wrapper by filters.js only for the
 * duration of the animation, so `will-change` is never permanently set.
 * Spec: openspec/changes/add-grid-reflow/specs/grid-reflow/spec.md
 * ------------------------------------------------------------------------- */
.airloop-filtered-set.al-reflowing [data-post-id],
.airloop-filtered-set.al-reflowing .airloop-record-item,
.al-reflowing > [data-post-id],
.al-reflowing > .airloop-record-item {
    transition: transform 250ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
    .al-reflowing [data-post-id],
    .al-reflowing .airloop-record-item {
        transition: none !important;
    }
}
