/* ==========================================================
   1. FILE: fun-wordsearch.css
   PURPOSE: Scoped layout and visual rules for Travel Word Search
   AUTHOR: Raphael Kessler Rebuild / October 2025
   ========================================================== */

/* ----------------------------------------------------------
   2. GLOBAL RESET (localised scope)
   Restricts all styling to the Word Search container only
   ---------------------------------------------------------- */

#game.game-wordsearch,
#game.game-wordsearch * {
  box-sizing: border-box;
  font-family: "Segoe UI", Arial, sans-serif;
}

/* ----------------------------------------------------------
   3. PAGE CONTAINER
   Defines layout, background, and spacing for this game only
   ---------------------------------------------------------- */

#game.game-wordsearch {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 30px 0 60px;
  background: #f9f9f9;               /* matches site base */
}

#game.game-wordsearch .ws-wrapper {
  position: relative;
  display: block;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  padding: 28px 36px;
  width: auto;
  height: auto !important;
  min-height: fit-content !important;
  margin-bottom: 40px;
  overflow: visible;
  text-align: center;
}

/* ----------------------------------------------------------
   4. GRID + WORD LIST LAYOUT
   Two-column layout: grid left, word list right
   ---------------------------------------------------------- */

#game.game-wordsearch .ws-layout {
  display: grid;
  grid-template-columns: auto 220px;
  gap: 28px;
  justify-content: center;
  align-items: start;
}

/* ----------------------------------------------------------
   5. WORD GRID
   Defines cell size, style, and hover effects
   ---------------------------------------------------------- */

#game.game-wordsearch .ws-grid {
  display: grid;
  grid-template-columns: repeat(15, 30px);
  grid-auto-rows: 30px;
  gap: 3px;
  font-family: "Courier New", monospace;
  user-select: none;
}

#game.game-wordsearch .ws-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ccc;
  border-radius: 5px;
  width: 30px;
  height: 30px;
  font-weight: 700;
  color: #333;
  background: #fff;
  cursor: pointer;
  transition: background .2s;
}

#game.game-wordsearch .ws-cell:hover {
  background: #eaf3ff;
}

#game.game-wordsearch .ws-cell.found {
  background: #4caf50;
  color: #fff;
}

/* ----------------------------------------------------------
   6. WORD LIST (RIGHT PANEL)
   Aligned vertically; words struck through once found
   ---------------------------------------------------------- */

#game.game-wordsearch .ws-side {
  text-align: left;
  font-weight: 600;
  color: #005eb8;
}

#game.game-wordsearch .ws-side ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#game.game-wordsearch .ws-side li.done {
  text-decoration: line-through;
  color: #888;
}

/* ----------------------------------------------------------
   7. RETURN BUTTON
   Fixed position under wrapper, non-overlapping
   ---------------------------------------------------------- */

#game.game-wordsearch .fun-return {
  text-align: center;
  margin-top: 24px;
}

#game.game-wordsearch .fun-return button,
#game.game-wordsearch .fun-return a {
  background: #005eb8;
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s;
  text-decoration: none;
}

#game.game-wordsearch .fun-return button:hover,
#game.game-wordsearch .fun-return a:hover {
  background: #004080;
}

/* ----------------------------------------------------------
   8. RESPONSIVE RULES
   Stack grid + list vertically below 768px
   ---------------------------------------------------------- */

@media (max-width: 768px) {
  #game.game-wordsearch .ws-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  #game.game-wordsearch .ws-side {
    text-align: center;
  }
}

/* ----------------------------------------------------------
   9. FOOTER PROTECTION
   Ensures no overlap with site footer block
   ---------------------------------------------------------- */

footer {
  position: relative !important;
  margin-top: 40px;
  z-index: 1;
}

/* ==========================================================
   fun-wordsearch.css — Word Search Styling
   raph.co.uk rebuild / October 2025
   ========================================================== */


/* ----------------------------------------------------------
   1. BASE LAYOUT
   Creates two-column layout (grid left, word list right)
   ---------------------------------------------------------- */

.ws-layout {
  display: grid;
  grid-template-columns: auto 220px;
  gap: 2rem;
  justify-content: center;
  align-items: flex-start;
  margin: 0 auto;
  padding: 1rem;
  max-width: 960px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}

@media (max-width: 768px) {
  .ws-layout {
    grid-template-columns: 1fr;
  }
}


/* ----------------------------------------------------------
   2. GRID STYLING
   Core interactive grid
   ---------------------------------------------------------- */

.ws-grid {
  border-collapse: collapse;
  user-select: none;
  justify-self: center;
}

.ws-grid td {
  width: 32px;
  height: 32px;
  text-align: center;
  border: 1px solid #ccc;
  font-size: 20px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  border-radius: 6px;
}

.ws-cell.selected {
  background: #ffd70088;
}

.ws-cell.found {
  border-radius: 8px;
}


/* ----------------------------------------------------------
   3. WORD LIST
   Fixed-width side panel for word targets
   ---------------------------------------------------------- */

.ws-side {
  min-width: 200px;
  font-size: 1.05rem;
  line-height: 1.7em;
  text-align: left;
  color: #005eb8;
}

.ws-side ul {
  margin: 0;
  padding-left: 1rem;
  list-style: none;
}

.ws-side li {
  margin-bottom: 0.25rem;
}

.ws-side li.done {
  color: #777;
  text-decoration: line-through;
}


/* ----------------------------------------------------------
   4. RETURN BUTTON
   Matches other Fun & Games pages
   ---------------------------------------------------------- */

.fun-return {
  text-align: center;
  margin-top: 2rem;
}

.fun-btn {
  background: #005eb8;
  color: #fff;
  font-size: 1rem;
  padding: 0.6rem 1.3rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.fun-btn:hover {
  background: #003f80;
}


/* ----------------------------------------------------------
   5. SPACING / FOOTER SAFETY
   Prevents overlap with footer icons
   ---------------------------------------------------------- */

#game {
  min-height: 0;
  margin-bottom: 2rem;
}

/* Geo-Memory Flip System — Final Stable Version */
.gm-card {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  perspective: 1000px;
}

.gm-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
}

.gm-card.flipped .gm-inner {
  transform: rotateY(180deg);
}

.gm-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 14px;
  overflow: hidden;
}

.gm-front {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, #003366 0%, #005eb8 100%);
}

.gm-back {
  transform: rotateY(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.gm-back img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
}
/* Geo-Memory Grid */
.gm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  justify-items: center;
  align-items: center;
  margin: 1rem auto;
  max-width: 900px;
}

/* Each card */
.gm-card {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  perspective: 1000px;
  cursor: pointer;
}

/* Inner wrapper for 3D flip */
.gm-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
}

/* Flipped state */
.gm-inner.flipped {
  transform: rotateY(180deg);
}

/* Faces (front + back) */
.gm-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 14px;
  overflow: hidden;
}

/* Front (question side) */
.gm-front {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 2rem;
  color: white;
  background: linear-gradient(135deg, #003366 0%, #005eb8 100%);
}

/* Back (image side) */
.gm-back {
  transform: rotateY(180deg);
  background: #fff;
}

.gm-back img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Matched cards stay face-up */
.gm-card.gm-matched .gm-inner {
  transform: rotateY(180deg);
  cursor: default;
}

/* Responsive tweak for small screens */
@media (max-width: 600px) {
  .gm-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
  }
  .gm-front { font-size: 1.5rem; }
}
