/*
Theme Name: Solitaired CA
Theme URI: https://solitaired.ca/
Author: Solitaired CA
Description: Free Solitaire and Spider Solitaire. Every Solitaire deal is solver-checked before it is dealt — no unwinnable games.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: solitaired-ca
*/

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Brand greens */
  --felt-dark:  #0b3d2e;
  --felt:       #14543f;
  --felt-light: #1c6b50;
  --felt-table: #1a5c47;   /* card-table surface */

  /* Gold accent */
  --gold:       #d4af37;
  --gold-light: #e8c766;
  --gold-dim:   rgba(212,175,55,0.18);

  /* Neutrals */
  --cream:      #f6f3ea;
  --ink:        #1a241f;
  --ink-soft:   #4a5750;
  --muted:      rgba(246,243,234,0.65);
  --line:       rgba(255,255,255,0.13);
  --line-dark:  rgba(0,0,0,0.09);

  /* Cards */
  --card-bg:    #ffffff;
  --red-suit:   #c0112f;
  --black-suit: #111;
  --card-back1: #1a4a36;
  --card-back2: #0e3226;

  /* Geometry */
  --radius:     10px;
  --card-r:     8px;

  /* Card dimensions — override with CSS vars at breakpoints */
  --cw: 80px;
  --ch: 112px;
  --gap: 10px;
  --overlap: 28px;       /* face-down stack step */
  --overlap-up: 34px;    /* face-up card step — more room to read rank */

  /* Typography */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ============================================================
   RESET / BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.6;
  min-height: 100dvh;
}

img { max-width: 100%; display: block; }
a { color: inherit; }

.skip-link {
  position: absolute; left: -9999px; z-index: 10000;
  background: var(--gold); color: var(--ink); padding: 10px 16px;
}
.skip-link:focus { left: 10px; top: 10px; }

/* ============================================================
   HEADER — brand bar + game-switcher pill row
   ============================================================ */
.site-header {
  background: var(--felt-dark);
  color: var(--cream);
  position: sticky;
  top: 0;
  z-index: 500;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}

.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 20px;
  gap: 12px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--cream);
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.3rem; letter-spacing: 0.01em;
  white-space: nowrap;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(150deg, var(--felt-light), var(--felt-dark));
  border: 1.5px solid var(--gold);
  display: grid; place-items: center;
  color: var(--gold-light); font-size: 1.15rem; flex-shrink: 0;
}

.main-nav { display: flex; gap: 2px; align-items: center; }
.main-nav a {
  text-decoration: none; color: var(--cream);
  font-size: 0.9rem; padding: 7px 13px;
  border-radius: 999px; transition: background 0.15s;
}
.main-nav a:hover, .main-nav a:focus-visible { background: rgba(255,255,255,0.1); }
.main-nav a.is-active { background: var(--gold); color: var(--ink); font-weight: 600; }

.nav-toggle { display: none; }

@media (max-width: 720px) {
  .main-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch;
    background: var(--felt-dark); padding: 8px;
    border-bottom: 1px solid var(--line);
  }
  .main-nav.is-open { display: flex; }
  .nav-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    background: none; border: 1px solid var(--line); color: var(--cream);
    border-radius: 8px; padding: 7px 12px; font: inherit; font-size: 0.9rem; cursor: pointer;
  }
}

/* -- Game pill switcher (second header row) -- */
.game-pill-row {
  background: var(--felt);
  border-top: 1px solid var(--line);
}
.game-pill-row-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; gap: 6px; padding: 9px 20px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.game-pill {
  flex-shrink: 0; text-decoration: none;
  font-size: 0.87rem; font-weight: 600;
  color: rgba(246,243,234,0.82);
  background: rgba(255,255,255,0.07);
  padding: 7px 16px; border-radius: 999px;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.game-pill:hover, .game-pill:focus-visible { background: rgba(255,255,255,0.15); color: var(--cream); }
.game-pill.is-active { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.game-pill--ghost { background: transparent; border-color: var(--line); }

/* ============================================================
   GAME HERO — the green area that holds the board
   ============================================================ */
.game-hero {
  background: radial-gradient(ellipse 130% 120% at 50% -20%,
    var(--felt-light) 0%, var(--felt) 45%, var(--felt-dark) 100%);
  color: var(--cream);
  padding: 22px 16px 36px;
}
.game-hero-inner { max-width: 1200px; margin: 0 auto; }

.game-titlebar {
  display: flex; align-items: flex-start;
  justify-content: space-between; flex-wrap: wrap;
  gap: 10px; margin-bottom: 18px;
}
.game-titlebar h1 {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.5vw, 2rem);
}
.game-titlebar p { margin-top: 4px; color: var(--muted); font-size: 0.9rem; }

.win-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8rem; white-space: nowrap;
  background: var(--gold-dim); border: 1px solid rgba(212,175,55,0.45);
  color: var(--gold-light); padding: 5px 12px; border-radius: 999px;
}

