/* sandbox-map.css - Styles for Sandbox/Editable Imperialism Maps */

/* === Setup Panel === */
.sandbox-config-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    space-y: 1rem;
}

.sandbox-config-section h2 {
    margin-bottom: 0.75rem;
}

.config-row {
    margin-bottom: 1rem;
}

.config-row:last-child {
    margin-bottom: 0;
}

.config-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.config-select {
    width: 100%;
    max-width: 300px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--background);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.config-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--background);
    color: var(--text-primary);
    font-size: 0.95rem;
    width: 100%;
}

.config-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.config-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.config-option:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}

.config-option input[type="radio"] {
    margin-top: 0.25rem;
    accent-color: var(--accent-1);
}

.config-option-text {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.config-option-text strong {
    color: var(--text-primary);
    font-size: 0.95rem;
}

.config-option-text small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* === Team Editor (Generic Mode) === */
.team-editor-form {
    margin-top: 0.75rem;
}

.team-editor-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-end;
}

.team-editor-inputs .config-input {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
}

.color-pickers {
    display: flex;
    gap: 0.5rem;
}

.color-picker-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}

.color-picker-label span {
    color: var(--text-secondary);
}

.color-picker-label input[type="color"] {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 2px;
    cursor: pointer;
    background: var(--background);
}

.team-list {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.team-list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--background);
}

.team-list-item .team-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid;
    flex-shrink: 0;
}

.team-list-item .team-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.team-list-item .team-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.team-list-item .team-relocate-btn,
.team-list-item .team-remove-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 0.75rem;
    line-height: 1;
    transition: color 0.15s ease;
}

.team-list-item .team-relocate-btn:hover {
    color: var(--accent-1);
}

.team-list-item .team-remove-btn:hover {
    color: var(--error);
}

.placement-status {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background: var(--surface-hover);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--accent-1);
}

.placement-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-1);
    animation: pulse-indicator 1.5s infinite;
}

@keyframes pulse-indicator {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* === Simulation Controls === */
.sim-header {
    margin-bottom: 1rem;
}

.sim-buttons {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s ease;
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s ease;
}

.btn-outline:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* === Matchup Display === */
.matchup-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.matchup-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--surface);
}

.matchup-team {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.matchup-team-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 2px solid;
    flex-shrink: 0;
}

.matchup-team-name {
    font-weight: 600;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.matchup-vs {
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* User input mode: clickable team buttons in matchup cards */
.matchup-card.user-input .matchup-team {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
}

.matchup-card.user-input .matchup-team:hover {
    background: var(--surface-hover);
}

.matchup-card.user-input .matchup-team.selected-winner {
    background: var(--surface-hover);
    outline: 2px solid var(--accent-1);
    outline-offset: -2px;
}

.matchup-card.resolved {
    opacity: 0.6;
}

/* === Map + Spinner Layout === */
.map-and-spinner-wrapper {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.map-and-spinner-wrapper .map-column {
    flex: 1;
    min-width: 0;
}

.spinner-panel {
    flex-shrink: 0;
    width: 260px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* Idle state: dim spinner, show ready message */
.spinner-panel.spinner-idle {
    opacity: 0.5;
}

.spinner-panel.spinner-idle .spinner-controls {
    pointer-events: none;
}

.spinner-panel-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.spinner-container-compact {
    position: relative;
    width: 200px;
    height: 200px;
}

.spinner-container-compact #spinner-canvas {
    width: 100%;
    height: 100%;
}

.spinner-pointer {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 18px solid var(--accent-1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    z-index: 1;
}

.spinner-matchup-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    min-height: 1.4em;
}

.spinner-result {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    min-height: 1.5em;
}

.spinner-continue-btn {
    margin-top: 0.25rem;
}

.spinner-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.spinner-speed-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.spinner-speed-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.spinner-speed-btn {
    background: var(--background);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.15s ease;
}

.spinner-speed-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.spinner-speed-btn.active {
    background: var(--accent-1);
    border-color: var(--accent-1);
    color: #fff;
}

.spinner-skip-controls {
    display: flex;
    gap: 0.5rem;
}

.spinner-auto-continue-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
}

.spinner-auto-continue-label input[type="checkbox"] {
    accent-color: var(--accent-1);
}

/* === Instant Reveal Animation === */
.matchup-card.instant-reveal {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    animation: instant-card-reveal 0.4s ease-out forwards;
}

@keyframes instant-card-reveal {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.matchup-card .instant-winner {
    position: relative;
}

.matchup-card .instant-winner::after {
    content: '\2713';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    color: var(--accent-1);
    font-size: 1.1rem;
}

.matchup-card .instant-loser {
    opacity: 0.4;
}

/* === Winner Celebration Overlay === */
.winner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.winner-content {
    text-align: center;
    padding: 3rem;
    max-width: 500px;
}

.winner-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 1.5rem;
}

.winner-team-name {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.winner-team-badge {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    border: 4px solid;
}

.winner-rounds {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 1rem;
}

/* === Responsive === */
@media (max-width: 640px) {
    .team-editor-inputs {
        flex-direction: column;
    }

    .team-editor-inputs .config-input {
        max-width: none;
    }

    .matchup-cards {
        grid-template-columns: 1fr;
    }

    /* Stack map and spinner vertically on mobile */
    .map-and-spinner-wrapper {
        flex-direction: column;
    }

    .spinner-panel {
        width: 100%;
    }

    .spinner-container-compact {
        width: 160px;
        height: 160px;
    }

    .sim-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .sim-buttons .btn {
        text-align: center;
    }
}
