/**
 * Single FBMP build page (single-fbmp-build.php).
 * Builds on fbmp-repository.css for the color tokens, Inter, buttons and labels.
 * Metal America UI kit: warm canvas, flat white cards, one red action per block.
 */

.fbmp-repo.fbmp-build {
    padding-top: 20px;
}

/* Author display rules (e.g. .fbmp-region-result's grid) must not undo the hidden attribute */
.fbmp-build [hidden] {
    display: none !important;
}

.fbmp-build-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px; /* Tap target; the negative margin keeps the text where it sat */
    margin: -12px 0 8px;
    color: var(--fr-500);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: color var(--fr-fast) var(--fr-ease);
}

.fbmp-build-back:hover,
.fbmp-build-back:focus {
    color: var(--fr-900);
    text-decoration: none;
}

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

.fbmp-build-top {
    display: grid;
    gap: 16px;
    margin: 0 0 16px;
}

.fbmp-build-card {
    margin: 0 0 16px;
    padding: 20px;
    border: 1px solid var(--fr-border);
    border-radius: var(--fr-radius-card);
    background: #fff;
    box-shadow: var(--fr-shadow);
}

.fbmp-build-top .fbmp-build-card {
    margin: 0;
}

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

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

.fbmp-build-card-head .fbmp-build-card-title {
    margin: 0;
}

/* ---------- Photos ---------- */

.fbmp-gallery-stage {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: var(--fr-radius-card);
    background: var(--fr-100);
}

.fbmp-gallery-stage > img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
}

.fbmp-gallery-download,
.fbmp-gallery-nav {
    position: absolute;
    border: 0;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    color: var(--fr-900);
    cursor: pointer;
    transition: background-color var(--fr-fast) var(--fr-ease);
}

.fbmp-gallery-download {
    top: 12px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

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

.fbmp-gallery-nav {
    top: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    padding: 0;
    border-radius: 999px;
}

.fbmp-gallery-nav.is-prev {
    left: 12px;
}

.fbmp-gallery-nav.is-next {
    right: 12px;
}

.fbmp-gallery-count {
    position: absolute;
    right: 12px;
    bottom: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(23, 23, 23, 0.75);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.fbmp-gallery-thumbs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.fbmp-gallery-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    padding: 0;
    border: 2px solid transparent;
    border-radius: var(--fr-radius-inner);
    background: var(--fr-100);
    cursor: pointer;
    transition: border-color var(--fr-fast) var(--fr-ease);
}

.fbmp-gallery-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
}

.fbmp-gallery-thumb:hover {
    border-color: var(--fr-300);
}

.fbmp-gallery-thumb.is-active {
    border-color: var(--fr-900);
}

/* ---------- Listing details ---------- */

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

.fbmp-build-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 0;
}

.fbmp-build-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 16px;
    margin: 16px 0 0;
    padding: 16px 0 0;
    border-top: 1px solid var(--fr-100);
    font-size: 14px;
    line-height: 1.5;
}

.fbmp-build-facts dt {
    margin: 0;
    color: var(--fr-500);
    font-weight: 500;
}

.fbmp-build-facts dd {
    margin: 0;
    color: var(--fr-900);
    font-weight: 600;
}

.fbmp-build-summary {
    margin: 16px 0 0;
    color: var(--fr-700);
    font-size: 15px;
    line-height: 1.6;
}

.fbmp-build-summary p {
    margin: 0 0 8px;
}

/* ---------- Barndominium Shell requirements ---------- */

.fbmp-shell-specs {
    color: var(--fr-800);
    font-size: 15px;
    line-height: 1.6;
}

.fbmp-shell-specs-title {
    margin: 0 0 8px;
    font-family: inherit;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    text-transform: none;
    color: var(--fr-900);
}

.fbmp-shell-specs-note {
    display: block;
    width: fit-content;
    margin: 0 0 12px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--fr-tint-badge);
    color: var(--fr-red-text);
    font-size: 13px;
    font-weight: 600;
}

.fbmp-shell-specs p {
    margin: 0 0 12px;
}

.fbmp-shell-specs-subtitle,
.fbmp-shell-branding-title {
    margin: 16px 0 8px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    text-transform: none;
    color: var(--fr-900);
}

.fbmp-shell-specs-list {
    margin: 0 0 12px;
    padding-left: 20px;
}

.fbmp-shell-specs-list li {
    margin: 0 0 4px;
}

/* Sub-steps such as 7.a */
.fbmp-shell-specs-sublist {
    margin: 4px 0 0;
    padding-left: 20px;
    list-style: lower-alpha;
}

.fbmp-shell-specs a {
    color: var(--fr-900);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--fr-fast) var(--fr-ease);
}

.fbmp-shell-specs a:hover {
    color: var(--fr-red-text);
}

.fbmp-shell-specs-closeout {
    color: var(--fr-700);
}

.fbmp-shell-branding {
    margin: 16px 0 0;
    padding: 16px;
    border: 1px solid rgba(255, 36, 0, 0.3);
    border-radius: var(--fr-radius-inner);
    background: var(--fr-tint);
}

.fbmp-shell-branding-title {
    margin-top: 0;
    color: var(--fr-red-text);
}

.fbmp-shell-branding .fbmp-shell-branding-temp {
    margin: 0;
    color: var(--fr-700);
}

/* ---------- Price and design link ---------- */

.fbmp-build-region-grid {
    display: grid;
    gap: 16px;
}

/* Shells: the coverage note sits above the map on phones (see breakpoints for desktop) */
.fbmp-build-region-grid.is-shell {
    grid-template-areas:
        "coverage"
        "map"
        "controls";
}

