/* ===========================================================
   Clock Patience — game-specific styles only.
   Chrome, buttons, stats and the help modal come from shared.css.
   The 12 numbered piles ring a central Kings pile on a round
   clock face. Card width drives everything via --cw so the whole
   clock fits on a phone screen.
   =========================================================== */

:root {
  /* Card size scales with the viewport; the clock diameter follows. */
  --cw: clamp(38px, 11vw, 64px);
  --ch: calc(var(--cw) * 1.4);
  --clock: clamp(280px, 92vw, 460px);   /* clock face diameter */
  --radius: calc(var(--clock) / 2 - var(--ch) * 0.62); /* hour-pile orbit */
}

body { gap: 14px; }

/* ---------- top bar ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.top button { padding: 10px 20px; }
.stats { display: flex; gap: 10px; }
.stat { min-width: 60px; padding: 6px 12px; }
.stat .val { font-size: 1.1rem; }

/* ---------- board / clock face ---------- */
#board {
  display: flex;
  justify-content: center;
  width: 100%;
}
#clock {
  position: relative;
  width: var(--clock);
  height: var(--clock);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%,
      var(--surface) 0,
      var(--surface) 58%,
      var(--surface-2) 100%);
  border: 3px solid var(--border);
  box-shadow: 0 4px 18px var(--shadow);
}

/* ---------- pile slots ---------- */
.pile {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--cw);
  height: var(--ch);
  margin-left: calc(var(--cw) / -2);
  margin-top: calc(var(--ch) / -2);
  border-radius: calc(var(--cw) * 0.12);
  border: 2px dashed var(--border);
  background: var(--surface-2);
  /* Place each numbered pile at its clock angle. --i is 1..12 (12 at top).
     angle = (i/12) full turn; the pile is pushed out along --radius. */
  transform: rotate(calc(var(--i) * 30deg))
             translate(0, calc(var(--radius) * -1))
             rotate(calc(var(--i) * -30deg));
}
.pile.centre {
  /* Stays dead-centre; no rotation. */
  transform: none;
}

/* The hour label sits faintly behind each pile's cards. */
.pile::before {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cw) * 0.5);
  font-weight: 700;
  color: var(--muted);
  opacity: 0.45;
  pointer-events: none;
}

/* The active pile (next to draw from) glows so the player knows where to tap. */
.pile.active {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--accent), 0 4px 14px var(--shadow);
  z-index: 30;
}

/* A small fan of face-down cards already turned in (count badge). */
.pile .count {
  position: absolute;
  top: calc(var(--cw) * -0.18);
  right: calc(var(--cw) * -0.18);
  min-width: calc(var(--cw) * 0.42);
  height: calc(var(--cw) * 0.42);
  padding: 0 calc(var(--cw) * 0.08);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: calc(var(--cw) * 0.3);
  font-weight: 700;
  line-height: calc(var(--cw) * 0.42);
  text-align: center;
  z-index: 20;
}

/* ---------- cards ---------- */
.card {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--cw) * 0.12);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px var(--shadow);
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  z-index: 10;
}
.card .corner {
  position: absolute;
  top: calc(var(--cw) * 0.06);
  left: calc(var(--cw) * 0.09);
  line-height: 1;
  font-weight: 700;
  font-size: calc(var(--cw) * 0.36);
  text-align: center;
}
.card .corner .suit { font-size: calc(var(--cw) * 0.3); display: block; }
.card .pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cw) * 0.6);
  opacity: 0.9;
}
.card.red   { color: var(--red); }
.card.black { color: var(--text); }

/* Face-down card back (patterned), used for the brief deal-in flash. */
.card.down {
  background:
    repeating-linear-gradient(45deg,
      var(--blue-board) 0, var(--blue-board) 6px,
      var(--blue-board-dark) 6px, var(--blue-board-dark) 12px);
  border-color: var(--blue-board-dark);
}
.card.down .corner, .card.down .pip { display: none; }

/* The card that has just been turned does a quick pop as it lands. */
.card.flip { animation: cardPop 0.32s ease-out; }
@keyframes cardPop {
  0%   { transform: scale(0.6) rotate(-8deg); opacity: 0; }
  60%  { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ---------- end-of-game banner ---------- */
#status.win  { animation: pulse 1s ease-in-out infinite; }
#status.lose { font-weight: 700; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* Very small screens: shrink stat chips a touch more. */
@media (max-width: 380px) {
  .stat { min-width: 50px; padding: 5px 8px; }
  .stats { gap: 6px; }
  .top { gap: 8px; }
}
