/*
 * Desert Storm — tool-specific styles
 * Inherits all CSS variables from main.css — do not redefine them here.
 */

/* ── Side colour tokens ────────────────────────────────────────────────────── */
:root {
    --ds-near-color:   #3d9970;
    --ds-near-bg:      rgba(61, 153, 112, 0.10);
    --ds-near-border:  rgba(61, 153, 112, 0.30);

    --ds-center-color: #e8c02a;
    --ds-center-bg:    rgba(232, 192, 42, 0.10);
    --ds-center-border:rgba(232, 192, 42, 0.30);

    --ds-far-color:    #e85c5c;
    --ds-far-bg:       rgba(232, 92, 92, 0.10);
    --ds-far-border:   rgba(232, 92, 92, 0.30);
}

/* ── Shared button primitives ─────────────────────────────────────────────── */
.ds-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, opacity 0.15s;
    min-height: 44px;
}
.ds-btn:hover  { background: var(--accent-hover); }
.ds-btn:active { opacity: 0.85; }

.ds-btn-primary { background: var(--accent); }

.ds-btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
    min-height: 36px;
}

.ds-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.ds-btn-ghost:hover {
    background: var(--bg-card-hover, rgba(255,255,255,0.05));
    color: var(--text-primary);
}

/* ── Roster status bar ────────────────────────────────────────────────────── */
.ds-roster {
    margin-bottom: 1rem;
}

.ds-roster-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.45rem 0.75rem;
    flex-wrap: wrap;
}

.ds-roster-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
    flex: 1;
    min-width: 0;
}

.ds-roster-status--empty {
    font-style: italic;
    color: var(--text-muted);
}

.ds-roster-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
}

.ds-roster-badge--warn {
    background: rgba(232, 192, 42, 0.15);
    color: var(--ds-center-color);
    border: 1px solid rgba(232, 192, 42, 0.3);
}

.ds-roster-badge--ok {
    background: rgba(61, 153, 112, 0.12);
    color: var(--ds-near-color);
    border: 1px solid rgba(61, 153, 112, 0.25);
}

.ds-roster-edit-btn { margin-left: auto; }

/* ── Roster modal ─────────────────────────────────────────────────────────── */
.ds-roster-modal-content {
    max-height: 90vh;
}

.ds-roster-modal-body {
    padding: 0 1rem;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.ds-roster-textarea {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.9rem;
    padding: 0.65rem 0.75rem;
    resize: vertical;
    box-sizing: border-box;
    line-height: 1.7;
    flex: 1;
}
.ds-roster-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.ds-roster-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem 1rem;
    gap: 0.5rem;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    margin-top: 0.75rem;
}

.ds-roster-modal-footer-right {
    display: flex;
    gap: 0.5rem;
}

.ds-btn-danger {
    color: var(--ds-far-color);
    border-color: rgba(232, 92, 92, 0.3);
}
.ds-btn-danger:hover {
    background: rgba(232, 92, 92, 0.1);
    color: var(--ds-far-color);
    border-color: var(--ds-far-color);
}

/* ── Tab bar ──────────────────────────────────────────────────────────────── */
.ds-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 3px;
    margin-bottom: 1rem;
    width: fit-content;
}

.ds-tab-btn {
    padding: 0.45rem 1.1rem;
    background: transparent;
    border: none;
    border-radius: calc(var(--radius-md) - 2px);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    min-height: 40px;
    white-space: nowrap;
}
.ds-tab-btn:hover { color: var(--text-primary); }
.ds-tab-btn.is-active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

/* ── Views container ─────────────────────────────────────────────────────── */
.ds-view { animation: ds-fade-in 0.15s ease; }
@keyframes ds-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ── Map toolbar ─────────────────────────────────────────────────────────── */
.ds-map-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

/* ── Map image overlay ───────────────────────────────────────────────────── */
/*
 * The map and its pins were laid out for desktop widths. Below ~1000px,
 * fixed-width pins start to clash. .ds-map-scroll keeps the map at desktop
 * size and lets mobile users pan horizontally instead of squeezing pins.
 */
.ds-map-scroll {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 0.5rem;
}

.ds-map-image-wrapper {
    position: relative;
    width: 100%;
    min-width: 1000px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #1a0c00;
    user-select: none;
}

.ds-map-image {
    width: 100%;
    height: auto;
    display: block;
    pointer-events: none;
}

.ds-map-no-image[hidden] { display: none !important; }

.ds-map-no-image {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
    padding: 2rem;
}

.ds-map-no-image p { margin: 0; }

