/* ==========================================================
   PIXATHON — winners
   A pixel podium for the top three (2nd, 1st, 3rd left to right),
   then the top 10 as a leaderboard with Blox sitting on it.
   ========================================================== */
.win {
  --silver: #C3CADF;
  --silver-deep: #6E7697;
  --bronze: #CC8A55;
  --bronze-deep: #94592C;
}

.win-head { text-align: center; }
.win-head .lede { margin: 0 auto; text-wrap: pretty; }

/* ---------- podium ---------- */
.podium {
  --unit: clamp(64px, 10.5vw, 112px); /* the 3rd place block's height */
  max-width: 880px;
  margin: 0 auto clamp(64px, 11vh, 120px);
}
.podium-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas: "second first third";
  align-items: end;
  margin: 0;
  padding: 0;
  list-style: none;
}
/* the stage the blocks stand on */
.podium-row::after {
  content: "";
  grid-column: 1 / -1;
  height: 12px;
  margin: 0 calc(var(--unit) * -.3);
  background: var(--navy);
  box-shadow: 0 6px 0 var(--navy-deep);
}

.pod-1 { grid-area: first;  --medal: var(--gold);   --medal-deep: var(--gold-deep);   --h: 2.15; }
.pod-2 { grid-area: second; --medal: var(--silver); --medal-deep: var(--silver-deep); --h: 1.55; }
.pod-3 { grid-area: third;  --medal: var(--bronze); --medal-deep: var(--bronze-deep); --h: 1; }

.pod { display: flex; flex-direction: column; min-width: 0; text-align: center; }

.pod-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 clamp(6px, 1.4vw, 16px) clamp(14px, 2.4vh, 22px);
}
.pod-trophy {
  display: block;
  width: clamp(34px, 4.2vw, 48px);
  margin-bottom: 10px;
}
.pod-1 .pod-trophy { width: clamp(46px, 6vw, 70px); }
.pod-trophy [data-icon] { aspect-ratio: 1; }
/* silver and bronze: recolour the trophy's gold face (CSS beats the svg's fill attribute) */
.pod-2 .pod-trophy svg path:nth-child(2),
.pod-3 .pod-trophy svg path:nth-child(2) { fill: var(--medal); }
button.pod-trophy {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button.pod-trophy:focus-visible { outline-offset: 6px; }

.pod-place {
  margin: 0 0 6px;
  font-family: var(--f-pixel);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--medal-deep);
}
.pod-team {
  margin: 0;
  font-family: var(--f-pixel);
  font-weight: 700;
  font-size: clamp(15px, 2vw, 22px);
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-wrap: balance;
  color: var(--navy);
}
.pod-1 .pod-team {
  font-size: clamp(17px, 2.6vw, 30px);
  text-shadow: .07em .07em 0 var(--gold);
}

/* a few gold pixels twinkle around the winners */
.pod-card .spark {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 8px;
  height: 8px;
  background: var(--gold);
  box-shadow: 2px 2px 0 var(--navy-deep);
  opacity: 0;
  animation: pool-twinkle 2.4s steps(4) var(--d) infinite;
}

.pod-block {
  display: flex;
  justify-content: center;
  height: calc(var(--unit) * var(--h));
  padding-top: calc(var(--unit) * .2);
  background: var(--medal);
  border: 2px solid var(--navy);
  border-bottom: 0;
  /* a pixel bevel: lit top edge, shaded right side */
  box-shadow: inset 0 6px 0 rgb(255 255 255 / .32), inset -8px 0 0 rgb(11 19 54 / .12);
  transform-origin: 50% 100%;
}
/* the blocks touch; 1st place keeps both its borders */
.pod-2 .pod-block { border-right: 0; }
.pod-3 .pod-block { border-left: 0; }
.pod-num { width: calc(var(--unit) * .36); height: auto; }
.pod-1 .pod-num { width: calc(var(--unit) * .44); }

/* winners.js raises the blocks (3rd, 2nd, 1st), then drops the names in.
   If it never runs, the failsafe shows everything after 4s. */
