/* ============================================================
   ModernWormfare — unified design system
   Color/spacing/type tokens live in :root. The MudBlazor theme in
   AppTheme.cs mirrors these values so MudBlazor components and this
   custom markup render as one surface.
   ============================================================ */

:root {
    /* Surfaces */
    --mw-bg: #151a17;
    --mw-bg-2: #1a201c;
    --mw-surface: #1f2621;
    --mw-surface-2: #242c26;
    --mw-appbar: #141916;
    --mw-border: rgba(255, 255, 255, 0.08);
    --mw-border-strong: rgba(255, 255, 255, 0.16);

    /* Text */
    --mw-text: #e8ede9;
    --mw-text-strong: #f4f7f4;
    --mw-text-dim: #b9c4bc;
    --mw-text-faint: #859089;
    --mw-text-muted: #536159;

    /* Brand */
    --mw-primary: #4caf50;
    --mw-primary-bright: #77d67b;
    --mw-primary-soft: #b9f2bc;
    --mw-gold: #ffcf4d;
    --mw-info: #4fc3f7;
    --mw-danger: #ef5350;

    /* Type */
    --mw-font-display: "Black Ops One", "IBM Plex Sans", system-ui, sans-serif;
    --mw-font-body: "IBM Plex Sans", system-ui, sans-serif;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--mw-font-body);
    background-color: var(--mw-bg);
    color: var(--mw-text);
}

#app {
    min-height: 100vh;
}

a {
    color: inherit;
}

/* Raw headings (page heroes use plain <h1>) get the display face. */
h1, h2, h3, h4 {
    font-family: var(--mw-font-display);
    font-weight: 400;
}

/* ---------- App shell ---------- */

.app-shell,
.app-main {
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 0%, rgba(76, 175, 80, 0.12), transparent 34rem),
        radial-gradient(circle at 90% 100%, rgba(79, 195, 247, 0.05), transparent 30rem),
        var(--mw-bg);
}

.app-navbar {
    border-bottom: 1px solid var(--mw-border);
    background: rgba(20, 25, 22, 0.96) !important;
}

.app-brand {
    font-family: var(--mw-font-display);
    font-size: 1.15rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
    color: var(--mw-text-strong);
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    overflow-x: auto;
}

.app-nav-link {
    white-space: nowrap;
}

.app-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    border-top: 1px solid var(--mw-border);
    background: rgba(20, 25, 22, 0.96);
    padding: 0.5rem 1rem;
    color: var(--mw-text-faint);
    font-size: 0.78rem;
}

.app-footer__text {
    flex: 1;
}

.app-footer__ver {
    color: var(--mw-text-muted);
}

/* ---------- Page scaffolding ---------- */

.page-shell {
    width: min(100% - 2rem, 1180px);
    margin: 0 auto;
    padding: 3rem 0 4rem;
}

.page-shell--wide {
    max-width: 1180px;
}

.page-hero,
.page-header {
    max-width: 760px;
}

.page-hero {
    padding: 2rem 0 1.5rem;
}

.page-hero h1,
.page-header h1 {
    margin: 0.25rem 0 0.75rem;
    color: var(--mw-text-strong);
    font-size: clamp(2rem, 6vw, 3.6rem);
    line-height: 1.12;
    letter-spacing: 0.01em;
}

.page-hero h1:focus,
.page-header h1:focus {
    outline: none;
}

.page-header h1 {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
}

.page-hero p,
.page-header p {
    max-width: 680px;
    margin: 0;
    color: var(--mw-text-dim);
    font-size: 1.02rem;
    line-height: 1.65;
}

.page-eyebrow,
.mode-kicker {
    color: var(--mw-primary-bright) !important;
    font-size: 0.72rem !important;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

/* ---------- Flow trail (shared step indicator) ---------- */

.flow-trail {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 2rem 0;
    color: var(--mw-text-faint);
    font-size: 0.85rem;
}

.flow-step {
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--mw-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.025);
    white-space: nowrap;
}

.flow-step--active {
    border-color: rgba(119, 214, 123, 0.55);
    background: rgba(76, 175, 80, 0.12);
    color: var(--mw-primary-soft);
}

.flow-arrow {
    color: var(--mw-text-muted);
}

/* ---------- Cards ---------- */

.mode-grid {
    margin-top: 0.25rem;
}

.mode-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 250px;
    border: 1px solid var(--mw-border);
    background: linear-gradient(145deg, rgba(38, 48, 41, 0.96), rgba(27, 33, 29, 0.98)) !important;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.mode-card:hover {
    border-color: rgba(119, 214, 123, 0.4);
    transform: translateY(-2px);
}

.mode-card .mud-card-content {
    flex: 1;
}

.mode-card .mud-typography-h5 {
    margin: 0.75rem 0;
}

