/* ═══════════════════════════════════════════════════════
   DUNGEON VIEWER — Interactive Map + Accordion + Modal
   D&D dark theme: navy/dark bg, gold accents, Cinzel
   ═══════════════════════════════════════════════════════ */

.dungeon-viewer { margin: 1.5rem 0; }

/* ── Map Container ─────────────────────────────────── */
.dungeon-map-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 6px;
    overflow: hidden;
    background: #0a0a14;
}

.dungeon-map-wrapper img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ── Room Overlays ─────────────────────────────────── */
.dungeon-overlays {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

.dungeon-room-overlay {
    position: absolute;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    pointer-events: all;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dungeon-room-overlay:hover {
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
    z-index: 20;
}

.dungeon-room-overlay .room-label {
    font-size: 10px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9), 0 0 4px rgba(0,0,0,0.8);
    font-weight: 700;
    pointer-events: none;
    white-space: nowrap;
    font-family: 'Cinzel', serif;
    line-height: 1;
}

/* Type colors */
.room-type-empty   { background: rgba(76,175,80,0.12); border-color: rgba(76,175,80,0.35); }
.room-type-empty:hover { background: rgba(76,175,80,0.25); }

.room-type-combat  { background: rgba(244,67,54,0.18); border-color: rgba(244,67,54,0.45); }
.room-type-combat:hover { background: rgba(244,67,54,0.3); }

.room-type-treasure { background: rgba(255,215,0,0.18); border-color: rgba(255,215,0,0.45); }
.room-type-treasure:hover { background: rgba(255,215,0,0.3); }

.room-type-trap    { background: rgba(156,39,176,0.18); border-color: rgba(156,39,176,0.45); }
.room-type-trap:hover { background: rgba(156,39,176,0.3); }

.room-type-mixed   { background: rgba(255,152,0,0.18); border-color: rgba(255,152,0,0.45); }
.room-type-mixed:hover { background: rgba(255,152,0,0.3); }

.room-type-special { background: rgba(33,150,243,0.18); border-color: rgba(33,150,243,0.45); }
.room-type-special:hover { background: rgba(33,150,243,0.3); }

/* Highlight pulse */
@keyframes room-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255,215,0,0.5); border-color: #ffd700; }
    50% { box-shadow: 0 0 20px rgba(255,215,0,0.9); border-color: #fff; }
}
.dungeon-room-highlight { animation: room-pulse 0.8s ease-in-out 3; z-index: 15; }

