/* Inventory (I): the pause menu's MediEvil dress in Level 1's night palette, laid out
   like Diablo II. Weathered night stone, chunky bevels, lantern-amber selection; the
   gnome stands in a pool of warm light on the right while the world cools around it. */
#inventory-screen {
    --night-deep: #050b1f; --night: #0b1732; --night-stone: #1d2c5a; --moonlit: #c4d2f0;
    --moonlit-dim: #7186b4; --bone: #ece6d4; --lantern: #ffb338; --lantern-pale: #ffe2a6;
    /* One unit scales the whole screen with the window height. */
    --u: clamp(.75px, calc(100vh / 900), 2.1px);
    position: fixed; inset: 0; z-index: 75; pointer-events: none; user-select: none;
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif; color: var(--bone);
}
#inventory-screen[hidden] { display: none; }
/* The HUD steps aside while the inventory is up. */
body.inventory-open #game-hud { visibility: hidden; }

/* Dragging anywhere off the panel turns the camera round the gnome. */
.inv-stage { position: absolute; inset: 0; pointer-events: auto; cursor: grab; touch-action: none; }
#inventory-screen.is-turning .inv-stage { cursor: grabbing; }

/* Two-tone read: lantern warmth on the gnome, cool night falling away from it. */
.inv-light, .inv-shade { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .5s ease; }
.inv-light::before, .inv-light::after { content: ''; position: absolute; inset: 0; }
.inv-light::before {
    background: radial-gradient(ellipse 34% 58% at var(--gx, 70%) var(--gy, 50%), transparent 32%, rgba(4, 8, 24, .25) 64%, rgba(3, 6, 18, .52) 100%);
}
.inv-light::after {
    mix-blend-mode: screen;
    background: radial-gradient(ellipse 15% 32% at var(--gx, 70%) var(--gy, 50%), rgba(255, 196, 120, .2), rgba(255, 160, 70, .07) 55%, transparent 100%);
}
.inv-shade { background: linear-gradient(90deg, rgba(3, 6, 18, .66), rgba(3, 6, 18, .38) 32%, rgba(3, 6, 18, 0) 52%); }
#inventory-screen.is-open .inv-light, #inventory-screen.is-open .inv-shade { opacity: 1; }

/* Pinned by its top, roughly centred for a typical description: the description box
   grows downward with the selected item, so the slots never move. Centring it on its
   own height shifted the bag under a hovering mouse, which selected the neighbouring
   cell, which shrank the box back: the screen flickered between two positions. */
.inv-column {
    position: absolute; left: max(20px, 4vw); top: max(calc(28 * var(--u)), calc(50% - 410 * var(--u))); display: grid; gap: calc(14 * var(--u)); justify-items: start;
    transform: translateX(calc(-30 * var(--u))); opacity: 0; transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .25s ease;
}
#inventory-screen.is-open .inv-column { transform: none; opacity: 1; transition-delay: .22s; }

.inv-panel {
    position: relative; box-sizing: border-box; width: calc(500 * var(--u)); pointer-events: auto;
    padding: calc(34 * var(--u)) calc(20 * var(--u)) calc(18 * var(--u));
    /* Night stone with a fine weathered grain. */
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .78 0 0 0 0 .84 0 0 0 0 1 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E"),
        radial-gradient(ellipse at 30% 0%, rgba(60, 86, 160, .22), transparent 60%),
        linear-gradient(180deg, rgba(15, 27, 62, .95), rgba(5, 11, 31, .97));
    border: calc(3 * var(--u)) solid; border-color: #34477f #16224a #0c1534 #2a3c72;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .55), inset 0 0 0 calc(3 * var(--u)) rgba(5, 11, 31, .5),
        inset 0 0 0 calc(4 * var(--u)) rgba(255, 179, 56, .26), inset 0 0 calc(50 * var(--u)) rgba(0, 0, 0, .5),
        0 calc(18 * var(--u)) calc(50 * var(--u)) rgba(0, 0, 0, .7);
}
/* Lantern-amber studs at the corners, like iron fittings on a chest. */
.inv-panel::before, .inv-panel::after {
    content: '◆'; position: absolute; top: -.62em; left: -.5em; color: var(--lantern); font-size: calc(15 * var(--u));
    text-shadow: 0 0 8px rgba(255, 179, 56, .7);
}
.inv-panel::after { left: auto; right: -.5em; }

