/* custom.css - Variable-Based Theming */

/* 1. DEFAULT THEME (Blue Mode) */
:root {
    /* --- CORE COLORS --- */
    --bs-body-bg: rgba(43,62,80,1);
    --bs-body-color: rgba(235,235,235,1);

    /* --- TEXT & BG OVERRIDES (Fixes the Black Text Issues) --- */
    /* This forces .text-body-emphasis to be White */
    --bs-emphasis-color: #ffffff;

    /* This forces .text-muted / .small to be light gray */
    --bs-secondary-color: rgba(235,235,235, 0.6);

    /* This forces .bg-body-tertiary (Card BG) to be White (as you requested) */
    --bs-tertiary-bg: #ffffff;

    /* --- CUSTOM BRUKE VARIABLES --- */
    --bruke-nav-bg: rgba(72,101,131,1.00);
    --bruke-nav-color: rgba(255,255,255,0.95);
    --bruke-link-hover: #34d8ed;

    /* Button Colors for Blue Mode */
    --bruke-btn-color: #cccccc; /* Light Gray */
    --bruke-btn-border: #cccccc;
    --bruke-btn-hover-bg: #ffffff;
    --bruke-btn-hover-text: #333333;

    --bruke-hr-color: #ffffff;
    --bruke-hr-opacity: 0.5;
}

/* DARK MODE OVERRIDES */
[data-bs-theme="dark"] {
    /* Reset Bootstrap variables to dark mode defaults */
    --bs-body-bg: #212529;
    --bs-body-color: #dee2e6;
    --bs-emphasis-color: #fff;
    --bs-secondary-color: rgba(222, 226, 230, 0.75);
    --bs-tertiary-bg: rgba(255,255,255,0.05); /* Transparent/Grey in Dark Mode */

    /* Update Custom Variables */
    --bruke-nav-bg: #343a40;
    --bruke-nav-color: rgba(255,255,255,0.55);

    /* Button Colors for Dark Mode */
    --bruke-btn-color: #6c757d;
    --bruke-btn-border: #6c757d;
    --bruke-btn-hover-bg: #bbbbbb;
    --bruke-btn-hover-text: #000;

    --bruke-hr-color: inherit;
    --bruke-hr-opacity: 0.25;
}

/* 2. APPLY VARIABLES */

/* Navbar */
.bruke-navbar {
    background-color: var(--bruke-nav-bg);
    transition: background-color 0.3s ease;
}

.bruke-navbar .navbar-brand,
.bruke-navbar .nav-link {
    color: var(--bruke-nav-color);
    font-weight: 500;
}

.bruke-navbar .nav-link:hover {
    color: var(--bruke-link-hover);
}

/* Dropdowns */
.dropdown-menu {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    margin-top: 0;
}

/* Horizontal Rules */
hr {
    color: var(--bruke-hr-color);
    opacity: var(--bruke-hr-opacity);
}

/* Spotlight Images */
.spotlight img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.4);
}

/* 3. CUSTOM BUTTON CLASS (The "Gray" Button) */
/* We create a custom class so we don't have to fight btn-secondary or btn-light logic */
.btn-bruke {
    color: var(--bruke-btn-color);
    border-color: var(--bruke-btn-border);
    background-color: transparent;
}

.btn-bruke:hover {
    color: var(--bruke-btn-hover-text);
    background-color: var(--bruke-btn-hover-bg);
    border-color: var(--bruke-btn-hover-bg);
}

/* --- GAMES OVERVIEW STYLES --- */

/* 1. MAP CONTAINER */
.map-container {
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}

.map-pin {
    position: absolute;
    width: 32px;
    height: 32px;
    transform: translate(-50%, -100%);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.map-pin img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}

.map-pin:hover {
    transform: translate(-50%, -120%) scale(1.2);
    z-index: 10;
}

/* Admin pin editing (moved from an inline <style> in the Frosthaven overview) */
.editing-mode {
    border: 2px dashed #ffc107 !important;
    cursor: crosshair;
}
.editing-mode .map-pin {
    cursor: grab;
    touch-action: none; /* a touch drag moves the pin instead of scrolling the page */
}
.editing-mode .map-pin.dragging {
    cursor: grabbing;
    z-index: 1000;
}

/* A newly added pin glows a few times, so it's easy to find */
.map-pin-new img {
    animation: map-pin-glow 1s ease-in-out 5;
}
@keyframes map-pin-glow {
    50% {
        filter: drop-shadow(0 0 4px #ffc107) drop-shadow(0 0 10px #ffc107);
    }
}

/* The admin's "Map Pins" window */
.sticker-list {
    max-height: 55vh;
    overflow-y: auto;
}
.sticker-list .sticker-group {
    position: sticky; /* each heading stays in view while its group scrolls */
    top: 0;
    z-index: 3;
    color: var(--bs-secondary-color);
}
/* The blue theme sets --bs-emphasis-color and --bs-tertiary-bg to white,
   so Bootstrap's own hover would be white text on white. */
.sticker-list .list-group-item-action:not(.active):hover,
.sticker-list .list-group-item-action:not(.active):focus {
    color: var(--bs-body-color);
    background-color: rgba(255, 255, 255, 0.1);
}
.sticker-preview {
    min-height: 180px;
}
.sticker-preview img {
    max-width: 100%;
    max-height: 200px;
}
#pinModal .nav-link:not(.active) {
    color: var(--bs-secondary-color);
}