/* ── Map Legend ─────────────────────────────────────── */
.dungeon-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0.75rem 0;
    padding: 0.5rem 0.75rem;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.08);
}
.dungeon-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
}
.dungeon-legend-swatch {
    width: 12px; height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* ── Accordion Browser ─────────────────────────────── */
.dungeon-browser { margin-top: 1.5rem; }
.dungeon-browser h3 {
    font-family: 'Cinzel', serif;
    color: #ffd700;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}
.dungeon-wings { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 768px) { .dungeon-wings { grid-template-columns: 1fr; } }
.dungeon-wing {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    overflow: hidden;
}
.dungeon-wing summary {
    padding: 0.7rem 1rem;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: #ffd700;
    background: rgba(255,215,0,0.05);
    font-size: 0.9rem;
    user-select: none;
}
.dungeon-wing summary:hover { background: rgba(255,215,0,0.1); }
.dungeon-wing summary .wing-count {
    color: rgba(255,255,255,0.5);
    font-weight: 400;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}
.dungeon-wing[open] summary { border-bottom: 1px solid rgba(255,255,255,0.1); }
.dungeon-room-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.dungeon-room-item:last-child { border-bottom: none; }
.dungeon-room-item:hover { background: rgba(255,255,255,0.05); }
.dungeon-room-item .room-number {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: #ffd700;
    min-width: 2.5rem;
    font-size: 0.85rem;
}
.dungeon-room-item .room-icon {
    font-size: 1rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}
.dungeon-room-item .room-brief {
    flex: 1;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.65);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Room Detail Modal ────────────────────────────── */
.dungeon-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.75);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.dungeon-modal {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 1px solid #ffd700;
    border-radius: 12px;
    max-width: 700px;
    width: 92%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 1.5rem;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    animation: slideUp 0.25s ease;
}
@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.dungeon-modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255,215,0,0.2);
}
.dungeon-modal-header h3 {
    margin: 0;
    color: #ffd700;
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    flex: 1;
}
.dungeon-modal-header .room-type-badge { font-size: 1.5rem; }
.dungeon-modal-close {
    position: absolute;
    top: 0.75rem; right: 0.75rem;
    cursor: pointer;
    font-size: 1.5rem;
    color: rgba(255,255,255,0.4);
    background: none;
    border: none;
    line-height: 1;
    padding: 0.25rem;
    transition: color 0.15s;
}
.dungeon-modal-close:hover { color: #fff; }
.dungeon-modal-body { color: #e8dcc8; font-size: 0.95rem; line-height: 1.6; }
.room-detail-section { margin: 0.75rem 0; }
.room-detail-section h4 {
    font-family: 'Cinzel', serif;
    color: #e0c080;
    margin: 0.5rem 0 0.25rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.room-detail-section p { margin: 0.2rem 0; font-size: 0.9rem; }
.room-doors-list { list-style: none; padding: 0; margin: 0.25rem 0; }
.room-doors-list li {
    padding: 0.15rem 0; font-size: 0.85rem; display: flex; gap: 0.5rem;
}
.room-doors-list .door-direction {
    font-weight: bold; color: #a0c4ff; min-width: 3rem;
}
.room-doors-list .door-type { color: #d4a574; font-size: 0.8rem; }
.room-doors-list .door-desc { color: rgba(255,255,255,0.6); }
.room-trap-text { color: #ef9a9a; font-size: 0.85rem; white-space: pre-wrap; }
.room-features-text { color: rgba(255,255,255,0.7); font-style: italic; font-size: 0.85rem; }

/* ── Modal Navigation ─────────────────────────────── */
.dungeon-modal-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.dungeon-modal-nav button {
    background: rgba(255,215,0,0.1);
    border: 1px solid rgba(255,215,0,0.25);
    color: #ffd700;
    padding: 0.4rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    transition: background 0.15s;
}
.dungeon-modal-nav button:hover { background: rgba(255,215,0,0.2); }
.dungeon-modal-nav button:disabled { opacity: 0.3; cursor: not-allowed; }
.dungeon-modal-nav .room-counter {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.4);
    font-family: 'Cinzel', serif;
}

/* ── Loading State ────────────────────────────────── */
.dungeon-viewer-loading {
    padding: 2rem;
    text-align: center;
    color: rgba(255,255,255,0.5);
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
}

/* ── Zoom & Pan controls ────────────────────────────── */
.dungeon-map-wrapper { touch-action: none; cursor: grab; }
.dungeon-map-wrapper:active { cursor: grabbing; }

.map-zoom-bar.dungeon-zoom-bar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.6rem;
    padding: 0.35rem 0.5rem;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    width: fit-content;
}
.map-zoom-btn {
    width: 1.9rem;
    height: 1.9rem;
    background: rgba(255,215,0,0.12);
    border: 1px solid rgba(255,215,0,0.3);
    color: #ffd700;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.map-zoom-btn:hover { background: rgba(255,215,0,0.28); }
.map-zoom-hint {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.45);
    margin-left: 0.4rem;
    font-family: 'Cinzel', serif;
}

/* ── Scrollbar ────────────────────────────────────── */
.dungeon-modal::-webkit-scrollbar { width: 6px; }
.dungeon-modal::-webkit-scrollbar-track { background: transparent; }
.dungeon-modal::-webkit-scrollbar-thumb { background: rgba(255,215,0,0.3); border-radius: 3px; }
