/* Party Wall + Leaderboard + quest-unlock styles.
   Kept in its own file so the core styles.css stays focused on the hunt. */

/* Widen the shell for the TV/iPad party wall and leaderboard detail. */
#app.party-wide {
  width: min(100%, 1200px);
}

.party-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

/* ---------- Shared headers ---------- */
.pw-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
}
.pw-header .btn-ghost {
  min-height: 40px;
  padding: 8px 12px;
  flex-shrink: 0;
}
.pw-header .title-quest {
  font-size: clamp(1.35rem, 5.5vw, 2.1rem);
  margin: 0;
  line-height: 1.05;
}
.pw-header .kicker {
  margin-bottom: 2px;
}
.pw-header > div {
  flex: 1;
  min-width: 0;
}
.pw-sub {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
}
.pw-live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 0 rgba(126, 212, 184, 0.6);
  animation: pw-pulse 1.8s ease-out infinite;
}
@keyframes pw-pulse {
  0% { box-shadow: 0 0 0 0 rgba(126, 212, 184, 0.55); }
  70% { box-shadow: 0 0 0 12px rgba(126, 212, 184, 0); }
  100% { box-shadow: 0 0 0 0 rgba(126, 212, 184, 0); }
}

/* ---------- Party wall masonry ---------- */
.pw-grid {
  column-count: 1;
  column-gap: 12px;
}
@media (min-width: 520px) {
  .pw-grid { column-count: 2; }
}
@media (min-width: 720px) {
  .pw-grid { column-count: 3; column-gap: 14px; }
}
@media (min-width: 1100px) {
  .pw-grid { column-count: 4; }
}

.pw-empty {
  text-align: center;
  padding: 32px 12px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.pw-card {
  break-inside: avoid;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--glow-soft);
  display: flex;
  flex-direction: column;
}
.pw-card--new {
  animation: pw-enter 520ms var(--ease-pop) both;
}
@keyframes pw-enter {
  0% { opacity: 0; transform: translateY(-12px) scale(0.96); }
  100% { opacity: 1; transform: none; }
}

.pw-card__img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--blush);
}
.pw-card__img--placeholder {
  display: grid;
  place-items: center;
  min-height: 180px;
  font-size: 2.4rem;
}

.pw-card__gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  background: var(--blush);
}
.pw-card__shot {
  margin: 0;
  display: grid;
  gap: 2px;
}
.pw-card__shot-label {
  margin: 0;
  padding: 4px 6px 6px;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--muted);
  text-align: center;
}
.pw-modal__media .pw-card__gallery {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 10px;
}
.pw-modal__media .pw-card__img {
  max-height: 28vh;
  object-fit: cover;
}

.pw-card__body {
  padding: 10px 12px 12px;
  display: grid;
  gap: 6px;
}
.pw-card__text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--ink);
}
.pw-card__quest {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--lavender);
}

.pw-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}
.pw-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 0;
  flex: 1 1 120px;
  overflow: hidden;
}
.pw-user > :not(.pw-avatar) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pw-avatar {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--pink), var(--lavender));
  color: white;
  font-size: 0.66rem;
  font-weight: 800;
}
.pw-avatar.sm { width: 20px; height: 20px; font-size: 0.6rem; }

.pw-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}
.pw-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--panel-border);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  transition: transform 140ms var(--ease-pop), border-color 140ms, color 140ms;
}
.pw-chip:active { transform: scale(0.92); }
.pw-chip.is-liked {
  color: white;
  background: linear-gradient(145deg, var(--pink), var(--pink-deep));
  border-color: transparent;
}
.pw-chip span { font-variant-numeric: tabular-nums; }

/* ---------- Modal (comments + submissions viewer) ---------- */
.pw-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(74, 63, 85, 0.45);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 200ms ease;
}
.pw-modal.show { opacity: 1; }
.pw-modal__card {
  position: relative;
  width: min(100%, 460px);
  max-height: 88vh;
  overflow: auto;
  border-radius: var(--radius-lg);
  background: var(--cream);
  border: 1px solid var(--panel-border);
  box-shadow: var(--glow-pink);
  padding: 16px 16px 18px;
}
.pw-modal__card--wide { width: min(100%, 720px); }
.pw-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--panel-border);
  font-size: 1.1rem;
  color: var(--ink);
  z-index: 2;
}
.pw-modal__img {
  width: 100%;
  max-height: 46vh;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}
