/* Community Bulletin Frame */
.board-frame {
  flex: 1;
  min-height: 0;
  margin: 8px 0;
  /* Warm wooden noticeboard frame: faint grain + a bevel catching the light */
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.04) 0px,
      rgba(0, 0, 0, 0.05) 3px,
      rgba(255, 255, 255, 0.03) 7px
    ),
    linear-gradient(180deg, #a5713f 0%, #8a5a2e 100%);
  border-radius: 8px;
  padding: 14px;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.25),
    inset 0 -3px 0 rgba(0, 0, 0, 0.25),
    0 3px 6px rgba(var(--wall-shadow), 0.3),
    0 18px 36px rgba(var(--wall-shadow), 0.4);
  display: flex;
}

.board-canvas {
  flex: 1;
  background: #c9a27a url('cork.jpg') repeat;
  background-size: 340px auto;
  border-radius: 3px;
  /* Recessed into the frame: shadow along the top and a soft darker rim */
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.35),
    inset 0 0 40px rgba(90, 55, 25, 0.25);
  position: relative;
  overflow: hidden;
}

/* Add pointer-events: none so this never intercepts clicks */
.active-watermark {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  color: rgba(60, 35, 15, 0.18);
  font-size: 1.5rem;
  letter-spacing: 8px;
  pointer-events: none; /* <-- ENSURE THIS IS PRESENT */
}

/* Ensure the card is ready for clicks */
.spirit-slot {
  position: absolute;
  width: 44%;
  height: 44%;
  background: #fff;
  border: 3px solid #111;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    3px 8px 16px rgba(50, 30, 10, 0.4);
  cursor: pointer;
  transform: rotate(var(--card-tilt, 0deg));
  transition: transform 0.15s ease, outline 0.1s ease, z-index 0.1s ease;
  display: flex;
  flex-direction: column;
  pointer-events: auto; /* <-- FORCE CLICKS TO BE ALLOWED */
  z-index: 2;
}

/* Make inner elements pass clicks directly to the parent .spirit-slot */
.spirit-card-body,
.spirit-visual,
.spirit-visual img,
.spirit-tier-header,
.spirit-nameplate,
.spirit-title,
.pushpin {
  pointer-events: none; /* <-- Clicks will pass through to .spirit-slot */
}

.bulletin-board-area {
  position: relative;
  width: 100%;
  height: 100%;
}


/* Physical pushpin */
.pushpin {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 15px;
  height: 15px;
  background: radial-gradient(circle at 35% 30%, #ff8a8a 0%, #e02424 35%, #8f0000 100%);
  border-radius: 50%;
  border: 1px solid #550000;
  box-shadow: 2px 4px 4px rgba(0, 0, 0, 0.45);
  z-index: 10;
}

/* Smash selection focus */
.spirit-slot.available:hover {
  transform: rotate(0deg) scale(1.04) !important;
  outline: 4px solid var(--smash-gold);
  outline-offset: 2px;
  z-index: 30;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65);
}

.spirit-card-body {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.spirit-tier-header {
  background: #f7f7f7;
  border-bottom: 2px solid #111;
  padding: 4px;
  text-align: center;
}

.spirit-tier-header span {
  font-size: clamp(0.65rem, 1vw, 0.85rem);
  color: #111;
  letter-spacing: 1px;
}

.spirit-visual {
  flex: 1;
  min-height: 0;
  position: relative;
  background: radial-gradient(circle at center, #ffffff 0%, #dedede 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.spirit-visual img {
  height: 90%;
  width: auto;
  max-width: 85%;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.35));
}

.spirit-price-chip {
  position: absolute;
  bottom: 4px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  border: 1px solid #444;
  font-family: monospace;
  font-size: clamp(0.65rem, 0.85vw, 0.8rem);
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 2px;
}

.spirit-nameplate {
  background: #111;
  border-top: 2px solid #111;
  padding: 5px 6px;
  text-align: center;
}

.spirit-title {
  color: #fff;
  font-size: clamp(0.75rem, 1.1vw, 0.95rem);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sold State */
.spirit-slot.sold {
  background: #050505 !important;
  border-color: #000 !important;
  cursor: pointer; /* still opens, to show when it sold */
}

.spirit-slot.sold .spirit-card-body {
  opacity: 0.1;
  filter: grayscale(100%);
}

.sold-stamp-overlay {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.spirit-slot.sold .sold-stamp-overlay {
  display: flex;
}

.sold-banner {
  background: var(--sold-red);
  color: #fff;
  font-size: clamp(2rem, 3.5vw, 3rem);
  font-style: italic;
  padding: 6px 0;
  width: 140%;
  text-align: center;
  transform: rotate(-22deg);
  border-top: 4px solid #fff;
  border-bottom: 4px solid #fff;
  box-shadow: 0 0 20px rgba(209, 18, 18, 0.9);
  text-shadow: 3px 3px 0 #000;
}

/* =========================================================================
   ENTRANCE: cards fly in on page load and stick to the cork
   ~1.2s total. Thrown from near the viewer (big, blurred shadow), smack
   flat with a squash, then the pin pops in and a shine sweeps across.
   ========================================================================= */
.spirit-slot.fly-in {
  animation: cardFlyIn 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) var(--fly-delay) both;
}

.spirit-slot.fly-in .pushpin {
  animation: pinPop 0.28s cubic-bezier(0.3, 1.6, 0.5, 1) calc(var(--fly-delay) + 0.45s) both;
}

.spirit-slot.fly-in .spirit-visual::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.75) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: cardShine 0.6s ease-out calc(var(--fly-delay) + 0.55s) both;
  pointer-events: none;
}

