/* US Presidents by Picture (pictures spec §6): the control bar with the selected portrait enlarged beside the input,
   the portrait grid (4 columns on mobile, 9 on desktop so all 45 fit) and the page text. Tiles: /css/image-tile.css.
   Scoped under .q-pictures. Functional layout before the design pass; existing tokens only, following the flags quiz. */

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

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

/* ---------- control bar: sticky, so the preview and the input stay in view with the keyboard open ---------- */
.q-pictures__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-pictures__row { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.q-pictures__actions { display: flex; gap: var(--s2); margin-left: auto; }
.q-pictures__loading { font-size: 15px; }
.q-pictures__ask { display: flex; gap: var(--s3); align-items: flex-start; }
.q-pictures__ask:has(> [data-preview][hidden]):has(> [data-entry][hidden]) { display: none; }
.q-pictures__preview { flex: none; margin: 0; display: grid; gap: var(--s1); justify-items: start; }
.q-pictures__preview img { display: block; width: 96px; height: 120px; object-fit: cover; border-radius: 4px; }
.q-pictures__preview-name { font-size: 16px; font-weight: 700; max-width: 22ch; }
.q-pictures__preview-name:empty { display: none; }
.q-pictures__entry { flex: 1 1 auto; min-width: 0; }
.q-pictures__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-pictures__input:disabled { opacity: .5; }
.q-pictures__keys { display: none; margin-top: var(--s1); padding-inline: var(--s4); font-size: 13px; }
@media (pointer: fine) { .q-pictures__keys { display: block; } }
.q-pictures__feedback { margin-top: var(--s1); padding-inline: var(--s4); font-size: 15px; }

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

/* ---------- grid ---------- */
.q-pictures__gridwrap { position: relative; min-width: 0; }
.q-pictures__grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3) var(--s2);
}
.q-pictures .image-tile__frame { --tile-ratio: 4 / 5; }
.q-pictures .image-tile__frame img { object-fit: cover; border-radius: 2px; }
.q-pictures.is-playing .image-tile__frame, .q-pictures__grid:not([aria-hidden]) .image-tile__frame { background: none; }
.q-pictures:not(.is-playing) .image-tile.is-named button.image-tile__btn { cursor: pointer; } /* after the game: review */
.q-pictures:not(.is-playing) .image-tile.is-named .image-tile__frame { opacity: 1; }

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

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

@media (min-width: 600px) {
  .q-pictures__grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .q-pictures__game { padding: var(--s5); gap: var(--s4); }
  .q-pictures__bar { margin: calc(-1 * var(--s5)) calc(-1 * var(--s5)) 0; padding: var(--s4) var(--s5); }
  .q-pictures__preview img { width: 192px; height: 240px; }
  .q-pictures__entry { max-width: 480px; align-self: center; }
  .q-pictures__grid { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: var(--s4) var(--s3); }
}
/* Desktop: the bar becomes a sticky column on the left (preview above the input), so the grid has the full
   height and all 45 portraits fit on screen (spec §6) */
@media (min-width: 1024px) {
  .q-pictures__game { grid-template-columns: 280px minmax(0, 1fr); align-items: start; column-gap: var(--s5); }
  .q-pictures__bar {
    grid-column: 1; grid-row: 1 / span 3; position: sticky; top: var(--s4);
    margin: 0; padding: 0; border: 0; border-radius: 0;
  }
  .q-pictures__ask { flex-direction: column; }
  .q-pictures__entry { max-width: none; align-self: stretch; }
  .q-pictures__result, .q-pictures__after, .q-pictures__gridwrap { grid-column: 2; }
  .q-pictures__grid { gap: var(--s2); }
  .q-pictures .image-tile__label { min-height: 2.4em; font-size: 12px; }
}