.pw-modal__body { display: grid; gap: 8px; }

.pw-comments {
  display: grid;
  gap: 10px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
}
.pw-comment {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.pw-comment strong { font-size: 0.8rem; color: var(--ink); }
.pw-comment p { margin: 2px 0 0; font-size: 0.9rem; color: var(--ink); line-height: 1.35; }
.pw-comment-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.pw-comment-form .input-compact { flex: 1; min-width: 0; }
.pw-comment-form .btn { min-height: 40px; padding: 8px 16px; }

@media (max-width: 420px) {
  .pw-comment-form {
    flex-direction: column;
    align-items: stretch;
  }
  .pw-comment-form .btn {
    width: 100%;
  }
}

/* ---------- Leaderboard ---------- */
.lb-block + .lb-block {
  margin-top: 4px;
}

.lb-sample {
  margin: 0;
}

.lb-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lb-empty {
  margin: 0;
  padding: 8px 2px 4px;
}

.lb-section {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--pink-deep);
}

.lb-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  margin: 0;
  color: var(--ink);
  transition: transform 140ms var(--ease-pop), box-shadow 140ms;
}
.lb-row:hover { box-shadow: var(--glow-soft); }
.lb-row:active { transform: scale(0.99); }

.lb-row--ranked {
  grid-template-columns: 32px minmax(0, 1fr) auto;
  grid-template-areas:
    "rank name score"
    "rank time time"
    "stages stages";
  gap: 4px 10px;
  padding: 12px;
}

.lb-rank {
  grid-area: rank;
  align-self: start;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--pink-deep);
  line-height: 1;
  padding-top: 2px;
}
.lb-row--ranked:nth-child(1) .lb-rank::after { content: " 👑"; }

.lb-name {
  grid-area: name;
  font-weight: 700;
  font-size: 0.95rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-time {
  grid-area: time;
  font-family: var(--font-display);
  font-size: 0.98rem;
  color: var(--pink-deep);
  justify-self: start;
}

.lb-stages {
  grid-area: stages;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.lb-score {
  grid-area: score;
  align-self: start;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

@media (min-width: 640px) {
  .lb-row--ranked {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "rank name time score"
      "stages stages stages stages";
    align-items: center;
    gap: 8px 12px;
    padding: 12px 14px;
  }

  .lb-rank {
    font-size: 1.2rem;
    min-width: 28px;
    padding-top: 0;
  }

  .lb-name {
    font-size: 0.98rem;
  }

  .lb-time {
    font-size: 1.05rem;
    justify-self: end;
  }

  .lb-score {
    font-size: 0.82rem;
  }
}

.lb-submissions {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}
.lb-sub {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--panel-border);
}
.lb-sub__img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--blush);
}
.lb-sub__meta {
  min-width: 0;
}
.lb-sub__meta strong {
  font-size: 0.82rem;
  color: var(--ink);
  display: block;
  line-height: 1.3;
}
.lb-sub__meta p { margin: 4px 0; font-size: 0.86rem; color: var(--ink); line-height: 1.35; }

@media (min-width: 480px) {
  .lb-sub {
    grid-template-columns: 96px minmax(0, 1fr);
    padding: 8px;
  }
  .lb-sub__img {
    width: 96px;
    height: 96px;
  }
}

@media (max-width: 380px) {
  .lb-sub {
    grid-template-columns: 1fr;
  }
  .lb-sub__img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }
}

.lb-stage {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(184, 168, 255, 0.18);
  color: var(--lavender);
}
.lb-tag {
  display: inline-block;
  margin: 2px 4px 0 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 143, 171, 0.14);
  color: var(--pink-deep);
  font-size: 0.72rem;
  font-weight: 600;
}

/* ---------- Locked trail nodes (staggered unlocks) ---------- */
.trail-node.locked {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  border-style: dashed;
  border-color: rgba(155, 143, 168, 0.4);
  opacity: 0.78;
  cursor: not-allowed;
}
.trail-node.locked::after {
  content: "🔒";
  font-family: var(--font-body);
  font-size: 0.62rem;
}
.trail-node.locked:active { transform: none; }

.unlock-banner {
  margin: -2px 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(184, 168, 255, 0.16);
  border: 1px dashed rgba(184, 168, 255, 0.5);
  color: var(--lavender);
  font-size: 0.84rem;
  font-weight: 600;
}
.unlock-banner strong { color: var(--pink-deep); }
