/* === GRIMOIRE IDLE — Dark Fantasy Theme === */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121c;
    --bg-tertiary: #1a1a2e;
    --bg-card: #16162a;
    --bg-card-hover: #1e1e38;

    --text-primary: #e0d6c8;
    --text-secondary: #9a8f82;
    --text-muted: #5a524a;
    --text-accent: #d4a957;

    --border-dark: #2a2a3e;
    --border-glow: #d4a95733;

    --gold: #d4a957;
    --gold-dim: #8a6d2b;
    --purple: #6b3fa0;
    --purple-light: #9b6fd0;
    --purple-dark: #2d1b4e;
    --red: #8b2020;
    --red-light: #c0392b;
    --green: #2d6b3f;
    --green-light: #4a9;
    --blue: #2a4a7a;
    --blue-light: #5a8abf;

    /* Rarity colors */
    --rarity-common: #8a8a8a;
    --rarity-uncommon: #4a9a4a;
    --rarity-rare: #4a7abf;
    --rarity-epic: #9b59b6;
    --rarity-legendary: #d4a957;
    --rarity-mythic: #e74c3c;

    --font-display: 'Cinzel', serif;
    --font-body: 'Crimson Text', serif;

    --sidebar-width: 220px;
    --resource-bar-height: 48px;
}

/* === GLOBAL RESET === */
html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

h1, h2, h3, h4, h5 {
    font-family: var(--font-display);
    color: var(--text-accent);
    margin: 0 0 0.5em;
    font-weight: 600;
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

a {
    color: var(--purple-light);
    text-decoration: none;
}

a:hover {
    color: var(--gold);
}

::selection {
    background: var(--purple);
    color: var(--text-primary);
}

::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--purple-dark);
}

/* === PAGE LAYOUT === */
.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: linear-gradient(180deg, #0d0d1a 0%, #1a0a2e 100%);
    border-right: 1px solid var(--border-dark);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* === RESOURCE BAR === */
.resource-bar {
    height: var(--resource-bar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-display);
    font-size: 0.85rem;
}

.resource-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.resource-amount {
    color: var(--text-primary);
    font-weight: 600;
    min-width: 60px;
}

.resource-rate {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* === NAV MENU === */
.nav-brand {
    padding: 1.2rem 1rem;
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--gold);
    text-align: center;
    border-bottom: 1px solid var(--border-dark);
    letter-spacing: 2px;
    text-transform: uppercase;
    background: linear-gradient(180deg, transparent, rgba(212, 169, 87, 0.05));
}

.nav-menu {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    flex: 1;
}

.nav-menu-item {
    margin: 2px 8px;
}

.nav-menu-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: all 0.2s ease;
    font-family: var(--font-display);
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    text-decoration: none;
}

.nav-menu-link:hover {
    color: var(--text-primary);
    background: rgba(107, 63, 160, 0.15);
}

.nav-menu-link.active {
    color: var(--gold);
    background: rgba(212, 169, 87, 0.1);
    border-left: 2px solid var(--gold);
}

.nav-menu-link.locked {
    opacity: 0.3;
    pointer-events: none;
}

.nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

/* === CONTENT AREA === */
.content-area {
    padding: 1.5rem;
    flex: 1;
}

/* === CARDS === */
.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    padding: 1.2rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s ease;
}

.game-card:hover {
    border-color: var(--border-glow);
}

.game-card-header {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--text-accent);
    margin-bottom: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-dark);
}

/* === BUTTONS === */
.btn-grimoire {
    font-family: var(--font-display);
    font-size: 0.85rem;
    padding: 0.5rem 1.2rem;
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    background: linear-gradient(180deg, rgba(212, 169, 87, 0.15), rgba(212, 169, 87, 0.05));
    color: var(--gold);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.btn-grimoire:hover:not(:disabled) {
    background: linear-gradient(180deg, rgba(212, 169, 87, 0.25), rgba(212, 169, 87, 0.1));
    border-color: var(--gold);
    box-shadow: 0 0 8px rgba(212, 169, 87, 0.2);
}

.btn-grimoire:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-grimoire.btn-primary {
    background: linear-gradient(180deg, var(--purple), var(--purple-dark));
    border-color: var(--purple-light);
    color: var(--text-primary);
}

.btn-grimoire.btn-primary:hover:not(:disabled) {
    box-shadow: 0 0 12px rgba(107, 63, 160, 0.4);
}

.btn-grimoire.btn-danger {
    border-color: var(--red);
    color: var(--red-light);
}

/* === PROGRESS BAR === */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-dark);
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.1s linear;
    background: linear-gradient(90deg, var(--purple-dark), var(--purple));
}

