/* Opaque white content card — matches the lesson card so the word backdrop
   never bleeds through (lessons use a solid card, not the frosted game one). */
.game-card {
  background: #fff;
}

/* Tap-feedback easings, shared by every pressable button here.
   --press-quick: a fast, decisive press-down.
   --press-spring: a gentle overshoot on release, so the button settles back
   with a refined, tactile bounce instead of a flat snap. */
:root {
  --press-quick: cubic-bezier(0.3, 0, 0.2, 1);
  --press-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
}

/* ── Intro section ── */
.lesson-tip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(47, 159, 232, 0.07);
  border: 1px solid rgba(47, 159, 232, 0.18);
  border-radius: 12px;
  margin-bottom: 24px;
}

.lesson-tip p {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #173b50;
  margin: 0;
  line-height: 1.55;
}

.lesson-tip strong {
  color: var(--primary);
}

.match-intro-text {
  font-size: 1.06rem;
  font-weight: 600;
  color: #173b50;
  line-height: 1.7;
  margin: 0 0 24px;
  font-family: "Source Sans 3", sans-serif;
}


.match-section-label,
.match-note-label {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: "Source Sans 3", sans-serif;
  margin: 0 0 12px;
}

.match-pronoun-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.match-pronoun-card {
  background: rgba(47, 159, 232, 0.06);
  border: 2px solid rgba(47, 159, 232, 0.2);
  border-radius: 16px;
  padding: 20px 10px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  /* Elevated slab press — same button style as the other games. The slab is a
     box-shadow, so pressing never reflows the grid. */
  box-shadow: 0 4px 0 rgba(47, 159, 232, 0.28);
  /* Release settles back with a soft spring; colour shifts stay calm. */
  transition: transform 0.26s var(--press-spring),
              box-shadow 0.26s var(--press-spring),
              background 0.15s ease, border-color 0.15s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* no 300ms tap delay / double-tap zoom on mobile */
}

.match-pronoun-card:focus { outline: none; }
.match-pronoun-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Hover lift only on real pointing devices, so a touch tap doesn't leave the
   card stuck in the lifted/hover state ("sticky hover"). */
@media (hover: hover) {
  .match-pronoun-card:hover {
    background: rgba(47, 159, 232, 0.12);
    border-color: rgba(47, 159, 232, 0.4);
    box-shadow: 0 6px 0 rgba(47, 159, 232, 0.42);
    transform: translateY(-2px);
  }
}

/* Press drops onto the slab with a subtle squash — quick on the way down, then
   the base spring eases it back on release. */
.match-pronoun-card:active {
  transform: translateY(3px) scale(0.97);
  box-shadow: 0 1px 0 rgba(47, 159, 232, 0.28);
  transition: transform 0.07s var(--press-quick), box-shadow 0.07s var(--press-quick);
}

.match-pronoun-lt {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--text);
  font-family: "Nunito", sans-serif;
}

.match-pronoun-en {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  font-family: "Source Sans 3", sans-serif;
}

/* Playing state — highlight the card while its clip is sounding. */
.match-pronoun-card--playing {
  background: rgba(47, 159, 232, 0.14);
  border-color: var(--primary);
}

.match-note {
  font-family: "Source Sans 3", sans-serif;
}

.match-note p {
  font-size: 1.06rem;
  font-weight: 600;
  color: #173b50;
  line-height: 1.7;
  margin: 0 0 8px;
  font-family: "Source Sans 3", sans-serif;
}

.match-note p:last-child { margin-bottom: 0; }
.match-note strong { color: var(--primary); font-weight: 800; }

.match-game-instruction {
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  margin: 0 0 20px;
}

@media (max-width: 480px) {
  .match-pronoun-grid { gap: 8px; }
  .match-pronoun-card { padding: 16px 8px 12px; border-radius: 13px; }
  .match-pronoun-lt { font-size: 1.2rem; }
  .match-pronoun-en { font-size: 0.72rem; }
  .match-intro-text,
  .match-note p { font-size: 1.06rem; line-height: 1.7; }
  .match-section-label,
  .match-note-label { font-size: 0.78rem; }
}

