/* Virtual Bubble Wrap - Ultra Minimal Design (Based on Apteczka Skupienia & Plant Style) */

.bubble-wrap-widget,
.bubble-wrap-widget * {
    box-sizing: border-box;
}

:where(.wp-block-shortcode, .wp-block-group, .wp-block-columns, .wp-block-column, .wp-block-html, .entry-content, .entry-content > div, p) > .bubble-wrap-widget {
    margin: 0 auto 1.5rem !important;
}

:where(.wp-block-shortcode, .wp-block-group, .wp-block-columns, .wp-block-column, .wp-block-html, .entry-content, .entry-content > div, p) > .bubble-wrap-widget:last-child {
    margin-bottom: 0 !important;
}

.bubble-wrap-widget {
    max-width: 280px;
    width: 100%;
    margin: 0 auto 1.5rem;
    font-family: inherit;
    color: #2a2a2a;
}

.bubble-wrap-widget:last-child {
    margin-bottom: 0;
}

/* Collapsed state - tiny box like apteczka */
.bubble-wrap-collapsed {
    text-align: center;
    width: 100%;
}

.bubble-wrap-toggle {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    color: #2a2a2a;
    padding: 0.8rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 3rem;
    line-height: 1;
    border-radius: 0;
    gap: 0.3rem;
    white-space: nowrap;
}

.bubble-wrap-toggle:hover {
    background: #ffffff;
    border-color: #c5c5c5;
    box-shadow: 0 0 0 2px rgba(197, 197, 197, 0.35);
}

/* Expanded state - matches apteczka */
.bubble-wrap-expanded {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    padding: 0.4rem;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    width: 100%;
    display: none;
    flex-direction: column;
    gap: 0.4rem;
    align-items: stretch;
    position: relative;
    border-radius: 0;
}

.bubble-wrap-widget.expanded .bubble-wrap-collapsed {
    display: none;
}

.bubble-wrap-widget.expanded .bubble-wrap-expanded {
    display: flex;
    opacity: 1;
    transform: translateY(0);
    margin-top: 0.4rem;
}

/* Header - exactly like apteczka */
.bubble-wrap-header {
    position: relative;
    text-align: center;
}

.bubble-wrap-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: #2a2a2a;
    font-family: inherit;
}

.bubble-wrap-close {
    position: absolute;
    top: -0.2rem;
    right: -0.2rem;
    background: none;
    border: none;
    color: #666666;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem;
    line-height: 1;
    z-index: 2;
}

.bubble-wrap-close:hover {
    color: #2a2a2a;
}

/* Controls section */
.bubble-wrap-controls {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: center;
}

.problem-text {
    font-size: 0.75rem;
    font-weight: 400;
    color: #666666;
    text-align: center;
    font-family: inherit;
    line-height: 1.3;
}

/* Stats display */
.bubble-wrap-stats {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 1rem;
    font-size: 0.7rem;
    color: #666666;
    text-align: center;
    margin-top: 0.2rem;
}

.bubble-wrap-stats span {
    white-space: nowrap;
}

.bubble-wrap-stats strong {
    color: #2a2a2a;
    font-weight: 600;
}

/* All popped message */
.all-popped-message {
    font-size: 0.85rem;
    font-weight: 500;
    color: #28a745;
    text-align: center;
    font-family: inherit;
    line-height: 1.4;
    padding: 0.6rem;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-top: 0.5rem;
}

/* Buttons section */
.bubble-wrap-buttons {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.4rem;
}

.bubble-wrap-button {
    background: #466DD8;
    border: 1px solid #466DD8;
    color: #ffffff;
    padding: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70%;
    min-width: 200px;
    max-width: 320px;
    gap: 0.2rem;
    margin: 0 auto;
    border-radius: 5px;
    transition: background-color 0.15s ease;
}

.bubble-wrap-button:hover {
    background: #3758b4;
    border-color: #3758b4;
}

/* Bubble Container */
.bubble-wrap-container {
    padding: 0.8rem 0.4rem;
    overflow-y: auto;
    flex: 1;
    display: grid;
    gap: 5px;
    justify-content: center;
    align-content: start;
    max-height: 400px;
    /* grid-template-columns will be set dynamically by JavaScript */
}

/* Bubble */
.bubble {
    position: relative;
    aspect-ratio: 1;
    cursor: pointer;
    transition: all 0.1s ease;
}

.bubble-wrap-container.size-small .bubble {
    width: 25px;
    height: 25px;
}

.bubble-wrap-container.size-medium .bubble {
    width: 30px;
    height: 30px;
}

.bubble-wrap-container.size-large .bubble {
    width: 35px;
    height: 35px;
}

.bubble::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(200, 220, 240, 0.5) 30%,
        rgba(150, 180, 210, 0.6) 70%,
        rgba(120, 150, 180, 0.7) 100%);
    border-radius: 50%;
    border: 2px solid rgba(120, 150, 180, 0.4);
    box-shadow:
        inset -2px -2px 4px rgba(100, 130, 160, 0.3),
        inset 2px 2px 4px rgba(255, 255, 255, 0.6),
        0 2px 4px rgba(0, 0, 0, 0.08);
}

.bubble:hover::before {
    transform: scale(1.1);
    filter: brightness(1.1);
}

.bubble.popped::before {
    animation: pop 0.3s ease-out forwards;
}

@keyframes pop {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.5;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.bubble.popped {
    pointer-events: none;
}

/* Popped bubble - wklęsły, płaski ślad */
.bubble.popped::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at center,
            transparent 0%,
            transparent 30%,
            rgba(100, 130, 160, 0.12) 35%,
            rgba(100, 130, 160, 0.08) 50%,
            transparent 60%
        );
    border-radius: 50%;
    border: 1px solid rgba(100, 130, 160, 0.15);
    box-shadow:
        inset 1px 1px 3px rgba(80, 110, 140, 0.2),
        inset -1px -1px 2px rgba(255, 255, 255, 0.1);
    opacity: 0;
    animation: showFlat 0.3s ease-out 0.2s forwards;
}

@keyframes showFlat {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Footer */
.bubble-wrap-footer {
    padding-top: 0.4rem;
    border-top: 1px solid #e0e0e0;
    margin-top: 0.4rem;
}

.bubble-wrap-tip {
    margin: 0;
    font-size: 0.7rem;
    color: #666666;
    font-style: italic;
    text-align: center;
    line-height: 1.3;
}

/* Hidden state */
.hidden {
    display: none !important;
}

/* Zawsze rozwinięty w kontenerze mobilnym */
.mobile-column-content .bubble-wrap-widget {
    /* Widget zawsze rozwinięty w mobile */
}

.mobile-column-content .bubble-wrap-expanded {
    display: flex !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
}

.mobile-column-content .bubble-wrap-collapsed {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 480px) {
    .bubble-wrap-widget {
        max-width: 260px;
    }

    .bubble-wrap-container {
        padding: 0.4rem;
    }

    .bubble-wrap-button {
        padding: 0.4rem;
        font-size: 0.8rem;
    }
}

/* Animation for when all bubbles are popped */
@keyframes celebration {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.bubble-wrap-widget.all-popped .bubble-wrap-header h3 {
    animation: celebration 0.5s ease-in-out;
}
