/*
 * wordlink.css
 * ════════════════════════════════════════════════════════════
 * ALL rules are scoped under  .wl-wrap  so they cannot
 * conflict with your WordPress theme or any other page CSS.
 *
 * CUSTOMISING FOR YOUR SITE
 * ─────────────────────────
 * Override CSS variables inside your theme stylesheet:
 *
 *   .wl-wrap {
 *     --wl-bg:      #ffffff;   ← game background
 *     --wl-surface: #f8f8f8;   ← card/panel background
 *     --wl-text:    #111111;   ← main text colour
 *   }
 *
 * Override individual components by targeting the same
 * scoped selector in your theme CSS, e.g.:
 *
 *   .wl-wrap .wl-logo { font-family: 'Your Brand Font', serif; }
 *   .wl-wrap .wl-btn-primary { background: #your-brand-colour; }
 *
 * Game-specific variables (colours, radii, transitions) are
 * all listed in the :root block of .wl-wrap below.
 * ════════════════════════════════════════════════════════════
 */

/* ── Prevent body scroll inside iframe — height is reported via postMessage ── */
html, body { margin: 0; padding: 0; overflow-x: hidden; }

/* ── Reset (scoped) ── */
.wl-wrap *, .wl-wrap *::before, .wl-wrap *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Design tokens ── */
.wl-wrap {
  /* Layout & typography */
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  line-height: 1.5;

  /* Palette — override these in your theme to restyle the game */
  --wl-bg:               #f7f5f0;
  --wl-surface:          #ffffff;
  --wl-border:           #e2ddd6;
  --wl-text:             #1a1814;
  --wl-text-muted:       #7a7570;
  --wl-tile-bg:          #f0ece4;
  --wl-tile-hover:       #e8e2d8;
  --wl-tile-selected:    #1a1814;
  --wl-tile-sel-text:    #ffffff;

  /* Group colours (solved cards) */
  --wl-yellow-bg:        #f5c842;
  --wl-yellow-light:     #fdf4c5;
  --wl-yellow-text:      #5a4a00;
  --wl-green-bg:         #4caf6e;
  --wl-green-light:      #d4f0dc;
  --wl-green-text:       #0f4021;
  --wl-blue-bg:          #4a90d9;
  --wl-blue-light:       #d0e8f8;
  --wl-blue-text:        #0c2e5a;
  --wl-purple-bg:        #9b6dd6;
  --wl-purple-light:     #ead6f8;
  --wl-purple-text:      #300a5c;

  /* Difficulty dot colours (used in badges & legend) */
  --wl-dot-easy:         #f0b800;
  --wl-dot-medium:       #3a9e5c;
  --wl-dot-hard:         #3478c0;
  --wl-dot-tricky:       #7e52be;

  /* Geometry */
  --wl-radius:           10px;
  --wl-radius-sm:        6px;
  --wl-radius-pill:      100px;
  --wl-max-width:        640px;

  /* Motion */
  --wl-transition:       0.18s ease;

  /* Layout */
  background: var(--wl-bg);
  color: var(--wl-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 48px;
}

/* ────────────────────────────────────────────
   HEADER
   ──────────────────────────────────────────── */
.wl-wrap .wl-header {
  width: 100%;
  max-width: var(--wl-max-width);
  padding: 24px 0 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--wl-border);
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.wl-wrap .wl-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  color: var(--wl-text);
}

.wl-wrap .wl-logo span {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 300;
  color: var(--wl-text-muted);
  margin-top: 2px;
  letter-spacing: 0;
}

.wl-wrap .wl-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Language pill toggle */
.wl-wrap .wl-pill-toggle {
  display: flex;
  background: var(--wl-tile-bg);
  border-radius: var(--wl-radius-pill);
  padding: 3px;
}

.wl-wrap .wl-pill-btn {
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--wl-text-muted);
  padding: 5px 13px;
  border-radius: var(--wl-radius-pill);
  cursor: pointer;
  transition: var(--wl-transition);
  white-space: nowrap;
}

.wl-wrap .wl-pill-btn.active {
  background: var(--wl-text);
  color: #fff;
}

/* ────────────────────────────────────────────
   MAIN CONTENT WRAPPER
   ──────────────────────────────────────────── */
.wl-wrap main {
  width: 100%;
  max-width: var(--wl-max-width);
}

