/**
 * Word game — front-end styles for word-game-template.php.
 * Mirrors the sorting game's layout/chrome (Poppins, purple accent) with the
 * guess grid and on-screen keyboard on top.
 */

.word-game-wrap {
  max-width: 1200px; /* match the site content width (header/nav) */
  margin: 0 auto;
  /* Padding, not margin: a top margin collapses through #starlord_container
     (same gotcha the sorting game hit). */
  padding: 2rem 1rem 0;
}

.word-game {
  --wg-accent: #b898ff;
  --wg-accent-dark: #7c4dff;
  --wg-ink: #1a1a1a;
  --wg-muted: #6b6b72;
  --wg-line: #e6e6ec;
  --wg-radius: 12px;
  --wg-correct: #2f9e44; /* right letter, right spot */
  --wg-present: #f08c00; /* right letter, wrong spot */
  --wg-absent: #e03131;  /* letter not in the word */
  font-family: 'Poppins', system-ui, sans-serif;
  color: var(--wg-ink);
  /* Content uses the full width; a sticky skyscraper siderail sits beside it
     on desktop, with the grid gap as the gutter between them. */
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 2rem;
  align-items: start;
}
.word-game__main { min-width: 0; }
/* House-consistent bottom gutter beneath the last block (usually the board). */
.word-game__main > :last-child { margin-bottom: 3rem; }

/* Skyscraper siderail (160x600 / 300x600), sticky, desktop only. */
.word-game__siderail {
  position: sticky;
  top: 16px;
  align-self: start;
  width: 300px;
  min-height: 600px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* Video MREC shown only below the tablet breakpoint, where the siderail is gone. */
.word-game__video-mrec { display: none; }

@media (max-width: 991.98px) {
  .word-game { grid-template-columns: 1fr; }
  .word-game__siderail { display: none; }
  .word-game__video-mrec {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 250px;
    margin: 1.5rem 0;
  }
}

/* Breadcrumb back to /games (same style as the sorting game pages). */
.word-game__breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 .75rem;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--wg-accent-dark);
  text-transform: uppercase;
  letter-spacing: .08em;
  text-decoration: none;
}
.word-game__breadcrumb:hover,
.word-game__breadcrumb:focus-visible {
  color: #5b2ec4;
  text-decoration: none;
}
.word-game__breadcrumb-arrow {
  display: inline-block;
  transform: translateX(-2px);
}

/* Hero — the feature image, shown clean (no overlay, scrim or visible title:
   the artwork carries its own lettering). The h1 is screen-reader-only. */
.word-game__hero { margin-bottom: 1.5rem; }
.word-game__hero-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  border-radius: .5rem;
}
.word-game__title.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Intro / explainer (the post body copy) ---------------------------------- */
.word-game__intro {
  margin: 0 0 1.5rem;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--wg-ink);
}
.word-game__intro > :first-child { margin-top: 0; }
.word-game__intro > :last-child { margin-bottom: 0; }
.word-game__intro p { margin: 0 0 1rem; }

/* Play area --------------------------------------------------------------- */
.word-game__prompt { font-weight: 600; margin: 1.25rem 0 .6rem; }

/* Colour legend (what green/orange/red mean). */
.word-game__legend {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  margin: 0 0 1rem;
  font-size: .82rem;
  color: var(--wg-muted);
}
.word-game__legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.word-game__legend-tile {
  width: .95rem;
  height: .95rem;
  border-radius: 4px;
  display: inline-block;
}
.word-game__legend-tile.is-correct { background: var(--wg-correct); }
.word-game__legend-tile.is-present { background: var(--wg-present); }
.word-game__legend-tile.is-absent { background: var(--wg-absent); }

