/* Kadabra Room v27 — VHS cassette art refresh
   Goal: make the physical tapes read as VHS cassettes instead of compact audio
   cassettes. The main changes are:
   - top reel-window band with left/right clear windows
   - broad center paper label
   - larger rectangular shell proportions
   - darker shell texture and bottom tape door / flap
   Applied to shelf tapes, held tape, ejected tape, and the brief intake helper.
*/

/* ---------- Shelf tapes: front-facing VHS look ---------- */
.tape-stack .vhs-tape {
  height: 68px !important;
  padding: 6px 8px 6px !important;
  border-radius: 4px !important;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 16%, rgba(0,0,0,.28) 72%, rgba(0,0,0,.62) 100%),
    linear-gradient(90deg, rgba(255,255,255,.035), transparent 8% 92%, rgba(0,0,0,.6)),
    repeating-linear-gradient(0deg, #252525 0 2px, #141414 2px 5px),
    linear-gradient(180deg, #1e1e1e, #0d0d0d) !important;
  box-shadow:
    inset 0 1px rgba(255,255,255,.09),
    inset 0 -2px 4px rgba(0,0,0,.82),
    0 8px 14px rgba(0,0,0,.52) !important;
}

.tape-stack .vhs-tape::before {
  inset: 6px 8px 10px !important;
  border: 1px solid rgba(8,8,8,.94) !important;
  border-radius: 3px !important;
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), transparent 15%, rgba(0,0,0,.14) 70%, rgba(0,0,0,.36) 100%),
    linear-gradient(90deg, rgba(255,255,255,.03), transparent 9% 91%, rgba(0,0,0,.34)),
    linear-gradient(180deg, #303030 0%, #212121 38%, #161616 100%) !important;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.025),
    inset 0 10px 14px rgba(255,255,255,.018),
    inset 0 -10px 14px rgba(0,0,0,.22),
    0 1px 1px rgba(0,0,0,.4) !important;
}

.tape-stack .vhs-tape::after {
  left: 18px !important;
  right: 18px !important;
  bottom: 6px !important;
  height: 11px !important;
  border: 1px solid #2b2b2b !important;
  border-radius: 1px 1px 5px 5px !important;
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%) !important;
  background: linear-gradient(180deg, #151515 0, #070707 100%) !important;
  opacity: 1 !important;
}

.tape-stack .vhs-tape .tape-index,
.tape-stack .vhs-tape .tape-format {
  align-self: start !important;
  margin-top: 2px !important;
  padding-bottom: 0 !important;
  color: rgba(221,214,198,.86) !important;
  text-shadow: 0 1px rgba(0,0,0,.5) !important;
  font: 800 8px/1 var(--mono) !important;
  letter-spacing: .1em !important;
}

.tape-stack .vhs-tape .tape-meta {
  align-self: end !important;
  margin: 30px 0 13px !important;
  padding: 4px 9px 5px !important;
  border: 1px solid rgba(70,48,18,.38) !important;
  border-radius: 2px !important;
  background:
    linear-gradient(180deg, rgba(255,255,255,.48), rgba(255,255,255,.14) 18%, rgba(0,0,0,.05) 100%),
    linear-gradient(90deg, rgba(0,0,0,.08), transparent 12% 88%, rgba(0,0,0,.12)),
    var(--tape-label) !important;
  box-shadow:
    inset 0 1px rgba(255,255,255,.42),
    inset 0 -1px rgba(0,0,0,.08),
    0 1px 0 rgba(255,255,255,.06) !important;
}

.tape-stack .vhs-tape .tape-title {
  color: #17120d !important;
  font: 900 clamp(8.4px, .82vw, 10.6px)/1.03 var(--ui) !important;
  letter-spacing: .055em !important;
  text-shadow: 0 1px rgba(255,255,255,.2) !important;
}

.tape-stack .vhs-tape .tape-code {
  color: rgba(33,22,14,.84) !important;
  font: 800 5.6px/1 var(--mono) !important;
  letter-spacing: .16em !important;
}

.tape-stack .vhs-tape .tape-window {
  top: 8px !important;
  left: 13px !important;
  right: 13px !important;
  bottom: auto !important;
  width: auto !important;
  height: 18px !important;
  transform: none !important;
  border: 1px solid rgba(12,10,9,.94) !important;
  border-radius: 4px !important;
  background: linear-gradient(180deg, #191919 0%, #0b0b0b 100%) !important;
  box-shadow:
    inset 0 1px rgba(255,255,255,.035),
    inset 0 -1px rgba(0,0,0,.42),
    0 1px 2px rgba(0,0,0,.28) !important;
}

.tape-stack .vhs-tape .tape-window::before,
.tape-stack .vhs-tape .tape-window::after {
  content: "";
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 30px;
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(235,235,235,.22), rgba(180,180,180,.08) 34%, rgba(0,0,0,.45) 100%),
    radial-gradient(circle at 35% 28%, rgba(255,255,255,.16), transparent 42%),
    #111;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.28);
  opacity: .92;
}

