/* ══ Results archive ══ */
.nml-ra {
    padding: 0 0 80px;
    background: var(--color-bg);
    margin-top: 76px;
}

.nml-ra__heading {
    margin: 0 0 72px;
    text-align: center;
    background-color: #F5F6FA;
    padding: 72px 0;
    border-bottom: 1px solid var(--color-line);
    font-size: 56px;
    line-height: 64px;
    font-weight: 700;
}

.nml-ra__layout {
    display: grid;
    grid-template-columns: 307px 1fr;
    align-items: start;
    gap: 102px;
}

.nml-ra__sidebar {
    position: sticky;
    top: 100px;
}

.nml-ra__sidebar-title {
    margin: 0 0 24px;
    color: var(--color-text-primary);
    font-size: 32px;
    line-height: 40px;
    font-weight: 700;
}

/* Promo banner under the category list. */
.nml-ra__sidebar-banner {
    display: block;
    margin-top: 40px;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0px 2px 4px 0px #4C83F33D;
}

.nml-ra__sidebar-banner img {
    display: block;
    width: 100%;
    height: auto;
}

/* ── Category list (shared look with .nml-ba__cats) ── */
.nml-ra .nml-ba__cats {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.nml-ra .nml-ba__cat-item {
    border-bottom: 2px solid #D5DAFA;
}

.nml-ra .nml-ba__cat-item:first-child {
    border-top: 2px solid transparent;
}

.nml-ra .nml-ba__cat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 20px 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 26px;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-align: left;
    transition: all 0.3s;
}

.nml-ra .nml-ba__cat-item:hover .nml-ba__cat-btn {
    color: var(--color-text-primary);
}

.nml-ra .nml-ba__cat-item:hover {
    border-bottom: 2px solid #889CF1;
}

.nml-ra .nml-ba__cat-btn--active {
    border-bottom: 2px solid #FF4171;
    font-weight: 700;
}

.nml-ra .nml-ba__cat-btn--active:hover {
    border-bottom: 2px solid #F1005B;
}

.nml-ra .nml-ba__cat-dot {
    display: none;
    width: 8px;
    height: 8px;
    margin: 8px;
    border-radius: 50%;
    background: #FF4171;
    flex-shrink: 0;
}

.nml-ra .nml-ba__cat-btn--active .nml-ba__cat-dot {
    display: block;
}

.nml-ra .nml-ba__cat-item:has(.nml-ba__cat-btn--active) {
    border-bottom-color: #F1005B;
}

.nml-ra__cat-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ── Filter bar ── */
.nml-ra__filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
}

.nml-ra__select {
    position: relative;
    flex: 1;
}

.nml-ra__select-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 180px;
    padding: 10px 12px;
    background: #FFFFFF;
    border: 1px solid var(--color-line);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    line-height: 20px;
    font-weight: 400;
    color: var(--color-text-tertiary);
    transition: all 0.2s;
    width: 100%;
}

.nml-ra__select-btn:hover {
    border-color: #889CF1;
}

.nml-ra__select.is-open .nml-ra__select-btn,
.nml-ra__select--active .nml-ra__select-btn {
    border-color: #6281EC;
}

.nml-ra__select-icon {
    flex-shrink: 0;
}

.nml-ra__select-label {
    flex: 1;
    text-align: left;
}

.nml-ra__select-count {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 99px;
    background: #FF4171;
    color: #FFFFFF;
    font-size: 12px;
    font-weight: 700;
}

.nml-ra__select-chevron {
    flex-shrink: 0;
    transition: transform 0.2s;
}

.nml-ra__select.is-open .nml-ra__select-chevron {
    transform: rotate(180deg);
}

.nml-ra__dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    min-width: 100%;
    max-height: 280px;
    overflow-y: auto;
    margin: 0;
    padding: 8px;
    list-style: none;
    background: #FFFFFF;
    border: 1px solid #D5DAFA;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(11, 16, 31, 0.12);
}

.nml-ra__select.is-open .nml-ra__dropdown {
    display: block;
}

.nml-ra__option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
    color: #303D60;
    white-space: nowrap;
    transition: background 0.2s;
}

.nml-ra__option:hover {
    background: rgba(22, 47, 111, 0.06);
}

