/* Patch Hero (DEC-085), the mirror pilot. Centred and calm: one choice (which eye), one main button, then the
   mirror as large as the screen allows. Logical properties, so the same rules serve English and Arabic. */

.ph.wrap {
  max-width: 56rem;
}
.ph {
  display: grid;
  gap: 20px;
  padding-block: 16px 48px;
  text-align: center;
}
.ph-head {
  display: grid;
  gap: 10px;
}
.ph-head h1 {
  font-size: clamp(2.25rem, 8vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
:root[lang='ar'] .ph-head h1 {
  letter-spacing: 0;
  line-height: 1.3;
}
.ph-pilot {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--color-mist);
  color: var(--color-muted);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
  vertical-align: middle;
}
.ph-lead {
  color: var(--color-muted);
  font-size: 1.125rem;
  text-wrap: balance;
}

.lang-btn {
  min-height: var(--target-min);
  padding-inline: 20px;
  border: 2px solid var(--color-graphite);
  border-radius: var(--radius-pill);
  background: var(--color-page);
  color: var(--color-graphite);
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.lang-btn:hover {
  background: var(--color-mist);
}

/* Which eye: two halves of one pill, the person's own right eye always on the right (as in a mirror). */
.ph-eyes {
  display: grid;
  gap: 8px;
  justify-items: center;
  margin: 0;
  padding: 0;
  border: 0;
}
.ph-eyes legend {
  margin-bottom: 8px;
  padding: 0;
  font-weight: 700;
}
.ph-eye-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 26rem);
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-mist);
}
.ph-eye {
  min-height: 52px;
  padding-inline: 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-graphite);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 150ms;
}
.ph-eye[aria-pressed='true'] {
  background: var(--color-graphite);
  color: #fff;
}

/* The mirror */
.ph-stage {
  display: grid;
  justify-items: center;
}
.ph-stage[hidden] {
  display: none;
}
.ph-canvas {
  display: block;
  width: 100%;
  max-height: 70vh;
  max-height: 70svh;
  object-fit: contain;
  border-radius: 24px;
  background: var(--color-mist);
}
.ph-status:empty {
  display: none;
}
.ph-status {
  font-weight: 600;
}

/* The mirror's buttons stay at the bottom of the screen, as in the learn chapter. */
.ph-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 12px;
  margin-inline: calc(-1 * var(--gutter));
  padding: 12px var(--gutter) max(12px, env(safe-area-inset-bottom));
  background: var(--color-page);
  box-shadow: 0 -10px 18px -16px rgba(35, 39, 46, 0.45);
}
.ph-actions .button {
  flex: 1 1 12rem;
  max-width: 20rem;
}
.ph-actions .button[hidden] {
  display: none;
}

