/* Hero Selection Overlay - UI Toolkit Panel System */

/* ===== OVERLAY ===== */
.hero-selection-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 10, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.hero-selection-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== MAIN CONTAINER PANEL ===== */
.hero-selection-container {
    position: relative;
    z-index: 10;
    max-width: 90vw;
    width: 100%;
    height: 85vh;
    padding: 25px;
    background: transparent;
    animation: heroSelectionSlideUp 0.8s ease-out;
}

.hero-selection-container.panel > .panel-content {
    overflow-y: auto;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 1vh;
    scrollbar-width: thin;
    scrollbar-color: #4a3a35 #2a1a18;
}

/* ===== BROWN SCROLLBAR ===== */
.hero-selection-container.panel > .panel-content::-webkit-scrollbar {
    width: 10px;
}

.hero-selection-container.panel > .panel-content::-webkit-scrollbar-track {
    background: rgba(26, 15, 31, 0.5);
    border-radius: 5px;
    border: 1px solid #3a2a28;
}

.hero-selection-container.panel > .panel-content::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #5a4a45 0%, #3a2a28 100%);
    border-radius: 5px;
    border: 1px solid #4a3a35;
    box-shadow: inset 0 0 5px rgba(90, 74, 69, 0.3);
}

.hero-selection-container.panel > .panel-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #6a5a55 0%, #4a3a35 100%);
    box-shadow: 0 0 8px rgba(90, 74, 69, 0.6);
}

@keyframes heroSelectionSlideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===== BACK BUTTON ===== */
.hero-selection-back {
    position: absolute;
    top: calc(7.5vh - 27px);
    left: calc(5vw - 27px);
    z-index: 15;
    cursor: var(--cm-cursor-action, pointer);
}

.hero-selection-back.btn.panel {
    width: 36px;
    height: 36px;
    background: transparent;
}

.hero-selection-back.panel > .panel-content {
    font-size: 14px;
    line-height: 1;
    color: var(--kit-text-color, #8a7a75);
}

/* Selected state - keyboard/gamepad */
.hero-selection-back.gamepad-selected {
    --kit-frame-color: #6a5040;
    --kit-frame-inner: #4a3530;
    --kit-corner-color: #8a6a55;
    --kit-diamond-color: #aa8a70;
}

.hero-selection-back.gamepad-selected > .panel-texture {
    background:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
        radial-gradient(ellipse 80px 120px at 30% 25%, rgba(40, 25, 20, 0.15) 0%, transparent 70%),
        radial-gradient(ellipse 100px 80px at 70% 45%, rgba(35, 20, 18, 0.12) 0%, transparent 70%),
        linear-gradient(180deg,
            #18100c 0%,
            #201510 12%,
            #2a1a14 30%,
            #302018 45%,
            #281814 58%,
            #201210 70%,
            #140c08 100%
        );
    background-blend-mode: soft-light, normal, normal, normal;
}

.hero-selection-back.gamepad-selected > .panel-content {
    color: var(--text-brown-accent);
}

.hero-selection-back.gamepad-selected > .deco-frame::before {
    box-shadow:
        0 0 10px rgba(120, 90, 60, 0.2),
        inset 0 0 0 4px transparent,
        inset 0 0 0 6px var(--kit-frame-inner, #4a3530);
}

/* ===== HEADER - uses menu-header-ornate from menu.css ===== */
.hero-selection-header {
    flex-shrink: 0;
}

/* ===== ROSTER INFO - uses menu-subtitle from menu.css ===== */
.hero-selection-roster-info {
    text-align: center;
    flex-shrink: 0;
}

/* ===== HERO LIST ===== */
.hero-selection-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 300px));
    grid-auto-rows: max-content;
    justify-content: center;
    align-items: start;
    align-content: start;
    gap: 1vw;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1vh 1vw;
    scrollbar-width: thin;
    scrollbar-color: #4a3a35 #2a1a18;
}

.hero-selection-list::-webkit-scrollbar {
    width: 10px;
}

.hero-selection-list::-webkit-scrollbar-track {
    background: rgba(26, 15, 31, 0.5);
    border-radius: 5px;
    border: 1px solid #3a2a28;
}

.hero-selection-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #5a4a45 0%, #3a2a28 100%);
    border-radius: 5px;
    border: 1px solid #4a3a35;
    box-shadow: inset 0 0 5px rgba(90, 74, 69, 0.3);
}

.hero-selection-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #6a5a55 0%, #4a3a35 100%);
    box-shadow: 0 0 8px rgba(90, 74, 69, 0.6);
}

/* ===== HERO CARD - UI Kit Panel ===== */
.hero-selection-card.panel {
    cursor: var(--cm-cursor-action, pointer);
    transition: transform 220ms ease, box-shadow 220ms ease, filter 220ms ease;
}

.hero-selection-card.panel.frame-compact > .panel-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 13px 13px 10px !important;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
}