.mode-card .mud-typography-body2 {
    color: var(--mw-text-dim);
    line-height: 1.6;
}

.mode-card .mud-card-actions {
    padding: 1rem;
}

.form-card,
.table-card,
.loadout-shop,
.loadout-roster {
    border: 1px solid var(--mw-border);
    background: var(--mw-surface) !important;
}

.form-card {
    max-width: 680px;
}

.table-card {
    overflow-x: auto;
}

.empty-state {
    border: 1px dashed var(--mw-border-strong);
    background: rgba(255, 255, 255, 0.025) !important;
    color: var(--mw-text-dim);
}

/* ---------- Loadout ---------- */

.loadout-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1.5rem;
    align-items: start;
}

.loadout-shop {
    min-width: 0;
}

.loadout-roster {
    width: 100%;
}

.loadout-funds {
    color: var(--mw-gold) !important;
    font-weight: 700;
}

.loadout-ready {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Loadout shop: responsive card grid */
.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.shop-card {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.6rem 0.7rem !important;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--mw-surface) !important;
    transition: transform 0.05s ease, border-color 0.05s ease;
}

.shop-card:hover {
    transform: translateY(-1px);
    border-color: rgba(119, 214, 123, 0.5);
}

.shop-card--owned {
    border-color: rgba(76, 175, 80, 0.7) !important;
}

.shop-card--afford {
    border-color: rgba(79, 195, 247, 0.55) !important;
}

.shop-card--locked {
    opacity: 0.55;
    cursor: not-allowed;
}

.shop-card--free {
    border-color: rgba(255, 215, 0, 0.45) !important;
}

.shop-card__name {
    font-weight: 700;
    color: var(--mw-text-strong);
    font-size: 0.92rem;
}

.shop-card__price {
    color: var(--mw-gold);
    font-size: 0.82rem;
}

.shop-card__ammo {
    color: var(--mw-text-dim);
    font-size: 0.78rem;
}

.shop-card__chip {
    align-self: flex-start;
    margin-top: 0.25rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.shop-card__chip--ok {
    background: rgba(76, 175, 80, 0.22);
    color: var(--mw-primary-soft);
}

.shop-card__chip--no {
    background: rgba(255, 255, 255, 0.06);
    color: var(--mw-text-faint);
}

/* ---------- Action bar + slots (shared by loadout & in-game) ---------- */

.action-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--mw-border);
    border-radius: 8px;
    background: rgba(20, 25, 22, 0.96);
    overflow-x: auto;
    margin-bottom: 1.25rem;
}

.slot-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    min-width: 72px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: var(--mw-surface);
    cursor: default;
    user-select: none;
    transition: border-color 0.1s ease, transform 0.05s ease, opacity 0.1s ease;
}

.slot-card--swappable {
    cursor: grab;
}

.slot-card--swappable:active {
    cursor: grabbing;
}

.slot-card--swappable:hover {
    border-color: rgba(119, 214, 123, 0.5);
    transform: translateY(-1px);
}

.slot-card--empty {
    border-style: dashed;
    opacity: 0.4;
}

.slot-card--dragging {
    opacity: 0.35;
}

.slot-card--fixed {
    opacity: 0.75;
    cursor: not-allowed;
}

.slot-card--selected {
    border-color: var(--mw-primary) !important;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.4);
}

/* Stack-count badge pinned to the slot icon's corner. */
.slot-card__count {
    position: absolute;
    top: 0.2rem;
    right: 0.3rem;
    min-width: 1.1rem;
    padding: 0 0.25rem;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1.1rem;
    text-align: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    pointer-events: none;
}

/* Kind tints so weapon/sidearm/utility slots read at a glance. */
.slot-card--weapon { background: rgba(76, 175, 80, 0.13); }
.slot-card--sidearm { background: rgba(239, 83, 80, 0.13); }
.slot-card--utility { background: rgba(79, 195, 247, 0.13); }

.slot-card__key {
    font-size: 0.7rem;
    color: var(--mw-text-faint);
    font-weight: 700;
}

.slot-card__shape {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
}

.slot-card__name {
    font-size: 0.72rem;
    color: var(--mw-text-dim);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 64px;
}

.slot-card__ammo {
    font-size: 0.68rem;
    color: var(--mw-primary-bright);
    font-weight: 700;
}

