/* ==========================================================================
   AoE2 Unit Analyzer - Civ Analysis Page Styles
   Extends base.css -- do NOT duplicate body, container, header, nav, or h1 rules.
   ========================================================================== */

/* --- Civ Selector --- */
.civ-selector {
    text-align: center;
    margin-bottom: 20px;
}
.civ-selector h3 {
    margin-bottom: 12px;
    font-size: 1.1rem;
}
.step-label {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    margin-bottom: 10px;
}
.step-civ1 {
    background: rgba(201, 168, 76, 0.15);
    color: var(--gold);
}
.step-selected {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
}

.civ-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
    max-width: 900px;
    margin: 0 auto;
}
.civ-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 6px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    color: var(--text);
}
.civ-card:hover {
    transform: translateY(-2px);
    border-color: rgba(201, 168, 76, 0.3);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.civ-card.selected-civ1 {
    border-color: var(--gold);
    background: rgba(201, 168, 76, 0.15);
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.3);
}
.civ-card.disabled {
    opacity: 0.35;
    pointer-events: none;
}
.civ-emblem {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(201, 168, 76, 0.4);
    object-fit: cover;
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 5px;
}
.civ-card-name {
    font-size: 0.75rem;
    text-align: center;
    line-height: 1.2;
}

/* --- Results Container --- */
.results-container {
    display: none;
}
.results-container.visible {
    display: block;
}

/* --- Analysis Hero (header + strategic summary side-by-side) --- */
.analysis-hero {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 20px 24px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(201, 168, 76, 0.15);
    border-radius: 12px;
}
.analysis-emblem {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid rgba(201, 168, 76, 0.5);
    object-fit: cover;
    background: rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}
.analysis-hero-body {
    flex: 1;
    min-width: 0;
}
.analysis-civ-name {
    font-size: 1.6rem;
    color: var(--gold);
    margin: 0 0 4px;
}
.analysis-hero-narrative {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 10px;
}
.analysis-hero-body .pill-row {
    margin-bottom: 4px;
}
.analysis-hero-body .pill-row:last-child {
    margin-bottom: 0;
}

/* (Strategic summary merged into .analysis-hero above) */

/* --- Pills --- */
.pill-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.pill-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: 4px;
}
.pill {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    letter-spacing: 0.3px;
}
.pill-strong {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
}
.pill-weak {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

/* --- Role Columns Grid (4 columns: cav, ranged, inf, siege) --- */
.role-columns {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

/* --- Role Column --- */
.role-column {
    padding: 12px 8px;
    border-top: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 0 8px 8px;
    background: rgba(255, 255, 255, 0.02);
    min-width: 0;
}
.role-column.col-strong {
    border-top-color: #2ecc71;
    background: rgba(46, 204, 113, 0.05);
}
.role-column.col-strong .role-header {
    color: #2ecc71;
}
.role-column.has-signature {
    border-top-color: var(--gold);
    background: rgba(201, 168, 76, 0.06);
}
.role-column.has-signature .role-header {
    color: var(--gold);
}

/* --- Role Header --- */
.role-header {
    color: var(--gold);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    text-align: center;
}

/* --- Line Section (individual unit line within a column) --- */
.line-section {
    margin-bottom: 6px;
}

.line-label {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
    padding-left: 2px;
}

.line-unavailable {
    color: var(--text-dim);
    font-size: 0.75rem;
    padding: 4px 8px;
    opacity: 0.4;
}

/* --- Unit Wrap (entrance animation) --- */
.unit-wrap {
    margin-bottom: 8px;
    animation: cardSlideIn 0.35s ease both;
}

/* --- Multi-unit layout (2+ units in same line) --- */
.unit-wrap.multi-unit {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Unit Badge (horizontal card: icon left, info right) --- */
.unit-badge {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.15);
    text-align: left;
    position: relative;
    transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}
.unit-badge:hover {
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    transform: translateX(2px);
}

/* --- Signature Badge --- */
.unit-badge.signature {
    border-color: rgba(201, 168, 76, 0.3);
    border-left-color: var(--gold);
    border-left-width: 3px;
    background: linear-gradient(135deg, rgba(201, 168, 76, 0.1) 0%, rgba(201, 168, 76, 0.03) 100%);
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.1);
    padding: 10px 12px;
}
.unit-badge.signature:hover {
    background: linear-gradient(135deg, rgba(201, 168, 76, 0.16) 0%, rgba(201, 168, 76, 0.06) 100%);
    box-shadow: 0 2px 16px rgba(201, 168, 76, 0.2);
}

/* --- Signature Star --- */
.signature-star {
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 0.7rem;
    color: var(--gold);
    background: var(--bg-deep);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--gold);
    line-height: 1;
    box-shadow: 0 0 6px rgba(201, 168, 76, 0.3);
}

