/* Factions war room — steel palette, scoped layout */

body.factions-page {
    background-color: #05080f;
    min-height: 100vh;
}

body.factions-page::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image: url('../assets/factions-bg.jpg');
    background-size: cover;
    background-position: center center;
    background-attachment: fixed;
    filter: brightness(0.24) saturate(0.72);
    pointer-events: none;
}

body.factions-page::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(rgba(100, 116, 139, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100, 116, 139, 0.035) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse 90% 55% at 50% 0%, black 15%, transparent 72%);
    pointer-events: none;
}

/* ── Briefing hero ── */
.factions-hero {
    position: relative;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: linear-gradient(165deg, rgba(15, 23, 42, 0.94) 0%, rgba(5, 8, 15, 0.98) 100%);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.factions-hero::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.4), transparent);
}

.factions-brief-stat {
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.35);
}

/* ── Sort tabs ── */
.factions-sort-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.factions-sort-tab {
    padding: 0.55rem 1.15rem;
    border-radius: 0.5rem;
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
    color: #64748b;
    background: transparent;
}

.factions-sort-tab.active {
    background: linear-gradient(135deg, #475569, #334155);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.35);
}

.factions-sort-tab:not(.active):hover {
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.05);
}

/* ── Podium ── */
.factions-podium {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: end;
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    .factions-podium {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
    }
    .factions-podium .podium-slot-1 { order: 2; transform: translateY(-0.75rem); }
    .factions-podium .podium-slot-2 { order: 1; }
    .factions-podium .podium-slot-3 { order: 3; }
}

.faction-pod-card {
    position: relative;
    overflow: hidden;
    border-radius: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.15);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.75) 0%, rgba(5, 8, 15, 0.96) 100%);
    padding: 1.25rem 1rem 1.5rem;
    text-align: center;
    transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
    cursor: pointer;
}

.faction-pod-card.has-banner {
    background-size: cover;
    background-position: center top;
}

.faction-pod-card .faction-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(5, 8, 15, 0.5) 0%, rgba(5, 8, 15, 0.94) 75%);
    pointer-events: none;
    border-radius: inherit;
}

.faction-pod-card:hover {
    transform: translateY(-4px);
    border-color: rgba(56, 189, 248, 0.35);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.faction-pod-card.podium-rank-1 { border-color: rgba(56, 189, 248, 0.4); }
.faction-pod-card.podium-rank-2 { border-color: rgba(148, 163, 184, 0.3); }
.faction-pod-card.podium-rank-3 { border-color: rgba(180, 83, 9, 0.35); }

.faction-logo {
    width: 56px;
    height: 56px;
    border-radius: 0.65rem;
    object-fit: cover;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(0, 0, 0, 0.5);
    margin: 0 auto 0.65rem;
    display: block;
}

.faction-logo-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 0.65rem;
    border: 1px dashed rgba(148, 163, 184, 0.25);
    background: rgba(0, 0, 0, 0.35);
    margin: 0 auto 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    font-size: 1.25rem;
}

/* Podium cards get a larger, more prominent emblem than the ladder rows/dossier header */
.faction-pod-card .faction-logo,
.faction-pod-card .faction-logo-placeholder {
    width: 92px;
    height: 92px;
    border-radius: 1rem;
    margin: 0 auto 0.85rem;
    font-size: 2.25rem;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.faction-logo-sm {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    object-fit: cover;
    border: 1px solid rgba(148, 163, 184, 0.2);
    flex-shrink: 0;
}

/* ── Badges ── */
.faction-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    border: 1px solid rgba(148, 163, 184, 0.22);
    color: #94a3b8;
    background: rgba(15, 23, 42, 0.75);
    white-space: nowrap;
}

.faction-badge.recruiting {
    border-color: rgba(34, 197, 94, 0.35);
    color: #4ade80;
    background: rgba(34, 197, 94, 0.08);
}

.faction-badge.closed {
    border-color: rgba(239, 68, 68, 0.28);
    color: #f87171;
}

.faction-badge.top3 {
    border-color: rgba(56, 189, 248, 0.35);
    color: #38bdf8;
}

.faction-badge.wip {
    border-color: rgba(245, 158, 11, 0.35);
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.08);
}

/* ── Ladder table ── */
.factions-ladder-wrap {
    overflow-x: auto;
}

.factions-ladder-head,
.factions-ladder-row {
    display: grid;
    grid-template-columns: 2.75rem minmax(140px, 1fr) 4.5rem 5.5rem 5.5rem 5.5rem 5.5rem;
    gap: 0.65rem;
    align-items: center;
    min-width: 720px;
}

.factions-ladder-head {
    padding: 0.75rem 1.25rem;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #64748b;
}

.factions-ladder-row {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.15s;
    cursor: pointer;
}

.factions-ladder-row:last-child { border-bottom: none; }
.factions-ladder-row:hover { background: rgba(148, 163, 184, 0.06); }