/* ── Eyebrow ── */
.match-eyebrow {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  text-align: center;
  margin: 0 0 6px;
  font-family: "Nunito", sans-serif;
}

/* ── Info panel ── */
.match-info {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 14px;
  padding: 14px 16px 10px;
  margin-bottom: 24px;
}

.match-info-body {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.65;
  font-family: "Source Sans 3", sans-serif;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 200px;
  opacity: 1;
}

.match-info-body p { margin: 0 0 6px; }
.match-info-body p:last-child { margin-bottom: 8px; }
.match-info-body strong { color: var(--text); font-weight: 700; }

.match-info-body--hidden {
  max-height: 0;
  opacity: 0;
}

.match-info-toggle {
  background: none;
  border: none;
  font-size: 0.78rem;
  font-weight: 800;
  font-family: "Nunito", sans-serif;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  letter-spacing: 0.03em;
}

/* ── Match grid ── */
.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.match-col {
  display: grid;
  grid-auto-rows: 1fr;   /* equal-height rows; both columns stretch to match */
  gap: 8px;
}

/* ── Cards ── */
.match-card {
  width: 100%;
  padding: 20px 12px;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 800;
  font-family: "Nunito", sans-serif;
  cursor: pointer;
  text-align: center;
  /* Centre the label so short and multi-line cards read alike at equal height. */
  display: flex;
  align-items: center;
  justify-content: center;
  /* Elevated slab press — same button style as the other games. */
  box-shadow: 0 4px 0 rgba(6, 38, 61, 0.16);
  transition: transform 0.26s var(--press-spring),
              box-shadow 0.26s var(--press-spring),
              border-color 0.15s ease, background 0.15s ease;
  line-height: 1.3;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* no 300ms tap delay / double-tap zoom on mobile */
  letter-spacing: -0.01em;
}
.match-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Hover only on real pointers AND only on neutral tiles — never override the
   selected/matched/wrong colours, so no blue lingers on a tapped tile. */
@media (hover: hover) {
  .match-card:hover:not(:disabled):not(.match-card--selected):not(.match-card--matched):not(.match-card--wrong) {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 6px 0 rgba(47, 159, 232, 0.4);
    transform: translateY(-2px);
  }
}

.match-card:active:not(:disabled) {
  transform: translateY(3px) scale(0.97);
  box-shadow: 0 1px 0 rgba(6, 38, 61, 0.16);
  transition: transform 0.07s var(--press-quick), box-shadow 0.07s var(--press-quick);
}

.match-card--selected {
  border-color: var(--primary) !important;
  background: #bde3f8 !important;
  color: var(--primary) !important;
  box-shadow: 0 4px 0 var(--primary-dark) !important;
  transform: translateY(-2px);
}

.match-card--matched {
  border-color: #34c989;
  background: rgba(52, 201, 137, 0.12);
  color: #1a7a50;
  box-shadow: 0 4px 0 #1fae72;
  cursor: default;
  transform: none;
}

@keyframes wrong-shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-5px); }
  75%       { transform: translateX(5px); }
}

.match-card--wrong {
  border-color: #f05c5c;
  background: rgba(240, 92, 92, 0.1);
  color: #b83232;
  box-shadow: 0 4px 0 #d83c3c;
  animation: wrong-shake 0.35s ease both;
}

@media (max-width: 640px) {
  .match-grid { gap: 8px; }
  .match-card { padding: 18px 10px; font-size: 1rem; border-radius: 14px; }
}

/* ── Footer & score-modal nav buttons ───────────────────────────────────────
   Elevated, pressable slab — matches the nav buttons in the lessons and the
   other games (e.g. the drag game), replacing base.css's flat .nav-btn. The
   slab is a box-shadow so pressing never reflows the footer. */