/* ============================================================
   TOOLBAR + BUTTONS
   ============================================================ */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px;
  align-items: center;
}

.btn {
  font: inherit; font-weight: 600; font-size: 0.87rem;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.08);
  color: var(--cream);
  padding: 9px 18px; border-radius: 999px;
  cursor: pointer; transition: background 0.13s, transform 0.1s;
  white-space: nowrap; touch-action: manipulation;
}
.btn:hover, .btn:focus-visible { background: rgba(255,255,255,0.18); outline: none; }
.btn:active { transform: scale(0.97); }
.btn-gold { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-light); }
.btn-ghost { background: transparent; }

.btn-group {
  display: flex; gap: 2px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--line);
  border-radius: 999px; padding: 3px;
}
.btn-group .btn {
  border: none; background: transparent; padding: 7px 14px; font-size: 0.83rem;
}
.btn-group .btn[aria-pressed="true"] { background: var(--gold); color: var(--ink); border-radius: 999px; }

/* ============================================================
   STAT CARDS (moves / time / status row)
   ============================================================ */
.stat-cards {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
  align-items: stretch;
}
.stat-card {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 16px;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 80px;
}
.stat-card strong {
  font-size: 1.1rem; font-variant-numeric: tabular-nums;
  color: var(--cream);
}
.stat-card-label {
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted);
}
.stat-card--wide {
  flex: 1 1 200px; justify-content: center;
  font-size: 0.84rem; color: rgba(246,243,234,0.8);
}

/* ============================================================
   CARD TABLE FELT
   ============================================================ */
.table-felt {
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(255,255,255,0.06), transparent),
    var(--felt-table);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 18px 16px 22px;
  box-shadow:
    inset 0 0 80px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 20px 50px rgba(0,0,0,0.4);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   GAME ROWS — stock/waste/foundations & tableau
   ============================================================ */
.row-top {
  display: flex; justify-content: space-between;
  gap: 12px; margin-bottom: 20px;
  flex-wrap: wrap; align-items: flex-start;
}
.stock-waste { display: flex; gap: 10px; }
.foundations { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   CARD SLOTS (empty placeholders)
   ============================================================ */
.slot {
  width: var(--cw); height: var(--ch);
  border-radius: var(--card-r);
  border: 2px dashed rgba(255,255,255,0.22);
  position: relative; flex-shrink: 0;
  background: rgba(0,0,0,0.12);
}
.slot-suit {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: calc(var(--cw) * 0.4);
  color: rgba(255,255,255,0.16);
  pointer-events: none;
}
.empty-hint {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 1.4rem; color: rgba(255,255,255,0.28);
  pointer-events: none;
}

/* ============================================================
   TABLEAU GRID
   ============================================================ */
.tableau {
  display: grid;
  grid-template-columns: repeat(7, var(--cw));
  gap: var(--gap);
  justify-content: space-between;
  min-width: calc(7 * var(--cw) + 6 * var(--gap));
}
.tableau.spider {
  grid-template-columns: repeat(10, var(--cw));
  min-width: calc(10 * var(--cw) + 9 * var(--gap));
}

.column {
  position: relative;
  width: var(--cw);
}

/* ============================================================
   PLAYING CARDS
   ============================================================ */
.card {
  position: absolute; left: 0;
  width: var(--cw); height: var(--ch);
  border-radius: var(--card-r);
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 5px 6px;
  font-family: var(--font-body); font-weight: 700;
  user-select: none; touch-action: none; /* needed for Pointer Events drag */
  transition: box-shadow 0.12s, transform 0.12s;
  will-change: transform;
}

/* Face-up card — white with subtle shadow + border */
.card.red, .card.black {
  background: var(--card-bg);
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: 0 3px 6px rgba(0,0,0,0.22), 0 1px 2px rgba(0,0,0,0.12);
}
.card.red  { color: var(--red-suit); }
.card.black { color: var(--black-suit); }

/* Face-down — classic diagonal stripe back */
.card.face-down {
  background:
    repeating-linear-gradient(
      135deg,
      var(--card-back1) 0px, var(--card-back1) 5px,
      var(--card-back2) 5px, var(--card-back2) 10px
    );
  border: 1.5px solid var(--gold);
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  cursor: default;
}

.card .corner {
  font-size: calc(var(--cw) * 0.195);
  line-height: 1.1; display: flex;
  flex-direction: column; align-items: flex-start;
  gap: 1px;
}
.card .corner.bottom {
  align-self: flex-end; transform: rotate(180deg);
}
.card .pip {
  align-self: center;
  font-size: calc(var(--cw) * 0.36);
  line-height: 1;
  margin: auto 0;
}

/* Hover / selected / hint states */
.card.is-draggable { cursor: grab; }
.card.is-draggable:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.18);
  transform: translateY(-3px);
}
.card.is-selected {
  box-shadow: 0 0 0 3px var(--gold), 0 8px 20px rgba(0,0,0,0.35);
  transform: translateY(-4px);
}
.card.is-hint {
  box-shadow: 0 0 0 3px #4fc3f7, 0 8px 20px rgba(0,0,0,0.3);
}
.card.is-dragging {
  cursor: grabbing;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45), 0 4px 8px rgba(0,0,0,0.2);
  transform: rotate(2deg) scale(1.04);
  z-index: 2000 !important;
  transition: none;
}