/* --- Unit Badge Icon --- */
.unit-badge-icon {
    width: 64px;
    height: 64px;
    border-radius: 6px;
    border: 2px solid rgba(201, 168, 76, 0.25);
    background: rgba(0, 0, 0, 0.35);
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}
.signature-icon {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    border: 2px solid rgba(201, 168, 76, 0.5);
    background: rgba(0, 0, 0, 0.35);
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(201, 168, 76, 0.15), inset 0 1px 3px rgba(0, 0, 0, 0.4);
}
.icon-placeholder {
    background: rgba(255, 255, 255, 0.04);
}

/* --- Unit Badge Info (name + score stack) --- */
.unit-badge-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

/* --- Unit Badge Name --- */
.unit-badge-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.unit-badge.signature .unit-badge-name {
    color: var(--gold-light);
    font-size: 0.82rem;
}

/* --- Unit Badge Rank (pill style) --- */
.unit-badge-rank {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
    width: fit-content;
}
.rank-signature {
    background: rgba(201, 168, 76, 0.2);
    color: var(--gold);
}
.rank-strong {
    background: rgba(46, 204, 113, 0.18);
    color: #2ecc71;
}
.rank-average {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}
.rank-weak {
    background: rgba(230, 126, 34, 0.18);
    color: #e67e22;
}
.rank-poor {
    background: rgba(231, 76, 60, 0.18);
    color: #e74c3c;
}

/* --- Hover Tooltip (CSS-only, positioned above badge) --- */
.unit-badge-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: rgba(18, 13, 7, 0.96);
    border: 1px solid rgba(201, 168, 76, 0.3);
    border-radius: 8px;
    padding: 10px 12px;
    min-width: 180px;
    max-width: 260px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    white-space: normal;
    text-align: left;
}
.unit-badge:hover .unit-badge-tooltip {
    display: block;
}

/* Tooltip arrow */
.unit-badge-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(18, 13, 7, 0.96);
}