.progress-bar-fill.gold {
    background: linear-gradient(90deg, var(--gold-dim), var(--gold));
}

.progress-bar-fill.red {
    background: linear-gradient(90deg, var(--red), var(--red-light));
}

.progress-bar-fill.green {
    background: linear-gradient(90deg, var(--green), var(--green-light));
}

/* === UPGRADE GRID === */
.upgrade-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.8rem;
}

.upgrade-card {
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: 6px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.upgrade-card.affordable {
    border-color: rgba(212, 169, 87, 0.3);
}

.upgrade-card.affordable:hover {
    border-color: var(--gold);
    box-shadow: 0 0 8px rgba(212, 169, 87, 0.15);
    cursor: pointer;
}

.upgrade-card.maxed {
    border-color: rgba(74, 154, 74, 0.3);
    opacity: 0.7;
}

.upgrade-name {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--text-accent);
}

.upgrade-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.upgrade-level {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.upgrade-cost {
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--gold-dim);
    margin-top: auto;
}

.upgrade-cost.can-afford {
    color: var(--gold);
}

.upgrade-effect {
    font-size: 0.8rem;
    color: var(--green-light);
}

/* === BOOK CARD === */
.book-card {
    background: var(--bg-card);
    border: 2px solid var(--rarity-common);
    border-radius: 8px;
    padding: 0.8rem;
    text-align: center;
    transition: all 0.2s ease;
    min-width: 140px;
}

.book-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.book-card.uncommon { border-color: var(--rarity-uncommon); }
.book-card.rare { border-color: var(--rarity-rare); }
.book-card.epic { border-color: var(--rarity-epic); }
.book-card.legendary { border-color: var(--rarity-legendary); box-shadow: 0 0 8px rgba(212, 169, 87, 0.2); }
.book-card.mythic { border-color: var(--rarity-mythic); box-shadow: 0 0 12px rgba(231, 76, 60, 0.3); }

.book-locked {
    opacity: 0.45;
    border-style: dashed;
    background: var(--bg-primary);
}

.book-locked:hover {
    opacity: 0.65;
}

.book-card-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.book-card-rarity {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.book-card-rarity.common { color: var(--rarity-common); }
.book-card-rarity.uncommon { color: var(--rarity-uncommon); }
.book-card-rarity.rare { color: var(--rarity-rare); }
.book-card-rarity.epic { color: var(--rarity-epic); }
.book-card-rarity.legendary { color: var(--rarity-legendary); }
.book-card-rarity.mythic { color: var(--rarity-mythic); }

/* === SECTION HEADERS === */
.section-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

.section-header h2 {
    margin: 0;
}

.section-divider {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--border-dark), transparent);
}

/* === TOOLTIP === */
.tooltip-wrapper {
    position: relative;
    display: inline-block;
}

.tooltip-content {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-dark);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    white-space: nowrap;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.tooltip-wrapper:hover .tooltip-content {
    opacity: 1;
}

/* === SCRIBE BUTTON === */
.scribe-btn {
    min-width: 160px;
    position: relative;
    overflow: hidden;
}

.scribe-btn:active:not(:disabled) {
    transform: scale(0.96);
    transition: transform 0.05s ease;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 4px rgba(212, 169, 87, 0.2); }
    50% { box-shadow: 0 0 12px rgba(212, 169, 87, 0.4); }
}

@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

.animate-in {
    animation: fadeIn 0.3s ease forwards;
}

.pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-dark);
    }

    .main-content {
        margin-left: 0;
    }

    .resource-bar {
        flex-wrap: wrap;
        height: auto;
        padding: 0.5rem 1rem;
        gap: 0.8rem;
    }

    .upgrade-grid {
        grid-template-columns: 1fr;
    }
}

/* === LOGIN === */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #0a0a0f, #1a0a2e);
}

.login-container {
    width: 100%;
    max-width: 380px;
    padding: 1rem;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
}

.login-title {
    font-family: var(--font-display);
    font-size: 2.2rem;
    color: var(--gold);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.login-field {
    margin-bottom: 1rem;
    text-align: left;
}

.login-field label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    letter-spacing: 0.5px;
}

.login-input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-dark);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.login-input:focus {
    border-color: var(--purple);
    box-shadow: 0 0 6px rgba(107, 63, 160, 0.3);
}

.login-error {
    color: var(--red-light);
    font-size: 0.8rem;
    margin-bottom: 0.8rem;
}

.login-btn {
    width: 100%;
    padding: 0.7rem;
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* === UTILITY === */
.text-gold { color: var(--gold); }
.text-purple { color: var(--purple-light); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-red { color: var(--red-light); }
.text-green { color: var(--green-light); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
