/* ============================================
   GRID PATCH VISUAL INDICATORS
   Enchanted Stitching & Runic Enhancement Theme
   Shows bonuses from collected grid patches
   ============================================ */

/* === GRID CELL PATCH HIGHLIGHTS === */

/* Base styling for all patched cells - Enchanted stitching effect */
.grid-cell.grid-patch-active {
    position: relative;
    overflow: visible;
}

/* Golden stitching base effect for patched cells */
.grid-cell.grid-patch-active::before {
    content: '';
    position: absolute;
    inset: 2px;
    border: 2px dashed rgba(212, 168, 75, 0.5);
    border-radius: 4px;
    background: radial-gradient(ellipse at center,
            rgba(212, 168, 75, 0.06) 0%,
            transparent 70%);
    box-shadow:
        inset 0 0 8px rgba(212, 168, 75, 0.12);
    animation: enchanted-stitch 3s ease-in-out infinite;
    pointer-events: none;
    z-index: 2;
}

/* Corner patch bonus - Reinforced leather corners with brass studs */
.grid-cell.grid-patch-corner::before {
    border-style: solid;
    border-width: 3px;
    border-color: rgba(180, 140, 60, 0.65);
    inset: 1px;
    background:
        radial-gradient(circle at 10% 10%, rgba(255, 220, 120, 0.25) 0%, transparent 25%),
        radial-gradient(circle at 90% 10%, rgba(255, 220, 120, 0.25) 0%, transparent 25%),
        radial-gradient(circle at 10% 90%, rgba(255, 220, 120, 0.25) 0%, transparent 25%),
        radial-gradient(circle at 90% 90%, rgba(255, 220, 120, 0.25) 0%, transparent 25%),
        radial-gradient(ellipse at center, rgba(212, 168, 75, 0.08) 0%, transparent 60%);
    box-shadow:
        inset 0 0 10px rgba(212, 168, 75, 0.2),
        0 0 5px rgba(212, 168, 75, 0.25);
    animation: corner-stud-gleam 2.5s ease-in-out infinite;
}

/* Center patch bonus - Sacred rune glow */
.grid-cell.grid-patch-center::before {
    border: 2px solid rgba(255, 200, 100, 0.6);
    border-radius: 50%;
    inset: 6px;
    background: radial-gradient(circle at 50% 50%,
            rgba(255, 220, 150, 0.2) 0%,
            rgba(255, 200, 100, 0.12) 40%,
            transparent 70%);
    box-shadow:
        inset 0 0 12px rgba(255, 200, 100, 0.3),
        0 0 8px rgba(255, 200, 100, 0.35),
        0 0 16px rgba(255, 200, 100, 0.12);
    animation: rune-pulse 2s ease-in-out infinite;
}

/* Center rune symbol */
.grid-cell.grid-patch-center::after {
    content: '✦';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9rem;
    color: rgba(255, 200, 100, 0.45);
    text-shadow: 0 0 6px rgba(255, 200, 100, 0.5);
    pointer-events: none;
    z-index: 3;
    animation: rune-float 3s ease-in-out infinite;
}

/* Edge patch bonus - Reinforced binding stitches */
.grid-cell.grid-patch-edge::before {
    border: 2px dashed rgba(160, 130, 80, 0.55);
    background: linear-gradient(135deg,
            rgba(180, 150, 90, 0.06) 0%,
            transparent 30%,
            transparent 70%,
            rgba(180, 150, 90, 0.06) 100%);
    box-shadow:
        inset 0 0 5px rgba(160, 130, 80, 0.15);
}

/* Row patch bonus - Horizontal leather band */
.grid-cell.grid-patch-row::before {
    border: none;
    inset: 0;
    background: linear-gradient(0deg,
            transparent 0%,
            transparent 38%,
            rgba(139, 90, 43, 0.12) 42%,
            rgba(139, 90, 43, 0.18) 50%,
            rgba(139, 90, 43, 0.12) 58%,
            transparent 62%,
            transparent 100%);
    box-shadow: none;
    animation: none;
}

/* Row band decorative stitching line */
.grid-cell.grid-patch-row::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 6px;
    right: 6px;
    height: 1px;
    background: repeating-linear-gradient(90deg,
            rgba(212, 168, 75, 0.4) 0px,
            rgba(212, 168, 75, 0.4) 3px,
            transparent 3px,
            transparent 7px);
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 3;
}

