/* =============================================
   BOB Figure Builder — LEGO-style popup UI
   Design system: var(--clr-black / --clr-yellow)
   ============================================= */

/* --- Banner on shop page --- */
.bob-builder-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--clr-black);
    color: var(--clr-cream);
    border-radius: var(--radius-card);
    padding: 20px 28px;
    margin-bottom: 28px;
}

.bob-builder-banner-text h3 {
    margin: 0 0 4px;
    font-size: 1.2rem;
    font-weight: 800;
    color: #fed531;
}

.bob-builder-banner-text p {
    margin: 0;
    font-size: 0.9rem;
    color: #ccc;
}

.bob-builder-banner-btn {
    flex-shrink: 0;
    background: #fed531;
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

.bob-builder-banner-btn:hover {
    background: #ffc800;
    transform: translateY(-1px);
}

/* --- Dialog backdrop --- */
dialog.bob-builder-overlay {
    border: none;
    padding: 0;
    background: transparent;
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    overflow: visible;
}

dialog.bob-builder-overlay::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

/* --- Modal card --- */
.bob-builder-modal {
    background: #fff;
    border-radius: 16px;
    width: min(920px, 96vw);
    max-height: 88vh;
    margin: 4vh auto;
    display: flex;
    flex-direction: column;
    overflow: visible;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* --- Header row --- */
.bob-builder-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.bob-builder-tabs {
    display: flex;
    gap: 8px;
    flex: 1;
    flex-wrap: wrap;
}

.bob-tab {
    padding: 8px 22px;
    border-radius: 50px;
    border: 2px solid #000;
    background: #fff;
    color: #000;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.bob-tab:hover {
    background: #f5f5f5;
}

.bob-tab.active {
    background: #000;
    color: #fff;
}

.bob-builder-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.bob-builder-total-price {
    font-size: 1.1rem;
    font-weight: 800;
    color: #000;
    min-width: 64px;
    text-align: right;
}

.bob-builder-cancel-btn {
    padding: 8px 18px;
    border-radius: 8px;
    border: 2px solid #000;
    background: #fff;
    color: #000;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.bob-builder-cancel-btn:hover {
    background: #f5f5f5;
}

.bob-builder-add-btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    background: #000;
    color: #fed531;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.bob-builder-add-btn:hover {
    background: #222;
    transform: translateY(-1px);
}

/* --- Modal body: options + preview --- */
.bob-builder-body {
    display: flex;
    flex: 1;
    overflow: visible;
    min-height: 0;
}

/* --- Left: scrollable options grid --- */
.bob-builder-options {
    flex: 0 0 55%;
    overflow-y: auto;
    padding: 20px;
    border-right: 1px solid #e8e8e8;
}

.bob-options-group {
    margin-bottom: 24px;
}

.bob-options-group-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.bob-options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.bob-option-card {
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    padding: 10px 8px 8px;
    text-align: center;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.bob-option-card:hover {
    border-color: #aaa;
    background: #fafafa;
    transform: translateY(-1px);
}

.bob-option-card.selected {
    border-color: #000;
    background: #f5f5f0;
}

.bob-option-card img {
    width: 100%;
    max-width: 80px;
    height: 80px;
    object-fit: contain;
    display: block;
    margin: 0 auto 6px;
}

.bob-option-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
    line-height: 1.2;
}

.bob-option-price {
    font-size: 0.8rem;
    font-weight: 700;
    color: #000;
}

/* --- Right: figure preview --- */
.bob-builder-preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f4f4f0;
    padding: 24px 16px;
}

.bob-figure-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 140px;
}

.preview-part {
    display: block;
    width: 140px;
    object-fit: contain;
}

.preview-head {
    height: 110px;
    object-position: center 5%;
    margin-bottom: -58px;
    position: relative;
    z-index: 3;
}

.preview-body {
    height: 150px;
    object-position: center center;
    margin-bottom: -62px;
    position: relative;
    z-index: 2;
}

.preview-legs {
    height: 130px;
    object-position: center top;
    position: relative;
    z-index: 1;
}

.preview-label {
    margin-top: 16px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #888;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* AI-generated head sits higher — face is centred in frame unlike preset heads */
.preview-head.ai-head {
    object-position: center center;
    margin-bottom: -84px;
    transform: translateY(-18px);
}

/* --- AI Head card --- */
.bob-ai-card {
    border: 2px dashed #fed531 !important;
    background: linear-gradient(135deg, #fffdf0 0%, #fffbdf 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.bob-ai-card:hover {
    border-color: #ffc800 !important;
    background: #fffbdf;
    transform: translateY(-1px);
}

.bob-ai-card-icon {
    font-size: 2rem;
    line-height: 1;
    margin-bottom: 6px;
    display: block;
}

.bob-ai-card.loading {
    opacity: 0.65;
    pointer-events: none;
}

@keyframes bob-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.bob-ai-card.loading .bob-ai-card-icon {
    display: inline-block;
    animation: bob-spin 1s linear infinite;
}

/* --- AI source picker & webcam modal --- */
#bobAISourcePicker,
#bobWebcamModal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
    align-items: center;
    justify-content: center;
}

.bob-ai-picker-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
}

.bob-ai-picker-card {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 24px 20px 20px;
    width: min(320px, 90vw);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.bob-webcam-card {
    width: min(440px, 92vw);
}

.bob-ai-picker-title {
    font-weight: 800;
    font-size: 1rem;
    text-align: center;
    margin: 0 0 4px;
    color: #000;
}

.bob-ai-picker-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    background: #000;
    color: #fed531;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s;
}

.bob-ai-picker-btn:hover { background: #222; }

.bob-ai-picker-cancel {
    padding: 10px;
    background: transparent;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    color: #666;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s;
}

.bob-ai-picker-cancel:hover { border-color: #aaa; color: #333; }

/* --- "Build Your Own" button inside product cards --- */
.bob-build-btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 9px;
    background: #fed531;
    color: #000;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s;
}

.bob-build-btn:hover {
    background: #ffc800;
}

/* --- Build Your Own product card in shop grid --- */
.byo-card {
    border: 2px solid #000 !important;
    overflow: hidden;
}

.byo-card-hero-link {
    display: block;
    text-decoration: none;
}

.byo-card-hero {
    background: #0a0a0a;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    transition: background 0.2s;
}

.byo-card-hero-link:hover .byo-card-hero {
    background: #1a1a1a;
}

.byo-card-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #fed531;
    color: #000;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 50px;
}

.byo-card-icon {
    font-size: 3rem;
    color: #fed531;
    line-height: 1;
}

.byo-card-cta {
    display: block;
    width: 100%;
    padding: 10px;
    background: #000;
    color: #fed531;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}

.byo-card-cta:hover {
    background: #222;
    color: #fed531;
    transform: translateY(-1px);
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .bob-builder-modal {
        border-radius: 12px 12px 0 0;
        margin: auto 0 0;
        max-height: 92vh;
        width: 100vw;
    }

    .bob-builder-body {
        flex-direction: column-reverse;
    }

    .bob-builder-options {
        flex: 1;
        border-right: none;
        border-top: 1px solid #e8e8e8;
    }

    .bob-builder-preview-panel {
        padding: 16px;
        flex: 0 0 auto;
    }

    .bob-figure-preview { width: 100px; }
    .preview-part { width: 100px; }
    .preview-head { height: 78px; margin-bottom: -54px; }
    .preview-body { height: 100px; margin-bottom: -41px; }
    .preview-legs { height: 78px; }

    .bob-options-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .bob-builder-banner {
        flex-direction: column;
        text-align: center;
    }
}