.factions-ladder-head .col-active,
.factions-ladder-row .col-active {
    color: #38bdf8;
}

.factions-ladder-row .faction-identity {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.factions-ladder-row .faction-name-block {
    min-width: 0;
}

.factions-ladder-row .faction-name-block h4 {
    font-family: 'Oswald', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 0 0.25rem;
}

.factions-ladder-row .faction-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.factions-stat-cell {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    text-align: right;
    color: #94a3b8;
}

.factions-stat-cell.col-active {
    color: #38bdf8;
    font-weight: 700;
}

/* ── Recruitment cards ── */
.faction-recruit-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.1rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: linear-gradient(180deg, rgba(20, 28, 45, 0.85) 0%, rgba(5, 8, 15, 0.95) 100%);
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
    text-align: left;
    width: 100%;
}

.faction-recruit-card:hover {
    border-color: rgba(56, 189, 248, 0.3);
    transform: translateY(-2px);
}

/* ── Dossier modal ── */
.faction-dossier-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 5.5rem 1rem 2rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
    overflow-y: auto;
}

.faction-dossier-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.faction-dossier-panel {
    width: 100%;
    max-width: 680px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 0.85rem;
    background: linear-gradient(180deg, rgba(12, 18, 32, 0.98) 0%, rgba(5, 8, 15, 0.99) 100%);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65);
    transform: translateY(10px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.faction-dossier-overlay.active .faction-dossier-panel {
    transform: translateY(0);
}

.faction-dossier-banner {
    height: 100px;
    background-size: cover;
    background-position: center;
    position: relative;
}

.faction-dossier-banner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(5, 8, 15, 0.95) 100%);
}

.faction-dossier-body {
    padding: 1.25rem 1.35rem 1.5rem;
}

.faction-dossier-head {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.faction-dossier-close {
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.35);
    color: #64748b;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.faction-dossier-close:hover {
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.35);
}

.faction-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

@media (min-width: 480px) {
    .faction-stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.faction-stat-box {
    padding: 0.65rem 0.5rem;
    text-align: center;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.35);
}

.faction-stat-box .label {
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64748b;
    margin-bottom: 0.2rem;
}

.faction-stat-box .value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    font-weight: 700;
    color: #e2e8f0;
}

.faction-territory-teaser {
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    border-radius: 0.5rem;
    border: 1px dashed rgba(245, 158, 11, 0.25);
    background: rgba(245, 158, 11, 0.04);
}

.faction-territory-teaser .teaser-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: #fbbf24;
    margin-bottom: 0.35rem;
}

.faction-territory-teaser p {
    font-size: 0.75rem;
    color: #94a3b8;
    line-height: 1.5;
    margin: 0;
}

.faction-roster-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.faction-chart-row {
    display: flex;
    justify-content: center;
    margin: 0.75rem 0 1rem;
}

.faction-chart-wrap {
    position: relative;
    width: 100%;
    max-width: 220px;
    margin: 0 auto;
}

.faction-chart-wrap canvas {
    max-height: 160px;
}

.faction-chart-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    text-align: center;
    padding: 0 1.5rem;
}

.faction-chart-center .label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.52rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: #64748b;
}

.faction-chart-center .value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    color: #38bdf8;
    line-height: 1.1;
}

.faction-weight-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.65rem;
    margin-top: 0.65rem;
}

.faction-weight-legend span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.62rem;
    color: #94a3b8;
}

.faction-weight-legend i {
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    margin-right: 0.25rem;
    vertical-align: middle;
}

/* ── Enlist modal ── */
.faction-enlist-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(6px);
}

.faction-enlist-modal.hidden { display: none; }

.faction-enlist-modal textarea {
    width: 100%;
    min-height: 110px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    resize: vertical;
    font-family: inherit;
}

.faction-enlist-modal textarea:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.45);
}

/* ── Staff / command reference ── */
.factions-cmd-ref {
    border: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0.85rem;
    padding: 1.25rem 1.35rem;
}

.factions-cmd-ref h3 {
    font-family: 'Oswald', sans-serif;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #e2e8f0;
    margin: 0 0 0.75rem;
}

.factions-cmd-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 640px) {
    .factions-cmd-grid { grid-template-columns: 1fr 1fr; }
}

.factions-cmd-group h4 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: #64748b;
    margin: 0 0 0.5rem;
}

.factions-cmd-group ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.factions-cmd-group li {
    font-size: 0.78rem;
    color: #94a3b8;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    line-height: 1.45;
}

.factions-cmd-group li:last-child { border-bottom: none; }

.factions-cmd-group code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.08);
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
}

.factions-search {
    width: 100%;
    max-width: 16rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    border-radius: 0.65rem;
    padding: 0.55rem 0.85rem 0.55rem 2.25rem;
    font-size: 0.85rem;
}

.factions-search:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.4);
}

.factions-search-wrap {
    position: relative;
}

.factions-search-wrap i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 0.75rem;
    pointer-events: none;
}
