/* ═══════════════════════════════════════════════════════
   Global Stylesheet
   Import order: tokens → reset → layout → utilities
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ═══════════════════════════════════════════════════════
   1. DESIGN TOKENS
   ═══════════════════════════════════════════════════════ */
:root {
    /* Gray scale */
    --gray-darkest: #161317;
    --gray-dark: #2c262d;
    --gray-mid: #3a333b;
    --gray-light: #52474e;
    --gray-lightest: #7a676f;

    /* Red / damage */
    --red-darkest: #522d2d;
    --red-dark: #72403b;
    --red-mid: #895142;
    --red-light: #aa644d;

    /* Sand / parchment */
    --sand-darkest: #7e5c57;
    --sand-dark: #a68576;
    --sand-mid: #c2af91;
    --sand-light: #f5e9bf;

    /* Skin */
    --skin-darkest: #5d4e54;
    --skin-dark: #94797f;
    --skin-mid: #be9b97;
    --skin-light: #e6bdaf;

    /* Rotten green */
    --rg-darkest: #3f3e43;
    --rg-dark: #635d67;
    --rg-mid: #837481;
    --rg-light: #a99aa4;

    /* Light green / nature */
    --lg-darkest: #303332;
    --lg-dark: #494e4b;
    --lg-mid: #5e675f;
    --lg-light: #788374;

    /* Dark green / muted teal */
    --dg-darkest: #242426;
    --dg-dark: #3e4143;
    --dg-mid: #5d6567;
    --dg-light: #748382;

    /* Rarity */
    --rarity-common: var(--gray-lightest);
    --rarity-rare: #6fa3d4;
    --rarity-epic: #b07fd0;
    --rarity-legend: #d4a84b;

    /* Semantic aliases */
    --color-bg: var(--gray-darkest);
    --color-surface: var(--gray-dark);
    --color-border: var(--gray-light);
    --color-border-sub: var(--gray-mid);
    --color-text: var(--sand-light);
    --color-text-dim: var(--sand-dark);
    --color-text-muted: var(--gray-lightest);
    --color-accent: var(--red-mid);
    --color-accent-hi: var(--red-light);

    /* Pixel font */
    --font-pixel: 'Press Start 2P', monospace;
    --font-ui: ui-sans-serif, system-ui, sans-serif;

    /* Layout */
    --nav-w: 210px;
    --header-h: 58px;
    --footer-h: 42px;
    --bottom-nav-h: 56px;

    /* Pixel shadow — standard box outline used everywhere */
    --px-shadow: 0 0 0 2px var(--gray-lightest), 3px 3px 0 var(--gray-darkest);
    --px-shadow-red: 0 0 0 2px var(--red-mid), 3px 3px 0 var(--gray-darkest);
    --px-shadow-sand: 0 0 0 2px var(--sand-mid), 3px 3px 0 var(--gray-darkest);
    --px-shadow-lg: 0 0 0 2px var(--lg-mid), 3px 3px 0 var(--gray-darkest);
    --px-inset: inset 0 0 0 2px var(--gray-light);

    /* Transitions */
    --t-fast: 0.08s;
    --t-med: 0.15s;

    --px-scale: 2;

    --right-sidebar-size: 400px;
}

/* ═══════════════════════════════════════════════════════
   2. RESET
   ═══════════════════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-ui);
    font-size: calc(7.5px * var(--px-scale));
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

/* CRT scanline overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent 3px,
            rgba(0, 0, 0, .07) 3px,
            rgba(0, 0, 0, .07) 4px
    );
    pointer-events: none;
    z-index: 9999;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: var(--gray-darkest);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-light);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-lightest);
}

/* ═══════════════════════════════════════════════════════
   3. LAYOUT SHELL  (consumed by MainLayout.razor)
   ═══════════════════════════════════════════════════════ */

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Header ── */
#header {
    height: var(--header-h);
    flex-shrink: 0;
    background: var(--color-surface);
    border-bottom: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    gap: 10px;
    z-index: 50;
}

