/* ===========================================================
   Pyramid Solitaire — game-specific styles only.
   Chrome, buttons, stats and the help modal come from shared.css.
   Card width drives everything via --cw so the 7-row pyramid
   (base of 7 cards) fits, right down to a narrow phone screen.
   =========================================================== */

:root {
  /* The base row holds 7 cards laid out flat, so its width is the constraint:
     7 cards + 6 small gaps ≈ 7.36 card widths. The vw term is kept ≤ 12 so the
     base stays inside a ~360px phone (12vw × 7.36 ≈ 88% of the viewport). */
  --cw: clamp(38px, 12vw, 84px);
  --ch: calc(var(--cw) * 1.4);
  --row-overlap: calc(var(--ch) * 0.42);  /* vertical pull of each row up   */
}

body { gap: 14px; }

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

/* ---------- board layout ---------- */
#board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

/* ---------- the pyramid ---------- */
.pyramid {
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* Each row pulls up into the row above so cards overlap like a real pyramid. */
.pyr-row {
  display: flex;
  gap: calc(var(--cw) * 0.06);
}
.pyr-row + .pyr-row { margin-top: calc(var(--row-overlap) * -1); }

/* Each slot reserves a card-sized footprint even after the card is removed,
   so the triangle never collapses. */
.slot {
  position: relative;
  width: var(--cw);
  height: var(--ch);
}

/* ---------- lower area: stock + waste ---------- */
.lower {
  display: flex;
  gap: calc(var(--cw) * 0.4);
  justify-content: center;
}
.pile {
  position: relative;
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.12);
  border: 2px dashed var(--border);
  background: var(--surface-2);
}
/* Empty-stock recycle glyph (only while a recycle is still allowed). */
.stock.empty::after {
  content: "↻";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cw) * 0.5);
  color: var(--muted);
  pointer-events: none;
}
/* Out of passes: dim the recycle hint. */
.stock.dead { cursor: default; }
.stock.dead::after { content: "✕"; opacity: 0.4; }

/* ---------- cards ---------- */
.card {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cw);
  height: var(--ch);
  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;
  cursor: pointer;
  overflow: hidden;
}

.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.32);
  text-align: center;
}
.card .corner .suit { font-size: calc(var(--cw) * 0.28); display: block; }
.card .pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cw) * 0.56);
  opacity: 0.9;
}

.card.red   { color: var(--red); }
.card.black { color: var(--text); }

/* Face-down stock back: a patterned weave, no rank shown. */
.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);
  cursor: pointer;
}
.card.down .corner, .card.down .pip { display: none; }

/* Covered (locked) pyramid cards are dimmed and not interactive. */
.card.locked {
  filter: brightness(0.82) saturate(0.85);
  cursor: default;
}
:root[data-theme="dark"] .card.locked { filter: brightness(0.7); }

/* Selected card glows gold. */
.card.selected {
  outline: 3px solid var(--accent);
  outline-offset: -1px;
  box-shadow: 0 0 0 2px var(--accent), 0 4px 12px var(--shadow);
  z-index: 50;
}

/* ---------- win banner ---------- */
#status.win { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* Tighten stat chips on very small screens. */
@media (max-width: 380px) {
  .stat { min-width: 50px; padding: 5px 7px; }
  .stats { gap: 6px; }
}
