/**
 * FBMP Repository: listing, category pages, and password screens.
 * Metal America UI kit: warm canvas, flat white cards, pill controls,
 * dark pill for the active state, red only for the primary action.
 * The build photos carry the color, so the chrome around them stays quiet.
 * Loaded by fbmp_enqueue_repository_assets() in inc/fbmp-styles.php.
 */

.fbmp-repo {
    --fr-red: #FF2400;
    --fr-red-hover: #e02000;
    --fr-red-text: #d42000;
    --fr-tint: #fff8f6;
    --fr-tint-badge: #fff0ed;
    --fr-canvas: #faf9f7;
    --fr-900: #171717;
    --fr-800: #262626;
    --fr-700: #404040;
    --fr-600: #525252;
    --fr-500: #737373;
    --fr-300: #d4d4d4;
    --fr-100: #f5f5f5;
    --fr-border: rgba(229, 229, 229, 0.8);
    --fr-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    --fr-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --fr-fast: 160ms;

    /* One step under the UI kit's 16 / 12 / 24, at Logan's request */
    --fr-radius-card: 12px;
    --fr-radius-inner: 8px;
    --fr-radius-sheet: 16px;

    color-scheme: light;
    background: var(--fr-canvas);
    color: var(--fr-900);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    padding: 32px 0 96px;
}

.fbmp-repo *,
.fbmp-repo *::before,
.fbmp-repo *::after {
    box-sizing: border-box;
}

/* Same width and gutter as the site header, so the title lines up with the logo */
.fbmp-repo-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

.fbmp-repo .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Header ---------- */

.fbmp-repo-header {
    min-height: 0; /* main.css reserves 80px on every <header> for the site header */
    margin: 0 0 24px;
}

.fbmp-repo-title {
    margin: 0;
    font-family: inherit;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-transform: none;
    color: var(--fr-900);
}

.fbmp-repo-subtitle {
    margin: 4px 0 0;
    font-size: 15px;
    line-height: 1.5;
    color: var(--fr-500);
}

/* ---------- Category pills ---------- */

.fbmp-repo-filters {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 24px;
    padding: 4px;
    border: 1px solid var(--fr-border);
    border-radius: var(--fr-radius-card);
    background: #fff;
    box-shadow: var(--fr-shadow);
}

.fbmp-repo-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 999px;
    color: var(--fr-600);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color var(--fr-fast) var(--fr-ease), color var(--fr-fast) var(--fr-ease);
}

.fbmp-repo-pill:hover,
.fbmp-repo-pill:focus {
    background: var(--fr-100);
    color: var(--fr-900);
    text-decoration: none;
}

.fbmp-repo-pill.is-active,
.fbmp-repo-pill.is-active:hover {
    background: var(--fr-900);
    color: #fff;
}

.fbmp-repo-pill svg {
    flex: none;
}

/* Shells have their own password, so they sit apart from the open categories */
.fbmp-repo-pill.is-shells {
    margin-left: auto;
}

/* Locked Barndominium Shells pill: certification tooltip (opened by the template's script) */
.fbmp-repo-pill.is-locked {
    position: relative;
}

.fbmp-repo-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 20;
    display: none;
    width: max-content;
    max-width: 260px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--fr-900);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    text-align: left;
    white-space: normal;
    pointer-events: none;
}

.fbmp-repo-pill.is-tip-open .fbmp-repo-tooltip {
    display: block;
}

/* ---------- Locked shells popup (phones) ---------- */

.fbmp-repo-dialog {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: var(--fr-radius-sheet) var(--fr-radius-sheet) 0 0;
    background: #fff;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    color: var(--fr-900);
    font-family: inherit;
    text-align: center;
}

.fbmp-repo-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.fbmp-repo-dialog-title {
    margin: 0 0 6px;
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    text-transform: none;
    color: var(--fr-900);
}

.fbmp-repo-dialog p {
    margin: 0;
    color: var(--fr-700);
    font-size: 15px;
    line-height: 1.5;
}

.fbmp-repo-dialog-actions {
    display: grid;
    gap: 8px;
    margin-top: 20px;
}

.fbmp-repo-dialog-actions .fbmp-repo-btn {
    width: 100%;
    min-height: 44px;
    padding: 12px 24px;
    font-size: 16px;
}

@media (min-width: 600px) {
    .fbmp-repo-dialog {
        max-width: 420px;
        margin: auto;
        border-radius: var(--fr-radius-sheet);
    }
}

/* ---------- Category dropdown (phones only, see breakpoints) ---------- */

.fbmp-repo-select-wrap {
    display: none;
    margin: 0 0 16px;
}

