/* Fig. 03 · The fun part: participant card with its demo loop, class leaderboard, feature strip.
   Translated from claude/canvas/Main.dc.html (section#fun). */

.fun {
  --fun-water-full: 68px;
  /* Water height at rest: $155 of the $180 that fills the meter */
  --fun-water-rest: calc(var(--fun-water-full) * 155 / 180);
  background-color: var(--sand);
  border-top: 2px dashed color-mix(in srgb, var(--ink) 18%, transparent);
}

.fun p {
  margin: 0;
}

.fun-inner {
  padding-block: var(--section-pad);
  display: flex;
  flex-direction: column;
  gap: 56px;
}

/* Intro */
.fun-intro {
  max-width: 780px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.fun-label {
  color: var(--muted);
}

.fun-lede {
  font-size: 19px;
  line-height: 1.55;
  color: var(--muted);
  text-wrap: pretty;
}

/* The two cards */
.fun-cards {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 48px;
}

.fun-card-wrap {
  flex: 1 1 360px;
  min-width: 0;
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fun-card {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-card);
  box-shadow: 10px 10px 0 var(--ink);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.fun-card-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fun-card-label {
  color: var(--muted);
  font-size: 12px;
}

.fun-card-name {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.fun-card-event {
  font-size: 15px;
  color: var(--muted);
}

/* Tide meter */
.fun-meter {
  position: relative;
  height: 132px;
  border: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--ice);
}

.fun-meter-goal {
  position: absolute;
  left: 0;
  right: 0;
  top: 34px;
  border-top: 2px dashed color-mix(in srgb, var(--ink) 40%, transparent);
}

.fun-meter-prize {
  position: absolute;
  top: 7px;
  left: 14px;
  right: 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fun-meter-togo {
  color: var(--coral-text);
}

.fun-water {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--fun-water-full);
  background: var(--tide);
  /* Same 1.2s ease-out as the count-up in participant-demo.js */
  transition: height 1.2s cubic-bezier(0.33, 1, 0.68, 1);
}

.fun-water-top {
  position: absolute;
  left: 0;
  top: -14px;
  width: 100%;
  height: 30px;
}

/* Positioned from the water's top, so it rises with the water */
.fun-boat {
  position: absolute;
  right: 16%;
  top: -26px;
  width: 56px;
  animation-duration: 4.2s;
}

.fun-boat svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.fun-raised {
  position: absolute;
  left: 16px;
  bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--white);
}

.fun-raised-amount {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.fun-raised-word {
  font-size: 16px;
  font-weight: 600;
}

/* Gift pop-up */
.fun-popup {
  position: relative;
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px 8px 8px;
  background: var(--sunflower-light);
  border: var(--border);
  border-radius: 999px;
  /* Spring in: scale overshoots past 1 and settles */
  transition:
    opacity 0.2s ease,
    transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    visibility 0s;
}

.fun-pinwheel {
  flex: none;
  width: 32px;
  height: 32px;
}

.fun-popup-text {
  font-size: 16px;
}

.fun-confetti {
  position: absolute;
  right: -44px;
  top: -18px;
  width: 54px;
  height: 36px;
}

/* Demo states, set on the card by participant-demo.js. No attribute = the final state. */
[data-demo-state="leaving"] .fun-popup,
[data-demo-state="rest"] .fun-popup {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.85);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0s linear 0.2s;
}

[data-demo-state="rest"] .fun-popup {
  transform: scale(0.6);
  transition: none;
}

[data-demo-state="rest"] .fun-water,
[data-demo-state="pop"] .fun-water {
  height: var(--fun-water-rest);
  transition: none;
}

/* Poll */
.fun-poll {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fun-poll-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fun-poll-question {
  font-size: 18px;
  font-weight: 800;
}

.fun-poll-note {
  font-size: 15px;
  color: var(--muted);
}

.fun-poll-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fun-poll-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
  font-weight: 700;
}

.fun-poll-pct {
  font-family: var(--font-mono);
}

.fun-poll-track {
  height: 10px;
  border-radius: 5px;
  background: var(--bar-track);
}

.fun-poll-fill {
  width: var(--fun-bar);
  height: 100%;
  border-radius: 5px;
  background: var(--bar-blue);
}

.fun-poll-fill--lead {
  background: var(--sunflower);
}

.fun-give {
  width: 100%;
}

/* Class leaderboard */
.fun-board {
  flex: 1.4 1 440px;
  min-width: 0;
  background: var(--ink);
  color: var(--white);
  border: var(--border);
  border-radius: var(--radius-card);
  box-shadow: 10px 10px 0 color-mix(in srgb, var(--ink) 22%, transparent);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: rotate(0.8deg);
}

.fun-board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
}

.fun-board-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.fun-board-label {
  font-size: 12px;
  color: var(--pale);
}

.fun-board-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fun-board-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 76px;
  align-items: center;
  gap: 14px;
}

.fun-board-rank {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--pale);
}

.fun-board-row--first .fun-board-rank {
  color: var(--sunflower-light);
}

.fun-board-room {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.fun-board-name {
  font-size: 17px;
  font-weight: 700;
}

.fun-board-track {
  height: 12px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--white) 12%, transparent);
}

.fun-board-fill {
  width: var(--fun-bar);
  height: 100%;
  border-radius: 6px;
  background: var(--bar-blue);
}

.fun-board-row--first .fun-board-fill {
  background: var(--sunflower);
}

.fun-board-amount {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 17px;
}

.fun-board-note {
  padding-top: 14px;
  border-top: 1.5px dashed color-mix(in srgb, var(--white) 30%, transparent);
  font-size: 26px;
  color: var(--sunflower-light);
}

/* Feature strip */
.fun-features {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 20px 28px;
  font-size: 17px;
  line-height: 1.45;
  color: var(--muted);
}

/* Between phone and desktop, two by two reads better than three plus one */
@media (min-width: 600px) and (max-width: 1100px) {
  .fun-features {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.fun-features li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.fun-features strong {
  color: var(--ink);
}

.fun-bullet {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 4px;
}