@keyframes cardFlyIn {
  0% {
    opacity: 0;
    transform: translate(var(--fly-x), var(--fly-y)) rotate(var(--fly-rot)) scale(1.5);
    box-shadow: 30px 50px 60px rgba(0, 0, 0, 0.35);
  }
  15% { opacity: 1; }
  70% {
    /* impact: squashes flat against the cork */
    transform: rotate(var(--card-tilt, 0deg)) scale(0.95);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 1px 3px 6px rgba(0, 0, 0, 0.35);
  }
  85% { transform: rotate(var(--card-tilt, 0deg)) scale(1.02); }
  100% { opacity: 1; transform: rotate(var(--card-tilt, 0deg)) scale(1); }
}

@keyframes pinPop {
  0% { opacity: 0; transform: translate(-50%, -14px) scale(1.8); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

@keyframes cardShine {
  to { transform: translateX(120%); }
}

@media (prefers-reduced-motion: reduce) {
  .spirit-slot.fly-in,
  .spirit-slot.fly-in .pushpin,
  .spirit-slot.fly-in .spirit-visual::after {
    animation: none;
  }
  .spirit-slot.fly-in .spirit-visual::after { display: none; }
}

/* "Sold 4 hours ago" hint, shown while hovering a sold card */
.sold-ago-tip {
  position: absolute;
  bottom: 14%;
  left: 50%;
  transform: translate(-50%, 6px);
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.spirit-slot.sold:hover .sold-ago-tip {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Sold animation: only on a card that has just sold, not on every refresh.
   The card fades to black, the stamp slams down and the card jolts. */
.spirit-slot.just-sold {
  animation: soldJolt 0.35s ease-out 0.45s;
}

.spirit-slot.just-sold .spirit-card-body {
  animation: soldFade 0.5s ease-in;
}

.spirit-slot.just-sold .sold-banner {
  animation: slamStamp 0.3s cubic-bezier(0.1, 0.9, 0.2, 1) 0.4s backwards;
}

@keyframes slamStamp {
  0% { transform: rotate(-22deg) scale(2.6); opacity: 0; }
  100% { transform: rotate(-22deg) scale(1); opacity: 1; }
}

@keyframes soldFade {
  from { opacity: 1; filter: grayscale(0%); }
  to { opacity: 0.1; filter: grayscale(100%); }
}

@keyframes soldJolt {
  0%, 100% { transform: rotate(var(--card-tilt, 0deg)) translate(0, 0); }
  25% { transform: rotate(var(--card-tilt, 0deg)) translate(-4px, 3px); }
  50% { transform: rotate(var(--card-tilt, 0deg)) translate(3px, -2px); }
  75% { transform: rotate(var(--card-tilt, 0deg)) translate(-2px, 1px); }
}

@media (prefers-reduced-motion: reduce) {
  .spirit-slot.just-sold,
  .spirit-slot.just-sold .spirit-card-body,
  .spirit-slot.just-sold .sold-banner {
    animation: none;
  }
}

@media (max-width: 768px) {
  html, body {
    height: auto;
    overflow-y: auto;
  }
  .spa-layout {
    height: auto;
    min-height: 100vh;
    padding: 10px 0;
  }
  .board-frame {
    height: 750px;
  }
  .spirit-slot {
    width: 46%;
    height: 46%;
  }
}
/* A buyer has this card open in checkout (others can still join the queue) */
.spirit-slot.reserved .spirit-card-body {
  opacity: 0.55;
  filter: grayscale(60%);
}

/* Before a wave opens: one paper note pinned in the middle of the cork */
.board-closed-note {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-2deg);
  width: min(360px, 80%);
  padding: 30px 24px 24px;
  background: #fffdf6;
  border-radius: 3px;
  box-shadow: 3px 8px 18px rgba(0, 0, 0, 0.35);
  text-align: center;
  font-family: var(--font-body);
  color: var(--wall-ink);
}

.board-closed-note .closed-kicker {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--sold-red);
}

.board-closed-note h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 5vw, 2rem);
  line-height: 1.15;
}

.board-closed-note p:last-child {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.75;
}
