/* Base styles for the whole app - W5 Theme */
body {
    font-family: 'Alegreya Sans', sans-serif; 
    /* NEW: A subtle spotlight effect. It stays lighter in the center and fades to pitch black at the edges */
    background: radial-gradient(circle at 50% 30vh, #1a1a1a 0%, #050505 100%);
    background-attachment: fixed; /* Keeps the lighting locked in place when you scroll */
    color: #e0e0e0; 
    padding: 20px;
    font-size: 17px; 
    line-height: 1.6;
}

#app-container {
    max-width: 90%; 
    margin: 0 auto;
    background: #1e1b1a; /* Very dark, muddy brown/grey */
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
    border: 1px solid #3a322d;
}

/* Headings in Garou Blood Red */
h1, h2, h3 {
    font-family: 'Crimson Pro', serif; 
    color: #cf2b2b; /* A slightly brighter, more saturated red */
    letter-spacing: 1px; 
    /* NEW: A stark black shadow to lift the text, plus a very faint red glow */
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 1), 0 0 10px rgba(207, 43, 43, 0.3);
}

/* Tribe Card Grid Layout */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Individual Card Styling */
.card {
    border: 1px solid #4a3f38; 
    border-radius: 8px;
    padding: 15px;
    background: #262220; 
    /* NEW: Combined an outer shadow with an inner (inset) shadow for physical depth */
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.6);
}

.card-label {
    font-weight: bold;
    color: #b59a72; /* Muted bone/dust color for mechanical labels */
}

/* Dark Pack Glyph Styling */
.card-glyph {
    width: 60px; 
    height: 60px;
    object-fit: contain;
    display: block; 
    margin: 0 auto 15px auto; 
    /* NEW: Chaining invert, opacity, and the drop-shadow together! */
    filter: invert(1) opacity(0.8) drop-shadow(0px 0px 5px rgba(0,0,0,0.5));
}

/* Center the titles directly under the glyphs */
.card h2 {
    text-align: center;
    margin-top: 10px; /* Gives a tiny bit of breathing room from the image */
}

/* Horizontal line inside the cards */
hr {
    border: 0;
    height: 1px;
    background-color: #4a3f38;
    margin: 15px 0;
}

/* Read Full Lore Button Styling */
button {
    background-color: #7a1515; /* Deep red */
    color: #ffffff;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    margin-top: 10px;
    transition: background-color 0.2s ease-in-out;
}

/* Tiny inline icons for labels */
.inline-glyph {
    width: 24px;
    height: 24px;
    object-fit: contain;
    vertical-align: middle; /* Aligns the image perfectly with the text next to it */
    margin-right: 8px; /* Adds a small gap between the image and the word */
    opacity: 0.8; /* Slightly dims it so it doesn't distract from the main Tribe image */
}

/* Button Hover Effect */
button:hover {
    background-color: #9e1b1b; /* Brightens up when the mouse hovers over it */
}

/* --- Modal (Pop-up) Styling --- */
.modal {
    display: none; /* Hidden by default */
    position: fixed; 
    z-index: 1000; /* Sit on top of everything else */
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0, 0, 0, 0.8); /* Dark semi-transparent background */
}

.modal-content {
    background-color: #262220; /* Matches your W5 card theme */
    margin: 5% auto; /* 5% from the top and centered */
    padding: 30px;
    border: 1px solid #4a3f38;
    border-radius: 8px;
    width: 80%; /* Width of the popup */
    max-width: 800px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.9);
    color: #e0e0e0;
    /* Make it scrollable if the lore is really long */
    max-height: 80vh; 
    overflow-y: auto; 
}

.close-button {
    color: #9e1b1b;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover {
    color: #ff3333;
}

/* Style the headings inside the modal */
.modal-content h2 {
    margin-top: 0;
    border-bottom: 1px solid #4a3f38;
    padding-bottom: 10px;
}
.modal-content h3 {
    color: #b59a72;
    margin-top: 20px;
    margin-bottom: 5px;
}