.tape-stack .vhs-tape .tape-window::before { left: 6px; }
.tape-stack .vhs-tape .tape-window::after {
  right: 6px !important;
  left: auto !important;
  inset: 2px 6px 2px auto !important;
  width: 30px !important;
  height: auto !important;
}

.tape-stack .vhs-tape .tape-reel {
  top: 50% !important;
  width: 12px !important;
  height: 12px !important;
  margin-top: -6px !important;
  border: 4px dotted #d9d3c6 !important;
  border-radius: 50% !important;
  background: radial-gradient(circle at center, #ededed 0 1px, #8a8a8a 1px 2px, #0b0b0b 2px 100%) !important;
  box-shadow: 0 0 0 2px rgba(0,0,0,.3), inset 0 0 0 1px rgba(255,255,255,.08) !important;
}

.tape-stack .vhs-tape .tape-reel-left { left: 17px !important; }
.tape-stack .vhs-tape .tape-reel-right { right: 17px !important; }

.tape-stack .vhs-tape .tape-edge {
  bottom: 10px !important;
  color: rgba(226,219,203,.76) !important;
  font: 800 5.4px/1 var(--mono) !important;
  letter-spacing: .15em !important;
  text-shadow: 0 1px rgba(0,0,0,.48) !important;
}
.tape-stack .vhs-tape .tape-edge-left { left: 13px !important; }
.tape-stack .vhs-tape .tape-edge-right { right: 13px !important; }

.tape-stack .vhs-tape[data-game="golden-keep-sidescroller"] .tape-title,
.tape-stack .vhs-tape[data-game="dark-between-stations"] .tape-title,
.tape-stack .vhs-tape[data-game="prototype-os"] .tape-title,
.tape-stack .vhs-tape[data-game="tools-for-devs"] .tape-title {
  font-size: 8px !important;
  letter-spacing: .04em !important;
}

/* ---------- Generic VHS treatment for held, ejected, and loading-helper tapes ---------- */
.held-tape,
.ejected-tape,
.loaded-cassette-3d {
  overflow: hidden !important;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 13%, rgba(0,0,0,.28) 70%, rgba(0,0,0,.64) 100%),
    linear-gradient(90deg, rgba(255,255,255,.035), transparent 9% 91%, rgba(0,0,0,.6)),
    repeating-linear-gradient(0deg, #242424 0 3px, #141414 3px 7px),
    linear-gradient(180deg, #1f1f1f, #0c0c0c) !important;
  box-shadow:
    inset 0 1px rgba(255,255,255,.08),
    inset 0 -2px 4px rgba(0,0,0,.82),
    0 18px 28px rgba(0,0,0,.66) !important;
}

.held-tape {
  width: 292px !important;
  height: 174px !important;
  border-radius: 9px !important;
}

.held-tape::before {
  inset: 72px 58px 34px !important;
  border: 1px solid rgba(68,46,17,.42) !important;
  border-radius: 3px !important;
  background:
    linear-gradient(180deg, rgba(255,255,255,.48), rgba(255,255,255,.15) 18%, rgba(0,0,0,.05) 100%),
    linear-gradient(90deg, rgba(0,0,0,.08), transparent 12% 88%, rgba(0,0,0,.12)),
    var(--held-accent) !important;
  box-shadow: inset 0 1px rgba(255,255,255,.4), inset 0 -1px rgba(0,0,0,.08) !important;
}

.held-tape::after {
  left: 46px !important;
  right: 46px !important;
  bottom: 14px !important;
  height: 24px !important;
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%) !important;
  border: 1px solid #323232 !important;
  border-radius: 1px 1px 5px 5px !important;
  background: linear-gradient(180deg, #181818 0, #070707 100%) !important;
}

.held-window,
.ejected-window,
.loaded-cassette-3d > b {
  position: absolute !important;
  left: 18px !important;
  right: 18px !important;
  top: 18px !important;
  width: auto !important;
  height: 44px !important;
  border: 1px solid rgba(11,10,9,.96) !important;
  border-radius: 5px !important;
  background: linear-gradient(180deg, #191919 0%, #090909 100%) !important;
  box-shadow:
    inset 0 1px rgba(255,255,255,.045),
    inset 0 -1px rgba(0,0,0,.48),
    0 1px 2px rgba(0,0,0,.28) !important;
  transform: none !important;
  z-index: 1 !important;
}

.held-window::before,
.held-window::after,
.ejected-window::before,
.ejected-window::after,
.loaded-cassette-3d > b::before,
.loaded-cassette-3d > b::after {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 5px;
  width: 54px;
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(235,235,235,.24), rgba(180,180,180,.09) 33%, rgba(0,0,0,.45) 100%),
    radial-gradient(circle at 35% 30%, rgba(255,255,255,.18), transparent 42%),
    #101010;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.28);
  opacity: .93;
}

.held-window::before,
.ejected-window::before,
.loaded-cassette-3d > b::before { left: 8px; }
.held-window::after,
.ejected-window::after,
.loaded-cassette-3d > b::after { right: 8px; }

.held-label,
.ejected-tape-label,
.loaded-cassette-3d > span {
  color: #17120d !important;
  text-shadow: 0 1px rgba(255,255,255,.22) !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.held-label {
  left: 68px !important;
  right: 68px !important;
  top: 91px !important;
  font: 900 12px/1 var(--ui) !important;
  letter-spacing: .055em !important;
}

.held-reel {
  top: 25px !important;
  width: 29px !important;
  height: 29px !important;
  border: 7px dotted #d7d1c4 !important;
  border-radius: 50% !important;
  background: radial-gradient(circle at center, #ededed 0 2px, #8a8a8a 2px 4px, #0a0a0a 4px 100%) !important;
  box-shadow: 0 0 0 5px rgba(0,0,0,.28), inset 0 0 0 2px rgba(255,255,255,.06) !important;
}

.reel-left { left: 36px !important; }
.reel-right { right: 36px !important; }

.held-state {
  bottom: 12px !important;
}

.ejected-tape {
  height: 66px !important;
  border-radius: 5px !important;
}

.ejected-tape::before {
  inset: 29px 18px 13px !important;
  border: 1px solid rgba(68,46,17,.42) !important;
  background:
    linear-gradient(180deg, rgba(255,255,255,.48), rgba(255,255,255,.16) 18%, rgba(0,0,0,.05) 100%),
    linear-gradient(90deg, rgba(0,0,0,.08), transparent 12% 88%, rgba(0,0,0,.12)),
    var(--ejected-accent) !important;
  box-shadow: inset 0 1px rgba(255,255,255,.4), inset 0 -1px rgba(0,0,0,.08) !important;
}

.ejected-tape::after {
  left: 18px !important;
  right: 18px !important;
  bottom: 6px !important;
  height: 10px !important;
  border: 1px solid #2e2e2e !important;
  border-radius: 1px 1px 5px 5px !important;
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%) !important;
  background: linear-gradient(180deg, #171717 0, #070707 100%) !important;
  opacity: 1 !important;
}

.ejected-window,
.loaded-cassette-3d > b {
  left: 14px !important;
  right: 14px !important;
  top: 8px !important;
  height: 18px !important;
  border-radius: 4px !important;
}

.ejected-window::before,
.ejected-window::after,
.loaded-cassette-3d > b::before,
.loaded-cassette-3d > b::after {
  top: 2px;
  bottom: 2px;
  width: 30px;
  border-radius: 6px;
}

.ejected-reel,
.loaded-cassette-3d > i {
  top: 12px !important;
  width: 11px !important;
  height: 11px !important;
  border: 3px dotted #d7d1c4 !important;
  border-radius: 50% !important;
  background: radial-gradient(circle at center, #ededed 0 1px, #8a8a8a 1px 2px, #0a0a0a 2px 100%) !important;
  box-shadow: 0 0 0 2px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.06) !important;
}

.ejected-reel-left,
.loaded-cassette-3d > i:first-of-type { left: 22px !important; }
.ejected-reel-right,
.loaded-cassette-3d > i:last-of-type { right: 22px !important; }

.ejected-tape-label,
.loaded-cassette-3d > span {
  left: 20px !important;
  right: 20px !important;
  top: 35px !important;
  font: 900 7px/1 var(--ui) !important;
  letter-spacing: .055em !important;
}

.loaded-cassette-3d::before {
  inset: 29px 18px 13px !important;
  border: 1px solid rgba(68,46,17,.42) !important;
  background:
    linear-gradient(180deg, rgba(255,255,255,.48), rgba(255,255,255,.16) 18%, rgba(0,0,0,.05) 100%),
    linear-gradient(90deg, rgba(0,0,0,.08), transparent 12% 88%, rgba(0,0,0,.12)),
    var(--loaded-accent) !important;
  box-shadow: inset 0 1px rgba(255,255,255,.4), inset 0 -1px rgba(0,0,0,.08) !important;
}

.loaded-cassette-3d::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 6px;
  height: 10px;
  border: 1px solid #2e2e2e;
  border-radius: 1px 1px 5px 5px;
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%);
  background: linear-gradient(180deg, #171717 0, #070707 100%);
}

/* Improve the visual language of the shelf note while keeping the same behavior. */
.library-instruction {
  text-wrap: pretty;
}

@media (max-width: 870px) {
  .held-tape {
    width: 268px !important;
    height: 160px !important;
  }
  .held-window {
    left: 16px !important;
    right: 16px !important;
    top: 16px !important;
    height: 39px !important;
  }
  .held-window::before,
  .held-window::after {
    width: 47px;
  }
  .held-reel {
    top: 22px !important;
    width: 24px !important;
    height: 24px !important;
    border-width: 6px !important;
  }
  .reel-left { left: 33px !important; }
  .reel-right { right: 33px !important; }
  .held-label {
    top: 84px !important;
    left: 58px !important;
    right: 58px !important;
    font-size: 11px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ejected-tape:hover,
  .ejected-tape:focus-visible,
  .held-tape.is-following-pointer,
  .held-tape.is-following-pointer.is-over-drop-target,
  .held-tape.is-parked {
    transition: none !important;
  }
}
