/* ============================================================
   Matchbox: wooden tray underneath, printed cardboard sleeve
   that slides right on hover / focus / checked.
   ============================================================ */

.plate {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  animation: plate-in 0.5s var(--spring) both;
}

@keyframes plate-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.plate__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px dashed var(--rule-strong);
  padding-bottom: 0.35rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.plate__no { color: var(--char); font-weight: 700; }

/* ---------- box ---------- */
.box {
  position: relative;
  padding: 0.9rem 0.9rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--rule);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 10px 22px -16px rgba(35, 32, 30, 0.55);
}

.box__toggle {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

.box__stage {
  display: block;
  position: relative;
  aspect-ratio: 16 / 11;
  perspective: 900px;
  perspective-origin: 30% 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- tray ---------- */
.tray {
  position: absolute;
  inset: 6% 4% 10% 4%;
  border-radius: 3px;
  background:
    linear-gradient(180deg, var(--wood-dark), var(--wood) 14%, var(--wood) 86%, var(--wood-dark));
  box-shadow:
    inset 0 0 0 1px rgba(35, 32, 30, 0.35),
    inset 0 6px 10px -6px rgba(35, 32, 30, 0.45);
  overflow: hidden;
}

/* wooden grain lines */
.tray::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    rgba(107, 74, 47, 0.16) 0 1px,
    transparent 1px 7px
  );
  mix-blend-mode: multiply;
  pointer-events: none;
}

.tray__floor {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 6%;
  padding: 0.4rem 0.5rem;
  background: var(--paper-deep);
  border: 1px solid rgba(35, 32, 30, 0.3);
  box-shadow: inset 0 1px 3px rgba(35, 32, 30, 0.25);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s var(--spring) 0.08s, transform 0.45s var(--spring) 0.08s;
}

.tray__proverb {
  font-family: var(--mono);
  font-size: clamp(0.5rem, 1.5vw, 0.62rem);
  line-height: 1.35;
  color: var(--char);
}

.tray__addr {
  margin-top: 0.2rem;
  font-family: var(--mono);
  font-size: clamp(0.42rem, 1.2vw, 0.52rem);
  letter-spacing: 0.04em;
  color: var(--pink);
  text-transform: uppercase;
}

/* matches */
.tray__matches {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 9%;
  bottom: 34%;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 0.18rem 0.22rem;
  align-items: end;
}

.m {
  display: block;
  position: relative;
  height: 78%;
  border-radius: 1px;
  background: linear-gradient(90deg, #E9D9B8, #F3E7CC 45%, #D9C49C);
  box-shadow: 0 1px 0 rgba(35, 32, 30, 0.2);
}

.m::before {
  content: "";
  position: absolute;
  top: -26%;
  left: -6%;
  width: 112%;
  height: 34%;
  border-radius: 3px 3px 2px 2px;
  background: var(--head);
  box-shadow: inset 0 -1px 0 rgba(35, 32, 30, 0.35);
}

.m--r { --head: #D63A2F; }
.m--b { --head: #2A4FA8; }
.m--y { --head: #E8A81C; }

/* striker strip */
.tray__striker {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: 13%;
  background:
    repeating-linear-gradient(115deg, rgba(35, 32, 30, 0.22) 0 2px, transparent 2px 5px),
    linear-gradient(180deg, #7A5535, var(--striker));
  border-top: 1px solid rgba(35, 32, 30, 0.5);
}

/* ---------- sleeve ---------- */
.sleeve {
  position: absolute;
  inset: 0 0 6% 0;
  border-radius: 3px;
  overflow: hidden;
  transform-origin: left center;
  transform: translate3d(0, 0, 0) rotateY(0deg);
  transition: transform 0.72s var(--spring), box-shadow 0.72s var(--spring);
  box-shadow:
    0 2px 0 rgba(35, 32, 30, 0.28),
    0 14px 24px -14px rgba(35, 32, 30, 0.6);
  will-change: transform;
}

/* cardboard bevel + grain */
.sleeve::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background-image: var(--grain);
  background-blend-mode: multiply;
  opacity: 0.5;
  mix-blend-mode: multiply;
}

.sleeve::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border: 1px solid rgba(35, 32, 30, 0.4);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 0 rgba(35, 32, 30, 0.18),
    inset 2px 0 0 rgba(255, 255, 255, 0.25);
  border-radius: 3px;
}

.sleeve__art {
  position: absolute;
  inset: 0;
  background-color: var(--paper);
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.sleeve__label {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.3rem 0.45rem 0.35rem;
  background: rgba(247, 242, 231, 0.86);
  border-top: 1px solid rgba(35, 32, 30, 0.35);
  backdrop-filter: blur(1px);
}

.sleeve__brand {
  font-size: clamp(0.5rem, 1.6vw, 0.68rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--char);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sleeve__place {
  font-family: var(--mono);
  font-size: clamp(0.4rem, 1.2vw, 0.52rem);
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* the exposed wooden edge once the sleeve has slid */
.sleeve__edge {
  position: absolute;
  top: 0; bottom: 0;
  left: 0;
  width: 3px;
  z-index: 5;
  background: linear-gradient(180deg, var(--wood-dark), var(--wood));
}

/* ---------- open state ---------- */
.box__stage:hover .sleeve,
.box__stage:focus-visible .sleeve,
.box__toggle:checked ~ .box__stage .sleeve,
.box__toggle:focus-visible ~ .box__stage .sleeve {
  transform: translate3d(34%, -2%, 0) rotateY(-26deg);
  box-shadow:
    0 2px 0 rgba(35, 32, 30, 0.28),
    0 26px 34px -18px rgba(35, 32, 30, 0.65);
}

.box__stage:hover .tray__floor,
.box__stage:focus-visible .tray__floor,
.box__toggle:checked ~ .box__stage .tray__floor {
  opacity: 1;
  transform: none;
}

.box__stage:hover .tray,
.box__stage:focus-visible .tray,
.box__toggle:checked ~ .box__stage .tray {
  box-shadow:
    inset 0 0 0 1px rgba(35, 32, 30, 0.35),
    inset 0 6px 10px -6px rgba(35, 32, 30, 0.45),
    0 0 0 3px rgba(255, 79, 139, 0.16);
}

.box__stage:focus-visible {
  outline: 2.5px solid var(--blue);
  outline-offset: 4px;
}

/* keep the label readable while the sleeve is tilted */
.box__stage:hover .sleeve__label,
.box__toggle:checked ~ .box__stage .sleeve__label {
  background: rgba(247, 242, 231, 0.95);
}

@media (prefers-reduced-motion: reduce) {
  .plate { animation: none; }
  .sleeve, .tray__floor { transition-duration: 0.01ms; }
}