/* ────────────────────────────────────────────
   LEVEL SELECT SCREEN
   ──────────────────────────────────────────── */
.wl-wrap #wl-level-screen {
  width: 100%;
  text-align: center;
  padding: 10px 0 30px;
}

.wl-wrap #wl-level-screen h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  color: var(--wl-text);
}

.wl-wrap #wl-level-screen p {
  font-size: 0.88rem;
  color: var(--wl-text-muted);
  margin-bottom: 28px;
  line-height: 1.6;
}

.wl-wrap .wl-level-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.wl-wrap .wl-level-card {
  background: var(--wl-surface);
  border: 2px solid var(--wl-border);
  border-radius: var(--wl-radius);
  padding: 20px 14px 18px;
  cursor: pointer;
  transition: border-color var(--wl-transition), transform 0.12s ease, box-shadow var(--wl-transition);
  text-align: center;
  /* tap highlight for mobile */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.wl-wrap .wl-level-card:hover {
  border-color: var(--wl-text);
  transform: translateY(-2px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.08);
}

.wl-wrap .wl-level-card.wl-selected-level {
  border-color: var(--wl-text);
  background: var(--wl-text);
  color: #fff;
}

.wl-wrap .wl-level-emoji  { font-size: 1.8rem; margin-bottom: 8px; }
.wl-wrap .wl-level-name   { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.wl-wrap .wl-level-name-fr{ font-size: 0.75rem; font-weight: 400; opacity: 0.6; margin-bottom: 8px; font-style: italic; }
.wl-wrap .wl-level-desc   { font-size: 0.75rem; line-height: 1.5; opacity: 0.7; }

.wl-wrap .wl-level-dots {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 10px;
}

.wl-wrap .wl-ld {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.wl-wrap .wl-btn-start {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  background: var(--wl-text);
  color: #fff;
  border: none;
  border-radius: var(--wl-radius-pill);
  padding: 13px 36px;
  cursor: pointer;
  transition: var(--wl-transition);
  letter-spacing: 0.02em;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.wl-wrap .wl-btn-start:hover    { background: #333; }
.wl-wrap .wl-btn-start:disabled { background: #ccc; cursor: not-allowed; opacity: 0.5; }

/* ────────────────────────────────────────────
   GAME SCREEN
   ──────────────────────────────────────────── */
/* display controlled by JS — do not set display:none here */
.wl-wrap #wl-game-screen { width: 100%; }

.wl-wrap .wl-game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 10px;
  flex-wrap: wrap;
}

.wl-wrap .wl-game-level-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--wl-surface);
  border: 1px solid var(--wl-border);
  border-radius: var(--wl-radius-pill);
  padding: 5px 13px 5px 8px;
}

.wl-wrap .wl-badge-dot-row { display: flex; gap: 3px; }

.wl-wrap .wl-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.wl-wrap .wl-btn-change-level {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  background: none;
  border: 1px solid var(--wl-border);
  border-radius: var(--wl-radius-pill);
  padding: 5px 13px;
  cursor: pointer;
  color: var(--wl-text-muted);
  transition: var(--wl-transition);
}

.wl-wrap .wl-btn-change-level:hover {
  background: var(--wl-tile-bg);
  color: var(--wl-text);
}

/* ────────────────────────────────────────────
   INSTRUCTIONS PANEL
   ──────────────────────────────────────────── */
.wl-wrap .wl-instructions {
  background: var(--wl-surface);
  border: 1px solid var(--wl-border);
  border-radius: var(--wl-radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.wl-wrap .wl-icon   { font-size: 1.2rem; flex-shrink: 0; margin-top: 1px; }

.wl-wrap .wl-instructions p {
  font-size: 0.85rem;
  color: var(--wl-text-muted);
  line-height: 1.6;
}

.wl-wrap .wl-instructions strong { color: var(--wl-text); font-weight: 600; }

/* ────────────────────────────────────────────
   SOLVED GROUPS
   ──────────────────────────────────────────── */
.wl-wrap #wl-solved-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.wl-wrap .wl-solved-group {
  border-radius: var(--wl-radius);
  padding: 14px 18px;
  animation: wlSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes wlSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.wl-wrap .wl-sg-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.wl-wrap .wl-sg-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.65;
}

.wl-wrap .wl-trans-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  background: none;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: var(--wl-radius-pill);
  padding: 2px 10px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
  color: inherit;
}

.wl-wrap .wl-trans-btn:hover { opacity: 1; }

.wl-wrap .wl-sg-title {
  font-size: 0.93rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.wl-wrap .wl-sg-title-fr {
  font-weight: 400;
  opacity: 0.55;
  font-size: 0.8rem;
}

.wl-wrap .wl-sg-words {
  font-size: 0.83rem;
  font-weight: 400;
  opacity: 0.85;
  margin-bottom: 6px;
}

.wl-wrap .wl-sg-explanation {
  font-size: 0.78rem;
  line-height: 1.55;
  border-top: 1px solid rgba(0,0,0,0.08);
  padding-top: 7px;
  margin-top: 4px;
}

.wl-wrap .wl-exp-row { margin-bottom: 6px; }
.wl-wrap .wl-exp-word    { font-weight: 700; }
.wl-wrap .wl-exp-example { font-style: italic; opacity: 0.7; font-size: 0.72rem; }
.wl-wrap .wl-exp-fr {
  font-style: italic;
  opacity: 0.75;
  margin-top: 2px;
  padding-left: 8px;
  border-left: 2px solid rgba(0,0,0,0.12);
  font-size: 0.76rem;
}

/* ────────────────────────────────────────────
   TILE GRID
   ──────────────────────────────────────────── */
.wl-wrap #wl-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.wl-wrap .wl-tile {
  background: var(--wl-tile-bg);
  border: 2px solid transparent;
  border-radius: var(--wl-radius);
  padding: 0 8px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.93rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  color: var(--wl-text);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    background var(--wl-transition),
    border-color var(--wl-transition),
    color var(--wl-transition),
    transform 0.12s ease;
}

.wl-wrap .wl-tile:hover:not(.wl-selected) {
  background: var(--wl-tile-hover);
}

.wl-wrap .wl-tile.wl-selected {
  background: var(--wl-tile-selected);
  color: var(--wl-tile-sel-text);
  border-color: var(--wl-tile-selected);
  transform: translateY(-2px);
}

.wl-wrap .wl-tile.wl-shake { animation: wlShake 0.45s ease; }

@keyframes wlShake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

.wl-wrap .wl-tile.wl-pop { animation: wlPop 0.28s cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes wlPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}

/* ────────────────────────────────────────────
   MISTAKES ROW  (horizontal dots)
   ──────────────────────────────────────────── */
.wl-wrap .wl-mistakes-row {
  display: flex;
  flex-direction: row;       /* keep horizontal */
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 0.82rem;
  color: var(--wl-text-muted);
  font-weight: 500;
}

.wl-wrap .wl-dots-row {
  display: flex;
  flex-direction: row;       /* explicit — never vertical */
  gap: 6px;
  align-items: center;
}

.wl-wrap .wl-mistake-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--wl-text);
  flex-shrink: 0;
  transition: background 0.3s, transform 0.2s;
}

.wl-wrap .wl-mistake-dot.wl-used {
  background: #d4c8b8;
  transform: scale(0.85);
}

/* ────────────────────────────────────────────
   CONTROLS
   ──────────────────────────────────────────── */
.wl-wrap .wl-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.wl-wrap .wl-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  border: none;
  border-radius: var(--wl-radius-pill);
  padding: 10px 20px;
  cursor: pointer;
  transition: var(--wl-transition);
  letter-spacing: 0.02em;
  line-height: 1;
}