/* Item shapes: colored circles with emoji per item type */
.item-shape--rocket { background: rgba(229, 57, 53, 0.3); }
.item-shape--pistol { background: rgba(33, 150, 243, 0.3); }
.item-shape--shotgun { background: rgba(255, 152, 0, 0.3); }
.item-shape--sniper { background: rgba(229, 57, 53, 0.3); }
.item-shape--explosive { background: rgba(141, 110, 99, 0.3); }
.item-shape--drone { background: rgba(120, 144, 156, 0.3); }
.item-shape--minigun { background: rgba(255, 214, 0, 0.3); }
.item-shape--holygrenade { background: rgba(255, 215, 0, 0.3); }
.item-shape--clustergrenade { background: rgba(255, 152, 0, 0.3); }
.item-shape--bananabomb { background: rgba(255, 235, 59, 0.3); }
.item-shape--grenade { background: rgba(33, 150, 243, 0.3); }
.item-shape--airstrike { background: rgba(79, 195, 247, 0.3); }
.item-shape--mine { background: rgba(158, 158, 158, 0.3); }
.item-shape--jetpack { background: rgba(76, 175, 80, 0.3); }
.item-shape--bungee { background: rgba(76, 175, 80, 0.3); }
.item-shape--parachute { background: rgba(76, 175, 80, 0.3); }
.item-shape--medkit { background: rgba(239, 83, 80, 0.3); }
.item-shape--ninjarope { background: rgba(76, 175, 80, 0.3); }
.item-shape--teleport { background: rgba(156, 120, 216, 0.3); }
.item-shape--empty { background: rgba(255, 255, 255, 0.05); color: var(--mw-text-muted); }

/* ---------- Game page ---------- */

.game-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 48px);
    padding: 0.75rem 0.5rem 2rem;
    outline: none;
    background: var(--mw-bg);
    color: var(--mw-text);
}

/* Column that matches the canvas width so the HUD lines up with the playfield. */
.game-frame {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: min(100vw - 12px, calc((100vh - 210px) * 1.77778));
    max-width: 1120px;
}

.game-frame .action-bar {
    margin-bottom: 0;
}

.game-title {
    margin: 0 0 0.5rem;
    color: var(--mw-text-strong);
}

.game-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.plan-timer-bar {
    position: relative;
    align-self: stretch;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    margin: 4px 12px 8px;
}

.plan-timer-bar__fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.1s linear;
}

.plan-timer-bar__label {
    position: absolute;
    right: 0;
    top: -18px;
    font-size: 11px;
    color: #aaa;
}

.game-status {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.game-canvas {
    width: 100%;
    height: auto;
    max-width: 1120px;
    border: 2px solid var(--mw-primary);
    border-radius: 4px;
    image-rendering: pixelated;
    display: block;
}

.game-minimap {
    align-self: center;
    border: 1px solid var(--mw-border-strong);
    border-radius: 6px;
    image-rendering: pixelated;
    cursor: crosshair;
}

.game-hud {
    display: flex;
    gap: 1.25rem;
    align-items: baseline;
    flex-wrap: wrap;
}

.game-hud .mud-typography {
    white-space: nowrap;
}

.game-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 16, 14, 0.8);
    backdrop-filter: blur(3px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    z-index: 9999;
}

.game-over {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding-top: 4rem;
    text-align: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
    .app-brand {
        display: none;
    }

    .app-nav {
        width: 100%;
    }

    .app-nav-link {
        min-width: max-content;
        padding-inline: 0.65rem !important;
        font-size: 0.75rem !important;
    }

    .page-shell {
        width: min(100% - 1.25rem, 1180px);
        padding-top: 2rem;
    }

    .flow-trail {
        gap: 0.35rem;
        overflow-x: auto;
        padding-bottom: 0.35rem;
    }

    .loadout-layout {
        grid-template-columns: 1fr;
    }

    .action-bar {
        padding-bottom: 0.5rem;
    }

    .slot-card {
        min-width: 60px;
    }
}

/* Settings dialog: key-rebinding list */
.settings-tabs {
    max-width: 100%;
}

.rebind-list {
    outline: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.rebind-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.rebind-row .mud-button-root {
    min-width: 110px;
}

/* Map picker cards (single-player setup + lobby) */
.map-picker {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.map-card {
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    background: #1e1e2e;
    padding: 0;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.map-card:hover {
    transform: translateY(-2px);
}

.map-card--selected {
    border-color: var(--mud-palette-primary, #594ae2);
    box-shadow: 0 0 0 2px rgba(89, 74, 226, 0.35);
}

.map-card img {
    display: block;
    width: 100%;
    height: auto;
    image-rendering: pixelated;
}

.map-card__name {
    display: block;
    text-align: center;
    padding: 0.3rem 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #ddd;
}

/* Turn-transition banner overlay */
.turn-banner {
    position: absolute;
    top: 18%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.6rem 1.6rem;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    font-family: 'Black Ops One', sans-serif;
    font-size: 2rem;
    letter-spacing: 2px;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    animation: turn-banner-fade 2.2s ease forwards;
    z-index: 5;
}

@keyframes turn-banner-fade {
    0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    12% { opacity: 1; transform: translateX(-50%) translateY(0); }
    78% { opacity: 1; }
    100% { opacity: 0; }
}