.nml-ra__option--empty {
    color: #889CF1;
    cursor: default;
}

.nml-ra__option-box {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #D5DAFA;
    border-radius: 4px;
    background: var(--color-bg);
    transition: all 0.2s;
}

.nml-ra__option-box svg {
    opacity: 0;
    transition: opacity 0.2s;
}

.nml-ra__option--selected .nml-ra__option-box {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.nml-ra__option--selected .nml-ra__option-box svg {
    opacity: 1;
}

.nml-ra__reset {
    margin-left: auto;
    padding: 10px 11px;
    background: #FFFFFF;
    border: 1px solid #162F6F;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    line-height: 20px;
    font-weight: 700;
    color: #162F6F;
    transition: all 0.2s;
    flex: 1;
    max-width: 114px;
}

.nml-ra__reset:hover {
    background: #F5F6FA;
    border-color: #0F204D;
}

/* ── Selected filter chips ── */
/* Desktop: chips live inside the filter bar, wrapping below the selects. */
.nml-ra__chips {
    order: 10;
    flex-basis: 100%;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nml-ra__chips[hidden] {
    display: none;
}

.nml-ra__chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: #162F6F0A;
    border: 1px solid var(--color-line-blue);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    color: var(--color-text-primary);
    transition: all 0.2s;
}

.nml-ra__chip:hover {
    background: #EEF0FD;
    border-color: #889CF1;
}

.nml-ra__chip svg {
    flex-shrink: 0;
    color: #868686;
    width: 18px;
    height: 18px;
}

/* ── Cards ── */
.nml-ra__grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Empty state (no results) ── */
.nml-ra__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 32px 40px;
    background: #FFFFFF;
    border: 1px solid var(--color-line);
    border-radius: 12px;
    max-width: 594px;
    margin: 0 auto;
    width: 100%;
    box-shadow: 0px 1px 2px 0px #4C83F333;
}

.nml-ra__empty-title {
    margin: 0 0 12px;
    font-size: 32px;
    line-height: 40px;
    font-weight: 700;
    color: var(--color-text-primary);
}

.nml-ra__empty-text {
    margin: 0 0 24px;
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.nml-ra__empty-reset {
    border: 1px solid var(--color-primary);
    padding: 10px 24px;
    font-size: 14px;
    line-height: 20px;
    font-weight: 700;
    border-radius: 8px;
}

@media (max-width: 600px) {
    .nml-ra__empty {
        padding: 40px 16px;
    }
    .nml-ra__empty-title {
        font-size: 24px;
        line-height: 32px;
    }
}

.nml-ra__card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 24px;
    background: var(--color-bg);
    border-radius: 8px;
    transition: border-color 0.2s;
    border: 1px solid var(--color-line);
    box-shadow: 0px 1px 2px 0px #4C83F333;
}

.nml-ra__card--open {
    border-color: #889CF1;
}

/* Desktop visual order: head, body, tags (see-example floats top-right). */
.nml-ra__card-body { order: 1; }
.nml-ra__card-tags { order: 2; }

.nml-ra__card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.nml-ra__card-title {
    margin: 0;
    font-size: 24px;
    line-height: 32px;
    font-weight: 700;
    color: var(--color-text-primary);
    padding-right: 140px; /* room for the floating See Example button */
}

.nml-ra__see-example {
    position: absolute;
    top: 20px;
    right: 24px;
    z-index: 2;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--color-primary);
    border: 1px solid var(--color-primary-dark);
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    line-height: 16px;
    font-weight: 700;
    color: var(--color-text-white);
    white-space: nowrap;
    transition: all 0.2s;
}

.nml-ra__see-example:hover {
    background: #0F204D;
}

.nml-ra__see-example-chevron {
    transform: rotate(180deg);
    transition: transform 0.2s;
}

.nml-ra__see-example[aria-expanded="true"] .nml-ra__see-example-chevron {
    transform: rotate(0);
}

.nml-ra__card-body {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* override .nml-ra__card-body display:flex so [hidden] actually hides it */
.nml-ra__card-body[hidden] {
    display: none;
}

.nml-ra__card-image {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    background: none;
    border: none;
    border-radius: 8px;
    overflow: hidden;
}

.nml-ra__card-image::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 258px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #FFFFFF 77.14%);
    border-radius: 0 0 8px 8px;
    pointer-events: none;
    z-index: 0;
}