.wl-wrap .wl-btn-primary             { background: var(--wl-text); color: #fff; }
.wl-wrap .wl-btn-primary:hover       { background: #333; }
.wl-wrap .wl-btn-primary:disabled    { background: #ccc; cursor: not-allowed; }
.wl-wrap .wl-btn-secondary           { background: var(--wl-surface); color: var(--wl-text); border: 1px solid var(--wl-border); }
.wl-wrap .wl-btn-secondary:hover     { background: var(--wl-tile-bg); }
.wl-wrap .wl-btn-secondary:disabled  { opacity: 0.38; cursor: not-allowed; }

/* ────────────────────────────────────────────
   HINT PANEL
   ──────────────────────────────────────────── */
.wl-wrap .wl-hint-panel {
  background: var(--wl-surface);
  border: 1px solid var(--wl-border);
  border-radius: var(--wl-radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: none;
  animation: wlFadeIn 0.22s ease;
}

.wl-wrap .wl-hint-panel.wl-visible { display: block; }

.wl-wrap .wl-hint-panel h3 {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--wl-text-muted);
  margin-bottom: 10px;
}

.wl-wrap .wl-hint-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--wl-border);
  font-size: 0.84rem;
  line-height: 1.5;
}

.wl-wrap .wl-hint-item:first-of-type { border-top: none; }

.wl-wrap .wl-hint-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.wl-wrap .wl-hint-sub {
  font-size: 0.75rem;
  color: var(--wl-text-muted);
  margin-top: 1px;
}

/* ────────────────────────────────────────────
   WIN SCREEN
   ──────────────────────────────────────────── */
.wl-wrap #wl-win-screen {
  display: none;
  text-align: center;
  padding: 22px 0 0;
  animation: wlFadeIn 0.4s ease;
}

