@import "../css/tokens.css";

/* ==========================================================================
   Pocket Solitaire — Casino Emerald Felt & Phone-First Solitaire Table
   ========================================================================== */

:root {
  --color-felt: #15803d;
  --color-felt-deep: #14532d;
  --color-felt-shadow: #052e16;
  --color-felt-highlight: #22c55e;
  --color-gold: #f59e0b;
  --color-gold-bright: #fbbf24;
  --color-gold-deep: #b45309;
  --color-wood-rail: #2d1808;
  --color-wood-rail-border: #451a03;
  --color-card-border: #cbd5e1;
  --color-card-bg: #ffffff;
  --color-hud-bg: rgba(5, 46, 22, 0.88);
  --color-hud-border: rgba(245, 158, 11, 0.35);

  --card-radius: 7px;
  --card-aspect: 1.4;
  --card-width: clamp(42px, 12vw, 82px);
  --card-height: calc(var(--card-width) * var(--card-aspect));
  --tableau-gap: clamp(4px, 1.2vw, 10px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  background: var(--color-felt-deep);
  color: #f8fafc;
  font-family: var(--font-body, "Plus Jakarta Sans", sans-serif);
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* --- Hub Navigation Top Bar --- */
.hub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: #0f172a;
  color: #94a3b8;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 50;
}

.hub-bar a {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.15s ease;
}

.hub-bar a:hover {
  color: #7dd3fc;
}

/* --- Ad Rail --- */
.playyard-ad {
  width: 100%;
  max-width: 728px;
  margin: 0 auto;
  padding: 0.4rem 0.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ad-well {
  width: 100%;
  min-height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- Main Felt Table Shell --- */
.table-app {
  max-width: 720px;
  margin: 0 auto;
  min-height: calc(100vh - 100px);
  padding: 0.5rem 0.5rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.table-felt {
  background: radial-gradient(circle at 50% 30%, var(--color-felt) 0%, var(--color-felt-deep) 70%, var(--color-felt-shadow) 100%);
  border: 4px solid var(--color-wood-rail);
  box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.6), 0 8px 24px rgba(0, 0, 0, 0.45);
  border-radius: 18px;
  padding: 0.65rem 0.5rem 1rem;
  position: relative;
  overflow: hidden;
  flex: 1;
}

/* Subtle poker felt texture overlay */
.table-felt::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 16px 16px;
  pointer-events: none;
  opacity: 0.7;
}

/* --- HUD Header --- */
.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-hud-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-hud-border);
  border-radius: 12px;
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.65rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  position: relative;
  z-index: 10;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hud-stat {
  display: flex;
  flex-direction: column;
}

.hud-stat__label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  font-weight: 600;
}

.hud-stat__value {
  font-family: var(--font-label, "JetBrains Mono", monospace);
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
}

.hud-stat__value--gold {
  color: var(--color-gold-bright);
}

.hud-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* --- Action Buttons --- */
.btn-pill {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-family: var(--font-body, inherit);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.15s ease;
}

.btn-pill:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.btn-pill:active:not(:disabled) {
  transform: translateY(0);
}

.btn-pill:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn-pill--primary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0f172a;
  border-color: #fbbf24;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.btn-pill--primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.6);
}

.btn-pill--gold-pulse {
  animation: goldPulse 1.6s infinite ease-in-out;
}

@keyframes goldPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
    transform: scale(1.03);
  }
}

/* --- Top Row: Stock, Waste, Foundations --- */
.top-row {
  display: flex;
  justify-content: space-between;
  gap: var(--tableau-gap);
  margin-bottom: 0.9rem;
  position: relative;
  z-index: 5;
}

.stock-waste-group, .foundations-group {
  display: flex;
  gap: var(--tableau-gap);
}

.foundations-group {
  justify-content: flex-end;
}

/* --- Slot / Pile Container --- */
.card-slot {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  border: 1.5px dashed rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.18);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.waste-slot {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.08);
}

.stock-slot {
  cursor: pointer;
}

.stock-count-badge {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: #0f172a;
  color: var(--color-gold-bright);
  font-family: var(--font-label, monospace);
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid var(--color-gold);
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.recycle-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--color-gold-bright);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.9;
}

.foundation-watermark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.watermark-symbol {
  font-size: clamp(1.2rem, 3.2vw, 1.8rem);
  opacity: 0.25;
}

.watermark--spades, .watermark--clubs {
  color: #0f172a;
}

.watermark--hearts, .watermark--diamonds {
  color: #ef4444;
}

/* --- Tableau Grid --- */
.tableau-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--tableau-gap);
  min-height: 280px;
  position: relative;
  z-index: 5;
}

.tableau-col {
  position: relative;
  width: 100%;
  min-height: calc(var(--card-height) + 120px);
  border-radius: var(--card-radius);
  transition: background 0.15s ease;
}

