/* ===========================================================
   Klondike Solitaire — game-specific styles only.
   Chrome, buttons, stats and the help modal come from shared.css.
   Card width drives everything via the --cw custom property so the
   seven overlapping columns always fit, right down to ~360px wide.
   =========================================================== */

:root {
  /* Card width scales with the viewport; height follows a poker-ish ratio.
     clamp keeps 7 columns + gaps inside a narrow phone screen. */
  --cw: clamp(40px, 12.5vw, 78px);
  --ch: calc(var(--cw) * 1.4);
  --col-gap: clamp(3px, 1.2vw, 10px);  /* gap between columns / upper piles */
  --stack: calc(var(--ch) * 0.27);     /* vertical offset of stacked cards  */
}

/* Tighten the page so the wide board has room. */
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: 64px; padding: 6px 12px; }
.stat .val { font-size: 1.1rem; }

/* ---------- board layout ---------- */
#board {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: calc(var(--cw) * 7 + var(--col-gap) * 6 + 8px);
}

.upper, .tableau {
  display: grid;
  grid-template-columns: repeat(7, var(--cw));
  gap: var(--col-gap);
  justify-content: center;
}

/* The blank flex spacer pushes foundations to the right of stock/waste. */
.upper .spacer { display: none; }   /* grid handles spacing; keep slot empty */

/* ---------- pile slots (the empty "wells") ---------- */
.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);
}
/* Foundation wells get a faint suit ghost so the goal is obvious. */
.foundation::after {
  content: attr(data-ghost);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cw) * 0.42);
  color: var(--muted);
  opacity: 0.35;
  pointer-events: none;
}
/* Empty-stock recycle glyph. */
.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;
}

/* A tableau column is a relatively-positioned stack of absolute cards. */
.column {
  position: relative;
  width: var(--cw);
  min-height: var(--ch);
}
.column .pile-base {  /* dashed well shown only when a column is empty */
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.12);
  border: 2px dashed var(--border);
  background: var(--surface-2);
}

/* ---------- cards ---------- */
.card {
  position: absolute;
  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;
}
/* Cards in the stock/waste/foundation sit flat in their slot. */
.pile .card { position: absolute; top: 0; left: 0; }

/* Face-up card faces: a big corner index + a centre pip. */
.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.34);
  text-align: center;
}
.card .corner .suit { font-size: calc(var(--cw) * 0.30); 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;
}

/* Suit colours — reds use --red, blacks use the theme text colour. */
.card.red   { color: var(--red); }
.card.black { color: var(--text); }

/* Face-down cards: a patterned back, 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: default;
}
.card.down .corner, .card.down .pip { display: none; }

/* Selected card (and any cards riding along with it) glow 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;
}

/* A pile/column flagged as a legal drop target while a card is held. */
.drop-ok {
  outline: 3px dashed var(--green);
  outline-offset: 2px;
}

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

/* On very small screens, drop the stat chips' min width a touch more. */
@media (max-width: 380px) {
  .stat { min-width: 54px; padding: 5px 8px; }
  .stats { gap: 6px; }
}