/* ============================================================
   STOCK BADGE (Spider deals remaining)
   ============================================================ */
.stock-badge {
  position: absolute; bottom: -24px; left: 0; right: 0;
  text-align: center; font-size: 0.75rem;
  color: rgba(246,243,234,0.65);
  pointer-events: none;
}

/* ============================================================
   WIN OVERLAY + CONFETTI
   ============================================================ */
.win-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(11,61,46,0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.win-overlay.is-open { display: flex; }

.win-card {
  background: #fff;
  border-radius: 24px;
  padding: 40px 44px;
  max-width: 440px; width: 100%;
  text-align: center;
  box-shadow: 0 40px 100px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.12);
  animation: winPop 0.4s cubic-bezier(.34,1.56,.64,1) forwards;
  position: relative; /* sits above confetti canvas (z-index on overlay) */
  z-index: 9001;
}

@keyframes winPop {
  from { transform: scale(0.8) translateY(30px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

.win-trophy {
  font-size: 4rem; line-height: 1;
  margin-bottom: 12px;
  animation: trophyBounce 0.6s 0.3s cubic-bezier(.34,1.8,.64,1) both;
  display: block;
}
@keyframes trophyBounce {
  from { transform: scale(0) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0);      opacity: 1; }
}

.win-card h2 {
  font-family: var(--font-display);
  font-size: 2rem; margin-bottom: 8px; color: var(--ink);
}
.win-card > p {
  color: var(--ink-soft); margin-bottom: 28px; font-size: 1rem;
}

.win-actions {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
}
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--felt);
  color: var(--felt);
  font-weight: 600;
  padding: 11px 24px; border-radius: 999px;
  text-decoration: none; font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.btn-outline:hover { background: var(--felt); color: #fff; }

/* ============================================================
   CONTENT SECTIONS (SEO / articles below the game)
   ============================================================ */
.content-wrap { max-width: 880px; margin: 0 auto; padding: 52px 20px; }
.content-wrap.wide { max-width: 1200px; }
.content-wrap h2 {
  font-family: var(--font-display); font-size: 1.65rem;
  margin-top: 2.4em; margin-bottom: 0.55em; color: var(--ink);
}
.content-wrap h2:first-child { margin-top: 0; }
.content-wrap h3 { font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 0.4em; }
.content-wrap p { color: var(--ink-soft); margin-bottom: 1em; }
.content-wrap a.inline-link {
  color: var(--felt); font-weight: 600; text-decoration: underline;
  text-decoration-color: var(--gold); text-underline-offset: 3px;
}

.eyebrow {
  display: inline-block; font-size: 0.76rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--felt); background: rgba(20,84,63,0.08);
  border-radius: 999px; padding: 4px 12px; margin-bottom: 10px;
}

/* FAQ accordion */
.faq-list { border-top: 1px solid var(--line-dark); }
.faq-item { border-bottom: 1px solid var(--line-dark); padding: 16px 0; }
.faq-item summary {
  font-family: var(--font-display); font-size: 1.02rem;
  cursor: pointer; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.35rem; color: var(--felt); flex-shrink: 0; }
.faq-item[open] summary::after { content: "\2013"; }
.faq-item p { margin-top: 10px; margin-bottom: 0; }

/* How-to steps */
.howto-steps { padding-left: 1.4em; }
.howto-steps li { color: var(--ink-soft); margin-bottom: 0.6em; }

/* Game link cards */
.game-link-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 14px; margin: 22px 0; }
.game-link-card {
  display: block; text-decoration: none;
  border: 1px solid var(--line-dark); border-radius: var(--radius);
  padding: 18px; background: #fff;
  transition: box-shadow 0.15s, transform 0.15s;
}
.game-link-card:hover { box-shadow: 0 10px 28px rgba(0,0,0,0.08); transform: translateY(-2px); }
.game-link-card h3 { margin-bottom: 6px; color: var(--ink); font-family: var(--font-display); }
.game-link-card p { margin: 0; font-size: 0.9rem; color: var(--ink-soft); }