.wl-wrap #wl-win-screen h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.75rem;
  margin-bottom: 8px;
  color: var(--wl-text);
}

.wl-wrap #wl-win-screen p {
  color: var(--wl-text-muted);
  font-size: 0.88rem;
  margin-bottom: 18px;
}

/* ────────────────────────────────────────────
   FOOTER
   ──────────────────────────────────────────── */
.wl-wrap .wl-footer {
  margin-top: 36px;
  font-size: 0.73rem;
  color: var(--wl-text-muted);
  text-align: center;
  line-height: 1.9;
}

/* ────────────────────────────────────────────
   TOAST  (outside .wl-wrap, fixed position)
   ──────────────────────────────────────────── */
#wl-toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: #1a1814;
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 9px 22px;
  border-radius: 100px;
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 9999;
}

#wl-toast.wl-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ────────────────────────────────────────────
   SHARED ANIMATION
   ──────────────────────────────────────────── */
@keyframes wlFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ────────────────────────────────────────────
   RESPONSIVE
   ──────────────────────────────────────────── */

/* Tablet */
@media (max-width: 640px) {
  .wl-wrap {
    padding: 0 10px 32px;
  }
  .wl-wrap .wl-header {
    padding: 16px 0 14px;
    margin-bottom: 16px;
  }
  .wl-wrap .wl-level-cards {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .wl-wrap .wl-level-card {
    /* Horizontal layout on small screens */
    display: grid;
    grid-template-columns: 2.4rem 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 0 10px;
    padding: 12px 14px;
    text-align: left;
  }
  .wl-wrap .wl-level-emoji {
    font-size: 1.5rem;
    margin-bottom: 0;
    grid-row: 1 / 3;
    grid-column: 1;
    text-align: center;
  }
  .wl-wrap .wl-level-name {
    grid-row: 1;
    grid-column: 2;
    margin-bottom: 0;
    font-size: 0.95rem;
  }
  .wl-wrap .wl-level-name-fr {
    grid-row: 2;
    grid-column: 2;
    margin-bottom: 0;
    font-size: 0.72rem;
  }
  .wl-wrap .wl-level-desc {
    grid-row: 1 / 3;
    grid-column: 3;
    font-size: 0.72rem;
    text-align: right;
    max-width: 140px;
  }
  .wl-wrap .wl-level-dots {
    display: none; /* hidden on mobile — colour of border is enough */
  }
  .wl-wrap .wl-btn-start {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    margin-top: 4px;
  }
  .wl-wrap #wl-level-screen {
    padding: 8px 0 20px;
  }
  .wl-wrap #wl-level-screen p {
    font-size: 0.82rem;
    margin-bottom: 16px;
  }
}

/* Phone */
@media (max-width: 480px) {
  .wl-wrap .wl-logo            { font-size: 1.25rem; }
  .wl-wrap .wl-tile            { font-size: 0.78rem; height: 56px; }
  .wl-wrap .wl-controls        { gap: 5px; }
  .wl-wrap .wl-btn             { padding: 9px 12px; font-size: 0.78rem; }
  .wl-wrap .wl-level-desc      { display: none; } /* too cramped on very small screens */
  .wl-wrap .wl-level-card      { grid-template-columns: 2.2rem 1fr; }
  .wl-wrap .wl-level-name      { font-size: 0.88rem; }
  .wl-wrap .wl-game-topbar     { margin-bottom: 12px; }
  .wl-wrap .wl-instructions    { padding: 10px 12px; }
  .wl-wrap .wl-instructions p  { font-size: 0.8rem; }
  .wl-wrap #wl-grid            { gap: 6px; }
}