.nav-btn {
  padding: 14px 24px;
  border-radius: 14px;
  border: 2px solid rgba(6, 38, 61, 0.12);
  background: #fff;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 800;
  font-family: "Nunito", sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(6, 38, 61, 0.2);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* no 300ms tap delay / double-tap zoom on mobile */
  transition: transform 0.26s var(--press-spring),
              box-shadow 0.26s var(--press-spring),
              background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

@media (hover: hover) {
  .nav-btn:hover:not(:disabled) {
    background: rgba(47, 159, 232, 0.08);
    border-color: rgba(47, 159, 232, 0.35);
    box-shadow: 0 4px 0 rgba(47, 159, 232, 0.5);
    color: var(--primary);
    transform: translateY(-2px);
  }
}

.nav-btn:active:not(:disabled) {
  transform: translateY(3px) scale(0.98);
  box-shadow: 0 1px 0 rgba(6, 38, 61, 0.2);
  transition: transform 0.07s var(--press-quick), box-shadow 0.07s var(--press-quick);
}

.nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.nav-btn--primary {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 0 var(--primary-dark);
}

@media (hover: hover) {
  .nav-btn--primary:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 0 var(--primary-dark);
    transform: translateY(-2px);
  }
}

/* Both footer buttons share one box: equal width (flex with a shared cap) and
   equal height (same padding/font + no wrap) — like the lesson nav. The score
   modal's buttons live in .score-actions, so they're unaffected. */
.footer-actions .nav-btn {
  flex: 1 1 0;
  max-width: 210px;
  text-align: center;
  white-space: nowrap;
}

/* ── Fit the matching game to one view ───────────────────────────────────────
   ONLY while the matching activity is showing (gameSection visible). The learn
   screen stays a normal, scrollable page of its own. The grid fills the frame
   and its equal-height rows (1fr) shrink the cards so it all fits, no scroll. */
body:has(#gameSection:not([hidden])) { overflow: hidden; }

body:has(#gameSection:not([hidden])) .page-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  border: none;
  border-radius: 0;
  height: calc(100vh - 86px);
  min-height: 0;
  display: flex;
}
body:has(#gameSection:not([hidden])) .game { flex: 1; min-height: 0; display: flex; }
body:has(#gameSection:not([hidden])) .game-wrap { flex: 1; min-height: 0; display: flex; padding-top: 20px; padding-bottom: 20px; }
body:has(#gameSection:not([hidden])) .game-card {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
}

/* The activity column fills the remaining height; the grid's 1fr rows + the
   min-height:0 below let the cards shrink so everything fits with no scroll. */
#gameSection:not([hidden]) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#gameSection .match-grid {
  flex: 1;
  min-height: 0;
  grid-template-rows: 1fr;
}
#gameSection .footer-actions { margin-top: 16px; }

/* Flex columns + flex:1 cards reliably divide the bounded height equally, so
   the cards shrink to fit (grid 1fr won't shrink below the text's height). */
#gameSection .match-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#gameSection .match-card {
  min-height: 0;
  flex: 1 1 0;
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: clamp(0.78rem, 2.4vw, 1.1rem);
  line-height: 1.2;
}

@media (max-width: 840px) {
  body:has(#gameSection:not([hidden])) .page-shell { height: calc(100vh - 64px); }
}
@media (max-width: 640px) {
  body:has(#gameSection:not([hidden])) .page-shell { height: calc(100dvh - 64px); }
}

/* Respect reduced-motion: keep a small, instant press but drop the spring and
   the squash so there's no bounce. */
@media (prefers-reduced-motion: reduce) {
  .match-card,
  .match-pronoun-card,
  .nav-btn {
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }
  .match-card:active:not(:disabled),
  .match-pronoun-card:active,
  .nav-btn:active:not(:disabled) {
    transform: translateY(2px);
    transition: none;
  }
}
