/* ===========================================================
   FreeCell — 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
   eight cascades plus eight upper slots always fit, down to ~360px.
   =========================================================== */

:root {
  /* Eight cascades / eight upper cells must fit, so cards run narrower
     than Klondike. clamp keeps the layout inside a phone screen. */
  --cw: clamp(34px, 11vw, 70px);
  --ch: calc(var(--cw) * 1.4);
  --col-gap: clamp(2px, 1vw, 8px);     /* 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) * 8 + var(--col-gap) * 7 + 8px);
}

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

/* ---------- 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;
}
/* Free cells get a faint star ghost so an empty cell reads as "spare". */
.cell::after {
  content: "✦";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cw) * 0.4);
  color: var(--muted);
  opacity: 0.3;
  pointer-events: none;
}
.cell.filled::after { content: none; }

/* A cascade 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 a cell/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.36);
  text-align: center;
}
.card .corner .suit { font-size: calc(var(--cw) * 0.32); 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); }

/* 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: 52px; padding: 5px 8px; }
  .stats { gap: 6px; }
  .top { gap: 8px; }
  .top button { padding: 9px 16px; }
}
