/* Morse Code Alphabet: the control bar with the selected code enlarged beside the input, the grid of 36 text tiles
   (4 columns on mobile, up to 12 on desktop: 4x9, 6x6, 9x4, 12x3) and the page text. Tiles: /css/image-tile.css,
   text tiles here. Codes are drawn with · and −, letter-spaced so dots and dashes read apart (spec D8). Scoped under
   .q-morse. Functional layout before the design pass (listed for design review); existing tokens only, following
   Element Symbols. */

.q-morse { padding-block: var(--s5) var(--s7); }
.q-morse__intro { display: grid; gap: var(--s2); margin-bottom: var(--s5); max-width: 60ch; }
.q-morse__intro h1 { font-size: 28px; }

.q-morse__game { max-width: none; display: grid; gap: var(--s3); padding: var(--s3); }
.q-morse__game:focus { outline: none; }

/* ---------- control bar: sticky, so the preview and the input stay in view with the keyboard open ---------- */
.q-morse__bar {
  position: sticky; top: 0; z-index: 4;
  display: grid; gap: var(--s2);
  margin: calc(-1 * var(--s3)) calc(-1 * var(--s3)) 0; padding: var(--s3);
  background: var(--surface); border-radius: var(--r-card) var(--r-card) 0 0;
  border-bottom: 1px solid var(--line);
}
.q-morse__row { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.q-morse__actions { display: flex; gap: var(--s2); margin-left: auto; }
.q-morse__ask { display: flex; gap: var(--s3); align-items: flex-start; }
.q-morse__ask:has(> [data-preview][hidden]):has(> [data-entry][hidden]) { display: none; }
.q-morse__preview { flex: none; margin: 0; display: grid; gap: var(--s1); justify-items: start; }
.q-morse__preview-face {
  display: grid; place-items: center; min-width: 88px; height: 88px; padding-inline: var(--s3); border-radius: 8px;
  background: var(--surface-2); font-size: 32px; font-weight: 700; line-height: 1; letter-spacing: .14em; white-space: nowrap;
}
.q-morse__preview-name { font-size: 16px; font-weight: 700; max-width: 22ch; }
.q-morse__preview-name:empty { display: none; }
.q-morse__entry { flex: 1 1 auto; min-width: 0; }
.q-morse__input {
  width: 100%; min-height: 48px; padding: 0 var(--s4);
  font-size: 18px; /* 16 px or more keeps iOS from zooming on focus */
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
}
.q-morse__input:disabled { opacity: .5; }
.q-morse__keys { display: none; margin-top: var(--s1); padding-inline: var(--s4); font-size: 13px; }
@media (pointer: fine) { .q-morse__keys { display: block; } }
.q-morse__feedback { margin-top: var(--s1); padding-inline: var(--s4); font-size: 15px; }

.q-morse__result { display: grid; gap: var(--s3); padding-block: var(--s2); }
.q-morse__result .fig dd { font-size: 24px; }
.q-morse__after { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); }
.q-morse__after:not(:has(> :not([hidden]))) { display: none; }
.q-morse__hint, .q-morse__practice { font-size: 15px; }
.q-morse__practice { flex-basis: 100%; }

/* ---------- grid ---------- */
.q-morse__gridwrap { position: relative; min-width: 0; }
.q-morse__grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2) var(--s1);
}
.q-morse .image-tile__frame { --tile-ratio: 2 / 1; font-size: 18px; font-weight: 700; line-height: 1; letter-spacing: .12em; white-space: nowrap; color: var(--ink); }
.q-morse .image-tile__label { font-size: 15px; font-weight: 700; }
.q-morse:not(.is-playing) .image-tile.is-named button.image-tile__btn { cursor: pointer; } /* after the game: review */
.q-morse:not(.is-playing) .image-tile.is-named .image-tile__frame { opacity: 1; }

/* ---------- pause: cover the grid and hide the preview ---------- */
.q-morse__pause { inset: 0; padding: var(--s4); align-content: start; }
.q-morse__pause p { font-size: 18px; }
.q-morse.is-paused .q-morse__grid,
.q-morse.is-paused .q-morse__preview { visibility: hidden; }

/* ---------- your stats and the page text ---------- */
.q-morse__stats { max-width: none; display: grid; gap: var(--s4); margin-top: var(--s5); padding: var(--s4); }
.q-morse__stats .figs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.q-morse__stats .fig dd { font-size: 24px; }
.q-morse__recent { overflow-x: auto; }
.q-morse__recent caption { text-align: left; padding-bottom: var(--s2); }
.q-morse__table { width: 100%; border-collapse: collapse; font-size: 15px; }
.q-morse__table thead th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); padding: var(--s2); }
.q-morse__table td, .q-morse__table tbody th { padding: 6px var(--s2); border-bottom: 1px solid var(--line); height: 36px; text-align: left; }
.q-morse__about { display: grid; gap: var(--s3); max-width: 72ch; margin-top: var(--s7); }
.q-morse__about h2 { margin-top: var(--s4); }
.q-morse__about h3 { margin-top: var(--s2); }
.q-morse__about ol, .q-morse__about ul { margin: 0; padding-left: 1.4em; display: grid; gap: var(--s1); }

@media (min-width: 600px) {
  .q-morse__grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .q-morse__game { padding: var(--s5); gap: var(--s4); }
  .q-morse__bar { margin: calc(-1 * var(--s5)) calc(-1 * var(--s5)) 0; padding: var(--s4) var(--s5); }
  .q-morse__preview-face { min-width: 160px; height: 120px; font-size: 48px; }
  .q-morse__entry { max-width: 480px; align-self: center; }
  .q-morse__grid { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: var(--s3) var(--s2); }
}
/* Desktop: the bar becomes a sticky column on the left (preview above the input), so the grid has the full height */
@media (min-width: 1024px) {
  .q-morse__game { grid-template-columns: 280px minmax(0, 1fr); align-items: start; column-gap: var(--s5); }
  .q-morse__bar {
    grid-column: 1; grid-row: 1 / span 3; position: sticky; top: var(--s4);
    margin: 0; padding: 0; border: 0; border-radius: 0;
  }
  .q-morse__ask { flex-direction: column; }
  .q-morse__entry { max-width: none; align-self: stretch; }
  .q-morse__result, .q-morse__after, .q-morse__gridwrap { grid-column: 2; }
  .q-morse__grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s2) var(--s1); }
}
@media (min-width: 1200px) {
  .q-morse__grid { grid-template-columns: repeat(9, minmax(0, 1fr)); }
}