/* 2. 3D FLIP CARDS */
.flip-card {
    background-color: transparent;
    width: 100%;
    /* Aspect ratio for the card */
    aspect-ratio: 2.5 / 3.5;
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border-radius: 8px;
}

.character-link:hover .flip-card-inner,
.character-link:focus .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 8px;
    overflow: hidden;
}

.flip-card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flip-card-back {
    background-color: var(--bruke-nav-bg);
    color: #fff;
    transform: rotateY(180deg);
    border: 2px solid rgba(255,255,255,0.2);
}

.character-link { display: block; }
.character-link:hover { text-decoration: none; }


/* --- SCOPED VARIABLE OVERRIDES (No !important) --- */
/* We target the card specifically in "Blue Mode" (not dark).
   Instead of forcing properties, we redefine the variables that
   Bootstrap uses for text colors inside this scope.
*/
/* --- SCOPED VARIABLE OVERRIDES (Corrected Selector) --- */

/* FIX: We must check 'html' (the root), not 'body', because that is where
   the Javascript applies the data-bs-theme attribute.
*/
html:not([data-bs-theme="dark"]) .card {
    /* Tell inputs inside the card that the 'background' here is white */
    --bs-body-bg: #ffffff;

    /* Standard Text Colors for Light Mode (Blue Theme) */
    --bs-body-color: #212529;        /* Standard Dark Text */
    --bs-secondary-color: #6c757d;   /* Standard Grey Muted Text */
    --bs-heading-color: #212529;     /* Dark Headings */
    --bs-link-color: #0d6efd;        /* Standard Blue Links */
    --bs-link-hover-color: #0a58ca;

    /* Ensure the text actually uses these variables */
    color: var(--bs-body-color);
}

/* --- BACK TO TOP BUTTON --- */
#btn-back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: none; /* Hidden by default */
    z-index: 999; /* Ensure it sits on top of tables/maps */
    border-radius: 50%;
    width: 50px;
    height: 50px;

    /* Ensure visibility against page content */
    background-color: var(--bruke-nav-bg);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
}

#btn-back-to-top:hover {
    background-color: var(--bruke-link-hover); /* Your Cyan Hover Color */
    color: #000;
}

#game .screen.active {
    display: block;
}

/* Inventory chip autocomplete: keep dropdown text readable on hover/active */
.chip-suggestions .list-group-item {
    color: #212529;
    background-color: #fff;
}
.chip-suggestions .list-group-item:hover,
.chip-suggestions .list-group-item.active {
    color: #fff;
    background-color: #0d6efd;
    border-color: #0d6efd;
}

/* Inventory thumbnail: subtle cue that it's clickable to enlarge */
.img-thumb {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.img-thumb:hover {
    transform: scale(1.08);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* --- BOARD GAME INVENTORY: one list; a table on tablets and up, cards on phones --- */
#results {
    scroll-margin-top: 5rem; /* page links jump here; clears the sticky navbar */
}

.inv-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
}

@media (min-width: 768px) {
    .inventory-list .inv-name {
        max-width: 240px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Separator before the player-count and zone columns */
    .inventory-list .inv-sep {
        border-left: var(--bs-border-width) solid var(--bs-border-color);
    }
}

@media (max-width: 767.98px) {
    .inventory-list,
    .inventory-list tbody {
        display: block;
    }

    .inventory-list thead {
        display: none;
    }

    /* Each row becomes a card with three lines (the ::before and ::after
       pseudo-elements are full-width line breaks). */
    .inventory-list tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding: .75rem;
        border-bottom: var(--bs-border-width) solid var(--bs-border-color);
    }

    .inventory-list tbody td {
        padding: 0;
        border: 0;
    }

    /* Line 1: picture, name, rating */
    .inventory-list .inv-img,
    .inventory-list .inv-name,
    .inventory-list .inv-rating {
        order: 1;
    }
    .inventory-list .inv-img {
        margin-right: .75rem;
    }
    .inventory-list .inv-name {
        flex: 1 1 0;
        min-width: 0;
    }
    .inventory-list .inv-rating {
        margin-left: .75rem;
    }

    /* Line 2: rank, time, weight, zone and teach, each with its label */
    .inventory-list tbody tr::before {
        content: "";
        order: 2;
        flex-basis: 100%;
    }
    .inventory-list .inv-meta {
        order: 3;
        margin: .35rem .75rem 0 0;
    }
    .inventory-list .inv-meta::before {
        content: attr(data-label) " ";
        font-weight: 600;
    }
    .inventory-list .inv-meta:empty {
        display: none;
    }

    /* Line 3: how well the game plays at 1-8 players */
    .inventory-list tbody tr::after {
        content: "";
        order: 4;
        flex-basis: 100%;
    }
    .inventory-list .inv-player {
        order: 5;
        flex: 1 0 0;
        margin-top: .5rem;
        padding: .25rem 0;
        background-color: var(--bs-secondary-bg);
    }
    .inventory-list .inv-player::before {
        content: attr(data-label);
        display: block;
        font-size: .6rem;
        color: var(--bs-secondary-color);
    }
    .inventory-list .inv-player[data-label="1"] {
        border-radius: var(--bs-border-radius) 0 0 var(--bs-border-radius);
    }
    .inventory-list .inv-player[data-label="8"] {
        border-radius: 0 var(--bs-border-radius) var(--bs-border-radius) 0;
    }

    .inventory-list .inv-empty {
        flex-basis: 100%;
    }
}

/* Admin dashboard cards: lift slightly on hover (moved from an inline <style>) */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15) !important;
}