.fbmp-repo-select {
    display: block;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 10px 40px 10px 14px;
    border: 1px solid var(--fr-300);
    border-radius: var(--fr-radius-inner);
    outline: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23171717' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 14px center;
    box-shadow: none;
    color: var(--fr-900);
    font-family: inherit;
    font-size: 16px; /* 16px keeps iOS from zooming in on focus */
    font-weight: 600;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: border-color var(--fr-fast) var(--fr-ease), box-shadow var(--fr-fast) var(--fr-ease);
}

.fbmp-repo-select:focus {
    border-color: var(--fr-900);
    box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.1);
}

/* ---------- Restricted notice (shells) ---------- */

.fbmp-repo-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 20px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 36, 0, 0.3);
    border-radius: var(--fr-radius-card);
    background: var(--fr-tint);
    color: var(--fr-700);
    font-size: 14px;
    line-height: 1.5;
}

.fbmp-repo-notice svg {
    flex: none;
    margin-top: 2px;
    color: var(--fr-red-text);
}

.fbmp-repo-notice p {
    margin: 0;
}

.fbmp-repo-notice strong {
    color: var(--fr-red-text);
}

/* ---------- Count + pagination ---------- */

.fbmp-repo-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 16px;
}

.fbmp-repo-count {
    margin: 0;
    font-size: 14px;
    color: var(--fr-500);
    font-variant-numeric: tabular-nums;
}

.fbmp-repo-count strong {
    font-weight: 600;
    color: var(--fr-900);
}

.fbmp-repo-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.fbmp-repo-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 999px;
    color: var(--fr-700);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
    transition: background-color var(--fr-fast) var(--fr-ease), color var(--fr-fast) var(--fr-ease);
}

.fbmp-repo-pagination a.page-numbers:hover {
    background: var(--fr-100);
    color: var(--fr-900);
}

.fbmp-repo-pagination .page-numbers.current {
    background: var(--fr-900);
    color: #fff;
}

.fbmp-repo-pagination .page-numbers.dots {
    min-width: 24px;
    padding: 0;
    color: var(--fr-500);
}

.fbmp-repo-pagination-bottom {
    justify-content: center;
    margin-top: 32px;
}

/* ---------- Build cards ---------- */

.fbmp-repo-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.fbmp-repo-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--fr-border);
    border-radius: var(--fr-radius-card);
    background: #fff;
    box-shadow: var(--fr-shadow);
    color: var(--fr-900);
    text-decoration: none;
    transition: border-color var(--fr-fast) var(--fr-ease);
}

.fbmp-repo-card:hover,
.fbmp-repo-card:focus {
    border-color: var(--fr-900);
    color: var(--fr-900);
    text-decoration: none;
}

.fbmp-repo-card-media {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--fr-100);
}

.fbmp-repo-card-media img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
}

.fbmp-repo-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--fr-tint-badge);
    color: var(--fr-red-text);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
}

.fbmp-repo-card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    padding: 20px;
}

.fbmp-repo-card-type {
    color: var(--fr-500);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
}

.fbmp-repo-card-title {
    margin: 0;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: normal;
    text-transform: none;
    color: var(--fr-900);
}

/* The dimension line anchors to the card's foot, so it lines up across a row
   even when one title wraps to two lines. */
.fbmp-repo-card-meta {
    margin: auto 0 0;
    color: var(--fr-500);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.fbmp-repo-card-link {
    margin-top: auto;
    padding-top: 12px;
    color: var(--fr-700);
    font-size: 13px;
    font-weight: 600;
    transition: color var(--fr-fast) var(--fr-ease);
}

.fbmp-repo-card-meta + .fbmp-repo-card-link {
    margin-top: 0;
}

/* The grid stays quiet at rest. Red arrives on the card you are pointing at. */
.fbmp-repo-card:hover .fbmp-repo-card-link,
.fbmp-repo-card:focus-visible .fbmp-repo-card-link {
    color: var(--fr-red-text);
}

/* ---------- Empty state ---------- */

.fbmp-repo-empty {
    grid-column: 1 / -1;
    padding: 56px 24px;
    border: 1px solid var(--fr-border);
    border-radius: var(--fr-radius-card);
    background: #fff;
    box-shadow: var(--fr-shadow);
    text-align: center;
}

.fbmp-repo-empty img {
    display: block;
    width: 64px;
    height: 64px;
    margin: 0 auto 12px;
    object-fit: contain;
    opacity: 0.8;
}

.fbmp-repo-empty-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.fbmp-repo-empty-text {
    margin: 4px 0 0;
    color: var(--fr-500);
    font-size: 14px;
}

/* ---------- Password screen ---------- */

.fbmp-repo.fbmp-repo-gate {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 48px 16px 96px;
}

.fbmp-repo-gate-card {
    width: 100%;
    max-width: 384px;
    padding: 28px;
    border: 1px solid var(--fr-border);
    border-radius: var(--fr-radius-card);
    background: #fff;
    box-shadow: var(--fr-shadow);
}

.fbmp-repo-gate-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    border-radius: 999px;
    background: var(--fr-100);
    color: var(--fr-900);
}