/* Callout box */
.callout {
  background: rgba(20,84,63,0.06); border-left: 4px solid var(--felt);
  border-radius: 0 10px 10px 0; padding: 14px 18px; margin: 22px 0;
}
.callout p { margin: 0; color: var(--ink); }

/* Comparison table */
table.compare { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 0.92rem; }
table.compare th, table.compare td { text-align: left; padding: 10px 12px; border-bottom: 1px solid rgba(0,0,0,0.07); }
table.compare th { color: var(--felt); font-family: var(--font-display); }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--ink); color: rgba(246,243,234,0.7);
  padding: 28px 20px; text-align: center; font-size: 0.87rem;
}
.footer-links {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 16px; margin-bottom: 14px;
}
.site-footer a { color: rgba(246,243,234,0.82); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-bottom { color: rgba(246,243,234,0.45); font-size: 0.8rem; }

/* ============================================================
   AD SLOT CONTAINERS (empty until AdSense is approved)
   ============================================================ */
.ad-slot { display: block; min-height: 0; }
.ad-slot--leaderboard { min-height: 90px; }
.ad-slot--rectangle  { min-height: 250px; max-width: 336px; margin: 0 auto; }

/* ============================================================
   UTILITIES
   ============================================================ */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Large tablets & small desktops — narrower cards */
@media (max-width: 1000px) {
  :root { --cw: 68px; --ch: 95px; --overlap: 24px; --overlap-up: 30px; --gap: 8px; }
}

/* Tablets portrait — fit 7 or 10 cols with tighter cards */
@media (max-width: 780px) {
  :root { --cw: 54px; --ch: 76px; --overlap: 20px; --overlap-up: 25px; --gap: 6px; }
  .table-felt { padding: 12px 10px 16px; border-radius: 14px; }
  .row-top { gap: 8px; margin-bottom: 14px; }
  .foundations { gap: 6px; }
  .game-titlebar h1 { font-size: 1.3rem; }
  .btn { padding: 8px 14px; font-size: 0.82rem; }
  .btn-group .btn { padding: 6px 11px; font-size: 0.78rem; }
  .stat-card { padding: 6px 12px; min-width: 70px; }
  .stat-card strong { font-size: 0.98rem; }
}

/* Phones — smallest cards that are still finger-tappable */
@media (max-width: 520px) {
  :root { --cw: 42px; --ch: 59px; --overlap: 16px; --overlap-up: 20px; --gap: 5px; }
  .table-felt { padding: 10px 8px 14px; border-radius: 10px; }
  .game-hero { padding: 14px 10px 28px; }
  .card .pip { font-size: calc(var(--cw) * 0.34); }
  .card .corner { font-size: calc(var(--cw) * 0.22); }
  .toolbar { gap: 6px; }
  .btn { padding: 8px 12px; font-size: 0.8rem; }
  .btn-group { flex-wrap: wrap; border-radius: 12px; }
  .btn-group .btn { padding: 7px 10px; font-size: 0.75rem; }
  .game-titlebar { flex-direction: column; gap: 6px; }
  .win-card { padding: 24px 20px; }
  /* Spider 10-col on small screens: allow horizontal scroll on the felt */
  .tableau.spider { min-width: calc(10 * 42px + 9 * 5px); }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, .win-card { animation: none !important; transition: none !important; }
}