/* Hover state */
.hero-selection-card.panel:hover:where(body:not(.gamepad-active) *),
.hero-selection-card.panel.gamepad-selected {
    transform: translateY(-7px) scale(1.025);
    z-index: 10;
    --kit-frame-color: #6a5040;
    --kit-frame-inner: #4a3530;
    --kit-corner-color: #8a6a55;
    --kit-diamond-color: #aa8a70;
    --roster-card-accent: #a77f55;
    --roster-card-accent-bright: #e0b77b;
    box-shadow:
        0 22px 30px rgba(0, 0, 0, 0.64),
        0 0 16px rgba(166, 121, 75, 0.2);
}

.hero-selection-card.panel:hover:where(body:not(.gamepad-active) *) > .deco-frame::before,
.hero-selection-card.panel.gamepad-selected > .deco-frame::before {
    box-shadow:
        0 0 14px rgba(120, 90, 60, 0.34),
        inset 0 0 0 2px #120b0c,
        inset 0 0 0 4px color-mix(in srgb, var(--roster-card-accent) 64%, #251619);
}

/* Selected state - gold glow */
.hero-selection-card.panel.selected {
    --kit-frame-color: rgba(255, 215, 0, 0.7);
    --kit-frame-inner: rgba(218, 165, 32, 0.6);
    --kit-corner-color: rgba(255, 215, 0, 0.8);
    --kit-diamond-color: rgba(255, 215, 0, 0.9);
    --roster-card-accent: #b58a36;
    --roster-card-accent-bright: #f2cf6b;
    box-shadow:
        0 18px 28px rgba(0, 0, 0, 0.58),
        0 0 18px rgba(218, 165, 32, 0.32);
}

/* Legendary Card */
.hero-selection-card.panel.legendary {
    --kit-frame-color: rgba(255, 140, 0, 0.5);
    --kit-frame-inner: rgba(255, 100, 0, 0.4);
    --kit-corner-color: rgba(255, 140, 0, 0.6);
    --kit-diamond-color: rgba(255, 140, 0, 0.7);
    --roster-card-accent: #a9581f;
    --roster-card-accent-bright: #ff9d33;
    animation: legendaryGlow 3s ease-in-out infinite alternate;
}

@keyframes legendaryGlow {
    from {
        box-shadow: 0 0 10px rgba(255, 140, 0, 0.2);
    }
    to {
        box-shadow: 0 0 20px rgba(255, 140, 0, 0.4);
    }
}

/* Legendary selected - gold frame */
.hero-selection-card.panel.legendary.selected {
    --kit-frame-color: rgba(255, 215, 0, 0.7);
    --kit-frame-inner: rgba(218, 165, 32, 0.6);
    --kit-corner-color: rgba(255, 215, 0, 0.8);
    --kit-diamond-color: rgba(255, 215, 0, 0.9);
    --roster-card-accent: #b58a36;
    --roster-card-accent-bright: #f2cf6b;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
    animation: none;
}

/* ===== HERO PORTRAIT ===== */
.hero-card-portrait {
    position: relative;
    width: 100%;
    height: 40%;
    min-height: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--roster-card-accent-bright) 54%, transparent);
    background:
        linear-gradient(90deg, transparent 49.5%, rgba(196, 153, 99, 0.08) 50%, transparent 50.5%),
        linear-gradient(0deg, transparent 49.5%, rgba(196, 153, 99, 0.07) 50%, transparent 50.5%),
        radial-gradient(circle at 50% 52%, color-mix(in srgb, var(--roster-card-accent) 30%, transparent), transparent 55%),
        linear-gradient(160deg, rgba(34, 21, 19, 0.96), rgba(8, 6, 8, 0.98));
    box-shadow:
        inset 0 0 28px rgba(0, 0, 0, 0.72),
        0 2px 0 rgba(0, 0, 0, 0.78);
}

.hero-card-portrait::before {
    content: '';
    position: absolute;
    width: 72%;
    aspect-ratio: 1;
    border: 1px solid color-mix(in srgb, var(--roster-card-accent-bright) 22%, transparent);
    transform: rotate(45deg);
    box-shadow:
        0 0 0 10px rgba(8, 5, 7, 0.12),
        0 0 24px color-mix(in srgb, var(--roster-card-accent) 18%, transparent);
}

