/*
 * Reflex Tap — "How the Game works"
 * Place after Game Basics and before the item/question editor.
 * All selectors are scoped to .reflex-how to avoid affecting other games.
 */

.reflex-how {
  --reflex-ink: #101827;
  --reflex-line: #dbe3ee;
  --reflex-surface: #ffffff;
  --reflex-radius: 24px;

  /* One shared media-height system (owner 2026-10-13): the same token,
     the same values and the same contain/centre recipe in all three games. */
  --how-art-height: clamp(180px, 16vw, 245px);
  container-name: reflex-how;
  container-type: inline-size;
  width: 100%;
  margin-block: 28px 56px;
  padding: clamp(18px, 2vw, 28px);
  overflow: hidden;
  color: var(--reflex-ink);
  background: var(--reflex-surface);
  border: 1px solid var(--reflex-line);
  border-radius: var(--reflex-radius);
  box-shadow: 0 2px 5px rgb(15 23 42 / 10%);
}

.reflex-how__title {
  margin: 0 0 clamp(24px, 2.5vw, 36px);
  font-weight: 400;
  font-size: clamp(22px, 2vw, 28px);
  line-height: 1.15;
  font-family: var(--font-display);
  font-synthesis: none;
  letter-spacing: -0.02em;
}

.reflex-how__steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
  gap: clamp(18px, 2.25vw, 36px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.reflex-how__step {
  display: grid;
  grid-template-rows: var(--how-art-height) auto;
  min-width: 0;
  margin: 0;
  text-align: center;
}

/*
 * Every illustration receives the same fixed-height slot. This—not the PNG's
 * natural aspect ratio—is what keeps the phone from appearing taller.
 */
/* The equal-height media slot: artwork is vertically CENTRED, contain-
   fitted and never cropped; subtle per-step scales may exceed the slot. */
.reflex-how__visual {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  height: 100%;
  overflow: visible;
}

.reflex-how__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transform: scale(var(--art-scale, 1));
}

.reflex-how__caption {
  min-height: 2.45em;
  margin: 18px 0 0;
  font-weight: 800;
  font-size: clamp(17px, 1.35vw, 22px);
  line-height: 1.22;
  font-family: var(--font-body);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

/* Component width below 920px: intentional 2 × 2 layout. */
@container reflex-how (max-width: 919px) {
  .reflex-how__steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 36px;
  }

  .reflex-how__step {
    --how-art-height: clamp(190px, 33vw, 270px);
  }
}

/* Component width below 560px: one step per row. */
@container reflex-how (max-width: 559px) {
  .reflex-how {
    margin-block: 20px 40px;
    padding: 18px 16px 24px;
    border-radius: 20px;
  }

  .reflex-how__title {
    margin-bottom: 22px;
  }

  .reflex-how__steps {
    grid-template-columns: 1fr;
    row-gap: 34px;
  }

  .reflex-how__step {
    --how-art-height: clamp(190px, 66vw, 280px);
  }

  .reflex-how__caption {
    min-height: 0;
    margin-top: 12px;
    font-size: 18px;
  }
}

/* Fallback for older browsers without container queries. */
@supports not (container-type: inline-size) {
  @media (max-width: 920px) {
    .reflex-how__steps {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  @media (max-width: 560px) {
    .reflex-how__steps {
      grid-template-columns: 1fr;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .reflex-how *,
  .reflex-how *::before,
  .reflex-how *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Visible-art balancing (owner 2026-10-13): the tall phone canvases
   (864x717) carry ~30% taller visible art than the landscape ones
   (864x576) inside the equal slots. These SUBTLE scales (0.9-1.05,
   measured from each PNG alpha bounds) even the steps out; the approved
   artwork itself is never cropped, redrawn or edited. */
.reflex-how__step[data-step="1"] { --art-scale: 1.05; }
.reflex-how__step[data-step="2"] { --art-scale: 0.90; }
.reflex-how__step[data-step="3"] { --art-scale: 0.90; }
.reflex-how__step[data-step="4"] { --art-scale: 1.03; }
