/* Mini demo on the landing page (M3), on top of sha.css and site.css.

   The picture shows a projector and a phone. On the phone lies a screen of our own
   (.demo-screen) with the answers A–D and the feedback. Everything on that screen is sized in
   container units of its width (1cqw = 2.96 px of the picture), so it stays on top of the
   phone of the picture at every width.

   - Wide (from 601 px): the screen covers the phone screen of the picture. At rest it is
     transparent and only its buttons catch the taps, so the demo looks exactly like the
     picture; during the feedback it covers the phone screen.
   - Narrow (up to 600 px): the phone of the picture would be too small to tap. A larger phone
     drawn in CSS covers it, the projector stays visible next to it, smaller. */

.demo {
  --demo-a: #f09f8a;
  --demo-b: #556370;
  --demo-c: #f3d2c1;
  --demo-d: #313234;
}

.demo__stage {
  position: relative;
}

.demo__picture {
  width: 100%;
  height: auto;
}

/* Position of the phone screen in the picture (1438 × 792): x 1120, y 177, 296 × 590. */
.demo__device {
  position: absolute;
  top: 22.348%;
  left: 77.886%;
  width: 20.584%;
}

.demo__display {
  container-type: inline-size;
  position: relative;
  aspect-ratio: 296 / 590;
}

.demo__hint {
  margin-top: 1rem;
  color: rgba(255, 255, 255, 0.85);
  font-size: clamp(0.95rem, 1.3vw, 1.08rem);
  line-height: 1.6;
  letter-spacing: 0.02em;
  text-align: center;
}

/* ---------- The screen of the phone ---------- */

.demo-screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 15cqw;
  background: linear-gradient(#202529, #1a1e22);
  color: var(--white);
  font-size: 6.75cqw;
  line-height: 1;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.3s;
}

.demo-screen[data-phase='result'] {
  cursor: pointer;
}

.demo-screen[data-mood='correct'] {
  background: var(--success);
  color: var(--ink);
}

.demo-screen[data-mood='wrong'] {
  background: var(--wrong);
}

.demo-screen:focus {
  outline: none;
}

.demo-screen:focus-visible {
  outline: 3px solid var(--rose-light);
  outline-offset: -3px;
}

/* Dynamic island of the phone. */
.demo-screen::before {
  content: '';
  position: absolute;
  top: 2.7cqw;
  left: 34.5cqw;
  width: 29.7cqw;
  height: 8.1cqw;
  border-radius: 4.05cqw;
  background: #000;
}

.demo-screen__bar {
  position: absolute;
  top: 19.3cqw;
  right: 4.4cqw;
  left: 4.4cqw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 14.5cqw;
}

.demo .demo-screen__logo {
  width: auto;
  height: 100%;
}

.demo-screen__me {
  display: flex;
  align-items: center;
  gap: 4cqw;
  padding-top: 0.8cqw;
}

.demo-screen__score {
  min-width: 12.5cqw;
  padding: 1.5cqw 4cqw;
  border-radius: 2.4cqw;
  position: relative;
  top: 0.5cqw;
  background: var(--demo-a);
  color: var(--white);
  font-weight: 600;
  text-align: center;
}

.demo-screen__eyebrow {
  position: absolute;
  top: 42.4cqw;
  right: 0;
  left: 0;
  color: var(--rose);
  font-size: 6.3cqw;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
}

.demo-screen__answers {
  position: absolute;
  top: 58.8cqw;
  left: 2.4cqw;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 166fr 174fr;
  gap: 3.4cqw 2.7cqw;
  width: 95.9cqw;
  height: 118.2cqw;
}

/* The tones of the picture instead of the ones of the tool (.c-A … in sha.css). */
.demo .c-A {
  --tile-bg: var(--demo-a);
}

.demo .c-B {
  --tile-bg: var(--demo-b);
}

.demo .c-C {
  --tile-bg: var(--demo-c);
}

.demo .c-D {
  --tile-bg: var(--demo-d);
  --tile-ring: inset 0 0 0 max(0.9cqw, 1.5px) var(--white);
}

.demo-answer {
  position: relative;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4.7cqw;
  font: inherit;
  font-size: 26.7cqw;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s;
}