#header .logo {
    font-family: var(--font-pixel);
    font-size: calc(13px * var(--px-scale));
    color: var(--sand-light);
    text-shadow: 2px 2px 0 var(--red-dark), 4px 4px 0 var(--gray-darkest);
    letter-spacing: 2px;
    white-space: nowrap;
}

#header .logo span {
    color: var(--red-light);
}

#header .header-stats {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Body row ── */
#body-row {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ── Side nav ── */
#sidenav {
    width: var(--nav-w);
    flex-shrink: 0;
    background: var(--color-surface);
    border-right: 2px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 40;
}

/* ── Main content area ── */
#main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ── Footer ── */
#footer {
    height: var(--footer-h);
    flex-shrink: 0;
    background: var(--color-surface);
    border-top: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    font-size: calc(5px * var(--px-scale));
    color: var(--color-text-muted);
    font-family: var(--font-pixel);
    z-index: 50;
}

/* ── Mobile bottom nav ── */
#bottom-nav {
    display: none;
    height: var(--bottom-nav-h);
    flex-shrink: 0;
    background: var(--color-surface);
    border-top: 2px solid var(--color-border);
    z-index: 50;
}

/* ── Mobile detail sheet ── */
#detail-sheet {
    display: none;
    position: fixed;
    bottom: var(--bottom-nav-h);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-top: 2px solid var(--gray-lightest);
    z-index: 200;
    max-height: 82vh;
    overflow-y: auto;
}

#detail-sheet.show {
    display: block;
    animation: dv-slideup var(--t-med) ease;
}

/* ═══════════════════════════════════════════════════════
   5. SURFACE VARIANTS
   ═══════════════════════════════════════════════════════ */

.dv-panel {
    background: var(--color-surface);
    box-shadow: var(--px-shadow);
}

.dv-inset {
    background: var(--gray-darkest);
    box-shadow: var(--px-inset);
}

.dv-section {
    background: var(--gray-darkest);
    padding: 8px 10px;
}

/* ═══════════════════════════════════════════════════════
   6. TYPOGRAPHY UTILITIES
   ═══════════════════════════════════════════════════════ */

.dv-px {
    font-family: var(--font-pixel);
}

.dv-px-xs {
    font-family: var(--font-pixel);
    font-size: calc(4px * var(--px-scale));
    letter-spacing: 1px;
}

.dv-px-sm {
    font-family: var(--font-pixel);
    font-size: calc(5px * var(--px-scale));
    letter-spacing: 1px;
}

.dv-px-md {
    font-family: var(--font-pixel);
    font-size: calc(7px * var(--px-scale));
}

.dv-px-lg {
    font-family: var(--font-pixel);
    font-size: calc(9px * var(--px-scale));
}

.dv-px-xl {
    font-family: var(--font-pixel);
    font-size: calc(12px * var(--px-scale));
}

