/* Codex S.H.I.E.L.D. — styles communs au codex public (/codex/...) et au codex perso (/collection, /equipe, ...) */
:root {
    --bg: #0d0f15; --card: #171a21; --card-2: #10131a; --line: #2a2e37; --text: #f2f4f8; --muted: #8b919c; --dim: #535963;
    --accent: #5865F2; --gold: #f1c40f; --green: #2ecc71; --red: #e74c3c; --purple: #b48cf2; --orange: #f39c12;
    --font-title: 'Rajdhani', 'Segoe UI', system-ui, sans-serif; --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; font-family: var(--font-body); color: var(--text);
       background: radial-gradient(circle at top, #1d2230 0%, var(--bg) 65%) fixed; background-color: var(--bg); }
a { color: inherit; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px 48px; }

/* Couleur de tier : --tc (couleur), --tc-ink (texte posé dessus) */
.t-exclusif { --tc: #e0f7fa; --tc-ink: #0b0f19; } .t-legende { --tc: #ff4757; --tc-ink: #fff; } .t-s { --tc: #f1c40f; --tc-ink: #000; }
.t-a { --tc: #9b59b6; --tc-ink: #fff; } .t-b { --tc: #3498db; --tc-ink: #fff; } .t-c { --tc: #2ecc71; --tc-ink: #000; }
.t-d, .t-autre, .t-t1 { --tc: #95a5a6; --tc-ink: #fff; } .t-t2 { --tc: #2ecc71; --tc-ink: #000; } .t-t3 { --tc: #3498db; --tc-ink: #fff; }
.t-t4 { --tc: #9b59b6; --tc-ink: #fff; } .t-t5 { --tc: #f1c40f; --tc-ink: #000; } .t-t6 { --tc: #ff0055; --tc-ink: #fff; }
.t-icon { --tc: #e67e22; --tc-ink: #fff; }

/* En-tête de page */
.page-header { text-align: center; padding: 26px 0 14px; }
.page-header h1 { margin: 0; font-family: var(--font-title); font-size: 30px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; text-shadow: 0 0 15px rgba(88, 101, 242, 0.45); }
.page-header p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.page-header .player { color: var(--gold); font-weight: 700; }

/* Navigation du codex public (pilules) */
.nav-public { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.nav-public a, .nav-public button { background: var(--card); color: var(--muted); text-decoration: none; padding: 8px 15px; border-radius: 20px; font: 700 13px var(--font-body); border: 1px solid var(--line); cursor: pointer; transition: 0.15s; }
.nav-public a:hover { color: #fff; border-color: #454b57; }
.nav-public a.current { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 0 12px rgba(88, 101, 242, 0.4); }
.nav-public button.idea { background: var(--orange); color: #000; border-color: var(--orange); }

/* Navigation du codex perso (onglets) */
.nav-perso { background: #0f131c; border-bottom: 1px solid rgba(255, 255, 255, 0.08); display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; padding: 12px 16px 0; }
.nav-perso a { color: var(--muted); text-decoration: none; font: 700 15px var(--font-title); text-transform: uppercase; letter-spacing: 1px; padding: 10px 16px; border-bottom: 2px solid transparent; transition: 0.15s; }
.nav-perso a:hover { color: #fff; }
.nav-perso a.current { color: var(--gold); border-bottom-color: var(--gold); }

/* Barre d'outils collante : recherche + filtres */
.toolbar { position: sticky; top: 0; z-index: 50; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 6px;
           background: rgba(13, 15, 21, 0.92); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 12px; }
.search-input { flex: 1 1 220px; min-width: 0; background: var(--card-2); border: 1px solid var(--line); color: #fff; padding: 8px 14px; border-radius: 20px; outline: none; font: 13px var(--font-body); }
.search-input:focus { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-btn { background: var(--card-2); border: 1px solid var(--line); color: var(--muted); padding: 6px 12px; border-radius: 20px; cursor: pointer; font: 700 12px var(--font-body); transition: 0.15s; }
.filter-btn:hover { color: #fff; }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.result-count { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }

/* Sections */
.tier-section { margin-top: 24px; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font: 700 16px var(--font-title); letter-spacing: 2px; text-transform: uppercase; color: var(--tc, var(--accent)); white-space: nowrap; }
.section-head .line { flex: 1; height: 1px; background: linear-gradient(90deg, var(--tc, var(--accent)), transparent); opacity: 0.5; }
.section-head .count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.empty-msg { text-align: center; color: var(--muted); margin: 40px 0; font-style: italic; }

/* Grilles et cartes */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min, 170px), 1fr)); gap: 14px; }
.card { position: relative; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--tc, var(--line));
        border-radius: 12px; overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; }
.card.clickable { cursor: pointer; }
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55), 0 0 12px color-mix(in srgb, var(--tc, #000) 30%, transparent); }
.card.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-body { padding: 10px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card-title { margin: 0; font: 700 16px var(--font-title); line-height: 1.15; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.badge-tier { position: absolute; top: 8px; left: 8px; z-index: 2; padding: 3px 8px; border-radius: 6px; font: 800 11px var(--font-title); letter-spacing: 1px; text-transform: uppercase;
              background: var(--tc, #555); color: var(--tc-ink, #fff); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
.badge-corner { position: absolute; top: 8px; right: 8px; z-index: 2; background: rgba(0, 0, 0, 0.75); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 6px; padding: 2px 7px; font: 700 12px var(--font-title); }

.portrait { position: relative; aspect-ratio: var(--portrait-ratio, 4 / 5); background: var(--card-2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.portrait img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: top center; }
.portrait::after { content: ''; position: absolute; inset: auto 0 0 0; height: 35%; background: linear-gradient(to top, var(--card), transparent); pointer-events: none; }
.portrait .placeholder { font-size: 42px; opacity: 0.25; }
.fit-top { object-fit: cover; object-position: top center; } .fit-center { object-fit: cover; object-position: center center; }
.fit-bottom { object-fit: cover; object-position: bottom center; } .fit-contain { object-fit: contain !important; padding: 6px; }
.portrait-ribbon { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); z-index: 2; padding: 2px 16px; font: 700 12px var(--font-title); letter-spacing: 2px; white-space: nowrap; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--card-2); padding: 6px 4px; border-radius: 8px; }
.stat-box { display: flex; flex-direction: column; align-items: center; font-size: 10px; color: var(--muted); line-height: 1.25; text-align: center; }
.stat-val { font-size: 13px; font-weight: 800; color: #fff; }
.stat-box.dim .stat-val { color: var(--dim); }
.pill { display: block; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 12px; color: var(--muted); text-align: center; font-weight: 600; }
.pill b { color: #fff; }
.chip { display: inline-block; background: rgba(0, 210, 255, 0.08); border: 1px solid rgba(0, 210, 255, 0.3); color: #00d2ff; font-size: 11px; padding: 3px 8px; border-radius: 6px; font-weight: 600; }
.chip.purple { background: rgba(155, 89, 182, 0.1); border-color: rgba(155, 89, 182, 0.3); color: #c39bd3; }
.chip.gold { background: rgba(241, 196, 15, 0.1); border-color: rgba(241, 196, 15, 0.3); color: var(--gold); }
.chip.green { background: rgba(46, 204, 113, 0.1); border-color: rgba(46, 204, 113, 0.3); color: var(--green); }
.chip.muted { background: rgba(139, 145, 156, 0.08); border-color: var(--line); color: var(--muted); }

/* États (codex perso) */
.card.not-owned { filter: grayscale(100%); opacity: 0.45; }
.card.not-owned:hover { opacity: 0.8; }
.card.is-awakened { border-color: #ffd700; box-shadow: 0 0 14px rgba(255, 215, 0, 0.35); }
.card.is-awakened .card-title { color: #ffd700; }
.is-awakened .portrait-ribbon { background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.85), transparent); }
.card.is-equipped { border-color: var(--green); box-shadow: 0 0 14px rgba(46, 204, 113, 0.35); }
.card.is-equipped .card-title { color: var(--green); }
.is-equipped .portrait-ribbon { background: linear-gradient(90deg, transparent, rgba(46, 204, 113, 0.85), transparent); }

/* Panneaux, tableaux */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.panel-head { padding: 12px 16px; background: var(--card-2); border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { margin: 0; font: 700 18px var(--font-title); text-transform: uppercase; letter-spacing: 1px; }
.panel-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.panel-body { padding: 14px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
table.data th { background: rgba(0, 0, 0, 0.2); color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
table.data tr:last-child td { border-bottom: none; }
details.panel > summary { cursor: pointer; list-style: none; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary h3::after { content: ' ▾'; color: var(--muted); }
details.panel[open] > summary h3::after { content: ' ▴'; }

/* Modales */
.modal-overlay { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(4px); }
.modal-overlay.open { display: flex; }
.modal-content { position: relative; width: 100%; max-width: 520px; max-height: 85vh; overflow-y: auto; padding: 24px; background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--tc, var(--accent)); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8); }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: none; color: var(--muted); font-size: 26px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: #fff; }
.modal-title { margin: 0 34px 14px 0; font: 700 24px var(--font-title); line-height: 1.15; }
.modal-label { display: block; margin: 16px 0 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.list-rows { display: flex; flex-direction: column; gap: 6px; }
.list-rows > div { display: flex; justify-content: space-between; gap: 10px; background: var(--card-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; font-size: 13.5px; }
.list-rows .qty { font-weight: 700; color: var(--green); white-space: nowrap; }
.list-rows .hl { border-color: var(--red); color: var(--red); }
.text-box { background: rgba(88, 101, 242, 0.1); border-left: 3px solid var(--accent); padding: 12px; border-radius: 6px; font-size: 13.5px; line-height: 1.5; color: #e1e3e8; }
.idea-input { width: 100%; padding: 12px; margin-bottom: 12px; border-radius: 8px; background: var(--card-2); border: 1px solid var(--line); color: #fff; font-family: inherit; }
.idea-input:focus { outline: none; border-color: var(--orange); }
.btn { display: block; width: 100%; padding: 12px; border: none; border-radius: 8px; font: 700 15px var(--font-body); cursor: pointer; text-align: center; text-decoration: none; }
.btn-orange { background: var(--orange); color: #000; }

@media (max-width: 520px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(min(var(--card-min, 170px), 46%), 1fr)); gap: 10px; }
    .result-count { width: 100%; margin-left: 0; }
    .page-header h1 { font-size: 24px; }
    .nav-perso a { padding: 8px 10px; font-size: 13px; }
}

/* Types de héros (types_core.py) */
.type-badges { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.type-badge { background: rgba(155, 89, 182, 0.15); border: 1px solid rgba(155, 89, 182, 0.35); color: #e0c8ee; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; white-space: nowrap; }
details.type-chart-box { margin: 0 0 28px; }
details.type-chart-box > summary { cursor: pointer; list-style: none; }
details.type-chart-box > summary::-webkit-details-marker { display: none; }
details.type-chart-box > summary h2::after { content: ' ▾'; color: var(--muted); }
details.type-chart-box[open] > summary h2::after { content: ' ▴'; }
.tc-panel { background: linear-gradient(180deg, #1a1e27, var(--card-2)); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.tc-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; margin-bottom: 14px; font-size: 12px; color: var(--muted); }
.tc-legend span { display: inline-flex; align-items: center; gap: 7px; }
.tc-legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.tc-dot { width: 14px; height: 14px; border-radius: 4px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); }
.tc-hint { margin: 12px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.tc-hint b { color: var(--text); }
.type-chart-wrap { overflow: auto; max-height: 78vh; }
.type-chart { border-collapse: separate; border-spacing: 4px; margin: auto; font-variant-numeric: tabular-nums; }
.type-chart th, .type-chart td { padding: 0; }
.type-chart thead th { position: sticky; top: 0; z-index: 2; background: #191d26; vertical-align: bottom; padding: 4px 2px 8px; min-width: 56px; border-bottom: 3px solid var(--ty); border-radius: 8px 8px 0 0; transition: background 0.12s; }
.type-chart tbody th { position: sticky; left: 0; z-index: 1; background: #191d26; text-align: left; white-space: nowrap; font: 700 13px var(--font-body); padding: 0 12px 0 8px; border-left: 3px solid var(--ty); border-radius: 0 8px 8px 0; transition: background 0.12s; }
.type-chart tbody th .tc-ico { display: inline-block; width: 22px; font-size: 15px; }
.type-chart .tc-corner { left: 0; z-index: 3; border: 0; font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; text-align: right; }
.type-chart .tc-corner span { display: block; }
.type-chart thead .tc-ico { display: block; font-size: 20px; line-height: 1.3; }
.type-chart .tc-name { display: block; font-size: 10px; font-weight: 700; color: var(--ty); text-transform: uppercase; letter-spacing: 0.4px; }
.tc-cell { display: flex; align-items: center; justify-content: center; height: 38px; border-radius: 8px; font: 800 13px var(--font-body); background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.04); transition: transform 0.1s, box-shadow 0.1s, background 0.1s; }
.tc-super { background: linear-gradient(135deg, #2ecc71, #1e9e57); border-color: #3ee083; color: #062b16; box-shadow: 0 0 10px rgba(46, 204, 113, 0.25); }
.tc-peu { background: rgba(231, 76, 60, 0.16); border-color: rgba(231, 76, 60, 0.45); color: #ff8f84; }
.tc-nul { background: repeating-linear-gradient(135deg, #0a0b10 0 6px, #14161d 6px 12px); border-color: #3a3f4b; color: #8b919c; }
.type-chart tbody tr:hover th, .type-chart th.tc-col { background: #262c3a; }
.type-chart tbody tr:hover .tc-cell:not(.tc-super):not(.tc-peu):not(.tc-nul), .type-chart td.tc-col .tc-cell:not(.tc-super):not(.tc-peu):not(.tc-nul) { background: rgba(88, 101, 242, 0.12); }
.type-chart td:hover .tc-cell { transform: scale(1.12); box-shadow: 0 0 0 2px var(--accent), 0 6px 16px rgba(0, 0, 0, 0.5); position: relative; z-index: 1; }
@media (max-width: 640px) { .tc-panel { padding: 10px; } .type-chart thead th { min-width: 44px; } .type-chart .tc-name { display: none; } .tc-cell { height: 32px; font-size: 11px; } }
