/*!
 * UMD Love Data Week -- "Valentines Box" widget styling.
 *
 * Positioning: the Valentines Box button shares its round "pin" look and its
 * exact size/offset tokens (--ldw-pin-size, --ldw-pin-offset, --ldw-pin-gap,
 * and the accent colors) with the site's scroll-to-top button -- both now
 * defined once in css/main.css's "PINNED CORNER BUTTONS" section, not here,
 * so that shared look survives even when this file is swapped for an inert
 * stub on a deployment that has the Valentines Box switched off (see
 * deploy/package.py's --valentines flag). The scroll-to-top button itself is
 * styled by js/main.js now (it lives in <umd-element-scroll-top>'s shadow
 * root, unreachable from here), which dispatches a `ldw:pin-stack-change`
 * event on `document` whenever it shows or hides -- listened for below to
 * toggle .is-pushed-up, which nudges the Valentines button straight up by
 * one button-height plus --ldw-pin-gap so the two never overlap, and settles
 * it back down once the scroll-to-top button hides again.
 */

#ldw-val-root {
  position: fixed;
  right: var(--ldw-pin-offset);
  bottom: var(--ldw-pin-offset);
  z-index: 900;
  font-family: inherit;
  transform: translateY(0);
  transition: transform 0.25s ease;
}
#ldw-val-root.is-pushed-up {
  transform: translateY(calc(-1 * (var(--ldw-pin-size) + var(--ldw-pin-gap))));
}

.ldw-val-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--ldw-pin-gold);
  color: #1a1a1a;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

.ldw-val-fab-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--ldw-pin-gold);
  opacity: 0;
  pointer-events: none;
}
#ldw-val-fab.is-celebrating {
  animation: ldw-val-fab-celebrate 0.6s ease;
}
#ldw-val-fab.is-celebrating .ldw-val-fab-ring {
  animation: ldw-val-ring-burst 0.6s ease-out;
}
.ldw-val-badge.is-popping {
  animation: ldw-val-badge-pop 0.5s ease;
}
@keyframes ldw-val-fab-celebrate {
  0% { transform: scale(1); }
  30% { transform: scale(1.22); }
  55% { transform: scale(0.94); }
  75% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes ldw-val-ring-burst {
  0% { transform: scale(0.65); opacity: 0.6; }
  100% { transform: scale(1.9); opacity: 0; }
}
@keyframes ldw-val-badge-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.5); }
  100% { transform: scale(1); }
}

#ldw-val-panel[hidden] {
  display: none;
}

#ldw-val-panel {
  position: absolute;
  right: 0;
  bottom: calc(var(--ldw-pin-size) + 14px);
  width: min(320px, calc(100vw - 2 * var(--ldw-pin-offset)));
  max-height: min(480px, 70vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  color: #1a1a1a;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.28);
  padding: 16px;
}

.ldw-val-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  flex-shrink: 0; /* stays pinned at the top of the panel -- see #ldw-val-panel */
}
.ldw-val-panel__header h2 {
  font-size: 16px;
  margin: 0;
  color: var(--ldw-pin-accent);
}
#ldw-val-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #555;
  padding: 4px 6px;
  border-radius: 6px;
}
#ldw-val-close:hover,
#ldw-val-close:focus-visible {
  background: #f1f1f1;
  color: #1a1a1a;
}

.ldw-val-panel__subhead {
  font-size: 13px;
  color: #555;
  margin: 0 0 12px;
  flex-shrink: 0; /* stays pinned at the top of the panel -- see #ldw-val-panel */
}

.ldw-val-grid {
  list-style: none;
  margin: 0;
  padding: 10px 0 0;
  border-top: 1px solid #eee; /* separates the scrolling cards from the pinned header above */
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  /* The one part of the panel that actually scrolls */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.ldw-val-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 92px;
  justify-content: center;
}
.ldw-val-card.is-earned {
  background: #fff5f6;
  border-color: #f3c6cc;
  color: var(--ldw-pin-accent-dark);
}
.ldw-val-card.is-earned .ldw-val-card__icon { color: var(--ldw-pin-accent); }
.ldw-val-card.is-locked {
  color: #6b7280;
  border-style: dashed;
}
.ldw-val-card.is-locked .ldw-val-card__icon { color: #c9cdd3; }
.ldw-val-card.is-grand.is-earned {
  background: linear-gradient(135deg, #fff5f6, #fff9e0);
  border-color: var(--ldw-pin-gold);
}
.ldw-val-card.is-locked:focus-visible {
  outline: 3px solid var(--ldw-pin-gold);
  outline-offset: 2px;
}

.ldw-val-card__title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}
.ldw-val-card__tagline {
  font-size: 11px;
  line-height: 1.3;
  color: #6b6b6b;
}
/* A subtle nudge toward how to earn a still-locked valentine */
.ldw-val-card__hint {
  font-size: 11px;
  line-height: 1.3;
  color: #8a8f98;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.ldw-val-card.is-locked:hover .ldw-val-card__hint,
.ldw-val-card.is-locked:focus-within .ldw-val-card__hint {
  opacity: 1;
}

.ldw-val-panel__footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eee;
  text-align: center;
  flex-shrink: 0;
}
.ldw-val-info-link {
  font-size: 12px;
  color: var(--ldw-pin-accent);
  text-decoration: underline;
}

/* Toasts */
#ldw-val-toast-region {
  position: absolute;
  right: 0;
  bottom: calc(var(--ldw-pin-size) + 14px);
  width: max-content;
  max-width: min(280px, calc(100vw - 2 * var(--ldw-pin-offset)));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.ldw-val-toast {
  background: #1a1a1a;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  animation: ldw-val-toast-in 0.25s ease-out;
}
.ldw-val-toast__icon { color: var(--ldw-pin-gold); flex-shrink: 0; }
.ldw-val-toast.is-leaving { animation: ldw-val-toast-out 0.4s ease-in forwards; }

@keyframes ldw-val-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes ldw-val-toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
  #ldw-val-root, #ldw-val-badge, .ldw-val-fab-ring, .ldw-val-toast { animation: none !important; transition: none !important; }
}

@media (max-width: 420px) {
  .ldw-val-grid { grid-template-columns: 1fr 1fr; }
}
