/* ── DECIPHER ENGINE — letter-mapping ──────────────────────────────────────
 *
 * Generic UI for "decipher the script" puzzles: clickable train pairs +
 * alphabet pad + test rows + scratchpad. The Georgian Countries puzzle
 * was the original instance; per-puzzle styling (font, glyph size) is
 * driven by `body[data-decipher-font="..."]` so each shell only needs a
 * data attribute to plug in.
 * ───────────────────────────────────────────────────────────────────────── */

.gx-rosetta {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 22px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  position: relative;
}

.gx-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 36px;
}

.gx-word {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}
/* a whitespace-delimited word — its letters never wrap mid-way */
.gx-wgroup {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: center;
}
.gx-row .gx-english { justify-content: flex-start; }
.gx-row .gx-arrow-spacer {
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
}

.gx-letter {
  display: inline-block;
  min-width: 24px;
  padding: 6px 8px 18px;  /* extra bottom padding holds the subscript phoneme */
  border-radius: 4px;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  transition: all .14s;
  user-select: none;
  position: relative;
  z-index: 2;
}
.gx-letter.gx-geo {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 22px;
  line-height: 1;
  color: var(--accent);
  min-width: 28px;
  padding: 6px 10px 18px;
}
body[data-decipher-font="georgian"] .gx-letter.gx-geo {
  font-family: 'Noto Sans Georgian', serif;
  font-size: 26px;
  min-width: 32px;
}
body[data-decipher-font="serif"] .gx-letter.gx-geo {
  font-family: 'Cardo', 'Charter', Georgia, serif;
  font-size: 22px;
}

body[data-decipher-font="georgian"] .gx-alpha-chip .gx-alpha-geo {
  font-family: 'Noto Sans Georgian', serif;
  font-size: 24px;
  min-width: 28px;
}
body[data-decipher-font="serif"] .gx-alpha-chip .gx-alpha-geo {
  font-family: 'Cardo', 'Charter', Georgia, serif;
  font-size: 20px;
}
.gx-letter.gx-lat {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-dim);
  padding-bottom: 6px;       /* no subscript on Latin side */
  cursor: default;
}
.gx-letter.gx-lat:hover { transform: none; }

.gx-letter:hover {
  border-color: var(--hot);
  color: var(--ink);
  transform: translateY(-1px);
}

/* punctuation + whitespace gaps inside a word — visible but inert */
.gx-gap   { display: inline-block; width: 8px; }
.gx-punct {
  display: inline-block;
  align-self: flex-end;
  padding: 0 2px 4px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  user-select: none;
}

/* highlighted: every occurrence of the currently-active glyph */
.gx-letter.is-highlighted {
  border-color: var(--accent);
  background: rgba(245,184,64,.14);
  color: var(--accent);
  box-shadow: 0 0 0 2px rgba(245,184,64,.25);
}

/* sub-marked: every occurrence of a dragged substring (morpheme hunt).
   distinct blue-slate so it reads apart from the single-glyph highlight. */
.gx-letter.is-sub {
  border-color: #2858a0;
  background: rgba(40,88,160,.16);
  color: #2858a0;
  box-shadow: 0 0 0 2px rgba(40,88,160,.3);
}
.gx-letter.is-sub.is-sub-edge-l { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.gx-letter.is-sub.is-sub-edge-r { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }

/* subscript phoneme — comes from data-sub attribute set by JS as the user
 * types into the alphabet pad. tucked under the glyph in coral. */
.gx-letter.gx-geo[data-sub]::after {
  content: attr(data-sub);
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--hot);
  line-height: 1;
  pointer-events: none;
}
.gx-letter.gx-geo[data-sub=""]::after { content: none; }

/* ── ALPHABET PAD ──────────────────────────────────────────────────────── */

.gx-alphabet-pad {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 16px;
  border: 1px dashed rgba(245,184,64,.25);
  border-radius: 4px;
  background: rgba(245,184,64,.04);
}

.gx-alpha-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  border-radius: 4px;
  cursor: pointer;
  transition: all .14s;
}
.gx-alpha-chip:hover {
  border-color: var(--hot);
}
.gx-alpha-chip.is-active {
  border-color: var(--accent);
  background: rgba(245,184,64,.14);
  box-shadow: 0 0 0 2px rgba(245,184,64,.25);
}
.gx-alpha-chip.is-filled {
  border-color: rgba(111,201,122,.4);
  background: rgba(111,201,122,.06);
}
.gx-alpha-chip.is-filled.is-active {
  border-color: var(--accent);
  background: rgba(245,184,64,.14);
}

