/* ===== Aktywna plansza – Frontend styles ===== */

/* Hide spurious <br> tags injected by wpautop inside the game container */
#omni-game br {
    display: none;
}

/* Plansza container */
.plansza-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin: 0 auto 16px;
    line-height: 0;
}

.plansza-container img.plansza-bg-image {
    display: block;
    max-width: 100%;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

/* Hotspot overlays */
.plansza-hotspot {
    position: absolute;
    box-sizing: border-box;
    pointer-events: auto;
    transition: opacity 0.2s, box-shadow 0.2s;
}

.plansza-hotspot--point {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.plansza-hotspot--circle {
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.plansza-hotspot--rect {
    /* position set via inline styles */
}

.plansza-hotspot--polygon {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

/* Number badge inside hotspot */
.plansza-hotspot__number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    z-index: 2;
}

/* Pulse animation */
@keyframes plansza-pulse {
    0%   { opacity: 1; }
    50%  { opacity: 0.45; }
    100% { opacity: 1; }
}

.plansza-hotspot--pulsing {
    animation: plansza-pulse 2s ease-in-out infinite;
}

/* Focus-pulse: single flash when input is focused */
@keyframes plansza-flash {
    0%   { opacity: 1; }
    30%  { opacity: 0.2; }
    60%  { opacity: 1; }
    80%  { opacity: 0.35; }
    100% { opacity: 1; }
}

.plansza-hotspot--flash {
    animation: plansza-flash 0.7s ease-in-out;
}

/* Forced pulse (triggered by Pulsuj button) – runs for JS-controlled duration */
.plansza-hotspot--pulse-forced {
    animation: plansza-pulse 0.6s ease-in-out infinite;
}

/* Correct/wrong feedback */
.plansza-hotspot.correct {
    box-shadow: 0 0 0 3px #51cf66 !important;
    opacity: 0.9;
    animation: none !important;
}

.plansza-hotspot.wrong {
    box-shadow: 0 0 0 3px #ff6b6b !important;
    opacity: 0.9;
    animation: none !important;
}

/* Drop zone styling for "polacz" mode */
.plansza-hotspot.drop-zone {
    cursor: pointer;
    z-index: 1;
}

.plansza-hotspot.drop-zone.has-label {
    box-shadow: 0 0 0 2px #339af0;
}

.plansza-hotspot .plansza-dropped-label {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    background: #339af0;
    color: #fff;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    z-index: 3;
    line-height: 1.4;
}

/* ──── Label bank (tryb "polacz") ──── */
.plansza-label-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px;
    width: min(100%, 960px);
    max-width: 960px;
    margin: 12px auto;
    background: #f6f7f7;
    border: 2px dashed #c3c4c7;
    border-radius: 8px;
    min-height: 48px;
    justify-content: center;
}

.plansza-label-bank-title {
    width: 100%;
    text-align: center;
    font-size: 18px;
    color: #000;
    margin-bottom: 6px;
}

.plansza-label-tag {
    display: inline-block;
    padding: 8px 18px;
    background: #fff;
    border: 2px solid #2271b1;
    border-radius: 20px;
    font-size: 20px;
    font-weight: 600;
    color: #1d2327;
    cursor: grab;
    user-select: none;
    line-height: 1.2;
    transition: background 0.15s, transform 0.1s;
}

.plansza-label-tag:active {
    cursor: grabbing;
    transform: scale(1.05);
}

.plansza-label-tag.sortable-ghost {
    opacity: 0.4;
}

.plansza-label-tag.sortable-chosen {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.plansza-label-tag.used {
    opacity: 0.4;
    pointer-events: none;
}

/* ──── Inputs (tryb "podpisz") ──── */
.plansza-inputs {
    margin: 16px 0;
}

.plansza-inputs-hint {
    text-align: center;
    color: #000;
    font-size: 17px;
    margin-bottom: 14px;
    font-style: normal;
}

.plansza-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #e5e7ea;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.plansza-input-row:focus-within {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34,113,177,0.12);
}

.plansza-input-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2271b1;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.plansza-input-field {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #dcdcde;
    border-radius: 6px;
    font-size: 20px;
    background: #fafbfc;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    color: #1d2327;
}

.plansza-input-field::placeholder {
    color: #a8abb0;
    font-weight: 400;
}

.plansza-input-field:focus {
    border-color: #2271b1;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(34,113,177,0.15);
}

.plansza-input-field.correct {
    border-color: #51cf66;
    background: #f0fff4;
    color: #1a6b36;
}

.plansza-input-field.wrong {
    border-color: #ff6b6b;
    background: #fff5f5;
    color: #c00;
}

.plansza-input-feedback {
    font-size: 13px;
    font-weight: 600;
    min-width: 90px;
    text-align: right;
    flex-shrink: 0;
}

.plansza-input-feedback.correct {
    color: #2b8a3e;
}

.plansza-input-feedback.wrong {
    color: #c92a2a;
    font-size: 18px;
}

/* ──── Pulse button (per row) ──── */
.plansza-pulse-btn {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1.5px solid #2271b1;
    border-radius: 50%;
    background: #fff;
    color: #2271b1;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.plansza-pulse-btn:hover {
    background: #2271b1;
    color: #fff;
    transform: scale(1.1);
}

.plansza-pulse-btn:active {
    transform: scale(0.95);
}

/* ──── Opacity slider (frontend) ──── */
.plansza-front-controls {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin: 10px 0 14px;
    padding: 10px 12px;
    border: 1px solid #d6dde5;
    border-radius: 10px;
    background: #f8fafc;
}

.plansza-front-controls__opacity,
.plansza-front-controls__pulse {
    display: flex;
    align-items: flex-end;
}

.plansza-front-controls__opacity {
    flex: 1;
    min-width: 260px;
    gap: 12px;
}

.plansza-front-slider-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.plansza-front-slider-label {
    font-size: 17px;
    color: #000;
    font-weight: 700;
    white-space: nowrap;
}

.plansza-front-opacity-slider {
    --value: 30;
    width: 200px;
    height: 12px;
    border-radius: 999px;
    border: 1px solid #b6c2cf;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(
        to right,
        #2271b1 0%,
        #2271b1 calc(var(--value) * 1%),
        #d6dde6 calc(var(--value) * 1%),
        #d6dde6 100%
    );
    cursor: pointer;
}

.plansza-front-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #1b5d92;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.plansza-front-opacity-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #1b5d92;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.plansza-front-opacity-slider::-moz-range-track {
    height: 12px;
    border-radius: 999px;
    border: 1px solid #b6c2cf;
    background: #d6dde6;
}