.fbmp-repo-gate-icon svg {
    width: 20px;
    height: 20px;
}

.fbmp-repo-gate-title {
    margin: 0;
    font-family: inherit;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    text-align: center;
    text-transform: none;
    color: var(--fr-900);
}

.fbmp-repo-gate-subtitle {
    margin: 4px 0 24px;
    color: var(--fr-500);
    font-size: 15px;
    line-height: 1.5;
    text-align: center;
}

.fbmp-repo-gate-form {
    margin: 0;
}

.fbmp-repo-label {
    display: block;
    margin: 0 0 6px;
    color: var(--fr-800);
    font-size: 13px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
}

.fbmp-repo-input {
    display: block;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 10px 14px;
    border: 1px solid var(--fr-300);
    border-radius: var(--fr-radius-inner);
    outline: none;
    background: #fff;
    box-shadow: none;
    color: var(--fr-900);
    font-family: inherit;
    font-size: 16px; /* 16px keeps iOS from zooming in on focus */
    transition: border-color var(--fr-fast) var(--fr-ease), box-shadow var(--fr-fast) var(--fr-ease);
}

.fbmp-repo-input:focus {
    border-color: var(--fr-900);
    box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.1);
}

.fbmp-repo-gate-error {
    margin: 8px 0 0;
    color: var(--fr-red-text);
    font-size: 13px;
    font-weight: 500;
}

.fbmp-repo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    letter-spacing: normal;
    line-height: 1.2;
    text-transform: none;
    transition: background-color var(--fr-fast) var(--fr-ease);
}

.fbmp-repo-btn-primary {
    padding: 12px 24px;
    background: var(--fr-red);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    color: #fff;
    font-size: 16px;
    text-decoration: none;
}

.fbmp-repo-btn-primary:hover,
.fbmp-repo-btn-primary:focus {
    background: var(--fr-red-hover);
    color: #fff;
    text-decoration: none;
}

.fbmp-repo-btn-secondary {
    border: 1px solid var(--fr-300);
    background: #fff;
    color: var(--fr-900);
    text-decoration: none;
    transition: border-color var(--fr-fast) var(--fr-ease), color var(--fr-fast) var(--fr-ease);
}

.fbmp-repo-btn-secondary:hover,
.fbmp-repo-btn-secondary:focus {
    border-color: var(--fr-900);
    background: #fff;
    color: var(--fr-900);
    text-decoration: none;
}

/* Copy buttons turn green for a moment after copying */
.fbmp-repo-btn-secondary.is-done {
    border-color: #15803D;
    color: #15803D;
}

.fbmp-repo-btn-sm {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 14px;
}

.fbmp-repo-gate-form .fbmp-repo-btn {
    width: 100%;
    margin-top: 16px;
}

.fbmp-repo-gate-note {
    margin: 16px 0 0;
    color: var(--fr-500);
    font-size: 13px;
    text-align: center;
}

/* ---------- Focus + motion ---------- */

.fbmp-repo-pill:focus-visible,
.fbmp-repo-card:focus-visible,
.fbmp-repo-pagination a:focus-visible,
.fbmp-repo-btn:focus-visible {
    outline: 2px solid var(--fr-900);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .fbmp-repo *,
    .fbmp-repo *::before,
    .fbmp-repo *::after {
        transition: none !important;
    }
}

/* ---------- Breakpoints ---------- */

@media (min-width: 600px) {
    .fbmp-repo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 768px) {
    .fbmp-repo {
        padding: 40px 0 96px;
    }
}

@media (min-width: 960px) {
    .fbmp-repo-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .fbmp-repo-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Phones: dropdown instead of pills, smaller title, pagination only at the bottom. */
@media (max-width: 767px) {
    .fbmp-repo-title {
        font-size: 24px;
    }

    .fbmp-repo-filters {
        display: none;
    }

    .fbmp-repo-select-wrap {
        display: block;
    }
}

@media (max-width: 599px) {
    .fbmp-repo-pagination-top {
        display: none;
    }
}
