/* Resources - Frontend Styles v1.2.0 */

.nsr-resources-wrapper {
    --nsr-primary: #2563eb;
    --nsr-primary-hover: #1d4ed8;
    --nsr-text: #1f2937;
    --nsr-muted: #6b7280;
    --nsr-light: #9ca3af;
    --nsr-border: #e5e7eb;
    --nsr-bg: #f9fafb;
    --nsr-bg-hover: #f3f4f6;

    /* Search bar knobs — override these instead of writing page-specific CSS.
       Anywhere in Customizer → Additional CSS:

         .nsr-resources-wrapper {
             --nsr-search-bar-bg: #fff;    solid bar instead of transparent
             --nsr-search-bar-top: 88px;   clear a fixed theme header
         }

       No page ID and no !important needed — variables cascade past the
       theme's ID selectors because the declarations that consume them
       already carry !important. */
    --nsr-search-bar-bg: transparent;
    --nsr-search-bar-top: 0px;
    --nsr-search-bar-padding: 40px 0 30px;
    --nsr-search-input-padding: 18px 48px 18px 50px;
    --nsr-search-font-size: 1.2rem;
    --nsr-search-font-weight: 600;

    max-width: 960px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
    color: var(--nsr-text);
    line-height: 1.6;
}

/* ── Resource Count ── */

.nsr-resources-count {
    font-size: 0.9375rem;
    color: var(--nsr-muted);
    margin-bottom: 4px;
    text-align: center;
}

.nsr-resources-count strong {
    color: var(--nsr-text);
    font-weight: 700;
}

.nsr-resources-last-updated {
    font-size: 0.8125rem;
    color: var(--nsr-light);
    text-align: center;
    margin: 0 0 12px;
    font-style: italic;
}

/* ── Search Bar ──
   Themes style bare input/button elements from ID-rooted selectors
   (Enfold's "#top input[type=text]" is the usual offender), and an ID
   outranks any number of classes — which is why a class-only rule here
   would need a page-ID override to win.

   So these rules deliberately use the element ids the shortcode already
   emits (#nsr-search-bar / #nsr-search-input / #nsr-search-clear) rather
   than classes alone. That puts us at 1-1-1 against the theme's 1-0-1,
   and the !important flags mean we also win when the theme flags its own
   declarations — with two !importants, specificity breaks the tie.

   Layout properties are flagged; most colors are not, so a theme can
   still tint things to match. Because this depends on the ids, rendering
   two [nonstop_resources] shortcodes on one page duplicates them — the
   second search bar is styled but non-functional, since the JS binds by
   id too. One directory per page. */

.nsr-search-bar {
    position: sticky;
    top: var(--nsr-search-bar-top);
    z-index: 110;
    background: var(--nsr-search-bar-bg);
    padding: var(--nsr-search-bar-padding);
}

.nsr-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

#nsr-search-bar .nsr-search-icon {
    position: absolute;
    left: 18px;
    width: 18px !important;
    height: 18px !important;
    color: var(--nsr-primary);
    pointer-events: none;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.nsr-search-input-wrap:focus-within .nsr-search-icon {
    opacity: 1;
}

.nsr-resources-wrapper input#nsr-search-input {
    width: 100% !important;
    height: auto !important;
    padding: var(--nsr-search-input-padding) !important;
    margin: 0 !important;
    font-size: var(--nsr-search-font-size) !important;
    font-weight: var(--nsr-search-font-weight) !important;
    font-family: inherit !important;
    line-height: 1.4 !important;
    text-transform: none !important;
    color: var(--nsr-text);
    border: 1.5px solid var(--nsr-border) !important;
    border-radius: 50px !important;
    background: #fff !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02) !important;
    box-sizing: border-box !important;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.nsr-resources-wrapper input#nsr-search-input::placeholder {
    color: var(--nsr-light);
    font-weight: 400;
    opacity: 1;
}