.plansza-front-opacity-val {
    font-size: 15px;
    color: #0f3f68;
    font-weight: 600;
    min-width: 42px;
}

.plansza-front-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    cursor: pointer;
}

.plansza-front-switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.plansza-front-switch-ui {
    width: 48px;
    height: 26px;
    border-radius: 999px;
    background: #cfd8e2;
    border: 1px solid #afbcc9;
    position: relative;
    transition: background 0.2s ease;
}

.plansza-front-switch-ui::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease;
}

.plansza-front-switch input:checked + .plansza-front-switch-ui {
    background: #2271b1;
    border-color: #1b5d92;
}

.plansza-front-switch input:checked + .plansza-front-switch-ui::after {
    transform: translateX(22px);
}

.plansza-front-switch-text {
    font-size: 16px;
    color: #000;
    font-weight: 700;
}

/* ──── Actions ──── */
.plansza-actions {
    text-align: center;
    margin: 16px 0 0;
}

.omni-check-btn {
    display: inline-block;
    padding: 10px 36px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.omni-check-btn:hover {
    background: #135e96;
}

.omni-check-btn:disabled {
    background: #a0a5aa;
    cursor: not-allowed;
}

/* ──── Save result popup section ──── */
.omni-save-result-section {
    max-width: 400px;
    margin: 30px auto 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.omni-save-checkbox-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #2f5b24;
    margin: 0;
}

.omni-save-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #2f5b24;
    cursor: pointer;
}

.omni-save-checkbox-label:hover {
    color: #4f883d;
}