/* Styling for the introductory lore text */
.flavor-text {
    font-style: italic;
    font-size: 1.1em; /* Increases the size by about 10% to counteract the italics shrinking effect */
    color: #b59a72; /* Muted bone color */
    border-left: 3px solid #7a1515; /* Deep red accent line on the left */
    padding-left: 15px; /* Pushes the text away from the line */
    margin-bottom: 25px; /* Gives a nice gap before the mechanical lore starts */
}

/* --- Dynamic Moon Theme (Auspice Screen) --- */
body.theme-moon {
    background-color: #080b12; /* Very deep night sky */
}
body.theme-moon #app-container {
    background: #131821; /* Cool, dark slate */
    border-color: #263245;
}
body.theme-moon .card, body.theme-moon .modal-content {
    background: #1b222d; 
    border-color: #263245;
}
body.theme-moon h1, body.theme-moon h2, body.theme-moon h3 {
    color: #d1e2f3; /* Pale moonlight silver/blue */
}
body.theme-moon .flavor-text {
    color: #9cb2c7; 
    border-left: 3px solid #5a7b9c; /* Muted blue line instead of red */
}
body.theme-moon button {
    background-color: #334e68; /* Dark steel blue */
}
body.theme-moon button:hover {
    background-color: #4a6c8c;
}
body.theme-moon hr {
    background-color: #263245;
}
body.theme-moon .card-label {
    color: #7994b0;
}

