/* Coin flip tool. Layout comes from tool.css (.tool grid, .t-wheel area). */

.t-coin { display: flex; flex-direction: column; align-items: center; }

.coin-stage {
  --lift: 0;
  position: relative;
  width: min(100%, 400px);
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid; place-items: center;
  perspective: 900px;
  cursor: pointer;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
@media (max-width: 899px) { .coin-stage { width: min(100%, 280px); } }

.coin {
  position: relative;
  width: 64%; aspect-ratio: 1;
  transform-style: preserve-3d;
  z-index: 1;
}

.coin-face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 6px solid var(--foreground); border-radius: var(--r-full);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  color: var(--foreground);
}
/* The rim, drawn as its own ring so it stays crisp on both faces. */
.coin-face::before {
  content: ""; position: absolute; inset: 7%;
  border: 3px solid var(--foreground); border-radius: var(--r-full);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.45);
}
.coin-heads { background: var(--yes); }
/* Tails carries the same stripes as No on the wheel, so the sides never
   depend on colour alone. */
.coin-tails {
  transform: rotateX(180deg);
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.4) 0 3px, transparent 3px 11px),
    var(--no);
}
.face-big { font-family: var(--font-display); font-weight: 800; font-size: clamp(4rem, 12vw, 6.5rem); line-height: 1; }
.face-small { margin-top: 2px; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.coin-face.is-word .face-big { font-size: clamp(3rem, 9vw, 4.6rem); }

.coin-shadow {
  position: absolute; left: 50%; bottom: 7%;
  width: 52%; height: 9%;
  border-radius: 50%;
  background: var(--foreground);
  opacity: calc(0.22 - var(--lift) * 0.14);
  transform: translateX(-50%) scale(calc(1 - var(--lift) * 0.45));
}
.coin-stage.is-landed .coin-shadow { animation: land-squash 260ms var(--bounce); }
@keyframes land-squash {
  0% { transform: translateX(-50%) scale(1.15, 0.8); }
  100% { transform: translateX(-50%) scale(1); }
}

/* Gentle bob before the first flip, an invitation to toss it. */
.coin-stage.is-idle .coin { animation: coin-bob 1.8s ease-in-out infinite; }
@keyframes coin-bob {
  0%, 100% { transform: translateY(0) rotateX(0deg); }
  50% { transform: translateY(-4%) rotateX(14deg); }
}

/* Always-on hint, tucked away while the coin is in the air. */
.coin-hint {
  position: absolute; right: -4%; bottom: 10%; z-index: 2;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 16px 6px 6px;
  background: var(--tertiary); color: var(--foreground);
  border: var(--bw) solid var(--foreground); border-radius: var(--r-full);
  box-shadow: var(--pop);
  font-family: var(--font-display); font-weight: 800; font-size: 1rem; white-space: nowrap;
  transform: rotate(-7deg);
  pointer-events: none;
  transition: opacity 250ms ease;
  animation: pill-bob 1.3s var(--bounce) infinite alternate;
}
.coin-hint .hand {
  display: grid; place-items: center; width: 32px; height: 32px;
  background: var(--card); border: var(--bw) solid var(--foreground); border-radius: var(--r-full);
}
.coin-hint .hand .icon { width: 18px; height: 18px; animation: hand-flick 1.3s ease-in-out infinite; }
@keyframes hand-flick {
  0%, 100% { transform: translateY(3px); }
  50% { transform: translateY(-4px); }
}
.coin-stage.is-tossing .coin-hint { opacity: 0; }
@media (max-width: 899px) { .coin-hint { right: -6%; bottom: -1%; font-size: 0.9rem; } }

/* ---------- Best of N markers ---------- */

.pips { display: flex; justify-content: center; gap: 10px; margin-top: 6px; }
.pip {
  display: grid; place-items: center; width: 38px; height: 38px;
  border: var(--bw) dashed var(--input-border); border-radius: var(--r-full);
  font-family: var(--font-display); font-weight: 800; font-size: 0.95rem; color: var(--muted-fg);
}
.pip-heads, .pip-tails { border-style: solid; border-color: var(--foreground); color: var(--foreground); animation: pip-pop 300ms var(--bounce); }
.pip-heads { background: var(--yes); }
.pip-tails { background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.4) 0 2px, transparent 2px 7px), var(--no); border-radius: 10px; }
@keyframes pip-pop { from { transform: scale(0.4); } to { transform: scale(1); } }

.verdict-sub { display: block; margin-top: 4px; font-family: var(--font-body); font-size: 0.95rem; font-weight: 600; color: var(--muted-fg); }

/* ---------- Fair coin against real coin bars ---------- */

.bars-wide li { grid-template-columns: 11.5em minmax(0, 1fr) auto; }
.bars .mid { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 2px; background: var(--foreground); }
.bars li.note { display: block; }

@media (max-width: 600px) {
  .bars-wide li { grid-template-columns: 1fr; gap: 6px; }
  .bars-wide .val { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .coin-stage.is-idle .coin, .coin-hint, .coin-hint .hand .icon { animation: none; }
}