.omni-learner-name-field {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.omni-learner-name-field > label {
    display: block;
    font-size: 16px;
    font-weight: 500;
    color: #000;
    margin-bottom: 8px;
    text-align: center;
}

.omni-learner-name-input {
    width: 100%;
    padding: 18px 20px;
    font-size: 16px;
    line-height: 1.45;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 14px;
    box-sizing: border-box;
    min-height: 54px;
}

.omni-learner-name-input:focus {
    outline: none;
    border-color: #4f883d;
    box-shadow: 0 0 0 3px rgba(79, 136, 61, 0.15);
}

.omni-learner-name-input:read-only,
.omni-learner-name-input:disabled {
    background: #f0f0f0;
    cursor: not-allowed;
}

.omni-save-result-btn {
    display: block;
    width: 100%;
    padding: 14px 24px;
    margin: 8px 0 15px;
    background: linear-gradient(135deg, #4f883d 0%, #3e6c31 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.omni-save-result-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 136, 61, 0.3);
}

.omni-save-result-btn.saved {
    background-color: #4f883d !important;
    cursor: default;
}

.omni-save-result-btn:disabled {
    opacity: 0.7;
}

.omni-privacy-note {
    text-align: center;
    margin: 0;
    font-size: 16px;
    color: #000;
    font-style: italic;
}

.omni-save-result-message {
    margin-top: 15px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

.omni-save-result-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.omni-save-result-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ──── Loading state ──── */
.plansza-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #646970;
    font-size: 14px;
}

.plansza-loading .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #c3c4c7;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: plansza-spin 0.6s linear infinite;
    margin-right: 10px;
}

@keyframes plansza-spin {
    to { transform: rotate(360deg); }
}

/* ──── Fullscreen mode (module-controlled) ──── */
#omni-game.plansza-fullscreen-active {
    background: #fff !important;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    box-sizing: border-box;
}

#omni-game.plansza-fullscreen-active:fullscreen::backdrop {
    background: #fff !important;
}

#omni-game.plansza-fullscreen-fallback {
    position: fixed !important;
    inset: 0;
    z-index: 2147483000;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: none !important;
    margin: 0 !important;
}

body.plansza-fullscreen-lock {
    overflow: hidden !important;
}

#omni-game.plansza-fullscreen-active .plansza-container {
    display: table;
    align-self: center;
    margin: 0 auto 16px;
    max-width: 90vw;
    max-height: calc(100dvh - 260px);
}

#omni-game.plansza-fullscreen-active .plansza-container img.plansza-bg-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 90vw;
    max-height: calc(100dvh - 260px);
    margin: 0 auto;
}

#omni-game.plansza-fullscreen-active .omni-game-toolbar,
#omni-game.plansza-fullscreen-active .plansza-front-controls,
#omni-game.plansza-fullscreen-active .plansza-inputs,
#omni-game.plansza-fullscreen-active .plansza-actions {
    width: 100%;
    max-width: 90vw;
}

#omni-game.plansza-fullscreen-active .plansza-inputs {
    max-width: min(60vw, 960px);
    margin-left: auto;
    margin-right: auto;
}

#omni-game.plansza-fullscreen-active .plansza-label-bank {
    width: min(90vw, 1100px);
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

/* ──── Responsive ──── */
@media (max-width: 600px) {
    .omni-save-result-section {
        max-width: 100%;
        padding: 15px;
    }

    .plansza-hotspot__number {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }

    .plansza-label-tag {
        padding: 4px 12px;
        font-size: 18px;
    }

    .plansza-input-field {
        font-size: 20px;
        padding: 8px 10px;
    }

    .plansza-front-controls {
        display: block;
    }

    .plansza-front-controls__opacity,
    .plansza-front-controls__pulse {
        width: 100%;
        justify-content: space-between;
    }

    .plansza-front-controls__opacity {
        margin-bottom: 10px;
    }

    .plansza-front-slider-label {
        font-size: 15px;
    }

    .plansza-front-opacity-slider {
        width: 120px;
    }

    .plansza-front-switch-text {
        font-size: 14px;
    }

    #omni-game.plansza-fullscreen-active {
        padding: 14px 10px;
    }

    #omni-game.plansza-fullscreen-active .plansza-container {
        max-height: calc(100dvh - 220px);
    }

    #omni-game.plansza-fullscreen-active .plansza-container img.plansza-bg-image {
        max-height: calc(100dvh - 220px);
    }

    #omni-game.plansza-fullscreen-active .plansza-label-bank {
        width: 100%;
        max-width: 100%;
    }
}