/* Center the short text specifically on the Auspice cards */
body.theme-moon .card p,
body.theme-moon .card hr {
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

/* Styling for the Back Button */
.back-button {
    background-color: transparent;
    color: inherit; /* Automatically matches the text color of the current theme */
    border: 1px solid currentColor;
    padding: 5px 15px;
    border-radius: 4px;
    font-size: 0.9em;
    margin-bottom: 15px;
    width: auto; /* Overrides the 100% width of the normal buttons */
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.2s;
}

.back-button:hover {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

/* --- Dynamic Theme: Gifts (Umbral Teal/Green) --- */
body.theme-gifts h1, body.theme-gifts h2, body.theme-gifts h3 {
    color: #3b9175; /* A mystical, spiritual teal */
}
body.theme-gifts .flavor-text {
    color: #9cbdae; 
    border-left: 3px solid #286b55; /* Teal line instead of red */
}
body.theme-gifts button {
    background-color: #205c48; /* Dark spiritual green */
}
body.theme-gifts button:hover {
    background-color: #2b7a60;
}
body.theme-gifts .card-label {
    color: #6a9c89;
}

/* --- Dynamic Theme: Rites (Mystic Purple) --- */
body.theme-rites h1, body.theme-rites h2, body.theme-rites h3 {
    color: #8a6399; /* Muted amethyst */
}
body.theme-rites .flavor-text {
    color: #bfa6cc; 
    border-left: 3px solid #6c467a; 
}
body.theme-rites button {
    background-color: #51305e; /* Deep purple */
}
body.theme-rites button:hover {
    background-color: #6d427e;
}
body.theme-rites .card-label {
    color: #a382b0;
}

/* --- Dynamic Theme: Advantages (Bronze/Gold) --- */
body.theme-advantages h1, body.theme-advantages h2, body.theme-advantages h3 {
    color: #c9a05b; /* Aged bronze/gold */
}
body.theme-advantages .flavor-text {
    color: #d8ba82; 
    border-left: 3px solid #9c7b42; 
}
body.theme-advantages button {
    background-color: #7a5e2d; 
}
body.theme-advantages button:hover {
    background-color: #9c7b42;
}
body.theme-advantages .card-label {
    color: #b59865;
}
/* A special highlight for items currently in the cart */
.card.in-cart {
    border-color: #c9a05b;
    box-shadow: 0 0 15px rgba(201, 160, 91, 0.4);
    background-color: #24201a;
}

/* --- Dynamic Theme: Flaws (Crimson/Blood) --- */
body.theme-flaws h1, body.theme-flaws h2, body.theme-flaws h3 {
    color: #b33939; /* Muted crimson */
}
body.theme-flaws .flavor-text {
    color: #cc8e8e; 
    border-left: 3px solid #802020; 
}
body.theme-flaws button {
    background-color: #802020; 
}
body.theme-flaws button:hover {
    background-color: #b33939;
}
body.theme-flaws .card-label {
    color: #b36b6b;
}

/* Red highlight for Flaws in the cart */
.theme-flaws .card.in-cart {
    border-color: #b33939;
    box-shadow: 0 0 15px rgba(179, 57, 57, 0.4);
    background-color: #241515;
}

/* --- Dynamic Theme: Final Sheet --- */
body.theme-sheet h2, body.theme-sheet h3 {
    color: #e0e0e0;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
    margin-top: 25px;
}
.sheet-container {
    background-color: #16181a;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 30px;
    text-align: left;
}
.sheet-section {
    margin-bottom: 25px;
}
.sheet-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 10px;
    background-color: #1f2226;
    border-radius: 4px;
}
.sheet-label {
    font-weight: bold;
    color: #a0a0a0;
}
.sheet-value {
    color: #ffffff;
    font-weight: bold;
}
.print-button {
    background-color: #276b27;
    width: 100%;
    font-size: 1.2em;
    padding: 15px;
    margin-bottom: 40px;
}
/* Hide buttons when printing to PDF */
@media print {
    .print-button, .back-button {
        display: none !important;
    }
    body {
        background-color: white;
        color: black;
    }
    .sheet-container {
        border: none;
        background-color: white;
    }
    .sheet-row {
        background-color: #f0f0f0;
        color: black;
    }
    .sheet-value, .sheet-label, body.theme-sheet h2, body.theme-sheet h3 {
        color: black;
    }
}

/* --- Dynamic Theme: Core Stats (Slate Blue) --- */
body.theme-stats h1, body.theme-stats h2, body.theme-stats h3 {
    color: #5c7c99; 
}
body.theme-stats button {
    background-color: #3b536b; 
}
body.theme-stats button:hover {
    background-color: #5c7c99;
}
.array-tracker {
    display: flex; 
    justify-content: space-around; 
    text-align: center;
    background-color: #16181a; 
    border: 2px solid #5c7c99; 
    padding: 15px; 
    border-radius: 8px;
    margin-bottom: 20px;
}
.array-slot {
    font-size: 1.1em;
}
.slot-good { color: #276b27; font-weight: bold; }
.slot-bad { color: #d9534f; font-weight: bold; }

/* --- Dynamic Theme: Renown (Silver/Moonlight) --- */
body.theme-renown h1, body.theme-renown h2, body.theme-renown h3 {
    color: #e2e8f0; 
}
body.theme-renown .card {
    background-color: #1a202c;
}

/* Highlights the currently selected option when navigating back */
.selected-option {
    border: 2px solid #c9a05b !important; /* Gold border */
    box-shadow: 0 0 15px rgba(201, 160, 91, 0.4) !important; /* Soft gold glow */
    background-color: rgba(201, 160, 91, 0.1) !important; /* Slight gold tint */
}

/* --- Trait Hub Search Bar Styling --- */
#traitSearchBar:focus {
    outline: none;
    box-shadow: 0 0 10px rgba(201, 160, 91, 0.5); /* Gold glow by default */
}

/* Changes the glow to red if they are on the Flaw tab */
body.theme-flaws #traitSearchBar {
    border-color: #b33939 !important;
}
body.theme-flaws #traitSearchBar:focus {
    box-shadow: 0 0 10px rgba(179, 57, 57, 0.5) !important;
}

/* --- Global Navigation Bar --- */
#global-nav {
    position: sticky;
    top: 0;
    z-index: 900;
    background: #16181a;
    border-bottom: 2px solid #4a3f38;
    padding: 10px 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.9);
    flex-wrap: wrap; /* Allows buttons to wrap on mobile screens */
}

#global-nav button {
    background-color: transparent;
    border: 1px solid #4a3f38;
    color: #88a3bd;
    padding: 8px 15px;
    font-size: 0.95em;
    width: auto;
    margin-top: 0;
    transition: all 0.2s ease;
}

#global-nav button:hover {
    background-color: #262220;
    color: #fff;
    border-color: #7a1515;
}

/* The active/current section highlight */
#global-nav button.active-nav {
    background-color: #7a1515;
    color: #fff;
    border-color: #cf2b2b;
    box-shadow: 0 0 10px rgba(207, 43, 43, 0.3);
}