/* ==========================================================
   Word Mahjong page. Builds on site.css and the shared puzzle
   styles in codeword.css (settings bar, pills, pop-ups).
   ========================================================== */

.mj {
  --mj-face: #eef6f7;        /* tile face */
  --mj-face2: #d9e8ea;
  --mj-edge1: #a9c3c8;       /* tile thickness, light then dark */
  --mj-edge2: #55707a;
  --mj-ink: #06080f;         /* consonants */
  --mj-vowel: #b3126b;       /* vowels (deep pink) */
  --mj-sel: #ffcf6b;
}

.cw-back { color: inherit; text-decoration: none; }
.cw-back::before { content: "\2190  "; }
.cw-back:hover { color: var(--cyan-hot); }

/* ---------- word tray ---------- */
.mj-tray.panel { display: flex; flex-wrap: wrap; gap: .5rem; padding: .85rem 1rem; margin-bottom: 1rem; align-items: center; }
.mj-word {
  display: inline-flex; gap: 1px; padding: .3rem .5rem; border: 1px solid var(--line-strong); border-radius: 2px;
  font-weight: 800; font-size: 1.02rem; letter-spacing: .06em; line-height: 1.2; background: rgba(4,5,10,.6);
}
.mj-word span { color: #3f4f57; min-width: .7em; text-align: center; transition: color .25s, text-shadow .25s; }
.mj-word span.on { color: var(--cyan-hot); text-shadow: 0 0 8px rgba(160,225,225,.45); }
.mj-word.done { border-color: var(--cyan); box-shadow: 0 0 14px rgba(160,225,225,.25); }
.mj-word.done span { color: var(--ink); }
.mj-word.pics { font-family: var(--pixel); font-size: .68rem; font-weight: 400; color: var(--muted); align-items: center; gap: .35rem; }
.mj-word.pics img { width: 18px; height: 24px; object-fit: cover; border-radius: 2px; opacity: .35; filter: grayscale(1); transition: all .25s; }
.mj-word.pics img.on { opacity: 1; filter: none; box-shadow: 0 0 8px rgba(160,225,225,.4); }

/* ---------- board ---------- */
.mj-boardwrap {
  position: relative; background: rgba(4, 6, 12, .82); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 12px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
}
.mj-boardwrap::before, .mj-boardwrap::after { content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid var(--cyan); pointer-events: none; }
.mj-boardwrap::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.mj-boardwrap::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.mj-board { position: relative; z-index: 0; isolation: isolate; margin: 0 auto; user-select: none; -webkit-user-select: none; touch-action: manipulation; }

.mj-tile {
  position: absolute; border-radius: 5px; cursor: pointer; line-height: 1;
  background: linear-gradient(150deg, var(--mj-face) 0%, var(--mj-face2) 100%);
  border: 1px solid #c4d6d9; color: var(--mj-ink);
  box-shadow: var(--d1) var(--d1) 0 var(--mj-edge1), var(--d2) var(--d2) 0 var(--mj-edge2), calc(var(--d2) + 2px) calc(var(--d2) + 5px) 10px rgba(0,0,0,.55);
  transition: transform .14s ease, opacity .18s ease, filter .18s ease, background .14s;
}
.mj-tile[data-z="1"] { --mj-face: #f4fafb; }
.mj-tile[data-z="2"] { --mj-face: #f8fcfd; --mj-face2: #e2f0f2; }
.mj-tile[data-z="3"], .mj-tile[data-z="4"] { --mj-face: #ffffff; --mj-face2: #e6f4f6; }
.mj-tile .big { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: var(--fs); padding-top: 4%; }
.mj-tile .big.v { color: var(--mj-vowel); }
.mj-tile .sm { position: absolute; top: 3px; left: 4px; font-size: var(--fs2); font-weight: 700; color: #6d7e86; }
.mj-tile img { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); object-fit: cover; border-radius: 3px; pointer-events: none; }
.mj-tile.pic { background: linear-gradient(150deg, #20303a, #0b1218); border-color: #3c5560; }

.mj-board.dim .mj-tile.blocked { filter: brightness(.6) saturate(.7); cursor: default; }
.mj-tile.free:hover { transform: translate(-1px, -2px); border-color: var(--cyan); }
.mj-tile.sel { background: linear-gradient(150deg, #fff1c4, var(--mj-sel)); border-color: #b77a00; transform: translate(-2px, -3px); filter: none !important; }
.mj-tile.pic.sel { box-shadow: 0 0 0 3px var(--mj-sel), var(--d1) var(--d1) 0 var(--mj-edge1), var(--d2) var(--d2) 0 var(--mj-edge2); }
.mj-tile.hint { animation: mj-hint 1s ease-in-out infinite; filter: none !important; }
@keyframes mj-hint { 50% { box-shadow: 0 0 0 4px var(--cyan), 0 0 22px var(--cyan); transform: translate(-1px, -2px); } }
.mj-tile.out { opacity: 0; transform: scale(.7) translateY(-10px); pointer-events: none; }
.mj-tile.shake { animation: cw-shake .3s; }

/* ---------- tools ---------- */
.mj-tools { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: center; margin: .4rem 0 1.6rem; }
.mj-tools .btn { min-width: 6.5rem; justify-content: center; }
.mj-toggle { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .95rem; cursor: pointer; margin-left: .4rem; }
.mj-toggle input { width: 18px; height: 18px; accent-color: var(--cyan); }
.mj-info { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.1rem; }
.mj-cover-row { display: flex; flex-wrap: wrap; gap: .6rem; margin: .3rem 0 .8rem; }
.mj-cover-row a { display: block; width: 58px; transition: transform .15s; }
.mj-cover-row a:hover { transform: translateY(-3px); }
.mj-cover-row img { width: 100%; border-radius: 3px; box-shadow: 0 8px 18px -6px rgba(0,0,0,.9); }

@media (max-width: 760px) {
  .mj-info { grid-template-columns: 1fr; }
  .mj-tray.panel { padding: .6rem; gap: .35rem; }
  .mj-word { font-size: .92rem; padding: .25rem .4rem; }
  .mj-boardwrap { padding: 14px 6px; }
  .mj-tools .btn { min-width: 0; flex: 1 1 22%; padding-left: .4rem; padding-right: .4rem; }
  .mj-toggle { flex-basis: 100%; justify-content: center; margin: .2rem 0 0; }
}
.mj-tools .btn:disabled { opacity: .4; cursor: default; box-shadow: none; }