.nsr-resources-wrapper input#nsr-search-input:focus {
    border-color: var(--nsr-primary) !important;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08), 0 2px 8px rgba(0,0,0,0.06) !important;
}

/* Note: no !important on `display` — the JS toggles this button between
   none and flex via inline style, and inline styles lose to !important. */
.nsr-search-clear {
    display: none;
}

.nsr-resources-wrapper button#nsr-search-clear {
    position: absolute;
    right: 14px;
    width: 26px !important;
    height: 26px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    align-items: center;
    justify-content: center;
    border: none !important;
    background: var(--nsr-bg) !important;
    color: var(--nsr-muted);
    border-radius: 50% !important;
    font-size: 1rem !important;
    font-family: inherit !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    text-shadow: none !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.15s;
    padding: 0 !important;
    margin: 0 !important;
}

.nsr-resources-wrapper button#nsr-search-clear:hover {
    background: var(--nsr-border) !important;
    color: var(--nsr-text);
    transform: scale(1.1);
}

.nsr-search-results-count {
    display: none;
    font-size: 0.8rem;
    color: var(--nsr-muted);
    text-align: center;
    margin-top: 8px;
    font-weight: 500;
}

/* ── Category Navigation — Wrapping Block ── */

.nsr-resources-nav {
    padding: 12px 0;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--nsr-border);
    line-height: 2;
}

.nsr-resources-nav a {
    color: var(--nsr-primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 2px 0;
    transition: color 0.2s;
}

.nsr-resources-nav a:hover,
.nsr-resources-nav a:focus {
    color: var(--nsr-primary-hover);
    text-decoration: underline;
}

.nsr-nav-sep {
    color: var(--nsr-light);
    margin: 0 6px;
    user-select: none;
}

/* ── Category Sections ── */

.nsr-category-section {
    margin-bottom: 32px;
    scroll-margin-top: 100px;
}

.nsr-category-heading {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--nsr-text);
    padding-bottom: 6px;
    border-bottom: 2px solid var(--nsr-primary);
    margin-bottom: 8px;
    scroll-margin-top: 100px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nsr-category-title-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nsr-category-description {
    font-size: 0.875rem;
    color: var(--nsr-muted);
    margin: 0 0 12px;
    line-height: 1.5;
    font-style: italic;
}

/* Category edit link — same hover pattern as resource edit */
.nsr-edit-cat {
    opacity: 0;
}

.nsr-category-heading:hover .nsr-edit-cat {
    opacity: 1;
}

.nsr-top-link {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--nsr-light);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border: 1px solid var(--nsr-border);
    border-radius: 4px;
    transition: all 0.2s;
}

.nsr-top-link:hover {
    color: var(--nsr-primary);
    border-color: var(--nsr-primary);
}

/* ── Resources List — Compact Single-Line ── */

.nsr-resources-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nsr-resource-item {
    padding: 4px 0;
    border-bottom: 1px solid transparent;
    line-height: 1.7;
    transition: background 0.15s;
}

.nsr-resource-item:hover {
    background: var(--nsr-bg);
}

/* The main single line */
.nsr-resource-line {
    display: flex;
    align-items: baseline;
    gap: 0;
    flex-wrap: wrap;
}

/* Expand arrow — inline after links, chevron down/up */
.nsr-expand-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin-left: 6px;
    border: none;
    background: none;
    color: var(--nsr-light);
    cursor: pointer;
    transition: color 0.2s;
    vertical-align: middle;
}

.nsr-expand-btn:hover {
    color: var(--nsr-primary);
}

.nsr-expand-arrow {
    transition: transform 0.2s ease;
}

.nsr-resource-item.nsr-expanded .nsr-expand-arrow {
    transform: rotate(180deg);
}

/* Admin edit link — only visible when logged in */
.nsr-edit-link {
    display: inline-flex;
    align-items: center;
    margin-left: 5px;
    color: var(--nsr-light);
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    vertical-align: middle;
    text-decoration: none;
}

