/* Play-Mode Codex Drawer */

.codex-side-btn {
    position: fixed; right: 12px; top: 50%; transform: translateY(-50%);
    z-index: 950;
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 1px solid var(--gold, #b48a3c);
    background: var(--bg-panel, #2a221b);
    color: var(--gold, #b48a3c);
    font-size: 1.4rem; cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.codex-side-btn:hover { background: var(--bg-panel-hover, #3a2c20); }

.codex-drawer { position: fixed; inset: 0; z-index: 1000; }
.codex-drawer.hidden { display: none; }
.codex-drawer-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); }
.codex-drawer-panel {
    position: absolute; right: 0; top: 0; bottom: 0;
    width: 420px; max-width: 100vw;
    background: var(--bg-panel, #2a221b);
    border-left: 1px solid var(--gold, #b48a3c);
    display: flex; flex-direction: column; overflow: hidden;
}
.codex-drawer-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle, #3a2c20);
}
.codex-drawer-title { margin: 0; color: var(--gold, #b48a3c); }
.codex-drawer-close {
    background: none; border: none; color: var(--text-primary, #e8d6a8);
    font-size: 1.8rem; cursor: pointer; line-height: 1;
}
.codex-drawer-toolbar { padding: 8px 16px; border-bottom: 1px solid var(--border-subtle, #3a2c20); }
.codex-drawer-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.codex-empty, .codex-tow-stub {
    color: var(--text-muted, #b9a47a); text-align: center; padding: 24px 8px;
}
.codex-unit-row { padding: 8px 0; border-bottom: 1px solid var(--border-subtle, #3a2c20); }
.codex-points { color: var(--text-muted, #b9a47a); font-size: 0.85em; }
.codex-stub-list { list-style: none; padding: 0; }
.codex-stub-list li { padding: 4px 0; border-bottom: 1px solid var(--border-subtle, #3a2c20); }

.codex-category summary {
    padding: 8px 0; cursor: pointer;
    color: var(--gold, #b48a3c); font-weight: 700;
}
.codex-unit-list { list-style: none; padding: 0; margin: 0; }
.codex-unit-summary {
    display: flex; justify-content: space-between;
    padding: 6px 0; cursor: pointer;
}
.codex-unit-detail { padding: 8px 0 12px; }
.codex-unit-detail.hidden { display: none; }
.codex-stat-table { width: 100%; font-size: 0.8rem; border-collapse: collapse; }
.codex-stat-table th,
.codex-stat-table td {
    border: 1px solid var(--border-subtle, #3a2c20);
    padding: 2px 4px; text-align: center;
}
.codex-wargear-list,
.codex-rules-list { list-style: none; padding: 0; margin: 4px 0 8px; }
.codex-wargear-list li,
.codex-rules-list li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-subtle, #3a2c20);
}
.codex-unit-unmatched {
    display: flex; justify-content: space-between; align-items: center;
}
.codex-link-btn { font-size: 0.75rem; padding: 4px 8px; }

.codex-link-overlay {
    position: fixed; inset: 0; z-index: 1100;
    background: rgba(0, 0, 0, 0.55);
    display: flex; align-items: center; justify-content: center;
}
.codex-link-modal {
    background: var(--bg-panel, #2a221b);
    padding: 16px; border-radius: 8px;
    width: 480px; max-width: 92vw; max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--gold, #b48a3c);
}
.codex-link-list {
    list-style: none; padding: 0; margin: 12px 0;
    max-height: 40vh; overflow-y: auto;
}
.codex-link-row {
    padding: 8px;
    display: flex; justify-content: space-between; cursor: pointer;
    border-bottom: 1px solid var(--border-subtle, #3a2c20);
}
.codex-link-row.selected { background: rgba(180, 138, 60, 0.18); }
.codex-link-faction { color: var(--text-muted, #b9a47a); font-size: 0.75rem; }
.codex-link-actions { display: flex; justify-content: flex-end; gap: 8px; }
.codex-link-faction-toggle { display: block; margin: 6px 0; font-size: 0.8rem; }

@media (max-width: 768px) {
    .codex-drawer-panel {
        right: 0; left: 0; top: 0; bottom: 0;
        width: 100vw; max-width: 100vw;
        border-left: none;
    }
}

/* Detachment grouping (outer collapsible per detachment instance) */
.codex-detachment {
    border-top: 1px solid var(--border-subtle, #3a2c20);
    padding: 4px 0;
}
.codex-detachment:first-of-type { border-top: none; }
.codex-detachment-summary {
    padding: 10px 0 6px;
    cursor: pointer;
    color: var(--gold, #b48a3c);
    font-weight: 700;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.codex-detachment-name { color: var(--gold, #b48a3c); }
.codex-detachment-count { color: var(--text-muted, #b9a47a); font-weight: 500; font-size: 0.85em; }

/* Nested category inside a detachment — quieter than the top-level header */
.codex-detachment .codex-category summary {
    color: var(--text-primary, #e8d6a8);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 6px 0 2px 8px;
    text-transform: none;
    letter-spacing: 0;
}
.codex-detachment .codex-unit-list { padding-left: 8px; }

/* Equipment / non-weapon wargear */
.codex-equipment-list li { display: block; }
.codex-wargear-summary { color: var(--text-muted, #b9a47a); font-style: italic; }
.codex-wargear-desc {
    color: var(--text-muted, #b9a47a);
    font-size: 0.8em;
    margin: 4px 0 0;
    line-height: 1.4;
}
