/* ============================================================
   grammar-sentence.css — Sentence Building (Tap mode).

   Loaded alongside grammar-match.css, which provides the shared gm- frame
   chrome (frame, top bar, toggles, progress, completion) and colour tokens
   on .gm-stage. This file styles the sentence-specific pieces: the English
   prompt, the build area, the token pool, and the word tiles.
   ============================================================ */

/* English target sentence. */
.gm-sb-prompt {
  margin-top: 18px;
  padding: 13px 16px;
  background: var(--gm-inset);
  border: 1px solid var(--gm-line);
  border-radius: 12px;
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 600;
  color: var(--gm-ink);
  line-height: 1.4;
}

/* Build area — the sentence being assembled. */
.gm-sb-build {
  margin-top: 14px;
  min-height: 66px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  align-items: flex-start;
  padding: 12px;
  border: 1.5px dashed var(--gm-line2);
  border-radius: 14px;
  background: rgba(40, 40, 40, 0.015);
  transition: border-color 0.2s, background 0.2s;
}
.gm-sb-build.is-empty {
  align-items: center;
  justify-content: center;
}
.gm-sb-build.is-empty::after {
  /* Text supplied by sentence.js (data-empty-tap) so it can be translated;
     falls back to English if the attribute is somehow absent. */
  content: attr(data-empty-tap);
  color: var(--gm-faint);
  font-size: 13px;
}
/* In Write mode the words are handwritten, not tapped from a pool. */
.write-mode .gm-sb-build.is-empty::after { content: attr(data-empty-write); }
.gm-sb-build.is-correct {
  border-style: solid;
  border-color: var(--gm-green);
  background: rgba(47, 143, 91, 0.08);
}

/* Token pool — available words. */
.gm-sb-pool {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

/* Word tile. */
.gm-tok {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 14px;
  background: #fff;
  border: 1.5px solid var(--gm-line2);
  border-radius: 11px;
  cursor: pointer;
  font-family: inherit;
  color: var(--gm-ink);
  transition: border-color 0.15s, background 0.15s, transform 0.1s, opacity 0.2s;
}
@media (hover: hover) {
  .gm-tok:not(.is-used):hover { border-color: var(--gm-acc); }
}
.gm-tok:active { transform: translateY(1px); }
.gm-tok-jp {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 500;
  line-height: 1.3;
}
.gm-tok-jp ruby { ruby-position: over; }
.gm-tok-jp ruby rt {
  font-size: 0.5em;
  color: var(--gm-faint);
  font-weight: 400;
  line-height: 1;
}
.gm-tok-rom {
  font-size: 11px;
  color: var(--gm-faint);
  letter-spacing: 0.02em;
}
.gm-frame:not(.gm-show-romaji) .gm-tok-rom { display: none; }

/* A pool tile already placed in the build area. */
.gm-tok.is-used {
  opacity: 0.32;
  pointer-events: none;
}
/* Tiles sitting in the build area. */
.gm-tok-built {
  background: var(--gm-accbg);
  border-color: var(--gm-acc);
}

/* Footer actions. */
.gm-sb-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.gm-btn-primary:disabled,
.gm-btn-secondary:disabled,
.gm-ghostbtn:disabled {
  opacity: 0.45;
  cursor: default;
}

.gm-shake { animation: gmShake 0.45s ease; }

/* ── Tap / Write segmented control ──────────────────── */
.gm-sb-inputrow {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
/* The pen-settings gear/panel is the shared kana options-dropdown
   (css/options-panel.css) — it self-positions and styles itself, so no
   Sentence-Builder-specific panel CSS lives here. */
.gm-hw-options.gm-hidden { display: none; }

.gm-seg {
  display: inline-flex;
  background: var(--gm-inset);
  border: 1.5px solid var(--gm-line2);
  border-radius: 999px;
  padding: 2px;
}
.gm-seg-btn {
  border: none;
  background: transparent;
  color: var(--gm-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.gm-seg-btn.is-on { background: var(--gm-acc); color: #fff; }

/* ── Handwriting canvas (Write mode) ────────────────── */
.grammar-hw-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.grammar-hw-wrap[hidden] { display: none; }
.grammar-hw-frame {
  width: 280px;
  height: 280px;
  max-width: 86vw;
  aspect-ratio: 1 / 1;
  background: #fff;
  border: 1.5px solid var(--gm-line2);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}
.grammar-hw-cross { position: absolute; inset: 0; pointer-events: none; }
.grammar-hw-cross-v, .grammar-hw-cross-h {
  position: absolute;
  background-image: linear-gradient(to bottom, var(--gm-faint) 50%, transparent 50%);
  background-size: 1px 8px;
  opacity: 0.35;
}
.grammar-hw-cross-v { top: 0; bottom: 0; left: 50%; width: 1px; }
.grammar-hw-cross-h {
  top: 50%; left: 0; right: 0; height: 1px;
  background-image: linear-gradient(to right, var(--gm-faint) 50%, transparent 50%);
  background-size: 8px 1px;
}
.grammar-hw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.grammar-hw-score {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.grammar-hw-frame.miss-flash {
  animation: gmShake 0.4s ease-out;
  border-color: var(--gm-red);
}
.gm-sb-hwhint { font-size: 12px; color: var(--gm-faint); text-align: center; }