.gx-alpha-chip .gx-alpha-geo {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 20px;
  color: var(--accent);
  line-height: 1;
  min-width: 24px;
  text-align: center;
}
.gx-alpha-chip .gx-alpha-eq {
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
}
.gx-alpha-chip .gx-alpha-input {
  width: 50px;
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--line);
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  color: var(--hot);
  text-align: center;
  padding: 2px 4px;
  outline: none;
  transition: border-color .14s;
}
.gx-alpha-chip .gx-alpha-input:focus {
  border-bottom-color: var(--hot);
  border-bottom-style: solid;
}
.gx-alpha-chip.is-filled .gx-alpha-input {
  color: var(--hot);
  border-bottom-color: rgba(125,211,232,.4);
}

.gx-pad-hint {
  margin-top: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-style: italic;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 78ch;
}

/* ── TEST ──────────────────────────────────────────────────────────────── */

.gx-test {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gx-test-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: var(--bg-2);
  transition: border-color .14s, background .14s;
}
.gx-test-row.is-solved {
  border-color: rgba(111,201,122,.4);
  background: rgba(111,201,122,.05);
}
.gx-test-row.is-revealed {
  border-color: var(--line);
  background: var(--bg-2);
}
.gx-test-row.is-blind {
  border-style: dashed;
  border-color: rgba(125,211,232,.18);
}
.gx-test-row.is-blind .btn-check {
  color: var(--ink-dim);
  font-weight: 400;
  font-size: 11px;
  padding: 4px 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.gx-test-prompt {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.gx-test-row .gx-letter { cursor: pointer; }
.gx-test-row.is-solved .gx-letter,
.gx-test-row.is-revealed .gx-letter {
  cursor: default;
  background: transparent;
  border-color: transparent;
}
.gx-test-input {
  background: transparent;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 6px 12px;
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  min-width: 220px;
}
.gx-test-input:focus { outline: none; border-color: var(--hot); }
.gx-test-input.is-incorrect { border-color: var(--reveal); }
.gx-test-buttons {
  display: flex;
  gap: 6px;
}
.gx-test-buttons .btn-check {
  font-family: 'JetBrains Mono', monospace;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 4px 9px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: all .14s;
}
.gx-test-buttons .btn-check:hover { color: #b8efbe; border-color: #6fc97a; }
.gx-test-row .gx-feedback {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--reveal);
  margin-left: 8px;
}
.gx-test-row .gx-feedback.ok { color: #6fc97a; }
.gx-test-row .gx-feedback.dim { color: var(--muted); font-style: italic; }

.gx-test-row.is-solved .gx-test-input,
.gx-test-row.is-solved .btn-check,
.gx-test-row.is-revealed .gx-test-input,
.gx-test-row.is-revealed .btn-check { display: none; }

.gx-test-row .gx-answer-shown {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--ink);
}
.gx-test-row.is-revealed .gx-answer-shown { color: var(--ink-dim); font-style: italic; }

/* ── ARROW SVG OVERLAY ─────────────────────────────────────────────────── */


/* ── PERSISTENCE NOTE ──────────────────────────────────────────────────── */

.gx-persistence-note {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px dashed rgba(125,211,232,.25);
  border-radius: 3px;
  background: rgba(125,211,232,.03);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: .02em;
  color: var(--ink-dim);
}
.gx-persistence-note b {
  color: var(--ink);
  font-weight: 500;
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.gx-persistence-note .k {
  color: var(--accent);
  font-style: normal;
}

/* scratchpad rules moved to linguistics-puzzles.css (shared component) */

@media (max-width: 760px) {
  .gx-rosetta { padding: 16px 12px; gap: 12px; }

  /* stack each pair: source word on top, English below, both reading from
     the left. the arrow that sat between them on desktop is dropped. */
  .gx-row { grid-template-columns: 1fr; gap: 6px; }
  .gx-row .gx-arrow-spacer { display: none; }
  .gx-word { justify-content: flex-start; gap: 3px; }
  .gx-row .gx-english {
    justify-content: flex-start;
    padding-left: 12px;
    border-left: 2px solid var(--line-soft);
  }
  .gx-wgroup { gap: 3px; }
  .gx-test-prompt { gap: 3px; }

  /* shrink the glyph tiles so a whole word fits the narrow column.
     a single very long word can still scroll sideways inside its own
     group rather than pushing the whole page wide. */
  .gx-wgroup { max-width: 100%; min-width: 0; overflow-x: auto; }
  .gx-letter { min-width: 18px; padding: 4px 4px 13px; }
  .gx-letter.gx-geo,
  body[data-decipher-font="georgian"] .gx-letter.gx-geo,
  body[data-decipher-font="serif"] .gx-letter.gx-geo {
    font-size: 18px; min-width: 22px; padding: 4px 4px 13px;
  }
  .gx-letter.gx-lat { font-size: 15px; padding-bottom: 4px; }
  .gx-letter.gx-geo[data-sub]::after { font-size: 8px; bottom: 2px; }

  .gx-test-row { grid-template-columns: 1fr; gap: 10px; }
  .gx-test-prompt { max-width: 100%; }
  .gx-test-input { min-width: 0; width: 100%; }

  .gx-scratchpad-body { width: 280px; }
}