/* --- Tooltip content lines --- */
.tooltip-bonus {
    color: #2ecc71;
    font-size: 0.8rem;
    line-height: 1.4;
    margin-bottom: 3px;
}
.tooltip-missing {
    color: #e74c3c;
    font-size: 0.8rem;
    line-height: 1.4;
    margin-bottom: 3px;
}
.tooltip-rank {
    color: var(--text-dim);
    font-size: 0.75rem;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- Loading / Spinner --- */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px;
    color: var(--text-muted);
}
.loading-spinner .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(201, 168, 76, 0.2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- No Data --- */
.no-data {
    color: var(--text-dim);
    font-style: italic;
    padding: 20px;
    text-align: center;
}

/* --- Light Mode Overrides --- */
[data-theme="light"] .civ-card {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .civ-card:hover {
    border-color: rgba(139, 105, 20, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .civ-card.selected-civ1 {
    background: rgba(139, 105, 20, 0.1);
}
[data-theme="light"] .analysis-hero {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(139, 105, 20, 0.2);
}
[data-theme="light"] .role-column {
    background: rgba(0, 0, 0, 0.02);
    border-top-color: rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .role-column.col-strong {
    border-top-color: #2a9a50;
    background: rgba(42, 154, 80, 0.06);
}
[data-theme="light"] .role-column.has-signature {
    border-top-color: var(--gold);
    background: rgba(139, 105, 20, 0.06);
}
[data-theme="light"] .unit-badge {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
    border-left-color: rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .unit-badge:hover {
    background: rgba(0, 0, 0, 0.07);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .unit-badge.signature {
    border-color: rgba(139, 105, 20, 0.3);
    border-left-color: var(--gold);
    background: linear-gradient(135deg, rgba(139, 105, 20, 0.08) 0%, rgba(139, 105, 20, 0.03) 100%);
    box-shadow: 0 0 12px rgba(139, 105, 20, 0.08);
}
[data-theme="light"] .unit-badge-tooltip {
    background: rgba(244, 240, 232, 0.97);
    border-color: rgba(139, 105, 20, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .unit-badge-tooltip::after {
    border-top-color: rgba(244, 240, 232, 0.97);
}
[data-theme="light"] .unit-badge-icon {
    background: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .signature-icon {
    background: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .signature-star {
    background: var(--bg-deep);
}
[data-theme="light"] .pill-strong {
    background: rgba(42, 154, 80, 0.12);
    color: #1f7a3a;
}
[data-theme="light"] .pill-weak {
    background: rgba(200, 60, 50, 0.1);
    color: #b83030;
}
[data-theme="light"] .rank-good {
    background: rgba(42, 154, 80, 0.12);
    color: #1f7a3a;
}
[data-theme="light"] .rank-weak {
    background: rgba(200, 60, 50, 0.1);
    color: #b83030;
}
[data-theme="light"] .rank-average {
    background: rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .rank-signature {
    background: rgba(139, 105, 20, 0.12);
}
[data-theme="light"] .loading-spinner .spinner {
    border-color: rgba(139, 105, 20, 0.15);
    border-top-color: var(--gold);
}
[data-theme="light"] .tooltip-bonus {
    color: #1f7a3a;
}
[data-theme="light"] .tooltip-missing {
    color: #b83030;
}

/* --- Responsive: 768px — 2 columns --- */
@media (max-width: 768px) {
    .analysis-hero {
        gap: 16px;
        padding: 16px 20px;
    }
    .analysis-civ-name {
        font-size: 1.3rem;
    }
    .analysis-emblem {
        width: 56px;
        height: 56px;
    }
    .role-columns {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .unit-badge-name {
        font-size: 0.72rem;
    }
    .unit-badge-tooltip {
        left: 0;
        transform: none;
        min-width: 160px;
    }
}

/* --- Responsive: 600px — 1 column, hero stacks --- */
@media (max-width: 600px) {
    .civ-grid {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
        gap: 8px;
    }
    .civ-emblem {
        width: 36px;
        height: 36px;
    }
    .civ-card-name {
        font-size: 0.7rem;
    }
    .analysis-hero {
        flex-direction: column;
        text-align: center;
        align-items: center;
        gap: 12px;
        padding: 16px;
    }
    .analysis-hero-body .pill-row {
        justify-content: center;
    }
    .analysis-civ-name {
        font-size: 1.2rem;
    }
    .analysis-emblem {
        width: 56px;
        height: 56px;
    }
    .role-columns {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .unit-badge-icon {
        width: 52px;
        height: 52px;
    }
    .signature-icon {
        width: 60px;
        height: 60px;
    }
    .unit-badge-name {
        font-size: 0.7rem;
    }
    .unit-badge-rank {
        font-size: 0.55rem;
        padding: 1px 6px;
    }
    .role-header {
        font-size: 0.7rem;
    }
    .line-label {
        font-size: 0.62rem;
    }
}