.hero-card-portrait img {
    position: relative;
    z-index: 2;
    width: 82%;
    height: 82%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Legendary Portrait Glow */
.hero-selection-card.panel.legendary .hero-card-portrait img {
    filter: drop-shadow(0 0 8px rgba(255, 140, 0, 0.5));
}

/* ===== HERO CARD DETAILS ===== */
.hero-card-details {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
}

.hero-card-nameplate {
    position: relative;
    z-index: 4;
    min-height: 32px;
    margin: -9px 10px 5px;
    padding: 6px 12px 5px;
    box-sizing: border-box;
    background: linear-gradient(180deg, color-mix(in srgb, var(--roster-card-accent) 54%, #2a1916), #130c0d 72%);
    clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--roster-card-accent-bright) 58%, transparent);
}

.hero-card-name {
    overflow: hidden;
    font-size: clamp(15px, 0.95vw, 21px);
    line-height: 1.08;
    color: var(--text-brown-accent, #c0a080);
    font-weight: bold;
    font-family: 'SFPixelate', 'Courier New', monospace;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Legendary Name */
.hero-selection-card.panel.legendary .hero-card-name {
    color: #ff8c00;
    text-shadow:
        0 2px 4px rgba(0, 0, 0, 0.5),
        0 0 10px rgba(255, 140, 0, 0.4);
}

.hero-card-info {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 4px 5px;
    font-size: clamp(9px, 0.58vw, 12px);
    color: var(--text-brown-light, #a89a90);
    font-family: 'SFPixelate', 'Courier New', monospace;
}

.hero-card-info span {
    padding: 3px 5px;
    border: 1px solid rgba(120, 90, 72, 0.52);
    background: rgba(20, 12, 12, 0.78);
}

.hero-card-info span:first-child { color: #a9d8ef; }
.hero-card-info span:last-child { color: #e6b87d; }

.hero-card-mastery {
    margin: 0 4px 5px;
    color: var(--roster-card-accent-bright);
    font: 600 clamp(9px, 0.58vw, 12px)/1.2 'SFPixelate', 'Courier New', monospace;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.hero-card-categories {
    min-height: 1.3em;
    margin: 0 6px 4px;
    overflow: hidden;
    font-size: clamp(9px, 0.56vw, 12px);
    line-height: 1.3;
    color: #88dd88;
    font-family: 'SFPixelate', 'Courier New', monospace;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.hero-card-legendary {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 5;
    padding: 3px 6px;
    border: 1px solid rgba(255, 176, 79, 0.7);
    background: rgba(35, 15, 4, 0.84);
    color: #ff8c00;
    font-size: 14px;
    font-family: 'SFPixelate', 'Courier New', monospace;
    text-shadow: 0 0 8px rgba(255, 140, 0, 0.5);
}

/* Zdolność wrodzona bohatera */
.hero-card-passive {
    flex: 1;
    min-height: 0;
    margin: 2px 5px;
    padding: 6px 7px 5px;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--roster-card-accent) 48%, transparent);
    background: linear-gradient(180deg, rgba(11, 7, 8, 0.2), rgba(7, 5, 7, 0.62));
    text-align: left;
}

.hero-card-passive-name {
    color: #c49963;
    font-size: clamp(10px, 0.62vw, 13px);
    font-family: 'SFPixelate', 'Courier New', monospace;
}

.hero-card-passive-desc {
    display: -webkit-box;
    margin-top: 3px;
    overflow: hidden;
    color: var(--text-brown-light, #a89a90);
    font-size: clamp(9px, 0.55vw, 12px);
    font-family: 'SFPixelate', 'Courier New', monospace;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
}

.hero-card-add-button {
    flex: 0 0 auto;
    margin: 4px 6px 1px;
    padding: 6px 8px;
    cursor: var(--cm-cursor-action, pointer);
    border: 1px solid color-mix(in srgb, var(--roster-card-accent-bright) 72%, transparent);
    background: linear-gradient(180deg, rgba(79, 58, 37, 0.9), rgba(28, 18, 16, 0.96));
    color: #d8bd91;
    font: 600 clamp(9px, 0.58vw, 12px)/1.2 'SFPixelate', 'Courier New', monospace;
    text-transform: uppercase;
}

.hero-card-add-button:hover:where(body:not(.gamepad-active) *),
.hero-card-add-button:focus-visible {
    color: #ffe1a3;
    border-color: var(--roster-card-accent-bright);
    outline: none;
}

/* ===== NO HEROES AVAILABLE ===== */
.no-heroes-available {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-brown-light, #a89a90);
    font-size: 18px;
    font-family: 'SFPixelate', 'Courier New', monospace;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1920px) {
    .hero-selection-list {
        grid-template-columns: repeat(4, minmax(0, 270px));
        gap: 0.8vw;
    }

    .hero-selection-card.roster-card.panel {
        max-width: 270px;
    }
}

@media (max-width: 1366px) {
    .hero-selection-container {
        padding: 18px;
    }

    .hero-selection-list {
        grid-template-columns: repeat(3, minmax(0, 245px));
    }

    .hero-selection-card.roster-card.panel {
        max-width: 245px;
    }
}

@media (max-width: 1280px) {
    .hero-selection-container {
        padding: 15px;
    }

    .hero-selection-list {
        grid-template-columns: repeat(3, minmax(0, 225px));
        gap: 0.6vw;
    }

    .hero-selection-card.roster-card.panel {
        max-width: 225px;
    }
}

@media (max-width: 768px) {
    .hero-selection-list {
        grid-template-columns: repeat(2, minmax(0, 210px));
    }
}

/* Locked heroes remain visible with their acquisition condition. */
.hero-selection-card.locked { cursor: var(--cm-cursor-disabled, not-allowed); }
.hero-selection-card.locked .hero-card-portrait { filter: grayscale(1); opacity: 0.6; }
.hero-selection-card.locked .hero-card-add-button { display: none; }
