/* ============================================================
   grammar-memory.css — Kanji Memory (flip-card game).

   Loaded alongside grammar-match.css (shared gm- frame chrome + colour
   tokens + gmShake keyframe). Styles the prompt line, the card board, and
   the 3D flip cards (hint face = kanji + readings, glyph face = bare kanji).
   ============================================================ */

/* Prompt. */
.gm-mem-question {
  margin-top: 16px;
  text-align: center;
  font-size: clamp(15px, 3.6vw, 18px);
  color: var(--gm-muted);
  min-height: 30px;
}
.gm-mem-q-reading {
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 700;
  color: var(--gm-acc);
  font-size: 1.3em;
  margin: 0 3px;
}
.gm-mem-q-rom { color: var(--gm-faint); font-size: 0.85em; margin-left: 2px; }

/* Board. */
.gm-mem-board {
  margin-top: 16px;
  display: grid;
  /* Fill the available width — more columns on wider frames so the whole
     set is visible at once (ideal for a memory game), 2 on phones. */
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: clamp(8px, 2vw, 14px);
}
@media (max-width: 440px) {
  .gm-mem-board { grid-template-columns: repeat(2, 1fr); }
}

/* Flip card. */
.gm-mem-card {
  position: relative;
  aspect-ratio: 1 / 1.12;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  perspective: 900px;
  font-family: inherit;
}
.gm-mem-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.52s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.gm-mem-card.is-flipped .gm-mem-inner { transform: rotateY(180deg); }

.gm-mem-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border-radius: 14px;
  border: 1.5px solid var(--gm-line2);
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.gm-mem-hint { background: var(--gm-inset); }
.gm-mem-glyph {
  background: #fff;
  transform: rotateY(180deg);
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 500;
  font-size: clamp(34px, 9vw, 52px);
  color: var(--gm-ink);
}

.gm-mem-hint-kanji {
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 500;
  font-size: clamp(20px, 5.4vw, 28px);
  color: var(--gm-ink);
  line-height: 1;
}
.gm-mem-readings {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
  justify-content: center;
}
.gm-mem-reading {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}
.gm-mem-kana {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: clamp(12px, 3.3vw, 15px);
  color: var(--gm-acc);
  font-weight: 600;
}
.gm-mem-rom {
  font-size: 10px;
  color: var(--gm-faint);
}
.gm-frame:not(.gm-show-romaji) .gm-mem-rom,
.gm-frame:not(.gm-show-romaji) .gm-mem-q-rom { display: none; }

@media (hover: hover) {
  .gm-mem-card.is-flipped:not(.is-spent):hover .gm-mem-glyph { border-color: var(--gm-acc); }
}
.gm-mem-card.is-correct .gm-mem-glyph {
  border-color: var(--gm-green);
  background: rgba(47, 143, 91, 0.1);
}
.gm-mem-card.is-wrong { animation: gmShake 0.42s ease; }
.gm-mem-card.is-wrong .gm-mem-hint {
  border-color: var(--gm-red);
  background: rgba(177, 50, 42, 0.07);
}
.gm-mem-card.is-spent { opacity: 0.5; pointer-events: none; }