.nml-ra__card-image img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--color-line);
}

/* Loupe button centered over the preview image — mobile only. */
.nml-ra__card-zoom {
    display: none; /* shown on mobile */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(11, 16, 31, 0.72);
    color: #FFFFFF;
    cursor: zoom-in;
    z-index: 1;
    transition: background 0.2s, transform 0.2s;
}

.nml-ra__card-zoom:hover {
    background: #0B101F;
    transform: translate(-50%, -50%) scale(1.06);
}

.nml-ra__card-content {
    overflow-x: auto;
}

/* Action buttons overlaid on the bottom-right of the body (over image/content) */
.nml-ra__card-actions {
    position: absolute;
    right: 20px;
    bottom: 20px;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
}

.nml-ra__card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nml-ra__tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid #000000;
    border-radius: 8px;
    font-size: 12px;
    line-height: 16px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.nml-ra__tag-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ── Load more ── */
.nml-ra__load-more-wrap {
    display: flex;
    justify-content: center;
    margin-top: 32px;
}

/* hide the wrap when there are 8 or fewer cards (overrides display:flex) */
.nml-ra__load-more-wrap[hidden] {
    display: none;
}

.nml-ra__load-more {
    padding: 12px 32px;
    border: 1px solid var(--color-line);
    background: #162F6F0A;
    gap: 8px;
    font-size: 16px;
    line-height: 24px;
    font-weight: 700;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* spin the icon while loading (button is disabled during the fetch) */
.nml-ra__load-more svg {
    transform-origin: center;
}

.nml-ra__load-more:disabled svg {
    animation: nml-ra-spin 0.7s linear infinite;
}

@keyframes nml-ra-spin {
    to { transform: rotate(360deg); }
}

/* Mobile-only filter chrome — hidden on desktop. */
.nml-ra__filter-trigger,
.nml-ra__filters-head,
.nml-ra__filters-foot,
.nml-ra__filters-overlay {
    display: none;
}

/* ── Image preview popup ── */
.nml-ra__modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.nml-ra__modal.is-open {
    display: flex;
}

.nml-ra__modal-overlay {
    position: absolute;
    inset: 0;
    background: #06080BB8;
    backdrop-filter: blur(10px);
}

.nml-ra__modal-dialog {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    background: #FFFFFF;
    padding: 20px 16px;
    border-radius: 12px;
    border: 1px solid var(--color-line);
    box-shadow: 0px 6px 12px 0px #0D0D0D33;
}

.nml-ra__modal-close {
    position: absolute;
    top: 20px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
}

.nml-ra__modal-title {
    margin: 0 40px 15px 0;
    font-size: 24px;
    line-height: 32px;
    font-weight: 700;
    color: #0B101F;
}

.nml-ra__modal-image {
    margin: 0 0 16px;
}

.nml-ra__modal-image img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid #E3E7F4;
}