.nsr-resource-item:hover .nsr-edit-link {
    opacity: 1;
}

.nsr-edit-link:hover {
    color: var(--nsr-primary);
}

/* Resource name */
.nsr-resource-name {
    font-weight: 600;
    font-size: 0.9375rem;
}

.nsr-resource-name a {
    color: var(--nsr-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.nsr-resource-name a:hover {
    color: var(--nsr-primary-hover);
    text-decoration: underline;
}

/* ── Badges ── */

.nsr-badge-type,
.nsr-badge-cost,
.nsr-badge-inactive {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0 6px;
    border-radius: 8px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Resource type badge */
.nsr-badge-type {
    color: #6d28d9;
    background: #ede9fe;
}

/* Cost badges */
.nsr-badge-cost {
    color: #374151;
    background: #e5e7eb;
}

.nsr-badge-cost-free {
    color: #15803d;
    background: #dcfce7;
}

.nsr-badge-cost-freemium {
    color: #0e7490;
    background: #cffafe;
}

.nsr-badge-cost-paid {
    color: #9a3412;
    background: #ffedd5;
}

/* Inactive badge */
.nsr-badge-inactive {
    color: #b45309;
    background: #fef3c7;
}

/* Inline text links after the title */
.nsr-inline-links {
    margin-left: 6px;
    font-size: 0.8125rem;
}

.nsr-inline-links a {
    color: var(--nsr-primary);
    text-decoration: none;
    transition: color 0.15s;
}

.nsr-inline-links a:hover {
    color: var(--nsr-primary-hover);
    text-decoration: underline;
}

.nsr-link-sep {
    color: var(--nsr-light);
    margin: 0 4px;
    user-select: none;
}

/* ── Expandable Details Panel ── */

.nsr-resource-details {
    padding: 6px 0 8px 24px;
    font-size: 0.85rem;
    color: var(--nsr-muted);
    border-left: 2px solid var(--nsr-border);
    margin-left: 8px;
    margin-top: 2px;
}

/* Details panel hidden by default via inline style="display:none",
   toggled to display:block by JS on click. */

.nsr-resource-details p {
    margin: 2px 0;
    line-height: 1.5;
}

.nsr-resource-description {
    color: var(--nsr-text);
    margin-bottom: 4px !important;
}

.nsr-resource-provider {
    font-size: 0.8125rem;
    color: var(--nsr-muted);
}

/* ── Inactive Resource ── */

.nsr-resource-inactive {
    opacity: 0.5;
}

/* ── Section/item hidden by search ── */

.nsr-category-section.nsr-section-hidden {
    display: none;
}

.nsr-resource-item.nsr-card-hidden {
    display: none;
}

/* ── Responsive ── */

@media (max-width: 640px) {
    /* Scale the search field down by redefining the variables. Overriding
       the declarations directly wouldn't work — they carry !important, and
       a plain rule in a media query loses to an !important rule regardless
       of source order. */
    .nsr-resources-wrapper {
        padding: 0 12px;

        --nsr-search-bar-padding: 24px 0 18px;
        --nsr-search-input-padding: 14px 44px 14px 46px;
        --nsr-search-font-size: 1rem;
    }

    .nsr-search-input-wrap {
        max-width: 100%;
    }

    .nsr-resources-nav {
        padding: 8px 0;
        line-height: 1.9;
    }

    .nsr-resources-nav a {
        font-size: 0.8125rem;
    }

    .nsr-nav-sep {
        margin: 0 4px;
    }

    .nsr-category-heading {
        font-size: 1.05rem;
        scroll-margin-top: 80px;
    }

    .nsr-category-section {
        scroll-margin-top: 80px;
    }

    .nsr-resource-name {
        font-size: 0.875rem;
    }

    .nsr-inline-links {
        font-size: 0.75rem;
    }

    .nsr-resource-details {
        padding-left: 16px;
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}
