﻿/*
 * Spelling Dungeon
 * 
 * This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/
 * 
 * Copyright (c) 2026 The Spelling Dungeon Authors
 */

/* ── Pause & Inventory Layout ─────────────────────────────────────────────── */
#pause-menu {
    justify-content: center !important;
}

.pause-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2vw;
    padding: 2rem;
    width: 98vw;
    max-width: 98vw;
    transform: scale(var(--ui-scale));
    transform-origin: center;
}

.pause-options {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-left: 2px solid #333;
    padding-left: 2rem;
}

#pause-menu .sub-title {
    margin-top: 0;
    margin-bottom: 2rem;
}

/* ── Inventory & Equipment ────────────────────────────────────────────────── */

.inv-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2.2rem;
    flex: 1;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #444;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.inv-main-content {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.inventory-view {
    flex-grow: 1;
}

.equipment-view {
    flex-shrink: 0;
}

.gear-slots {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    max-height: 450px;
    /* Matching the approximate height cap of the storage grid */
    overflow-y: auto;
}

.gear-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.gear-group label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
}

.utensil-grid {
    display: grid;
    grid-template-columns: repeat(2, 60px);
    gap: 10px;
}

.equip-slot {
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #444;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #555;
    position: relative;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 4px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.equip-slot:hover {
    border-color: #ff8800;
    background: rgba(40, 40, 40, 0.8);
    box-shadow: 0 0 15px rgba(255, 136, 0, 0.2), inset 0 0 10px rgba(0, 0, 0, 0.5);
    transform: scale(1.05);
}

.equip-slot.filled {
    border-color: #666;
    background: rgba(255, 255, 255, 0.2);
    color: #eee;
}

.storage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    /* Fill all available horizontal space dynamically */
    width: 100%;
    gap: 12px;
    margin-top: 1rem;
    max-height: 408px;
    /* Clamp to approx 4.5 rows: (80 * 4.5) + (12 * 4) = 408px */
    overflow-y: auto;
    padding: 2px 10px 10px 2px;
}

.inv-cell {
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #333;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s;
    border-radius: 6px;
}

.inv-cell.filled {
    background: rgba(255, 255, 255, 0.2);
    border-color: #666;
}

.inv-cell:hover {
    border-color: #ffaa00;
    background: rgba(40, 40, 30, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.item-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#item-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid #ff9200;
    padding: 1rem;
    color: #fff;
    z-index: 1000;
    pointer-events: auto;
    /* Allow clicking buttons inside! */
    user-select: none;
    max-width: 250px;
    font-family: 'Courier New', monospace;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

#item-tooltip h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
}

#item-tooltip .rarity {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

#item-tooltip .stats {
    color: #44ff44;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

#item-tooltip .desc {
    font-style: italic;
    color: #bbb;
    font-size: 1.0rem;
}

/* ── Character Stats View ────────────────────────────────────────────────── */
#char-stats-view {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #333;
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.6rem 0.8rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    box-sizing: border-box;
    border-radius: 4px;
}

#char-stats-view h3 {
    grid-column: 1 / -1;
    margin: 0 0 0.5rem 0 !important;
}

.stat-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
    overflow: hidden;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: help;
    transition: all 0.2s;
    border-radius: 4px;
}

.stat-label {
    overflow: hidden;
    text-overflow: ellipsis;
    color: #eee;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05rem;
    flex-grow: 1;
}

.stat-value {
    flex-shrink: 0;
    color: #77dd77;
    font-weight: bold;
    font-size: 0.95rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 0, 0.4);
    text-align: center;
    min-width: 1.8rem;
}

.stat-row:hover {
    background: rgba(255, 136, 0, 0.15);
    border-color: rgba(255, 136, 0, 0.4);
    transform: translateY(-1px);
}

/* ── Inventory Utility Buttons ─────────────────────────────────────────── */
.secondary-btn {
    background: linear-gradient(180deg, rgba(30, 25, 20, 0.8) 0%, rgba(15, 10, 5, 0.9) 100%) !important;
    border-color: rgba(100, 80, 60, 0.3) !important;
    color: #a0927e !important;
    font-size: 0.75rem !important;
    letter-spacing: 1px !important;
    text-shadow: none !important;
    transition: all 0.2s ease !important;
}

.secondary-btn:hover {
    background: linear-gradient(180deg, rgba(50, 40, 30, 0.9) 0%, rgba(25, 15, 10, 0.95) 100%) !important;
    border-color: rgba(255, 136, 0, 0.4) !important;
    color: #ffe4c4 !important;
    transform: scale(1.01) !important;
}

#autoupgrade-toggle-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative;
    overflow: hidden;
}

#autoupgrade-toggle-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

#autoupgrade-toggle-btn:hover::after {
    opacity: 1;
}

/* ── Item Set Bonuses ────────────────────────────────────────────────────── */
#set-bonuses-view {
    margin-top: 1rem;
    border: 1px solid rgba(0, 255, 0, 0.1);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.set-bonuses-header {
    background: rgba(0, 255, 0, 0.05);
    padding: 0.6rem 0.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.7rem;
    color: #77dd77;
    letter-spacing: 0.1rem;
    transition: background 0.2s;
    user-select: none;
    border-bottom: 1px solid rgba(0, 255, 0, 0.1);
}

.set-bonuses-header:hover {
    background: rgba(0, 255, 0, 0.1);
}

.toggle-icon {
    font-size: 0.6rem;
    opacity: 0.7;
    transition: transform 0.2s;
}

.set-bonuses-list {
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.set-bonus-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.set-bonus-count {
    color: #77dd77;
    font-weight: bold;
    min-width: 1.5rem;
}

.set-bonus-label {
    color: #888;
    flex-grow: 1;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

.set-bonus-value {
    color: #fff;
    font-weight: bold;
    text-align: right;
}

/* ── Puzzle Chest Keyboard ────────────────────────────────────────────────── */
#puzzle-keyboard {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) scale(var(--ui-scale));
    transform-origin: bottom center;
    display: grid;
    grid-template-columns: repeat(13, 1fr);
    gap: 6px;
    background: rgba(68, 68, 68, 0.8);
    padding: 12px;
    border: 2px solid #666;
    border-radius: 10px;
    backdrop-filter: blur(8px);
    z-index: 100;
}

.puzzle-key {
    background: black;
    border: 1px solid #444;
    color: #eee;
    padding: 4px 8px;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    font-size: 2.2rem;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 50px;
    text-align: center;
    border-radius: 4px;
}

.puzzle-key:hover {
    background: #222;
    border-color: #ffcc00;
    color: #ffcc00;
}

.puzzle-key.used {
    background: #111;
    border-color: #222;
    color: #333;
    opacity: 0.15;
    cursor: default;
    transform: scale(0.9);
    pointer-events: none;
}

.shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, -50%, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, -50%, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, -50%, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, -50%, 0);
    }
}

/* ── Responsive Queries ──────────────────────────────────────────────────── */

@media (max-width: 1200px) {
    .pause-content {
        width: 95vw;
        gap: 2rem;
        padding: 1.5rem;
    }

    .inv-container {
        padding: 1.5rem;
    }
}

@media (max-width: 900px) {
    .inv-main-content {
        flex-direction: column-reverse;
        /* Gear on top or bottom if squeezed */
        align-items: center;
    }

    .equipment-view {
        width: 100%;
        display: flex;
        justify-content: center;
    }
}

@media (max-height: 800px) {
    .storage-grid {
        max-height: 300px;
    }

    #char-stats-view {
        padding: 0.5rem;
        font-size: 0.7rem;
    }
}