/**
 * DIY Chocolate Builder Stylesheet.
 * High-end responsive styles with clean layouts, animations, and typography.
 */

:root {
    --diy-primary: #a37254;
    --diy-primary-hover: #8c5f43;
    --diy-text: #333333;
    --diy-text-muted: #666666;
    --diy-bg-card: #ffffff;
    --diy-bg-body: #ffffff;
    --diy-border: #e8e2d9;
    --diy-radius: 4px;
    --diy-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --diy-font: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.kakao-diy-chocolate-builder {
    font-family: var(--diy-font);
    color: var(--diy-text);
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.kakao-diy-chocolate-builder * {
    box-sizing: border-box;
}

/* Builder Stack Layout */
.diy-builder-stack {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Center Visualizer Card styling */
.diy-visualizer-card {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 30px 0 60px 0;
    box-shadow: none;
}

@media (max-width: 768px) {
    .diy-builder-stack {
        gap: 12px;
    }
    .diy-visualizer-card {
        padding: 2px 0 10px 0;
    }
    .diy-section-card {
        padding: 16px;
        margin-bottom: 0;
    }
}

/* Bottom elements grid: Toppings (left) & Summary (right) */
.diy-bottom-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .diy-bottom-grid {
        grid-template-columns: 1fr;
    }
}

/* Section Cards styling */
.diy-section-card {
    background: var(--diy-bg-card);
    border: 1px solid var(--diy-border);
    border-radius: var(--diy-radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--diy-shadow);
}

.diy-step-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px dashed var(--diy-border);
    padding-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.diy-step-title::before,
.diy-step-title::after {
    content: "";
    display: inline-block;
    width: 40px;
    height: 1px;
    background: var(--diy-border);
    vertical-align: middle;
    margin: 0 15px;
}

.diy-step-title .step-num {
    background: var(--diy-primary) !important;
    color: #fff !important;
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    min-height: 26px !important;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 13px !important;
    margin-right: 10px !important;
    font-weight: bold !important;
    flex-shrink: 0 !important;
    aspect-ratio: 1 / 1 !important;
}

.diy-step-title .toppings-counter {
    margin-left: auto;
    font-size: 14px;
    background: #f7f5f0;
    color: var(--diy-primary);
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
}

/* 1. Base Chocolate Selector */
.diy-base-selector-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

@media (max-width: 768px) {
    .diy-base-selector-group {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .diy-base-selector-group {
        grid-template-columns: 1fr;
    }
}

.diy-base-btn {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--diy-border);
    padding: 10px 14px;
    border-radius: var(--diy-radius);
    cursor: pointer;
    text-align: left;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.diy-base-btn:hover {
    background: #ffffff;
    border-color: var(--diy-primary);
    box-shadow: 0 4px 12px rgba(163, 114, 84, 0.08);
}

.diy-base-btn.active {
    border-color: var(--diy-primary);
    background: #faf8f5;
    box-shadow: 0 4px 15px rgba(163, 114, 84, 0.12);
}

.base-texture-preview {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background-size: cover;
    background-position: center;
    margin-right: 12px;
    border: 1px solid rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.base-details {
    display: flex;
    flex-direction: column;
}

.base-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--diy-text);
    line-height: 1.3;
}

.base-price {
    font-size: 12px;
    color: var(--diy-text-muted);
    margin-top: 2px;
}

.diy-base-btn.active .base-price {
    color: var(--diy-primary);
    font-weight: 600;
}

/* Chocolate Bar Live Visualizer */
.diy-chocolate-preview-container {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.diy-chocolate-bar {
    position: relative;
    width: 100%;
    max-width: 880px;
    aspect-ratio: 680 / 330; /* Calculates height dynamically to keep perfect 185x90mm horizontal proportions */
    background: transparent;
    overflow: hidden;
    margin: 0 auto;
    border: none;
    border-radius: 6px;
    box-shadow: 0 20px 40px rgba(45, 25, 15, 0.15), 0 8px 16px rgba(45, 25, 15, 0.1);
    transition: transform 0.3s ease;
}

.diy-layer-base {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.4s ease;
}

.diy-toppings-overlays {
    position: absolute;
    top: 2%;
    left: 2%;
    width: 96%;
    height: 96%;
    pointer-events: none;
}

.diy-topping-overlay-img {
    position: absolute;
    top: 0;
    width: 33.333%; /* Each layer takes exactly one third of the horizontal space */
    height: 100%;
    object-fit: cover; /* Fills its respective column perfectly */
    opacity: 0;
    transform: scale(1.1) translateY(-15px); /* Soft start state */
    pointer-events: none;
}

/* Position columns side-by-side */
.diy-topping-overlay-img.layer-pos-0 {
    left: 0;
}

.diy-topping-overlay-img.layer-pos-1 {
    left: 33.333%;
}

.diy-topping-overlay-img.layer-pos-2 {
    left: 66.666%;
}

/* CSS Animation for Toppings sprinkle effect */
.diy-topping-overlay-img.active {
    opacity: 1;
    transform: scale(1) translateY(0);
    animation: sprinkleFall 1.0s cubic-bezier(0.1, 0.9, 0.2, 1.0) forwards;
}

/* Sprinkle fall animation (very gentle, smooth sliding settle) */
@keyframes sprinkleFall {
    0% {
        transform: scale(1.1) translateY(-15px) rotate(-1deg);
        filter: blur(2px);
        opacity: 0;
    }
    100% {
        transform: scale(1) translateY(0) rotate(0deg);
        filter: blur(0);
        opacity: 1;
    }
}

/* 2. Toppings Grid */

.diy-toppings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-height: 450px;
    overflow-y: auto;
    padding-right: 5px;
}

@media (max-width: 600px) {
    .diy-toppings-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.diy-toppings-grid::-webkit-scrollbar {
    width: 6px;
}
.diy-toppings-grid::-webkit-scrollbar-thumb {
    background: var(--diy-border);
    border-radius: 3px;
}

.diy-topping-item {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.topping-inner {
    border: 1px solid var(--diy-border);
    background: #fff;
    border-radius: var(--diy-radius);
    padding: 12px;
    text-align: center;
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.25s ease;
}

.diy-topping-item:hover .topping-inner {
    border-color: var(--diy-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.04);
}

.diy-topping-item.selected .topping-inner {
    border-color: var(--diy-primary);
    background: #faf8f5;
    box-shadow: 0 4px 12px rgba(163, 114, 84, 0.08);
}

.topping-img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    margin-bottom: 8px;
    background-color: #f7f5f0;
}

.topping-no-img {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.topping-info {
    display: flex;
    flex-direction: column;
    margin-top: auto;
}

.topping-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--diy-text);
    line-height: 1.3;
}

.topping-price {
    font-size: 11px;
    color: var(--diy-text-muted);
    margin-top: 3px;
    font-weight: 500;
}

.diy-topping-item.selected .topping-price {
    color: var(--diy-primary);
    font-weight: 600;
}

/* Checkbox Indicator inside topping item */
.topping-checkbox {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--diy-border);
    border-radius: 50%;
    background: #fff;
    transition: all 0.2s ease;
}

.diy-topping-item.selected .topping-checkbox {
    border-color: var(--diy-primary);
    background: var(--diy-primary);
}

.diy-topping-item.selected .topping-checkbox::after {
    content: '';
    position: absolute;
    left: 4.5px;
    top: 1.5px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

/* Disabled topping item styles */
.diy-topping-item.disabled {
    opacity: 0.5;
}
.diy-topping-item.disabled:not(.selected) {
    cursor: not-allowed;
}
.diy-topping-item.disabled:not(.selected) .topping-inner:hover {
    border-color: var(--diy-border);
    transform: none;
    box-shadow: none;
}

/* 3. Summary & WooCommerce form card */
.diy-summary-card {
    background: #fffdfb;
    border-color: #ebdcb9;
}

.diy-summary-details {
    margin-bottom: 24px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    margin-bottom: 12px;
}

.summary-label {
    color: var(--diy-text-muted);
}

.summary-value {
    font-weight: 600;
}

.toppings-summary-row {
    flex-direction: column;
    align-items: flex-start;
}

.summary-toppings-list {
    margin: 8px 0 0 0;
    padding: 0;
    list-style: none;
    width: 100%;
}

.summary-toppings-list li {
    font-size: 13px;
    font-weight: 500;
    padding: 4px 0;
    border-bottom: 1px solid rgba(0,0,0,0.03);
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.summary-toppings-list li.empty-toppings-msg {
    color: var(--diy-text-muted);
    font-style: italic;
    border-bottom: none;
    font-size: 12px;
}

.summary-toppings-list .remove-summary-topping {
    color: var(--diy-primary);
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    margin-left: 8px;
}

.summary-divider {
    border-top: 1px solid var(--diy-border);
    margin: 16px 0;
}

.total-row {
    margin-bottom: 0;
}

.total-price {
    font-size: 20px;
    color: var(--diy-primary);
    font-weight: 700;
}

/* Add to Cart form integration */
.diy-purchase-row {
    display: flex;
    gap: 15px;
    align-items: center;
}



.qty-btn {
    width: 35px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    color: var(--diy-text-muted);
}
.qty-btn:hover {
    background: #f7f5f0;
    color: var(--diy-text);
}

.qty-input {
    width: 50px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--diy-border);
    border-right: 1px solid var(--diy-border);
    font-size: 15px;
    font-weight: 600;
    outline: none;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.diy-submit-btn {
    flex-grow: 1;
    background: var(--diy-primary) !important;
    color: #fff !important;
    border: none !important;
    height: 48px;
    border-radius: var(--diy-radius) !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    cursor: pointer;
    transition: background-color 0.2s ease !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.diy-submit-btn:hover {
    background: var(--diy-primary-hover) !important;
}

@media (max-width: 480px) {
    .diy-step-title::before,
    .diy-step-title::after {
        display: inline-block !important;
        width: 15px !important;
        margin: 0 6px !important;
    }
    .diy-step-title {
        font-size: 15px !important;
    }
    .diy-section-card {
        padding: 16px !important;
    }
    .diy-purchase-row {
        flex-direction: column !important;
        align-items: center !important;
        gap: 12px !important;
        width: 100% !important;
    }
    .diy-purchase-row .quantity-input-box {
        width: 120px !important;
        margin: 0 auto !important;
    }
    .diy-purchase-row .add-to-cart-btn {
        width: 100% !important;
        text-align: center !important;
    }
}