.tableau-empty-slot {
  width: var(--card-width);
  height: var(--card-height);
  border-radius: var(--card-radius);
  border: 1.5px dashed rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.25);
  font-weight: 800;
  font-size: 1.1rem;
  font-family: var(--font-label, monospace);
  pointer-events: none;
}

/* --- Card Base Styling --- */
.card {
  width: var(--card-width);
  height: var(--card-height);
  position: absolute;
  top: 0;
  left: 0;
  border-radius: var(--card-radius);
  cursor: pointer;
  touch-action: none;
  transform-origin: center center;
  transition: transform 0.18s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)), box-shadow 0.18s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.card__inner {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: var(--card-radius);
  overflow: hidden;
}

.card__face {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card--faceup .card__face--back {
  display: none;
}

.card--facedown .card__face--front {
  display: none;
}

.card--facedown {
  cursor: default;
}

.card--waste-under {
  pointer-events: none;
  filter: brightness(0.92);
}

.card-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- Card States & Animations --- */
.card.is-dragged-placeholder {
  opacity: 0.28;
  filter: grayscale(0.5);
}

.card.is-shaking {
  animation: cardWobble 0.32s ease-in-out;
}

@keyframes cardWobble {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px) rotate(-2deg); }
  50% { transform: translateX(4px) rotate(2deg); }
  75% { transform: translateX(-2px) rotate(-1deg); }
}

.card.is-hint-src, .stock-slot.is-hint-src {
  box-shadow: 0 0 0 3px var(--color-gold-bright), 0 0 16px var(--color-gold-bright) !important;
  animation: hintPulse 1.2s infinite ease-in-out;
  z-index: 100 !important;
}

.card.is-hint-dest, .card-slot.is-hint-dest, .tableau-col.is-hint-dest {
  box-shadow: 0 0 0 3px #38bdf8, 0 0 16px #38bdf8 !important;
  animation: hintDestPulse 1.2s infinite ease-in-out;
  z-index: 100 !important;
}

@keyframes hintPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes hintDestPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* --- Dragging Layer --- */
.drag-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10000;
}

.drag-stack {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  will-change: transform;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.55));
}

.is-dragging-card {
  position: absolute;
  left: 0;
  width: 100%;
  height: 100%;
}

/* --- Bottom Toolbar Controls --- */
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  background: var(--color-hud-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-hud-border);
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  margin-top: 0.65rem;
}

.bottom-bar__left, .bottom-bar__right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* --- Toast Feedback --- */
.game-toast {
  position: fixed;
  bottom: 75px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  border: 1px solid var(--color-gold);
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9000;
  max-width: 90vw;
  text-align: center;
}

.game-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Modals & Overlays --- */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-sheet {
  background: #0f172a;
  border: 2px solid var(--color-gold);
  border-radius: 20px;
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7), 0 0 24px rgba(245, 158, 11, 0.25);
  text-align: center;
  position: relative;
  animation: sheetPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes sheetPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-sheet h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-gold-bright);
  margin-bottom: 0.35rem;
}

.modal-sheet .modal-lede {
  color: #94a3b8;
  font-size: 0.9rem;
  margin-bottom: 1.2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  margin-bottom: 1.3rem;
  text-align: left;
}

.stats-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}

.stats-item__label {
  font-size: 0.7rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.stats-item__val {
  font-family: var(--font-label, monospace);
  font-size: 1.15rem;
  font-weight: 800;
  color: #f8fafc;
  margin-top: 2px;
}

.stats-item__val--gold {
  color: var(--color-gold-bright);
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}

.modal-actions .btn-pill {
  flex: 1;
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
  justify-content: center;
}

/* --- Rules List --- */
.rules-list {
  text-align: left;
  font-size: 0.88rem;
  color: #cbd5e1;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.2rem;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 0.4rem;
}

.rules-list b {
  color: var(--color-gold-bright);
}

/* --- Canvas Cascade Overlay --- */
.cascade-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 950;
}

/* --- SEO Editorial & Info Section Below Table --- */
.below-section {
  max-width: 720px;
  margin: 1.5rem auto 0;
  padding: 1.2rem 1.2rem 2.5rem;
  background: #0f172a;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}

.below-section h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 0.5rem;
}

.below-section p {
  font-size: 0.88rem;
  line-height: 1.55;
  margin-bottom: 0.85rem;
  color: #94a3b8;
}

.below-section p a {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 600;
}

.below-section p a:hover {
  text-decoration: underline;
}

/* Responsive fine-tuning */
@media (max-width: 480px) {
  .hud-stat__value {
    font-size: 0.88rem;
  }
  .btn-pill {
    padding: 0.32rem 0.48rem;
    font-size: 0.74rem;
  }
  .modal-sheet {
    padding: 1.1rem;
  }
}