/* Difficulty picker. */
.word-game__levels {
  display: flex;
  justify-content: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin: 0 0 1.1rem;
}
.word-game__level {
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  padding: .55rem 1.2rem;
  background: #fff;
  border: 2px solid var(--wg-line);
  border-radius: var(--wg-radius);
  cursor: pointer;
  color: var(--wg-ink);
}
.word-game__level:hover { border-color: var(--wg-accent); }
.word-game__level.is-selected {
  border-color: var(--wg-accent-dark);
  background: #f4f0ff;
}
.word-game__level:disabled { opacity: .55; cursor: default; }
.word-game__level-name { font-weight: 700; }
.word-game__level-detail { font-size: .78rem; color: var(--wg-muted); }

/* Guess grid --------------------------------------------------------------- */
.word-game__grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  margin: 0 0 1rem;
}
.word-game__row {
  display: grid;
  grid-template-columns: repeat(var(--wg-cols, 5), minmax(0, 3.4rem));
  gap: .4rem;
}
.word-game__tile {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border: 2px solid var(--wg-line);
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
  font-size: 1.4rem;
  text-transform: uppercase;
  user-select: none;
  -webkit-user-select: none;
}
.word-game__tile.is-filled { border-color: var(--wg-accent); }
.word-game__tile.is-correct { background: var(--wg-correct); border-color: var(--wg-correct); color: #fff; }
.word-game__tile.is-present { background: var(--wg-present); border-color: var(--wg-present); color: #fff; }
.word-game__tile.is-absent { background: var(--wg-absent); border-color: var(--wg-absent); color: #fff; }

/* Not-a-word feedback: shake the active row. */
.word-game__row.is-shake { animation: wg-shake .45s ease; }
@keyframes wg-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* On-screen keyboard -------------------------------------------------------- */
.word-game__keyboard {
  margin: .5rem auto 0;
  max-width: 34rem;
}
.word-game__keyboard[hidden] { display: none; }
.word-game__key-row {
  display: flex;
  justify-content: center;
  gap: .3rem;
  margin-bottom: .3rem;
}
.word-game__key {
  font: inherit;
  font-weight: 600;
  flex: 1 1 0;
  max-width: 2.9rem;
  min-width: 0;
  padding: .65rem 0;
  border: 1px solid var(--wg-line);
  border-radius: 6px;
  background: #f2f2f6;
  color: var(--wg-ink);
  cursor: pointer;
  text-transform: uppercase;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.word-game__key:hover { background: #e7e2f7; }
.word-game__key--wide { max-width: 4.6rem; flex: 1.6 1 0; font-size: .8rem; }
.word-game__key.is-correct { background: var(--wg-correct); border-color: var(--wg-correct); color: #fff; }
.word-game__key.is-present { background: var(--wg-present); border-color: var(--wg-present); color: #fff; }
.word-game__key.is-absent { background: var(--wg-absent); border-color: var(--wg-absent); color: #fff; }

/* Controls ---------------------------------------------------------------- */
.word-game__controls { display: flex; justify-content: center; align-items: center; gap: 1.25rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.word-game__btn {
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  padding: .6rem 1.4rem;
  cursor: pointer;
  border: 2px solid transparent;
}
.word-game__btn--primary { background: var(--wg-accent-dark); color: #fff; }
.word-game__btn--primary:hover { background: #6a3df0; }
.word-game__btn--primary:disabled { opacity: .5; cursor: default; }
.word-game__btn--ghost { background: transparent; border-color: var(--wg-accent); color: var(--wg-accent-dark); }

.word-game__status { margin: 0; color: var(--wg-muted); flex: 1 1 100%; text-align: center; min-width: 0; }
.word-game__status:empty { display: none; }
.word-game__noscript { color: #e53935; }

/* Result + form ----------------------------------------------------------- */
.word-game__result {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border: 1px solid var(--wg-line);
  border-radius: var(--wg-radius);
  background: #faf8ff;
}
.word-game__score { font-size: 1.2rem; margin: 0 0 1rem; }
.word-game__score strong { color: var(--wg-accent-dark); }
.word-game__form[hidden] { display: none; }
.word-game__form-intro { font-weight: 600; margin: 0 0 .6rem; }
.word-game__form-note { margin: 0 0 .8rem; font-size: .78rem; line-height: 1.4; color: var(--wg-muted, #666); }
/* "Known player" mode: we already have their details — drop the whole sign-up
   prompt and leave just the manual "Submit to leaderboard" button. */
.word-game__form.is-known [data-lb-intro],
.word-game__form.is-known [data-lb-note],
.word-game__form.is-known [data-lb-fields],
.word-game__form.is-known [data-lb-consent] { display: none; }

/* Known-player recognition banner (shown on load, above the game board). */
.word-game__known {
  margin: 0 0 1.25rem;
  padding: .9rem 1.1rem;
  border: 1px solid var(--wg-line);
  border-radius: var(--wg-radius);
  background: #faf8ff;
}
.word-game__known-name { font-weight: 700; margin: 0 0 .3rem; }
.word-game__known .word-game__form-note { margin: 0; }
.word-game__fields { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.word-game__field { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; }
.word-game__field:last-of-type { grid-column: 1 / -1; }
.word-game__field input {
  font: inherit;
  padding: .55rem .7rem;
  border: 1px solid var(--wg-line);
  border-radius: 8px;
}
.word-game__field input:focus-visible { outline: 2px solid var(--wg-accent-dark); outline-offset: 1px; }
.word-game__form button[type="submit"] { margin-top: .9rem; }
.word-game__form-feedback { margin: .6rem 0 0; font-size: .9rem; color: var(--wg-accent-dark); min-height: 1.1em; }
/* Honeypot — visually hidden but present in the DOM for bots. */
.word-game__hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Marketing-consent opt-in (unticked by default). */
.word-game__consent { display: flex; align-items: flex-start; gap: .5rem; margin: .2rem 0 .9rem; font-size: .82rem; line-height: 1.35; color: var(--wg-ink, #333); cursor: pointer; }
.word-game__consent input { flex: 0 0 auto; margin-top: .15rem; }

/* Leaderboard ------------------------------------------------------------- */
.word-game__leaderboard { margin-top: 2rem; }
.word-game__leaderboard-title { font-size: 1.3rem; margin: 0 0 .75rem; }
.word-game__board { list-style: none; margin: 0; padding: 0; }
.word-game__board-row {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  align-items: center;
  gap: .5rem;
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--wg-line);
}
.word-game__board-row.is-me {
  background: #f4f0ff;
  border-radius: 8px;
  border-bottom-color: transparent;
  font-weight: 600;
}
.word-game__board-row.is-me em { color: var(--wg-accent-dark); font-style: normal; font-size: .8rem; }
.word-game__board-rank { font-weight: 700; color: var(--wg-accent-dark); }
.word-game__board-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-game__board-score { font-variant-numeric: tabular-nums; font-weight: 600; }
/* "Your position" break between the top 10 and an out-of-top-10 player. */
.word-game__board-sep {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin: .4rem 0;
  padding: .3rem 0;
  color: var(--wg-accent-dark);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.word-game__board-sep::before,
.word-game__board-sep::after {
  content: '';
  flex: 1;
  height: 0;
  border-top: 2px dashed var(--wg-accent);
  opacity: .8;
}
.word-game__board-empty { color: var(--wg-muted); font-style: italic; padding: .6rem .8rem; }
.word-game__board-note { margin: .8rem 0 0; font-size: .8rem; color: var(--wg-muted); }

@media (max-width: 560px) {
  .word-game__fields { grid-template-columns: 1fr; }
  .word-game__field:last-of-type { grid-column: auto; }
  .word-game__row { grid-template-columns: repeat(var(--wg-cols, 5), minmax(0, 2.9rem)); }
  .word-game__tile { font-size: 1.2rem; }
  .word-game__key { padding: .8rem 0; }
}
