/* The exhibition wall: nine risograph matchboxes with sliding sleeves */

.plates {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.75rem, 3.5vw, 3rem) clamp(1.25rem, 2.5vw, 2.25rem);
  padding: 2.25rem 0 1rem;
  list-style: none;
  margin: 0;
}

.plate {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-width: 0;
}

/* Pure CSS filtering: each radio hides every plate that is not its own */
#f-tokyo:checked ~ .plates .plate:not([data-cat="tokyo"]),
#f-prague:checked ~ .plates .plate:not([data-cat="prague"]),
#f-maritime:checked ~ .plates .plate:not([data-cat="maritime"]) {
  display: none;
}

/* Caption: catalog number, name, place and date */
.plate .cap {
  display: grid;
  gap: 0.2rem;
  padding-top: 0.7rem;
  border-top: 1.5px solid var(--charcoal);
}
.plate .cat { color: var(--muted); }
.plate .name {
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  font-size: 1.02rem;
  line-height: 1.1;
}
.plate .meta {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

/* ---- The matchbox itself ---------------------------------------------- */

.box {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
  width: 100%;
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: relative;
  aspect-ratio: 1 / 0.72;
  perspective: 900px;
  perspective-origin: 30% 50%;
}

/* Inner wooden tray, sits behind the sleeve */
.tray {
  position: absolute;
  inset: 6% 3% 6% 3%;
  border-radius: 4px;
  background:
    linear-gradient(180deg, #C9A16B 0%, #B4884F 42%, #9C7038 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 240, 214, 0.55),
    inset 0 -3px 0 rgba(60, 36, 12, 0.35),
    0 14px 22px -12px rgba(35, 32, 30, 0.55);
  overflow: hidden;
  transform: translateZ(-1px);
  transition: transform 0.85s var(--sleeve);
}

/* Striker strip along the top edge of the tray */
.tray::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 13%;
  background:
    repeating-linear-gradient(90deg, rgba(35,32,30,0.22) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #7A4A22, #4E2C11);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.4);
}

/* Matchsticks: rows of red, blue and yellow heads */
.sticks {
  position: absolute;
  inset: 16% 9% 30% 9%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6% 4%;
  align-items: end;
}
.stick {
  position: relative;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #E8CFA6, #F6E4C2 45%, #D9BC8C);
  box-shadow: 1px 0 0 rgba(90, 60, 25, 0.35);
}
.stick::before {
  content: "";
  position: absolute;
  left: -6%;
  right: -6%;
  top: -9%;
  height: 24%;
  border-radius: 50% 50% 45% 45%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.6), transparent 55%), var(--head, var(--riso-pink));
  box-shadow: 0 1px 0 rgba(0,0,0,0.25);
}
.stick:nth-child(3n+2) { --head: var(--soy-blue); }
.stick:nth-child(3n+3) { --head: var(--marigold); }

/* Hidden interior print on the tray floor */
.tray-print {
  position: absolute;
  inset: auto 10% 8% 10%;
  font-family: var(--mono);
  font-size: clamp(0.5rem, 1.05vw, 0.62rem);
  line-height: 1.35;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #3B2410;
  opacity: 0;
  transition: opacity 0.5s var(--spring) 0.12s;
}

/* The printed cardboard sleeve */
.sleeve {
  position: absolute;
  inset: 0;
  border-radius: 5px;
  background: var(--newsprint);
  transform-origin: left center;
  transform: translate3d(0, 0, 0) rotateY(0deg);
  transition: transform 0.85s var(--sleeve), box-shadow 0.85s var(--sleeve);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.7) inset,
    0 0 0 1px rgba(35,32,30,0.55),
    0 16px 26px -14px rgba(35, 32, 30, 0.6);
  overflow: hidden;
  will-change: transform;
}

/* Cardboard bevel: light top edge, darker bottom edge */
.sleeve::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.55), transparent 18%, transparent 82%, rgba(35,32,30,0.16)),
    linear-gradient(90deg, rgba(255,255,255,0.35), transparent 8%, transparent 92%, rgba(35,32,30,0.12));
}

.sleeve svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Ink layers overprint each other */
.sleeve svg .ink { mix-blend-mode: multiply; }
/* Deliberate 1.5px riso misregistration */
.sleeve svg .off-b { transform: translate(1.5px, 1.5px); }
.sleeve svg .off-p { transform: translate(-1.5px, 1px); }
.sleeve svg .off-y { transform: translate(1px, -1.5px); }

/* Open state: hover, keyboard focus, or a tapped checkbox */
.box:hover .sleeve,
.open:focus-visible ~ .box .sleeve,
.open:checked ~ .box .sleeve {
  transform: translate3d(26%, 0, 0) rotateY(-16deg);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.7) inset,
    0 0 0 1px rgba(35,32,30,0.55),
    0 26px 34px -18px rgba(35, 32, 30, 0.7);
}
.box:hover .tray-print,
.open:focus-visible ~ .box .tray-print,
.open:checked ~ .box .tray-print { opacity: 0.9; }
.box:hover .tray,
.open:focus-visible ~ .box .tray,
.open:checked ~ .box .tray { transform: translate3d(3%, 0, -1px); }

.open:focus-visible ~ .box { outline: 3px solid var(--soy-blue); outline-offset: 4px; }

/* The checkbox that keeps a box open; it sits right before its box */
.open {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  pointer-events: none;
}

@media (max-width: 900px) {
  .plates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .plates { grid-template-columns: 1fr; }
  .stage { aspect-ratio: 1 / 0.66; }
}