.ds-map-no-image code {
    display: inline-block;
    margin-top: 0.35rem;
    padding: 0.3rem 0.65rem;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono, monospace);
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.ds-map-pins {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* ── Objective pins ──────────────────────────────────────────────────────── */
.ds-map-pin {
    position: absolute;
    /* transform applied inline per-objective via pinDir */
    background: rgba(10, 12, 18, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 7px;
    padding: 6px 10px;
    width: 150px;
    pointer-events: all;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ds-map-pin[data-side="near"]   { border-color: var(--ds-near-border); }
.ds-map-pin[data-side="center"] { border-color: var(--ds-center-border); }
.ds-map-pin[data-side="far"]    { border-color: var(--ds-far-border); }

.ds-map-pin.ds-drag-over {
    border-color: #4ade80 !important;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.30);
}

.ds-map-pin-header {
    display: flex;
    align-items: center;
    gap: 3px;
    /* only add bottom margin when player list follows */
    margin-bottom: 0;
}

.ds-map-pin-header:has(+ ul) {
    margin-bottom: 4px;
}

.ds-map-pin-label {
    font-size: 0.62rem;
    font-weight: 700;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.01em;
}

.ds-map-pin[data-side="near"]   .ds-map-pin-label { color: var(--ds-near-color); }
.ds-map-pin[data-side="center"] .ds-map-pin-label { color: var(--ds-center-color); }
.ds-map-pin[data-side="far"]    .ds-map-pin-label { color: var(--ds-far-color); }

/* ── Player count badge ──────────────────────────────────────────────────── */
.ds-map-count {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    flex-shrink: 0;
    line-height: 1.6;
}

/* ── Add player button ───────────────────────────────────────────────────── */
.ds-map-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}
.ds-map-add:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(232, 147, 42, 0.08);
}

/* ── Player list in pin ──────────────────────────────────────────────────── */
.ds-map-card-players {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Each row (filled or empty) is a fixed height so PIN_SLOTS always fit */
.ds-map-player-item,
.ds-map-slot-empty {
    height: 19px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ds-map-player-item {
    gap: 4px;
    cursor: grab;
}

.ds-map-player-item:active { cursor: grabbing; }

.ds-map-player-item.ds-dragging { opacity: 0.35; }

.ds-map-player-name {
    font-size: 0.76rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.ds-map-player-multi {
    flex-shrink: 0;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 3px;
    background: rgba(232, 192, 42, 0.18);
    color: var(--ds-center-color);
    border: 1px solid rgba(232, 192, 42, 0.4);
    cursor: help;
    letter-spacing: 0.02em;
}

.ds-map-player-item.is-multi .ds-map-player-name {
    color: var(--ds-center-color);
}

.ds-map-player-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 3px;
    color: transparent;
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.ds-map-player-item:hover .ds-map-player-remove {
    color: var(--text-muted);
}
.ds-map-player-remove:hover {
    background: rgba(232, 92, 92, 0.18);
    color: var(--ds-far-color) !important;
}

/* ── Summary view ────────────────────────────────────────────────────────── */
.ds-summary-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}

.ds-copy-feedback {
    font-size: 0.85rem;
    color: var(--ds-near-color);
    font-weight: 600;
    min-width: 60px;
}

.ds-summary-text {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
    font-family: var(--font-mono, monospace);
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0 0 1rem;
}

.ds-summary-unassigned {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
}

.ds-summary-unassigned h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 0.35rem;
}

.ds-summary-unassigned p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
    word-break: break-word;
}

/* ── Empty states ────────────────────────────────────────────────────────── */
.ds-empty-state {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 2rem 0;
    text-align: center;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */

/* display:flex on .ds-modal-backdrop overrides the browser's [hidden] rule. */
.ds-modal-backdrop[hidden] { display: none !important; }

.ds-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 0;
}

.ds-modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    outline: none;
}

@media (min-width: 560px) {
    .ds-modal-backdrop {
        align-items: center;
        padding: 1rem;
    }
    .ds-modal-content {
        border-radius: var(--radius-lg);
        max-height: 70vh;
    }
}

.ds-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem 0.5rem;
    flex-shrink: 0;
}

.ds-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.ds-modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 0;
    flex-shrink: 0;
}
.ds-modal-close:hover { color: var(--text-primary); }

.ds-modal-hint {
    padding: 0 1rem 0.5rem;
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.ds-modal-player-list {
    overflow-y: auto;
    padding: 0 0.5rem 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ds-modal-player {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.7rem 0.85rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    min-height: 48px;
    transition: background 0.12s, border-color 0.12s;
    width: 100%;
}
.ds-modal-player:hover {
    background: var(--bg-card-hover, rgba(255,255,255,0.05));
    border-color: var(--border);
}
.ds-modal-player.is-assigned {
    background: rgba(61, 153, 112, 0.12);
    border-color: var(--ds-near-border);
    color: var(--ds-near-color);
}
.ds-modal-player.is-assigned:hover {
    background: rgba(61, 153, 112, 0.2);
}

.ds-modal-player-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.ds-modal-player-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    text-align: left;
}

.ds-modal-elsewhere {
    font-size: 0.72rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.ds-modal-player.is-elsewhere .ds-modal-elsewhere {
    color: var(--ds-center-color);
    opacity: 0.8;
}

.ds-modal-check {
    font-size: 1rem;
    color: var(--ds-near-color);
    font-weight: 700;
    flex-shrink: 0;
    margin-left: 0.5rem;
    width: 1.2em;
    text-align: right;
}

.ds-modal-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}
