/* "Could some of it be yours?": six things to tick and one button. The boxes
   are real checkboxes inside their labels, so the whole tile is the target and
   a keyboard or a screen reader needs nothing from a script. */

.check {
  padding: var(--section) 0;
}

.reasons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: var(--s-3);
}

.reason {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 3.75rem;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease,
    transform var(--dur-press) var(--ease-out);
}

.reason:active {
  transform: scale(0.98);
}

.reason input {
  display: grid;
  place-content: center;
  flex: none;
  width: 1.375rem;
  height: 1.375rem;
  margin: 0;
  border: 1.5px solid var(--muted);
  border-radius: var(--r-sm);
  background: var(--surface);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease;
}

/* The tick is cut out of a white square, and is there before it is seen:
   it grows the last little way rather than from nothing. */
.reason input::before {
  content: "";
  width: 0.8rem;
  height: 0.8rem;
  background: #fff;
  clip-path: polygon(13% 50%, 0 64%, 38% 100%, 100% 24%, 87% 11%, 37% 72%);
  opacity: 0;
  transform: scale(0.7);
  transition: opacity var(--dur-press) ease, transform var(--dur-press) var(--ease-out);
}

.reason input:checked {
  border-color: var(--forest);
  background: var(--forest);
}

.reason input:checked::before {
  opacity: 1;
  transform: scale(1);
}

/* Where the browser can tell a tile that its box is ticked or focused, the
   whole tile shows it; where it cannot, the box alone does. */
@supports selector(:has(a)) {
  .reason:has(input:checked) {
    border-color: var(--forest);
    background: var(--mint);
  }

  .reason input:focus-visible {
    outline: none;
  }

  .reason:has(input:focus-visible) {
    outline: 3px solid var(--forest);
    outline-offset: 2px;
  }
}

/* The tick is a white shape on a green box. Where the browser paints the
   colours itself both would be lost, so there the box is the system's own. */
@media (forced-colors: active) {
  .reason input {
    -webkit-appearance: auto;
    appearance: auto;
  }

  .reason input::before {
    display: none;
  }
}

.check-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4) var(--s-5);
  margin-top: var(--s-5);
  padding: var(--s-4) var(--s-4) var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  background: var(--moss);
}

.check-summary {
  font-weight: 500;
  line-height: 1.35;
}

.check-result .btn {
  flex: none;
}

.check .fine {
  margin-top: var(--s-4);
}

@media (hover: hover) and (pointer: fine) {
  .reason:hover {
    border-color: var(--muted);
  }
}

@media (max-width: 34rem) {
  .reasons {
    grid-template-columns: minmax(0, 1fr);
  }

  .check-result {
    flex-direction: column;
    align-items: stretch;
    padding: var(--s-4);
  }
}