.nml-ra__modal-actions {
    position: static; /* override .nml-ra__card-actions absolute overlay */
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nml-ra__modal-actions .btn-primary,
.nml-ra__modal-actions .btn-outlined {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

/* ── Responsive ── */
@media (max-width: 991px) {
    .nml-ra {
        margin-top: 62px;
    }

    .nml-ra__layout {
        grid-template-columns: 1fr;
        gap: 32px;
    }
    /* Hide the category sidebar on mobile — show posts from all categories. */
    .nml-ra__sidebar {
        display: none;
    }

    /* ── Card reflow: title → tags → See Example → body ── */
    .nml-ra__card-title {
        padding-right: 0;
    }
    .nml-ra__card-head { order: 0; }
    .nml-ra__card-tags { order: 1; }
    .nml-ra__see-example {
        order: 2;
        position: static;
        top: auto;
        right: auto;
        width: 100%;
        padding: 12px 16px;
        font-size: 14px;
        line-height: 20px;
    }
    .nml-ra__card-body { order: 3; }

    /* Show the loupe; the buttons move into the popup instead of the overlay. */
    .nml-ra__card-zoom {
        display: flex;
    }
    .nml-ra__card-body .nml-ra__card-actions {
        display: none;
    }

    .nml-ra__heading {
        margin: 0 0 32px;
        padding: 32px 0;
        font-size: 40px;
        line-height: 48px;
    }

    /* Mobile "Filters" trigger button. */
    .nml-ra__filter-trigger {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        width: 100%;
        margin: 0;
        padding: 12px;
        background: var(--color-primary);
        border: 1px solid var(--color-primary-dark);
        border-radius: 8px;
        cursor: pointer;
        font-size: 14px;
        line-height: 20px;
        font-weight: 700;
        color: #FFFFFF;
        margin-bottom: 32px;
    }

    /* Overlay behind the drawer. */
    .nml-ra__filters-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1001;
        background: rgba(11, 16, 31, 0.48);
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    .nml-ra__filters-overlay.is-open {
        opacity: 1;
        pointer-events: auto;
    }

    /* The filter bar becomes a bottom drawer. */
    .nml-ra__filters {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 1002;
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        max-height: 88dvh;
        overflow-y: auto;
        margin: 0;
        padding: 0 20px calc(20px + env(safe-area-inset-bottom, 0));
        background: #FFFFFF;
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -8px 32px rgba(11, 16, 31, 0.18);
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    }
    .nml-ra__filters.is-open {
        transform: translateY(0);
    }

    /* Drawer header (handle + close + title). */
    .nml-ra__filters-head {
        display: flex;
        align-items: center;
        justify-content: center;
        position: sticky;
        top: 0;
        z-index: 1;
        margin: 0 -20px;
        padding: 28px 20px 0px;
        background: #FFFFFF;
        border-radius: 12px 12px 0 0;
        border: 1px solid var(--color-line);
        border-bottom: none;
    }
    .nml-ra__filters-head::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: #D5DAFA;
        border-radius: 99px;
    }
    .nml-ra__filters-title {
        font-size: 18px;
        line-height: 26px;
        font-weight: 700;
        color: #0B101F;
    }
    .nml-ra__filters-close {
        position: absolute;
        left: 20px;
        top: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        padding: 0;
        background: none;
        border: none;
        color: #303D60;
        cursor: pointer;
    }

    /* Clear button (top-right of the drawer header). */
    .nml-ra__filters-clear {
        position: absolute;
        right: 20px;
        top: 24px;
        padding: 0;
        background: none;
        border: none;
        font-size: 16px;
        line-height: 24px;
        font-weight: 700;
        color: var(--color-primary);
        cursor: pointer;
    }

    /* Chips inside the drawer — under the header, above the selects. */
    .nml-ra__chips {
        order: 0;
        margin: 0;
    }

    /* Selects fill the drawer width. */
    .nml-ra__select,
    .nml-ra__select-btn {
        width: 100%;
    }
    .nml-ra__dropdown {
        position: static;
        box-shadow: none;
        border: none;
        padding: 4px 0 0;
        max-height: 240px;
    }

    /* Hide the desktop reset; the drawer uses Cancel / Apply. */
    .nml-ra__reset {
        display: none;
    }

    /* Drawer footer. */
    .nml-ra__filters-foot {
        display: flex;
        gap: 12px;
        position: sticky;
        bottom: 0;
        margin: 0 -20px;
        padding: 16px 20px;
        background: #FFFFFF;
        border-top: 1px solid #D5DAFA;
    }
    .nml-ra__filters-cancel,
    .nml-ra__filters-apply {
        flex: 1;
        padding: 14px 20px;
        border-radius: 8px;
        cursor: pointer;
        font-size: 15px;
        line-height: 20px;
        font-weight: 700;
        transition: all 0.2s;
    }
    .nml-ra__filters-cancel {
        background: rgba(22, 47, 111, 0.04);
        border: 1px solid #D5DAFA;
        color: #162F6F;
    }
    .nml-ra__filters-apply {
        background: #162F6F;
        border: 1px solid #0F204D;
        color: #FFFFFF;
    }

    .nml-ra__chip {
        padding: 8px;
        border-radius: 4px;
        font-size: 12px;
        line-height: 16px;
    }
}

@media (max-width: 600px) {
    .nml-ra__card {
        padding: 16px 20px;
    }

    .nml-ra__modal-title {
        font-size: 18px;
        line-height: 26px;
    }
}
