/* solitaire.css — solitaire.gameshack.org
   Sits on top of the shared GameShack style.css (header, nav, footer). */

.sol-main {
  --felt: #1B4332;
  --felt-dark: #143326;
  --felt-line: rgba(255, 255, 255, 0.22);
  --bar-text: #f3efe2;
  --accent: #e9b949;
  position: relative;
  background: radial-gradient(ellipse at 50% 30%, #23573f 0%, var(--felt) 55%, var(--felt-dark) 100%);
  color: var(--bar-text);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- top bar ---------- */

.sol-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 980px;
  margin: 0 auto;
  padding: 0.5rem 16px;
}
.sol-bar__right {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}
.sol-status {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  margin-left: 0.25rem;
  min-width: 0;
}
.sol-deal {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
}
.sol-moves {
  font-size: 0.95rem;
  opacity: 0.85;
  white-space: nowrap;
}
.sol-btn {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--bar-text);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.sol-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.18); }
.sol-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sol-btn:disabled { opacity: 0.4; cursor: default; }
.sol-btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #1d1a10;
}
.sol-btn--accent:hover:not(:disabled) { background: #f2c862; }
.sol-btn[hidden] { display: none; }

.sol-btn--icon { font-size: 1.1rem; line-height: 1; padding: 0.4rem 0.6rem; }
.sol-btn--small { font-size: 0.82rem; padding: 0.25rem 0.6rem; }

/* ---------- still-winnable indicator ---------- */

.sol-indicator {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 1.9rem;
}
.sol-indicator[hidden] { display: none; }
.sol-indicator.is-win      { color: #8fe3a8; }
.sol-indicator.is-lost     { color: #ff9b8f; }
.sol-indicator.is-unknown  { color: rgba(243, 239, 226, 0.7); font-weight: 500; }
.sol-indicator.is-checking { color: rgba(243, 239, 226, 0.6); font-weight: 500; }

/* ---------- settings ---------- */

.sol-panel.sol-panel--settings { text-align: left; max-height: calc(100% - 8px); overflow-y: auto; }
.sol-panel--settings h2 { text-align: center; }
.sol-option {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.6rem 0;
  border-top: 1px solid #e4dcc6;
  cursor: pointer;
}
.sol-option:last-of-type { border-bottom: 1px solid #e4dcc6; }
.sol-option input { margin-top: 0.2rem; width: 1.15rem; height: 1.15rem; accent-color: #1B4332; flex: none; }
.sol-option strong { display: block; font-size: 0.98rem; }
.sol-option small { display: block; color: #5d5747; font-size: 0.85rem; margin-top: 0.1rem; }

/* ---------- statistics ---------- */

.sol-stats__title {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
  text-align: center;
}
.sol-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0;
}
.sol-stats div {
  background: #f1ecdd;
  border-radius: 6px;
  padding: 0.45rem 0.3rem;
  text-align: center;
}
.sol-stats dt { font-size: 0.75rem; color: #5d5747; }
.sol-stats dd { margin: 0.1rem 0 0; font-size: 1.25rem; font-weight: 700; }
.sol-stats__note {
  font-size: 0.8rem;
  color: #5d5747;
  text-align: center;
  margin: 0.6rem 0 1rem;
}
.sol-link-btn {
  font: inherit;
  color: #8a2433;
  background: none;
  border: none;
  padding: 0 0 0 0.35rem;
  text-decoration: underline;
  cursor: pointer;
}
.sol-link-btn.is-armed { font-weight: 700; }
.sol-win-stats { font-size: 0.9rem; color: #5d5747; margin-top: -0.5rem; }

/* ---------- table ---------- */

.sol-table {
  position: relative;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  overflow: hidden;
  /* height is set by game.js to fill the rest of the screen */
}

.sol-slot,
.sol-card {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cw, 80px);
  height: var(--ch, 116px);
  border-radius: var(--cr, 6px);
}

.sol-slot {
  border: 2px solid var(--felt-line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--felt-line);
  font-size: calc(var(--cw, 80px) * 0.42);
  line-height: 1;
  box-sizing: border-box;
}
.sol-slot--stock { cursor: pointer; touch-action: none; }
.sol-slot--stock.is-recycle { color: rgba(255, 255, 255, 0.6); border-color: rgba(255, 255, 255, 0.4); }

.sol-card {
  cursor: pointer;
  touch-action: none;
  /* Glide in and settle. Keep SLIDE_MS in game.js in step with this. */
  transition: transform 0.3s cubic-bezier(0.22, 0.8, 0.3, 1);
  will-change: transform;
  perspective: calc(var(--cw, 80px) * 7);
}

/* ---------- the card itself: a front and a back on a turnable inner layer ---------- */

.sol-card__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  /* Stay on its own GPU layer, so when a flip ends the browser doesn't
     drop the layer and repaint the card (that showed as a blink). */
  will-change: transform;
}
.sol-card.face-down .sol-card__inner { transform: rotateY(180deg); }

.sol-card__face {
  position: absolute;
  inset: 0;
  border-radius: var(--cr, 6px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  /* Ease the lifted shadow back down rather than snapping it off. */
  transition: box-shadow 0.2s ease-out;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.sol-card__back { transform: rotateY(180deg); }
.sol-card__face svg {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
/* The deck's back design takes its colour from fill. */
.sol-card__back svg { fill: #8a2433; }

.sol-card.face-down { cursor: default; }
.sol-card.is-stock { cursor: pointer; }
.sol-card.is-dragging { transition: none; }
.sol-card.is-dragging .sol-card__face { box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45); }

/* ---------- turning over ----------
   Hop: the card lifts a little, turns edge-on (back disappears), keeps turning
   to show its face, and settles. Flat: the same turn without the lift. */
.sol-card.flip-up-hop .sol-card__inner    { animation: sol-flip-up-hop 0.42s ease-in-out both; }
.sol-card.flip-down-hop .sol-card__inner  { animation: sol-flip-down-hop 0.42s ease-in-out both; }
.sol-card.flip-up-flat .sol-card__inner   { animation: sol-flip-up-flat 0.3s ease-in-out both; }
.sol-card.flip-down-flat .sol-card__inner { animation: sol-flip-down-flat 0.3s ease-in-out both; }
/* Only a hop lifts the card, so only a hop gets the bigger shadow. A flat turn
   keeps its resting shadow the whole way, so nothing changes when it ends. */
.sol-card.flip-up-hop .sol-card__face,
.sol-card.flip-down-hop .sol-card__face { box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35); }

@keyframes sol-flip-up-hop {
  0%   { transform: translateY(0) scale(1) rotateY(180deg); }
  50%  { transform: translateY(calc(var(--ch, 116px) * -0.14)) scale(1.06) rotateY(90deg); }
  100% { transform: translateY(0) scale(1) rotateY(0deg); }
}
@keyframes sol-flip-down-hop {
  0%   { transform: translateY(0) scale(1) rotateY(0deg); }
  50%  { transform: translateY(calc(var(--ch, 116px) * -0.14)) scale(1.06) rotateY(90deg); }
  100% { transform: translateY(0) scale(1) rotateY(180deg); }
}
@keyframes sol-flip-up-flat {
  from { transform: rotateY(180deg); }
  to   { transform: rotateY(0deg); }
}
@keyframes sol-flip-down-flat {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(180deg); }
}

/* Instant moves: resizing, and dragging cards under the finger. */
.sol-table.no-anim .sol-card { transition: none; }

/* Dealing: a little slower so the deal reads as a deal. Keep DEAL_SLIDE_MS in game.js in step. */
.sol-table.is-dealing .sol-card { transition: transform 0.36s cubic-bezier(0.22, 0.8, 0.3, 1); }

/* Nudge when a tapped card has nowhere to go. */
.sol-card.shake .sol-card__inner { animation: sol-shake 0.3s ease-in-out; }
@keyframes sol-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@media (prefers-reduced-motion: reduce) {
  .sol-card,
  .sol-table.is-dealing .sol-card { transition: none; }
  .sol-card .sol-card__inner { animation: none !important; }
}

/* ---------- overlays ---------- */

.sol-overlay {
  position: absolute;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 25, 18, 0.55);
  padding: 16px;
}
.sol-overlay[hidden] { display: none; }
.sol-panel {
  background: #fbf8ef;
  color: #1d1a10;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  max-width: 22rem;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.sol-panel h2 { margin: 0 0 0.4rem; font-size: 1.4rem; }
.sol-panel p { margin: 0 0 1rem; }
.sol-panel__actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}
.sol-panel .sol-btn:not(.sol-btn--accent) {
  color: #1d1a10;
  background: #ece6d4;
  border-color: #d6ceb6;
}

@media (max-width: 560px) {
  /* Deal number and move count stack into a small two-line block. */
  .sol-status { flex-direction: column; gap: 0; line-height: 1.15; }
  .sol-deal, .sol-moves { font-size: 0.8rem; }
}

@media (max-width: 420px) {
  .sol-bar { gap: 0.35rem; padding: 0.4rem 10px; }
  .sol-btn { padding: 0.4rem 0.55rem; font-size: 0.85rem; }
}