.fbmp-build-region-grid.is-shell .fbmp-build-map {
    grid-area: map;
}

.fbmp-build-region-grid.is-shell .fbmp-build-coverage {
    grid-area: coverage;
    margin: 0;
    border-radius: var(--fr-radius-inner);
}

.fbmp-build-region-grid.is-shell .fbmp-build-region-controls {
    grid-area: controls;
}

/* Both maps have a dark background baked in */
.fbmp-build-map {
    overflow: hidden;
    border-radius: var(--fr-radius-inner);
    background: #000;
}

.fbmp-build-map img {
    display: block;
    width: 100%;
    height: auto;
}

.fbmp-region-picker {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.fbmp-region-picker legend {
    padding: 0;
}

.fbmp-region-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.fbmp-region-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--fr-300);
    border-radius: var(--fr-radius-inner);
    background: #fff;
    color: var(--fr-700);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: border-color var(--fr-fast) var(--fr-ease), background-color var(--fr-fast) var(--fr-ease), color var(--fr-fast) var(--fr-ease);
}

/* Visually hidden, still reachable by keyboard and screen readers */
.fbmp-region-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
}

.fbmp-region-option:hover {
    border-color: var(--fr-900);
}

.fbmp-region-option:has(input:focus-visible) {
    outline: 2px solid var(--fr-900);
    outline-offset: 2px;
}

.fbmp-region-option.is-selected {
    border-color: var(--fr-900);
    background: var(--fr-900);
    color: #fff;
}

.fbmp-region-swatch {
    flex: none;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: var(--swatch);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.fbmp-region-option.is-selected .fbmp-region-swatch {
    box-shadow: 0 0 0 2px #fff;
}

.fbmp-region-prompt {
    margin: 12px 0 0;
    color: var(--fr-500);
    font-size: 14px;
}

.fbmp-region-alert {
    margin: 12px 0 0;
    color: var(--fr-red-text);
    font-size: 14px;
    font-weight: 600;
}

.fbmp-region-result {
    display: grid;
    gap: 12px;
    margin: 16px 0 0;
}

.fbmp-region-result .fbmp-region-prompt {
    margin: 0;
}

.fbmp-region-price {
    margin: 0;
    color: var(--fr-700);
    font-size: 14px;
    line-height: 1.5;
}

.fbmp-region-price strong {
    color: var(--fr-900);
}

.fbmp-link-box {
    padding: 16px;
    border: 1px solid var(--fr-border);
    border-radius: var(--fr-radius-inner);
    background: var(--fr-canvas);
}

.fbmp-link-box + .fbmp-link-box {
    margin-top: 12px;
}

.fbmp-link-box-label {
    display: block;
    margin: 0 0 4px;
    color: var(--fr-500);
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
}

/* Neutral so the Open design button stays the one red action in the block */
.fbmp-design-link-hyperlink {
    color: var(--fr-700);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
    transition: color var(--fr-fast) var(--fr-ease);
}

.fbmp-design-link-hyperlink:hover {
    color: var(--fr-red-text);
}

.fbmp-link-box-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 0;
}

/* ---------- Description to copy and paste ---------- */

.fbmp-build-copy .fbmp-content {
    max-width: 72ch;
    color: var(--fr-800);
    font-size: 15px;
    line-height: 1.65;
}

/* The ai-generate-onload mu-plugin styles its loading state for a dark page; restyle it here */
.fbmp-build .ai-loading {
    justify-content: flex-start;
    gap: 10px;
    padding: 8px 0;
    color: var(--fr-500);
    text-align: left;
}

.fbmp-build .ai-loading p {
    margin: 0;
}

.fbmp-build .loading-spinner {
    border-color: var(--fr-300);
    border-top-color: var(--fr-900);
}

.fbmp-build .ai-error {
    padding: 0;
    color: var(--fr-red-text);
    text-align: left;
}

/* ---------- Focus ---------- */

.fbmp-build-back:focus-visible,
.fbmp-gallery-download:focus-visible,
.fbmp-gallery-nav:focus-visible,
.fbmp-gallery-thumb:focus-visible,
.fbmp-design-link-hyperlink:focus-visible,
.fbmp-shell-specs a:focus-visible {
    outline: 2px solid var(--fr-900);
    outline-offset: 2px;
}

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

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

@media (min-width: 768px) {
    .fbmp-repo.fbmp-build {
        padding-top: 32px;
    }

    .fbmp-build-card {
        padding: 24px;
    }

    .fbmp-build-title {
        font-size: 28px;
    }
}

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

    /* Two columns keep the requirements readable without leaving half the card empty */
    .fbmp-shell-specs {
        column-count: 2;
        column-gap: 40px;
    }

    .fbmp-shell-specs-title,
    .fbmp-shell-specs-note {
        column-span: all;
    }

    .fbmp-shell-specs-subtitle {
        break-after: avoid;
    }

    .fbmp-shell-specs-list,
    .fbmp-shell-branding {
        break-inside: avoid;
    }

    .fbmp-build-top {
        grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
        align-items: start;
        gap: 24px;
        margin-bottom: 24px;
    }

    .fbmp-build-card {
        margin-bottom: 24px;
    }

    .fbmp-build-region-grid {
        grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
        align-items: start;
        gap: 24px;
    }

    /* Shells on desktop: map on the left, coverage note over the design link on the right */
    .fbmp-build-region-grid.is-shell {
        grid-template-areas:
            "map coverage"
            "map controls";
        grid-template-rows: auto 1fr;
        row-gap: 16px;
    }
}