.demo-answer:active {
  transform: scale(0.96);
}

.demo-answer:focus {
  outline: none;
}

.demo-answer:focus-visible {
  z-index: 1;
  outline: 3px solid var(--rose-light);
  outline-offset: 2px;
}

/* ---------- Feedback (in the look of view-ANSWERED and view-RESULT on the phone) ---------- */

.demo-screen__sent,
.demo-screen__result {
  position: absolute;
  top: 36cqw;
  right: 6cqw;
  bottom: 8cqw;
  left: 6cqw;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5cqw;
  text-align: center;
  animation: demo-fade 0.2s ease-out;
}

.demo-screen[data-phase='sent'] .demo-screen__sent,
.demo-screen[data-phase='result'] .demo-screen__result {
  display: flex;
}

.demo-screen:not([data-phase='question']) .demo-screen__question {
  display: none;
}

.demo-screen__badge {
  justify-content: center;
  width: 28cqw;
  height: 28cqw;
  border-radius: 4.7cqw;
  font-size: 15cqw;
  font-weight: 700;
}

.demo-screen__title {
  font-size: 8cqw;
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

.demo-screen__icon {
  display: grid;
  place-items: center;
  width: 30cqw;
  height: 30cqw;
  border-radius: 50%;
  background: var(--white);
  font-size: 16cqw;
  font-weight: 700;
  animation: demo-pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) backwards;
}

.demo-screen[data-mood='correct'] .demo-screen__icon {
  color: #3f7a52;
}

.demo-screen[data-mood='wrong'] .demo-screen__icon {
  color: var(--wrong);
}

.demo-screen__result .demo-screen__title {
  font-size: 11.5cqw;
  animation: demo-pop 0.45s 0.1s cubic-bezier(0.2, 1.4, 0.4, 1) backwards;
}

.demo-screen__points {
  font-size: 8cqw;
  font-weight: 700;
}

.demo-screen__correct {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-size: max(5.5cqw, 0.7rem);
  font-weight: 600;
}

.demo-screen[data-mood='correct'] .demo-screen__correct {
  display: none;
}

.demo-screen__correct .badge {
  width: 2.2em;
  height: 2.2em;
  border-radius: 0.6em;
  background: var(--tile-bg);
  color: var(--tile-fg);
}

/* Read out by screen readers, not shown. */
.demo-screen__status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@keyframes demo-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes demo-pop {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- Wide: at rest the picture shows through ---------- */

@media (min-width: 601px) {
  .demo-screen[data-phase='question'] {
    background: transparent;
    transition: none;
  }

  .demo-screen[data-phase='question']::before,
  .demo-screen[data-phase='question'] .demo-screen__bar,
  .demo-screen[data-phase='question'] .demo-screen__eyebrow {
    visibility: hidden;
  }

  .demo-answer {
    background: transparent;
    box-shadow: none;
    color: transparent;
  }

  @media (hover: hover) {
    .demo-answer:hover {
      background: rgba(255, 255, 255, 0.12);
    }
  }
}

/* ---------- Narrow: a larger phone in CSS, the projector smaller next to it ---------- */

@media (max-width: 600px) {
  .demo__stage {
    display: grid;
    align-items: center;
  }

  .demo__picture,
  .demo__device {
    grid-area: 1 / 1;
  }

  .demo__picture {
    justify-self: start;
    width: 76%;
  }

  .demo__device {
    position: relative;
    top: auto;
    left: auto;
    justify-self: end;
    width: 48%;
    padding: 1.7%;
    /* Screen corner (15cqw) plus the bezel, as a share of width and height of the device. */
    border-radius: 17.5% / 9.1%;
    background: #070707;
    box-shadow: inset 0 0 0 1.5px #5b5551, 0 0 0 1px #2c2926, 0 6px 18px rgba(0, 0, 0, 0.35);
  }
}

/* ---------- Reduced motion: switch without animation ---------- */

@media (prefers-reduced-motion: reduce) {
  .demo-screen,
  .demo-screen *,
  .demo-screen::before {
    animation: none !important;
    transition: none !important;
  }

  .demo-answer:active {
    transform: none;
  }
}