/* dv-label — małe dekoracyjne etykiety sekcji, uppercase */
.dv-label {
    font-family: var(--font-pixel);
    font-size: calc(4.5px * var(--px-scale));
    color: var(--color-text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.dv-title {
    font-family: var(--font-pixel);
    font-size: calc(9px * var(--px-scale));
    color: var(--sand-light);
}

.dv-text-dim {
    color: var(--color-text-dim);
}

.dv-text-muted {
    color: var(--color-text-muted);
}

.dv-text-pos {
    color: #7adb6a;
}

.dv-text-neg {
    color: var(--red-light);
}

/* ═══════════════════════════════════════════════════════
   7. STAT BAR
   ═══════════════════════════════════════════════════════ */

.dv-bar-wrap {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.dv-bar-label-row {
    display: flex;
    justify-content: space-between;
    font-size: calc(6px * var(--px-scale));
    color: var(--sand-dark);
}

.dv-bar-val {
    font-family: var(--font-pixel);
    font-size: calc(6px * var(--px-scale));
    color: var(--sand-light);
}

.dv-bar-track {
    height: 8px;
    background: var(--gray-darkest);
    box-shadow: var(--px-inset);
    position: relative;
    overflow: hidden;
}

.dv-bar-fill {
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    transition: width .4s steps(14);
}

.dv-bar-hp {
    background: var(--red-mid);
    box-shadow: inset 0 -2px 0 var(--red-darkest);
}

.dv-bar-mp {
    background: #4a7db5;
    box-shadow: inset 0 -2px 0 #2d4e72;
}

.dv-bar-xp {
    background: var(--sand-dark);
    box-shadow: inset 0 -2px 0 var(--sand-darkest);
}

.dv-bar-stam {
    background: var(--lg-mid);
    box-shadow: inset 0 -2px 0 var(--lg-darkest);
}

.dv-bar-atk {
    background: var(--red-light);
    box-shadow: inset 0 -2px 0 var(--red-darkest);
}

.dv-bar-def {
    background: var(--dg-light);
    box-shadow: inset 0 -2px 0 var(--dg-darkest);
}

.dv-bar-str {
    background: var(--red-light);
}

.dv-bar-vit {
    background: var(--lg-mid);
}

.dv-bar-int {
    background: #4a7db5;
}

.dv-bar-dex {
    background: var(--sand-dark);
}

/* ═══════════════════════════════════════════════════════
   8. STAT ROW
   Zasada: label (muted, mały) po lewej, wartość (jasna, pixel, większa) po prawej
   ═══════════════════════════════════════════════════════ */

.dv-srow {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    border-bottom: 1px solid #2a2027;
}

.dv-srow:last-child {
    border: none;
}

/* Label — font-ui, muted, mniejszy */
.dv-srow-label {
    font-family: var(--font-ui);
    font-size: calc(6px * var(--px-scale));
    color: var(--sand-dark);
    flex: 1;
}

/* Wartość — pixel font, jasny, większy od labela */
.dv-srow-val {
    font-family: var(--font-pixel);
    font-size: calc(7px * var(--px-scale));
    color: var(--sand-light);
}

/* ═══════════════════════════════════════════════════════
   9. NAV SECTION LABEL (inside sidenav)
   ═══════════════════════════════════════════════════════ */

.dv-nav-section {
    padding: 10px 10px 4px;
    font-family: var(--font-pixel);
    font-size: calc(4px * var(--px-scale));
    color: var(--gray-lightest);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.dv-nav-sep {
    height: 2px;
    background: var(--color-border);
    margin: 6px 10px;
}

/* ═══════════════════════════════════════════════════════
   10. FILTER CONTROLS (radio pills, checkboxes)
   ═══════════════════════════════════════════════════════ */

.dv-radio {
    display: none;
}

.dv-radio + label {
    font-family: var(--font-pixel);
    font-size: calc(5px * var(--px-scale));
    padding: 4px 9px;
    cursor: pointer;
    background: var(--gray-darkest);
    color: var(--gray-lightest);
    box-shadow: 0 0 0 2px var(--gray-light), 2px 2px 0 var(--gray-darkest);
    display: inline-block;
    user-select: none;
    transition: background var(--t-fast);
}

.dv-radio + label:hover {
    background: var(--gray-light);
    color: var(--sand-dark);
}

.dv-radio:checked + label {
    background: var(--red-darkest);
    color: var(--sand-light);
    box-shadow: 0 0 0 2px var(--red-mid), 2px 2px 0 var(--gray-darkest);
}

.dv-check {
    display: none;
}

.dv-check + label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: calc(5px * var(--px-scale));
    color: var(--sand-dark);
    cursor: pointer;
    user-select: none;
}

.dv-check + label::before {
    content: '';
    display: inline-block;
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    background: var(--gray-darkest);
    box-shadow: 0 0 0 2px var(--gray-light);
}

.dv-check:checked + label::before {
    background: var(--red-darkest);
    box-shadow: 0 0 0 2px var(--red-mid);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 6'%3E%3Crect x='0' y='3' width='2' height='2' fill='%23f5e9bf'/%3E%3Crect x='2' y='4' width='1' height='1' fill='%23f5e9bf'/%3E%3Crect x='3' y='1' width='1' height='3' fill='%23f5e9bf'/%3E%3Crect x='4' y='0' width='1' height='2' fill='%23f5e9bf'/%3E%3C/svg%3E");
    background-size: 9px 9px;
    background-repeat: no-repeat;
    background-position: center;
}

/* ═══════════════════════════════════════════════════════
   11. RARITY UTILITIES
   ═══════════════════════════════════════════════════════ */

.dv-slot-border-rare {
    box-shadow: inset 0 0 0 2px var(--rarity-rare) !important;
}

.dv-slot-border-epic {
    box-shadow: inset 0 0 0 2px var(--rarity-epic) !important;
}

.dv-slot-border-legend {
    box-shadow: inset 0 0 0 2px var(--rarity-legend) !important;
}

/* ═══════════════════════════════════════════════════════
   12. HEADER STAT CHIP
   ═══════════════════════════════════════════════════════ */

.dv-hstat {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-pixel);
    font-size: calc(5.5px * var(--px-scale));
    background: var(--gray-darkest);
    padding: 4px 8px;
    box-shadow: 0 0 0 2px var(--gray-light), 2px 2px 0 var(--gray-darkest);
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════
   13. BADGE / PILL
   ═══════════════════════════════════════════════════════ */

.dv-badge {
    font-family: var(--font-pixel);
    font-size: calc(5px * var(--px-scale));
    background: var(--red-dark);
    color: var(--sand-light);
    padding: 2px 5px;
    box-shadow: 1px 1px 0 var(--gray-darkest);
    white-space: nowrap;
}

.dv-badge-sand {
    background: var(--sand-darkest);
    box-shadow: 0 0 0 2px var(--sand-mid), 2px 2px 0 var(--gray-darkest);
}

/* ═══════════════════════════════════════════════════════
   14. ANIMATIONS
   ═══════════════════════════════════════════════════════ */

@keyframes dv-blink {
    0%, 100% {
        opacity: 1
    }
    50% {
        opacity: 0
    }
}

@keyframes dv-float {
    0%, 100% {
        transform: translateY(0)
    }
    50% {
        transform: translateY(-3px)
    }
}

@keyframes dv-slideup {
    from {
        transform: translateY(100%)
    }
    to {
        transform: translateY(0)
    }
}

@keyframes dv-fadein {
    from {
        opacity: 0;
        transform: translateY(5px)
    }
    to {
        opacity: 1;
        transform: translateY(0)
    }
}

@keyframes dv-pulse {
    0%, 100% {
        opacity: 1
    }
    50% {
        opacity: .6
    }
}

.dv-anim-blink {
    animation: dv-blink 1.4s step-start infinite;
}

.dv-anim-float {
    animation: dv-float 3s ease-in-out infinite;
}

.dv-anim-fadein {
    animation: dv-fadein var(--t-med) ease;
}

.dv-anim-pulse {
    animation: dv-pulse 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════
   15. RESPONSIVE
   ═══════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    #sidenav {
        display: none;
    }

    #bottom-nav {
        display: flex;
    }

    #footer {
        display: none;
    }

    #header .logo {
        font-size: calc(10px * var(--px-scale));
    }

    #header .hstat-hide {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════
   16. GRID UTILITIES
   ═══════════════════════════════════════════════════════ */

.dv-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.dv-grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--dv-grid-min, 260px), 1fr));
    gap: 10px;
}

@media (max-width: 768px) {
    .dv-grid-2col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .dv-grid-auto {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════════════════════════════════════════════
   17. BADGE VARIANTS
   ═══════════════════════════════════════════════════════ */

.dv-badge-dim {
    opacity: 0.4;
}