/* Vault contents as a safe-deposit drawer (js/vault-items.js, js/vault-view.js).
 * The drawer is a physical thing, so it keeps the same steel and felt in light and dark mode;
 * only the total above it follows the page theme. Motion: transform/opacity only.
 */
:root {
  --vi-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --vi-felt: #1C1F26;
  --vi-felt-light: #282C35;
  --vi-steel-hi: #C3C8CF;
  --vi-steel: #8E949D;
  --vi-steel-lo: #6A7079;
  --vi-card: #F5F0E5;
  --vi-card-ink: #141414;
  --vi-card-ink-2: #5B5B5B;
  --vi-red: var(--sw-red, #E30613);
}

.sw-record .vi-tray { grid-column: 4 / -1; min-width: 0; }
@media (max-width: 768px) { .sw-record .vi-tray { grid-column: 1 / -1; } }

/* Total */
.vi-total {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 0 0 16px; padding-top: 12px; border-top: 1px solid var(--sw-ink, #111);
  color: var(--sw-ink-2, #555); font-size: var(--sw-text-sm, 0.875rem);
}
.vi-total strong {
  color: var(--sw-ink, #111); font-weight: var(--sw-weight-display, 800);
  font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.75rem); line-height: 1; letter-spacing: -0.02em;
  font-feature-settings: "kern", "tnum", "lnum";
}

/* Drawer: steel frame, felt lining */
.vi-drawer {
  position: relative; overflow: hidden; padding: 10px; border-radius: 6px;
  background: linear-gradient(180deg, var(--vi-steel-hi), var(--vi-steel) 55%, var(--vi-steel-lo));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -2px 0 rgba(0, 0, 0, 0.18), 0 28px 44px -28px rgba(0, 0, 0, 0.6);
}
.vi-felt {
  position: relative; border-radius: 3px; padding: clamp(16px, 2.6vw, 28px);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.09'/%3E%3C/svg%3E"),
    radial-gradient(120% 90% at 50% 0%, var(--vi-felt-light), var(--vi-felt) 70%);
  box-shadow: inset 0 10px 24px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.vi-items {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 28px 24px;
}
.vi-item { display: flex; flex-direction: column; min-width: 0; }

/* Lid: covers the felt until the drawer scrolls into view, then slides away */
.vi-lid {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #BFC4CB, #969CA5 60%, #7A808A);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}
.vi-lid[hidden] { display: none; }
.vi-lid-plate {
  padding: 8px 18px; border: 1px solid rgba(0, 0, 0, 0.28); background: rgba(255, 255, 255, 0.14);
  color: #3A3E44; font-weight: 800; letter-spacing: 0.24em; font-size: 0.9rem;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}
.vi-lid-handle {
  width: min(160px, 40%); height: 18px; border-radius: 10px;
  background: linear-gradient(180deg, #EEF0F3, #A3A9B1);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 6px 10px rgba(0, 0, 0, 0.35);
}

/* Well: the recess each object sits in */
.vi-well {
  position: relative; aspect-ratio: 4 / 3; border-radius: 8px;
  display: grid; place-items: center; perspective: 800px; touch-action: pan-y;
  background: radial-gradient(70% 60% at 50% 45%, rgba(255, 255, 255, 0.07), transparent 70%);
  box-shadow: inset 0 6px 16px rgba(0, 0, 0, 0.55), inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}
.vi-object {
  position: relative; z-index: 1; width: 76%; height: 76%;
  display: block; padding: 0; border: 0; background: none; color: inherit; font: inherit;
}
button.vi-object { cursor: zoom-in; }
button.vi-object:focus-visible { outline: 2px solid #fff; outline-offset: 6px; border-radius: 4px; }
.vi-tilt {
  position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d;
  transform: translateY(var(--lift, 0px)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 700ms var(--vi-spring);
}
.vi-well.is-handled { --lift: -8px; }
.vi-well.is-handled .vi-tilt { transition-duration: 180ms; }
/* the light catches the surface where the pointer is */
.vi-tilt::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 30%), rgba(255, 255, 255, 0.35), transparent 45%);
  mix-blend-mode: soft-light; transition: opacity 300ms var(--vi-spring);
}
.vi-well.is-handled .vi-tilt::after { opacity: 1; }

.vi-shadow {
  position: absolute; left: 16%; right: 16%; bottom: 8%; height: 18%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.75), transparent);
  transform: translate(var(--sx, 0px), var(--sy, 0px)) scale(var(--ss, 1));
  transition: transform 700ms var(--vi-spring), opacity 300ms var(--vi-spring);
}
.vi-well.is-handled .vi-shadow { --ss: 0.88; opacity: 0.75; transition-duration: 180ms, 300ms; }

/* Stack: quantity shown as up to three copies */
.vi-layer {
  position: absolute; inset: 0;
  transform: translate(calc(var(--i) * 7px), calc(var(--i) * -8px));
  filter: brightness(calc(1 - var(--i) * 0.14));
}
.vi-kind-bar .vi-layer { transform: translateY(calc(var(--i) * -15px)); }
.vi-kind-cash .vi-layer, .vi-kind-document .vi-layer { transform: translate(calc(var(--i) * 5px), calc(var(--i) * -5px)) rotate(calc(var(--i) * 3deg)); }
.vi-art { display: block; width: 100%; height: 100%; overflow: visible; }
.vi-art text { font-family: var(--sw-sans, system-ui, sans-serif); }

/* Photo or video of the real item, laid on the felt like a print */
.vi-print {
  position: absolute; inset: 0; display: block; padding: 6px 6px 20px; background: #FBFAF7;
  transform: rotate(-2deg); box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
}
.vi-item:nth-child(even) .vi-print { transform: rotate(1.6deg); }
.vi-print img, .vi-print video { display: block; width: 100%; height: 100%; object-fit: cover; background: #222; }

.vi-qty {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  padding: 2px 8px; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(0, 0, 0, 0.45);
  color: #F5F0E5; font-weight: 800; font-size: 0.85rem; font-feature-settings: "kern", "tnum";
}
html[dir="rtl"] .vi-qty { right: auto; left: 10px; }

/* Living details: metal glints now and then, the watch ticks, gems sparkle */
.vi-glint { transform: translateX(-70px) skewX(-18deg); animation: vi-glint 6.5s var(--d, 0s) infinite var(--vi-spring); }
@keyframes vi-glint {
  0%, 72% { transform: translateX(-70px) skewX(-18deg); }
  100% { transform: translateX(250px) skewX(-18deg); }
}
.vi-second { transform-box: view-box; transform-origin: 100px 75px; animation: vi-tick 60s steps(60) infinite; }
@keyframes vi-tick { to { transform: rotate(360deg); } }
.vi-sparkle { transform-box: fill-box; transform-origin: center; opacity: 0; animation: vi-twinkle 3.4s var(--d, 0s) infinite ease-out; }
@keyframes vi-twinkle {
  0%, 60%, 100% { opacity: 0; transform: scale(0.2) rotate(0deg); }
  75% { opacity: 1; transform: scale(1) rotate(45deg); }
}

/* Card tag beneath each object */
.vi-card {
  position: relative; margin-top: 14px; padding: 14px 16px 16px;
  background: var(--vi-card); color: var(--vi-card-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 2px 0 rgba(0, 0, 0, 0.25), 0 12px 18px -10px rgba(0, 0, 0, 0.7);
  transform: rotate(-0.5deg);
}
.vi-item:nth-child(even) .vi-card { transform: rotate(0.5deg); }
.vi-card::before { /* punched hole */
  content: ""; position: absolute; top: 12px; right: 14px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--vi-felt); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8);
}
html[dir="rtl"] .vi-card::before { right: auto; left: 14px; }
.vi-index { display: block; color: var(--vi-red); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; font-feature-settings: "kern", "tnum"; }
.vi-name { margin: 6px 0 4px; color: var(--vi-card-ink); font-size: 1.05rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
.vi-desc { margin: 0; color: var(--vi-card-ink-2); font-size: 0.85rem; line-height: 1.45; }
.vi-facts {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px;
  margin: 12px 0 0; padding-top: 12px; border-top: 1px dashed rgba(0, 0, 0, 0.22);
}
.vi-facts dt { color: var(--vi-card-ink-2); font-size: 0.72rem; }
.vi-facts dd { margin: 2px 0 0; color: var(--vi-card-ink); font-size: 0.9rem; font-weight: 600; font-feature-settings: "kern", "tnum"; overflow-wrap: anywhere; }
.sw-record .vi-card .category-tag { color: var(--vi-card-ink); border-color: rgba(0, 0, 0, 0.25); padding: 1px 6px; font-size: 0.78rem; }

.vi-media { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.vi-thumb {
  position: relative; width: 46px; height: 46px; padding: 0; border: 0; overflow: hidden; cursor: zoom-in;
  background: #111; transition: transform 300ms var(--vi-spring);
}
.vi-thumb:hover { transform: translateY(-2px); }
.vi-thumb:focus-visible { outline: 2px solid var(--vi-red); outline-offset: 2px; }
.vi-thumb img, .vi-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vi-thumb .media-play, .vi-print .media-play { transform: translate(-50%, -50%) scale(0.6); }

@media (prefers-reduced-motion: reduce) {
  .vi-glint, .vi-second, .vi-sparkle { animation: none; }
  .vi-sparkle { opacity: 0; }
  .vi-tilt, .vi-shadow, .vi-thumb { transition: none; }
}