/* Column patch bonus - Vertical leather band */
.grid-cell.grid-patch-column::before {
    border: none;
    inset: 0;
    background: linear-gradient(90deg,
            transparent 0%,
            transparent 38%,
            rgba(139, 90, 43, 0.12) 42%,
            rgba(139, 90, 43, 0.18) 50%,
            rgba(139, 90, 43, 0.12) 58%,
            transparent 62%,
            transparent 100%);
    box-shadow: none;
    animation: none;
}

/* Column band decorative stitching line */
.grid-cell.grid-patch-column::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: repeating-linear-gradient(180deg,
            rgba(212, 168, 75, 0.4) 0px,
            rgba(212, 168, 75, 0.4) 3px,
            transparent 3px,
            transparent 7px);
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 3;
}

/* Global patch bonus - Subtle magical aura */
.grid-cell.grid-patch-global::before {
    border: 1px solid rgba(212, 168, 75, 0.2);
    background: radial-gradient(ellipse at center,
            rgba(212, 168, 75, 0.04) 0%,
            transparent 70%);
    animation: global-aura 4s ease-in-out infinite;
}

/* Hide ::after for cells that don't need symbols */
.grid-cell.grid-patch-active:not(.grid-patch-center):not(.grid-patch-row):not(.grid-patch-column)::after {
    content: none;
}

/* Animations */
@keyframes enchanted-stitch {

    0%,
    100% {
        border-color: rgba(212, 168, 75, 0.4);
        box-shadow: inset 0 0 5px rgba(212, 168, 75, 0.1);
    }

    50% {
        border-color: rgba(212, 168, 75, 0.6);
        box-shadow: inset 0 0 8px rgba(212, 168, 75, 0.18);
    }
}

@keyframes corner-stud-gleam {

    0%,
    100% {
        box-shadow:
            inset 0 0 8px rgba(212, 168, 75, 0.15),
            0 0 3px rgba(212, 168, 75, 0.2);
    }

    50% {
        box-shadow:
            inset 0 0 12px rgba(212, 168, 75, 0.28),
            0 0 6px rgba(212, 168, 75, 0.35);
    }
}

@keyframes rune-pulse {

    0%,
    100% {
        box-shadow:
            inset 0 0 10px rgba(255, 200, 100, 0.25),
            0 0 6px rgba(255, 200, 100, 0.3);
        border-color: rgba(255, 200, 100, 0.5);
    }

    50% {
        box-shadow:
            inset 0 0 16px rgba(255, 200, 100, 0.4),
            0 0 12px rgba(255, 200, 100, 0.45),
            0 0 20px rgba(255, 200, 100, 0.15);
        border-color: rgba(255, 200, 100, 0.8);
    }
}

@keyframes rune-float {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.15);
        opacity: 0.8;
    }
}

@keyframes global-aura {

    0%,
    100% {
        background: radial-gradient(ellipse at center,
                rgba(212, 168, 75, 0.03) 0%,
                transparent 70%);
    }

    50% {
        background: radial-gradient(ellipse at center,
                rgba(212, 168, 75, 0.07) 0%,
                transparent 70%);
    }
}

/* === ITEM GRID PATCH INDICATOR - Enchanted Seal === */

/* Container for grid patch bonus indicator on items */
/* Container for grid patch bonus indicator on items */
.grid-patch-indicator {
    position: absolute;
    bottom: calc(var(--badge-offset-bottom, 0px) + (var(--cell-size) * 0.1));
    left: calc(var(--badge-offset-left-bottom, 0px) - (var(--cell-size) * 0.05));
    display: flex;
    align-items: center;
    gap: 0.15em;
    background:
        linear-gradient(145deg,
            rgba(92, 61, 30, 0.95) 0%,
            rgba(60, 40, 20, 0.98) 100%);
    color: #d4a84b;
    padding: 0.15em 0.35em;
    border-radius: 4px;
    font-family: var(--font-heading);
    font-size: calc(var(--cell-size) * 0.22);
    font-weight: 700;
    white-space: nowrap;
    z-index: 60;
    border: max(1px, calc(var(--cell-size) * 0.02)) solid rgba(212, 168, 75, 0.55);
    box-shadow:
        0 2px 5px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        inset 0 -1px 0 rgba(0, 0, 0, 0.15);
    pointer-events: none;
    animation: seal-appear 0.4s ease-out;
}