/* Choices: which eye, which emblem, and Patch Ally. */
.ph-choices {
  display: grid;
  gap: 18px;
}
.ph-choices[hidden] {
  display: none;
}
.ph-emblems {
  display: grid;
  justify-items: center;
  margin: 0;
  padding: 0;
  border: 0;
}
.ph-emblems legend {
  margin-bottom: 8px;
  padding: 0;
  font-weight: 700;
}
.ph-emblem-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 36rem);
}
@media (max-width: 30rem) {
  .ph-emblem-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.ph-emblem {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 84px;
  padding: 8px 4px 6px;
  border: 2px solid var(--color-line);
  border-radius: 18px;
  background: var(--color-page);
  color: var(--color-graphite);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    border-color 150ms,
    background-color 150ms;
}
.ph-emblem:hover {
  border-color: var(--color-graphite);
}
.ph-emblem[aria-pressed='true'] {
  border-color: var(--color-graphite);
  background: #fff6dc;
  box-shadow: inset 0 0 0 2px var(--color-amber);
}
.ph-emblem-icon {
  width: 46px;
  height: 46px;
}
.ph-ally-row {
  display: grid;
  justify-items: center;
  gap: 6px;
}
.ph-ally {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding-inline: 22px;
  border: 2px solid var(--color-graphite);
  border-radius: var(--radius-pill);
  background: var(--color-page);
  color: var(--color-graphite);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.ph-ally::before {
  content: '';
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-graphite);
  border-radius: 6px;
  background: var(--color-page);
}
.ph-ally[aria-pressed='true'] {
  background: var(--color-graphite);
  color: #fff;
}
.ph-ally[aria-pressed='true']::before {
  border-color: var(--color-amber);
  background: var(--color-amber);
  box-shadow: inset 0 0 0 3px var(--color-graphite);
}
.ph-ally-hint {
  color: var(--color-muted);
  font-size: 0.9375rem;
}
.ph-power {
  max-width: 34rem;
  margin-inline: auto;
  font-size: 1.125rem;
  font-weight: 700;
  text-wrap: balance;
}
.ph-power[hidden] {
  display: none;
}
@media (prefers-reduced-motion: no-preference) {
  .ph-emblem[aria-pressed='true'] .ph-emblem-icon {
    animation: ph-pop 600ms cubic-bezier(0.16, 1, 0.3, 1);
  }
}

/* The preview: a cartoon child wearing the patch, so the art shows before the camera starts. */
.ph-preview-wrap {
  display: grid;
  justify-items: center;
}
.ph-preview-wrap[hidden] {
  display: none;
}
.ph-preview {
  display: block;
  width: min(100%, 300px);
  aspect-ratio: 400 / 420;
}

/* The way to the grown-ups' page. */
.ph-grown-link {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  min-height: var(--target-min);
  color: var(--color-graphite);
  font-weight: 700;
  text-align: center;
}

/* The pilot's count, small and quiet under the mirror. */
.ph-count {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 12px;
  color: var(--color-muted);
}
.ph-count[hidden] {
  display: none;
}
.ph-recount {
  min-height: var(--target-min);
  padding-inline: 12px;
  border: 0;
  background: none;
  color: var(--color-graphite);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.ph-note {
  max-width: 36rem;
  margin-inline: auto;
  color: var(--color-muted);
}

/* The learn chapter (DEC-085): five screens, one drawing each, a big line for the child and a small one for the
   grown-up, then Back and Next. */
.ph-learn,
.ph-mirror-part {
  display: grid;
  gap: 18px;
}
.ph-learn[hidden],
.ph-mirror-part[hidden] {
  display: none;
}
.ph-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ph-dots li {
  width: 28px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--color-line);
  transition: background-color 300ms;
}
.ph-dots li.on {
  background: var(--color-amber);
}
.ph-step-title {
  font-size: clamp(1.5rem, 5vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.ph-step-title:focus {
  outline: none;
}
:root[lang='ar'] .ph-step-title {
  letter-spacing: 0;
  line-height: 1.35;
}
.ph-art {
  display: grid;
  justify-items: center;
  min-height: 120px;
}
.ph-art svg {
  display: block;
  width: 100%;
  max-width: 40rem;
  height: auto;
}
.ph-art-canvas {
  display: block;
  width: min(100%, 300px);
  aspect-ratio: 400 / 420;
}
.ph-art-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.ph-art-actions[hidden] {
  display: none;
}
.ph-art-button {
  min-height: 52px;
  padding-inline: 22px;
  border: 2px solid var(--color-graphite);
  border-radius: var(--radius-pill);
  background: var(--color-page);
  color: var(--color-graphite);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 150ms;
}
.ph-art-button[aria-pressed='true'] {
  background: var(--color-graphite);
  color: #fff;
}
.ph-art-note {
  color: var(--color-muted);
  font-size: 0.9375rem;
}
.ph-art-note[hidden] {
  display: none;
}
.ph-art-live {
  min-height: 0;
  font-weight: 700;
}
.ph-kid {
  max-width: 34rem;
  margin-inline: auto;
  font-size: clamp(1.25rem, 4.5vw, 1.5rem);
  font-weight: 700;
  line-height: 1.35;
  text-wrap: balance;
}
.ph-grown {
  max-width: 38rem;
  margin-inline: auto;
  padding: 14px 18px;
  border-radius: 16px;
  background: var(--color-mist);
  color: var(--color-graphite);
  text-align: start;
}
/* Back and Next stay at the bottom of the screen while the screen's words are read. */
.ph-nav {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-inline: calc(-1 * var(--gutter));
  padding: 12px var(--gutter) max(12px, env(safe-area-inset-bottom));
  background: var(--color-page);
  box-shadow: 0 -10px 18px -16px rgba(35, 39, 46, 0.45);
}
.ph-nav .button {
  flex: 1 1 0;
  max-width: 16rem;
}
.ph-nav .button[hidden] {
  display: none;
}
.ph-skip {
  justify-self: center;
  min-height: var(--target-min);
  padding-inline: 12px;
  border: 0;
  background: none;
  color: var(--color-graphite);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.ph-skip[hidden] {
  display: none;
}

/* The drawings' moving parts. At rest for people who ask for less motion: the end state, without the movement. */
.ph-art .ph-hand {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: translate(-60px, 170px) rotate(-18deg);
  opacity: 0;
}
.ph-art .covered .ph-hand {
  transform: none;
  opacity: 1;
}
.ph-art .ph-quiet-view {
  opacity: 0;
}
.ph-art .covered .ph-quiet-view {
  opacity: 1;
}
.ph-art .covered .ph-sight-strong {
  opacity: 0;
}
.ph-art .ph-fading {
  opacity: 0.55;
}
@media (prefers-reduced-motion: no-preference) {
  .ph-art .ph-hand {
    transition:
      transform 700ms cubic-bezier(0.16, 1, 0.3, 1),
      opacity 250ms;
  }
  .ph-art .ph-quiet-view,
  .ph-art .ph-sight-strong {
    transition: opacity 600ms 250ms;
  }
  .ph-art .ph-flow {
    animation: ph-flow 1.1s linear infinite;
  }
  .ph-art .ph-card {
    transform-box: fill-box;
    transform-origin: center;
    animation: ph-bob 2.4s ease-in-out infinite;
  }
  .ph-art .ph-card-b {
    animation-delay: -1.2s;
  }
  .ph-art .ph-z {
    transform-box: fill-box;
    transform-origin: center;
    animation: ph-z 2.4s 1.2s ease-in-out infinite both;
  }
  .ph-art .ph-z-2 {
    animation-delay: 1.5s;
  }
  .ph-art .ph-z-3 {
    animation-delay: 1.8s;
  }
  .ph-art .ph-fading {
    animation: ph-fade 1.6s 0.6s both;
  }
  .ph-art .ph-merged {
    transform-box: fill-box;
    transform-origin: center;
    animation: ph-pop 2.2s ease-in-out infinite;
  }
  .ph-art .ph-beam {
    animation: ph-glow 2.4s ease-in-out infinite;
  }
  .ph-dots li {
    transition: background-color 300ms;
  }
}
@keyframes ph-flow {
  to {
    stroke-dashoffset: -44;
  }
}
@keyframes ph-bob {
  50% {
    transform: translateY(-6px);
  }
}
@keyframes ph-z {
  0% {
    opacity: 0;
    transform: translate(-4px, 8px) scale(0.7);
  }
  25%,
  75% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translate(4px, -8px) scale(1.1);
  }
}
@keyframes ph-fade {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.55;
  }
}
@keyframes ph-pop {
  50% {
    transform: scale(1.12);
  }
}
@keyframes ph-glow {
  50% {
    opacity: 0.55;
  }
}