.inv-title {
    position: absolute; top: 0; left: 50%; transform: translate(-50%, -58%); margin: 0; padding: 0 .6em;
    background: var(--night-deep); white-space: nowrap;
    color: var(--bone); font-size: calc(30 * var(--u)); font-weight: bold; letter-spacing: .24em; text-transform: uppercase;
    text-shadow: 0 2px 0 #000, 0 0 3px #000, 0 0 14px rgba(196, 210, 240, .35);
}
.inv-note { margin: calc(-6 * var(--u)) 0 calc(4 * var(--u)); text-align: center; color: var(--moonlit-dim); font-style: italic; font-size: calc(15 * var(--u)); }

.inv-heading {
    display: flex; align-items: center; gap: calc(8 * var(--u)); margin: calc(12 * var(--u)) 0 calc(8 * var(--u));
    color: var(--moonlit); font-size: calc(12.5 * var(--u)); font-weight: bold; letter-spacing: .22em; text-transform: uppercase;
    text-shadow: 0 2px 0 #000;
}
.inv-heading::after { content: ''; order: 1; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(113, 134, 180, .5), rgba(113, 134, 180, .08)); }
.inv-heading svg { width: calc(30 * var(--u)); height: calc(30 * var(--u)); margin: calc(-8 * var(--u)) 0; filter: drop-shadow(0 2px 2px #000); }

/* ---- Equipment: carved sockets beside the gnome's numbers ---- */
/* Weapon over Off hand, a tall Cloak, the valuables (Neck, Arms) beneath, the Head-Chest-
   Legs-Feet column, then the stats; spaced evenly across the panel. */
.inv-equipment {
    position: relative; display: grid; justify-content: space-evenly;
    grid-template-columns: repeat(3, calc(54 * var(--u))) calc(176 * var(--u)); grid-template-rows: repeat(4, calc(54 * var(--u)));
    gap: calc(7 * var(--u)) 0; padding: calc(4 * var(--u)) 0;
    grid-template-areas: "weapon cloak head stats" "weapon cloak chest stats" "offhand cloak legs stats" "neck arms feet stats";
}
.inv-stats {
    grid-area: stats; margin: 0; padding: calc(10 * var(--u)) calc(14 * var(--u)); display: grid; align-content: space-evenly;
    background: rgba(5, 11, 31, .62); border: 1px solid rgba(113, 134, 180, .3); box-shadow: inset 0 0 calc(18 * var(--u)) rgba(0, 0, 0, .55);
}
.inv-stat { display: grid; grid-template-columns: 1fr auto; align-items: baseline; row-gap: calc(2 * var(--u)); }
.inv-stat dt { color: var(--moonlit); font-size: calc(11.5 * var(--u)); font-weight: bold; letter-spacing: .2em; text-transform: uppercase; text-shadow: 0 2px 0 #000; }
.inv-stat dd {
    margin: 0; font-size: calc(24 * var(--u)); font-weight: bold; line-height: 1; font-variant-numeric: lining-nums;
    background: linear-gradient(to bottom, #fff7df 0%, var(--lantern-pale) 45%, var(--lantern) 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 2px 0 #000) drop-shadow(0 0 1px #000);
}
.inv-stat dd small { font-size: .6em; }
.inv-stat__note { grid-column: 1 / -1; color: var(--moonlit-dim); font-size: calc(12 * var(--u)); font-style: italic; }
.inv-stat__bar {
    grid-column: 1 / -1; height: calc(5 * var(--u)); border: 1px solid rgba(255, 179, 56, .45); background: rgba(5, 11, 31, .8);
}
.inv-stat__bar i { display: block; height: 100%; background: linear-gradient(to bottom, #f08a6a, #b8321e 60%, #6e1408); }
.inv-slot {
    position: relative; z-index: 1; box-sizing: border-box; padding: 0; display: grid; place-items: center; cursor: pointer;
    color: inherit; font: inherit; transition: box-shadow .12s ease, border-color .12s ease;
}
.inv-slot:focus-visible { outline: none; }
.inv-slot--equip {
    width: 100%; height: 100%;
    background: radial-gradient(circle at 50% 38%, #15265a, #060c22 72%);
    border: 1px solid; border-color: #0a1230 #2f437e #3a5091 #121c42;
    box-shadow: inset 0 calc(3 * var(--u)) calc(8 * var(--u)) rgba(0, 0, 0, .85), 0 1px 0 rgba(196, 210, 240, .08);
}
.inv-slot--equip .inv-icon { position: absolute; inset: calc(3 * var(--u)); background: center / cover no-repeat; }
.inv-slot--equip[data-slot="weapon"] .inv-icon, .inv-slot--equip[data-slot="cloak"] .inv-icon { inset: auto calc(3 * var(--u)); aspect-ratio: 1; width: auto; }
.inv-silhouette { width: 62%; height: 62%; max-height: calc(36 * var(--u)); color: rgba(113, 134, 180, .3); }
.inv-silhouette svg { display: block; width: 100%; height: 100%; }
.inv-slot.has-item .inv-silhouette { display: none; }

/* ---- Bag of Holding: one starry void with faint seams ---- */
.inv-bag {
    position: relative; display: grid; grid-template-columns: repeat(8, 1fr); overflow: hidden;
    border-radius: calc(5 * var(--u)); border: 1px solid rgba(170, 130, 240, .3);
    background: radial-gradient(ellipse 80% 120% at 50% 20%, #2c1b5c 0%, #150b33 45%, #05030f 100%);
    box-shadow: inset 0 0 calc(26 * var(--u)) rgba(0, 0, 0, .9), inset 0 0 calc(70 * var(--u)) rgba(90, 50, 180, .25), 0 0 calc(18 * var(--u)) rgba(110, 60, 210, .12);
}
.inv-stars {
    position: absolute; inset: -40%; pointer-events: none; opacity: .6;
    background-image:
        radial-gradient(circle, rgba(255, 255, 255, .95) 0 1px, transparent 1.6px),
        radial-gradient(circle, rgba(214, 190, 255, .75) 0 .9px, transparent 1.5px),
        radial-gradient(circle, rgba(255, 236, 200, .6) 0 .7px, transparent 1.3px);
    background-size: 97px 83px, 61px 73px, 43px 37px;
    background-position: 0 0, 31px 19px, 11px 41px;
    animation: inv-drift 90s linear infinite;
}
@keyframes inv-drift { to { transform: translate(-97px, -83px); } }
.inv-slot--bag {
    aspect-ratio: 1; background: transparent; border: 0;
    box-shadow: inset 0 0 0 .5px rgba(170, 150, 240, .14);
}
/* Items float in the void, feathered into it, each at its own pace. */
.inv-slot--bag .inv-icon {
    position: absolute; inset: 7%; background: center / cover no-repeat;
    -webkit-mask-image: radial-gradient(circle, #000 50%, transparent 71%); mask-image: radial-gradient(circle, #000 50%, transparent 71%);
    animation: inv-float 4.2s ease-in-out infinite alternate;
}
.inv-slot--bag:nth-child(3n) .inv-icon { animation-duration: 5.1s; animation-delay: -1.3s; }
.inv-slot--bag:nth-child(3n + 1) .inv-icon { animation-duration: 3.7s; animation-delay: -2.2s; }
@keyframes inv-float { from { transform: translateY(calc(-2 * var(--u))) rotate(-2deg); } to { transform: translateY(calc(2 * var(--u))) rotate(2deg); } }
.inv-icon[hidden] { display: none; }

/* Selection: the pause menu's lantern amber. */
.inv-slot.is-selected { z-index: 2; }
.inv-slot--equip.is-selected { border-color: var(--lantern); box-shadow: 0 0 0 1px rgba(255, 179, 56, .5), 0 0 calc(16 * var(--u)) rgba(255, 179, 56, .42), inset 0 calc(3 * var(--u)) calc(8 * var(--u)) rgba(0, 0, 0, .7); }
.inv-slot--bag.is-selected {
    background: radial-gradient(circle, rgba(255, 190, 90, .2), transparent 70%);
    box-shadow: inset 0 0 0 calc(2 * var(--u)) var(--lantern), inset 0 0 calc(14 * var(--u)) rgba(255, 179, 56, .45);
}
.inv-count {
    position: absolute; right: 8%; bottom: 4%; z-index: 1; color: var(--bone); font-size: calc(15 * var(--u)); font-weight: bold;
    text-shadow: 0 0 2px #000, 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000, 0 -1px 0 #000;
}
/* A lifted item leaves a dim trace behind and hovers, ghosted, over the cursor. */
.inv-slot.is-held .inv-icon { opacity: .28; animation: none; }
.inv-slot--bag.is-held { box-shadow: inset 0 0 0 1px rgba(255, 179, 56, .6); }
.inv-slot.has-ghost::before {
    content: ''; position: absolute; inset: 7%; background: var(--ghost) center / cover no-repeat; opacity: .6;
    -webkit-mask-image: radial-gradient(circle, #000 50%, transparent 71%); mask-image: radial-gradient(circle, #000 50%, transparent 71%);
}

/* ---- Description ---- */
.inv-detail {
    margin-top: calc(14 * var(--u)); min-height: calc(104 * var(--u)); padding: calc(10 * var(--u)) calc(12 * var(--u));
    display: grid; grid-template-columns: calc(84 * var(--u)) 1fr; gap: calc(14 * var(--u)); align-items: start;
    background: rgba(5, 11, 31, .62); border: 1px solid rgba(113, 134, 180, .3); box-shadow: inset 0 0 calc(18 * var(--u)) rgba(0, 0, 0, .55);
}
.inv-detail__art {
    width: calc(84 * var(--u)); aspect-ratio: 1; display: grid; place-items: center; background: center / cover no-repeat;
    -webkit-mask-image: radial-gradient(circle, #000 55%, transparent 72%); mask-image: radial-gradient(circle, #000 55%, transparent 72%);
    color: rgba(113, 134, 180, .4);
}
.inv-detail__art svg { width: 58%; height: 58%; }
.inv-detail__text { display: grid; gap: calc(3 * var(--u)); align-content: start; }
.inv-detail [hidden] { display: none; }
.inv-detail h4 {
    margin: 0; font-size: calc(21 * var(--u)); font-weight: bold; letter-spacing: .03em; justify-self: start;
    background: linear-gradient(to bottom, #fff7df 0%, var(--lantern-pale) 45%, var(--lantern) 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    filter: drop-shadow(0 2px 0 #000) drop-shadow(0 0 1px #000);
}
.inv-detail.is-empty h4 { background-image: linear-gradient(to bottom, var(--moonlit), var(--moonlit-dim)); }
.inv-kind { margin: 0; color: var(--moonlit-dim); font-style: italic; font-size: calc(14 * var(--u)); }
.inv-description { margin: calc(2 * var(--u)) 0 0; color: var(--bone); font-size: calc(15.5 * var(--u)); line-height: 1.35; }
.inv-effect { margin: 0; color: var(--lantern-pale); font-size: calc(14.5 * var(--u)); text-shadow: 0 1px 0 #000; }
.inv-use {
    justify-self: start; margin-top: calc(4 * var(--u)); padding: calc(4 * var(--u)) calc(14 * var(--u)); pointer-events: auto; cursor: pointer;
    font: inherit; font-size: calc(13 * var(--u)); letter-spacing: .16em; text-transform: uppercase; color: var(--lantern-pale);
    background: radial-gradient(circle at 40% 35%, #2a3f80, var(--night)); border: 1px solid var(--moonlit-dim); border-radius: calc(14 * var(--u));
    text-shadow: 0 1px 0 #000;
}
.inv-use:hover { border-color: var(--lantern); color: #fff7df; }
.inv-relic { margin: calc(2 * var(--u)) 0 0; color: var(--moonlit); font-size: calc(11.5 * var(--u)); letter-spacing: .12em; text-transform: uppercase; }

.inv-footer {
    display: flex; gap: calc(24 * var(--u)); color: var(--bone); font-size: calc(13 * var(--u)); letter-spacing: .18em; text-transform: uppercase;
    text-shadow: 0 2px 0 #000;
}
.inv-footer b {
    display: inline-grid; place-items: center; min-width: 1.6em; height: 1.6em; margin-right: .45em; padding: 0 .35em;
    border-radius: 1em; background: radial-gradient(circle at 40% 35%, #2a3f80, var(--night)); border: 1px solid var(--moonlit-dim);
    color: var(--lantern-pale); font-size: .9em; letter-spacing: 0;
}

@media (prefers-reduced-motion: reduce) {
    .inv-light, .inv-shade, .inv-column { transition: none; }
    .inv-stars, .inv-slot--bag .inv-icon { animation: none; }
}

/* The Energy Potion's countdown, bottom left while it lasts; hidden under the menus. */
.effects-hud {
    position: fixed; left: 18px; bottom: 18px; z-index: 30; pointer-events: none; padding: 5px 12px 6px;
    font: 600 13px/1.2 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif; letter-spacing: .12em; text-transform: uppercase;
    color: #d9ffd8; text-shadow: 0 1px 2px #000; background: rgba(8, 20, 14, .62); border: 1px solid rgba(110, 220, 130, .45); border-radius: 14px;
}
.effects-hud[hidden], body.inventory-open .effects-hud { display: none; }