.grid-patch-icon {
    font-size: 1.1em;
    filter: drop-shadow(0 0 2px rgba(212, 168, 75, 0.4));
}

.grid-patch-value {
    color: #90e890;
    text-shadow: 0 0 3px rgba(100, 200, 100, 0.35);
    letter-spacing: -0.02em;
}

@keyframes seal-appear {
    0% {
        opacity: 0;
        transform: scale(0.7);
    }

    60% {
        transform: scale(1.08);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Item with grid patch bonus - Enchanted golden thread outline */
.grid-patch-bonus-active {
    filter: drop-shadow(0 0 3px rgba(212, 168, 75, 0.3)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.grid-patch-bonus-active .item-subcell-filled {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 1px 0 0 rgba(255, 255, 255, 0.3),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(212, 168, 75, 0.2);
}

/* === ACTIVE GRID PATCHES PANEL - Leather Pouch Style === */

/* Panel container - positioned to the right of the grid */
.active-patches-panel {
    position: absolute;
    right: -180px;
    top: 0;
    transform: none;
    background:
        radial-gradient(circle at 50% 0, rgba(255, 255, 255, 0.05), transparent 70%),
        radial-gradient(circle at 0 50%, rgba(255, 255, 255, 0.03), transparent 50%),
        linear-gradient(145deg,
            rgba(65, 45, 25, 0.98) 0%,
            rgba(45, 30, 15, 0.99) 100%);
    border: 3px solid rgba(139, 90, 43, 0.8);
    /* Responsive Scaling based on cell-size */
    /* Base width 100px + proportional scaling */
    min-width: calc(85px + var(--cell-size) * 0.9);
    max-width: calc(95px + var(--cell-size) * 1.1);

    /* Scale padding and border slightly */
    padding: calc(var(--cell-size) * 0.14) calc(var(--cell-size) * 0.12);
    border-width: max(2px, calc(var(--cell-size) * 0.05));
    border-radius: calc(var(--cell-size) * 0.2);
    box-shadow:
        0 10px 25px rgba(0, 0, 0, 0.65),
        0 4px 8px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -2px 6px rgba(0, 0, 0, 0.25);
    z-index: 10;
}

/* Leather binding stitching effect */
.active-patches-panel::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px dashed rgba(212, 168, 75, 0.35);
    border-radius: 4px;
    pointer-events: none;
}

/* Decorative brass corner studs */
.active-patches-panel::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    background:
        radial-gradient(circle at 5% 5%, rgba(212, 168, 75, 0.4) 0%, transparent 12%),
        radial-gradient(circle at 95% 5%, rgba(212, 168, 75, 0.4) 0%, transparent 12%),
        radial-gradient(circle at 5% 95%, rgba(212, 168, 75, 0.4) 0%, transparent 12%),
        radial-gradient(circle at 95% 95%, rgba(212, 168, 75, 0.4) 0%, transparent 12%);
    pointer-events: none;
    border-radius: 3px;
}

.patches-header {
    font-family: var(--font-display);
    /* Scale font size: Base ~0.4rem + dynamic part */
    font-size: max(0.55rem, calc(var(--cell-size) * 0.011rem));
    color: #d4a84b;
    text-align: center;
    margin-bottom: 3px;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(139, 90, 43, 0.45);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 1;
}

/* Small decorative flourish under header */
.patches-header::after {
    content: '—✦—';
    display: block;
    font-size: 0.3rem;
    margin-top: 1px;
    opacity: 0.45;
    letter-spacing: 0.03em;
}

.active-patches-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    z-index: 1;
}

/* Individual patch item - Wax seal style */
.active-patch-item {
    display: flex;
    align-items: center;
    gap: calc(var(--cell-size) * 0.08);
    padding: calc(var(--cell-size) * 0.08) calc(var(--cell-size) * 0.1);
    background: linear-gradient(90deg,
            rgba(45, 35, 20, 0.8) 0%,
            rgba(35, 25, 15, 0.9) 100%);
    border-radius: 5px;
    border: 1px solid rgba(139, 90, 43, 0.4);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    /* overflow: hidden; */
    cursor: help;
}

.active-patch-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(45deg, transparent 0%, rgba(255, 255, 255, 0.03) 50%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.active-patch-item:hover {
    background: linear-gradient(90deg,
            rgba(65, 50, 30, 0.9) 0%,
            rgba(50, 35, 20, 0.95) 100%);
    border-color: rgba(212, 168, 75, 0.6);
    transform: translateX(-4px) scale(1.02);
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.4),
        0 0 10px rgba(212, 168, 75, 0.15);
}

.active-patch-item:hover::before {
    opacity: 1;
}

.active-patch-icon {
    font-size: max(0.85rem, calc(var(--cell-size) * 0.018rem));
    flex-shrink: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.active-patch-name {
    font-family: var(--font-body);
    font-size: max(0.55rem, calc(var(--cell-size) * 0.012rem));
    color: #e5dbc5;
    line-height: 1.1;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}

/* Rarity-based wax seal glow */
.active-patch-item.rarity-common {
    border-left: 3px solid rgba(160, 140, 100, 0.8);
}

.active-patch-item.rarity-common .active-patch-icon {
    filter: drop-shadow(0 0 2px rgba(150, 130, 95, 0.4));
}

.active-patch-item.rarity-uncommon {
    border-left: 3px solid rgba(100, 200, 100, 0.8);
    box-shadow: inset 10px 0 20px -10px rgba(100, 200, 100, 0.1);
}

.active-patch-item.rarity-uncommon .active-patch-icon {
    filter: drop-shadow(0 0 3px rgba(90, 165, 90, 0.5));
}

.active-patch-item.rarity-rare {
    border-left: 3px solid rgba(100, 160, 255, 0.85);
    box-shadow: inset 10px 0 20px -10px rgba(100, 160, 255, 0.15);
}

.active-patch-item.rarity-rare .active-patch-icon {
    filter: drop-shadow(0 0 4px rgba(95, 140, 210, 0.6));
    animation: rare-glow 2s ease-in-out infinite;
}

@keyframes rare-glow {

    0%,
    100% {
        filter: drop-shadow(0 0 3px rgba(95, 140, 210, 0.5));
    }

    50% {
        filter: drop-shadow(0 0 6px rgba(95, 140, 210, 0.8));
    }
}

/* === ATMOSPHERIC PATCH TOOLTIP === */

/* Tooltip container - hidden by default, appears on LEFT (to avoid clipping) */
.patch-tooltip {
    position: absolute;
    right: calc(100% + 12px);
    left: auto;
    top: 50%;
    transform: translateY(-50%);
    width: 200px;
    padding: 12px 14px;
    background:
        linear-gradient(145deg,
            rgba(58, 42, 22, 0.98) 0%,
            rgba(38, 28, 15, 0.99) 100%);
    border: 2px solid rgba(139, 90, 43, 0.7);
    border-radius: 8px;
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.65),
        0 2px 8px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 200;
}

/* Tooltip arrow pointing RIGHT (towards the panel) */
.patch-tooltip::after {
    content: '';
    position: absolute;
    right: -8px;
    left: auto;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: rgba(38, 28, 15, 0.98);
}

/* Tooltip border arrow */
.patch-tooltip::before {
    content: '';
    position: absolute;
    right: -11px;
    left: auto;
    top: 50%;
    transform: translateY(-50%);
    border: 7px solid transparent;
    border-left-color: rgba(139, 90, 43, 0.7);
}

/* Show tooltip on hover - slide in from right */
.active-patch-item:hover .patch-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(-4px);
}

/* Tooltip header - patch name */
.patch-tooltip-header {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: #d4a84b;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(139, 90, 43, 0.5);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.04em;
    text-align: center;
}

/* Decorative flourish under header */
.patch-tooltip-header::after {
    content: '—✦—';
    display: block;
    text-align: center;
    font-size: 0.5rem;
    color: rgba(212, 168, 75, 0.5);
    margin-top: 6px;
    letter-spacing: 0.1em;
}

/* Tooltip description */
.patch-tooltip-desc {
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: #d8cdb8;
    line-height: 1.5;
    margin-bottom: 10px;
    font-style: italic;
    text-align: left;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 8px;
}

/* Tooltip effect - the bonus */
.patch-tooltip-effect {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    color: #90e890;
    background: rgba(100, 200, 100, 0.12);
    padding: 8px 10px;
    border-radius: 5px;
    border: 1px solid rgba(100, 200, 100, 0.3);
    text-shadow: 0 0 5px rgba(100, 200, 100, 0.35);
    text-align: center;
    line-height: 1.4;
}