.pod-3 { --rise: 0ms;   --drop: 620ms; }
.pod-2 { --rise: 160ms; --drop: 820ms; }
.pod-1 { --rise: 320ms; --drop: 1080ms; }
html.js .pod-block { transition: transform .8s var(--ease-spring) var(--rise); }
html.js .pod-card { transition: opacity .45s var(--ease-out) var(--drop), transform .7s var(--ease-spring) var(--drop); }
html.js .podium:not(.go) .pod-block { transform: scaleY(0); animation: pod-failsafe 0s 4s forwards; }
html.js .podium:not(.go) .pod-card { opacity: 0; transform: translateY(-32px); animation: pod-failsafe 0s 4s forwards; }
@keyframes pod-failsafe { to { opacity: 1; transform: none; } }

.podium.go .pod-1 .pod-trophy [data-icon] { animation: trophy-bob 3.2s ease-in-out 2.2s infinite; }
.podium .pod-1 .pod-trophy.hop [data-icon] { animation: trophy-hop .5s var(--ease-out); }
@keyframes trophy-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(-5deg); }
}
@keyframes trophy-hop {
  30% { transform: translateY(-14px) rotate(-10deg) scale(1.08); }
  60% { transform: translateY(0) scale(1.06, .94); }
}

/* ---------- top 10 ---------- */
.board {
  max-width: 880px;
  margin: 0 auto clamp(56px, 10vh, 104px);
}
.board-head {
  --blox-w: clamp(84px, 11vw, 124px);
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.board-head .sec-title { margin: 10px 0 20px; }

/* Blox sits on the top edge of the list, with a speech bubble beside */
.board-blox {
  flex-shrink: 0;
  width: var(--blox-w);
  aspect-ratio: 31 / 28;
  margin: 0 clamp(12px, 4vw, 40px) 2px 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.board-blox img {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  transform-origin: 50% 100%;
  animation: blox-twitch 7s steps(1) infinite;
}
.board-blox.hop img { animation: blox-hop .45s var(--ease-out), blox-twitch 7s steps(1) infinite; }
.board-blox:focus-visible { outline: none; }
.board-blox:focus-visible img { filter: drop-shadow(0 -3px 0 var(--gold)); }
@keyframes blox-twitch {
  0%, 90%, 94%, 100% { translate: 0 0; }
  92%, 96% { translate: 0 -3px; }
}
@keyframes blox-hop {
  0% { transform: none; }
  30% { transform: translateY(-14px) scale(.96, 1.04); }
  60% { transform: translateY(0) scale(1.05, .95); }
  100% { transform: none; }
}
.board-say {
  position: absolute;
  right: calc(clamp(12px, 4vw, 40px) + var(--blox-w) + 14px);
  bottom: calc(var(--blox-w) * .5);
  max-width: min(240px, 42%);
  margin: 0;
  padding: 10px 12px;
  background: var(--navy);
  color: var(--cream);
  font-family: var(--f-pixel);
  font-size: 11px;
  letter-spacing: .05em;
  line-height: 1.6;
  box-shadow: 4px 4px 0 var(--gold);
  transform-origin: 100% 50%;
}
.board-say::after { content: ""; position: absolute; right: -10px; top: 50%; width: 10px; height: 10px; margin-top: -5px; background: var(--navy); }
.board-say.pop { animation: say-pop .35s var(--ease-spring); }
@keyframes say-pop {
  from { opacity: 0; transform: scale(.85); }
  to { opacity: 1; transform: none; }
}

.board-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(14px, 2.4vw, 24px);
  padding: 10px clamp(14px, 2.4vw, 22px) 10px 10px;
  background: var(--row-bg, var(--cream));
  border: 2px solid var(--navy);
  box-shadow: 4px 4px 0 var(--navy);
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.row:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--gold); }
.row-1 { --medal: var(--gold); }
.row-2 { --medal: var(--silver); }
.row-3 { --medal: var(--bronze); }
.row-1, .row-2, .row-3 { --row-bg: color-mix(in srgb, var(--medal) 16%, var(--cream)); }

.row-rank {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  font-family: var(--f-pixel);
  font-weight: 700;
  font-size: 20px;
  color: var(--navy);
  background: var(--medal, var(--cream-2));
  border: 2px solid var(--navy);
}
.row-1 .row-rank, .row-2 .row-rank, .row-3 .row-rank {
  box-shadow: inset 0 4px 0 rgb(255 255 255 / .32), 3px 3px 0 var(--navy-deep);
}
.row-team {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
  color: var(--navy);
}
/* ---------- team members + repo link (winners.js) ---------- */
.row { position: relative; }
.team-link { color: inherit; text-decoration: none; }
/* the whole card or row is the link */
.team-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.has-link { cursor: pointer; }
.has-link:hover .pod-team, .has-link:hover .row-team { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.team-link:focus-visible { outline: none; }
.has-link:has(.team-link:focus-visible) { outline: 3px solid var(--gold); outline-offset: 4px; }
button.pod-trophy { position: relative; z-index: 2; }

/* GitHub link: a quiet text link at the row's right end, fading in on
   hover, so the name can go to the live project while the repo stays close */
.row.has-gh { padding-right: 96px; }
.row-gh {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: clamp(14px, 2.4vw, 22px);
  translate: 4px -50%;
  padding: 4px 2px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  text-decoration: none;
  opacity: 0;
  transition: opacity .18s, translate .18s var(--ease-out), color .15s;
}
.row:hover .row-gh, .row:focus-within .row-gh { opacity: 1; translate: 0 -50%; }
.row-gh:hover, .row-gh:focus-visible { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; outline: none; }

.team-who {
  position: absolute;
  z-index: 5;
  top: calc(100% + 8px);
  left: 50%;
  width: max-content;
  max-width: min(320px, 80vw);
  margin: 0;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
  color: var(--cream);
  background: var(--navy);
  border: 2px solid var(--navy);
  box-shadow: 4px 4px 0 var(--gold);
  pointer-events: none;
  opacity: 0;
  translate: -50% -4px;
  transition: opacity .15s, translate .15s var(--ease-out);
}
.row .team-who { top: calc(100% - 4px); left: 74px; translate: 0 -4px; text-align: left; }
.has-who:hover, .has-who:focus-within { z-index: 4; }
.has-who:hover .team-who, .has-who:focus-within .team-who { opacity: 1; translate: -50% 0; }
.row.has-who:hover .team-who, .row.has-who:focus-within .team-who { translate: 0 0; }

/* no hover on touch screens: show the members under the name instead */
@media (hover: none) {
  .team-who, .row .team-who {
    position: static;
    width: auto;
    max-width: none;
    padding: 0;
    margin-top: 4px;
    font-size: 13px;
    font-weight: 400;
    color: var(--ink-3);
    background: none;
    border: 0;
    box-shadow: none;
    opacity: 1;
    translate: none;
  }
  .row .team-who { grid-column: 2; margin-top: -8px; }
  .row-gh { opacity: 1; translate: 0 -50%; }
}

/* the rows come in one after another, not the list as a block */
.board-list.reveal { opacity: 1; transform: none; }
html.js .board-list:not(.in) .row { opacity: 0; }
.board-list.in .row { animation: row-in .6s var(--ease-out) calc(var(--i) * 55ms) both; }
@keyframes row-in {
  from { opacity: 0; translate: 0 18px; }
  to { opacity: 1; translate: 0 0; }
}

.win .closer { max-width: 880px; margin-inline: auto; }

/* ---------- phones ---------- */
@media (max-width: 600px) {
  .podium { --unit: 56px; }
  .pod-card { padding: 0 4px 12px; }
  .pod-place { font-size: 10px; letter-spacing: .1em; }
  .pod-team { font-size: 12px; }
  .pod-1 .pod-team { font-size: 14px; }
    .row-rank { width: 44px; height: 44px; font-size: 17px; }
  .row-team { font-size: 16px; }
  .row.has-gh { padding-right: 78px; }
  .row-gh { font-size: 12px; }
  }
