/* ==========================================================================
   Task dialog and rules dialog
   ========================================================================== */

.modal {
  width: min(100% - 32px, 600px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: var(--c-white);
  color: var(--c-ink);
  box-shadow: 0 40px 80px -30px rgba(20, 4, 70, 0.7);
  overscroll-behavior: contain;
}

.modal--wide {
  width: min(100% - 32px, 720px);
}

.modal::backdrop {
  background: rgba(26, 10, 77, 0.6);
  backdrop-filter: blur(4px);
}

.modal[open] {
  animation: modal-in 0.45s var(--ease-spring);
}

.modal[open]::backdrop {
  animation: fade-in 0.3s ease-out;
}

.modal.is-closing {
  animation: modal-out 0.2s ease-in forwards;
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px 0;
}

.modal__eyebrow {
  color: var(--c-pink);
  font-weight: 500;
}

.modal__title {
  font-family: var(--f-head);
  font-size: 24px;
  font-weight: 700;
  --lh: 1.2;
}

.modal__close {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c-lavender);
  color: var(--c-ink);
  transition: background-color 0.2s, rotate 0.3s var(--ease-spring);
}

.modal__close:hover {
  background: var(--c-lilac);
  rotate: 90deg;
}

.modal__close svg {
  width: 18px;
  height: 18px;
}

.modal__body {
  display: grid;
  gap: 16px;
  padding: 20px 28px 28px;
}

@media (max-width: 639px) {
  .modal {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 24px 24px 0 0;
  }

  .modal[open] {
    animation-name: sheet-in;
  }

  .modal__head {
    padding: 20px 20px 0;
  }

  .modal__body {
    padding: 16px 20px 24px;
  }
}

/* ---------- Tabs (daily task / bonus) ---------- */

.tabs {
  display: flex;
  gap: 4px;
  margin: 16px 28px 0;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--c-lavender);
}

.tabs__tab {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--c-ink);
  font-weight: 500;
  transition: background-color 0.2s, box-shadow 0.2s;
}

.tabs__tab[aria-selected="true"] {
  background: var(--c-white);
  box-shadow: 0 2px 8px -4px rgba(35, 24, 67, 0.4);
}

.tabs__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-pink);
}

@media (max-width: 639px) {
  .tabs {
    margin-inline: 20px;
  }
}

/* ---------- Task ---------- */

.task {
  display: grid;
  gap: 16px;
}

.task__question {
  font-family: var(--f-head);
  font-size: 21px;
  font-weight: 700;
  --lh: 1.3;
  overflow-wrap: anywhere;
}

.task__link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--c-purple);
  font-weight: 500;
  text-underline-offset: 3px;
}

.task__link svg {
  width: 16px;
  height: 16px;
}

.task__form {
  display: grid;
  gap: 16px;
}

.task__note {
  color: var(--c-ink-soft);
  font-size: 14px;
}

.task__counter {
  justify-self: end;
  color: var(--c-ink-soft);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Answer options */
.options {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--c-line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, transform 0.2s var(--ease-out);
}

.option:hover {
  border-color: var(--c-lilac);
  background: #faf8ff;
}

.option:has(:checked) {
  border-color: var(--c-purple);
  background: var(--c-lavender);
}

.option:has(:disabled) {
  cursor: default;
}

.option:has(:focus-visible) {
  outline: 3px solid var(--c-pink);
  outline-offset: 2px;
}

.option__input {
  display: grid;
  flex-shrink: 0;
  place-content: center;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 2px solid var(--c-line-strong);
  border-radius: 50%;
  appearance: none;
  background: var(--c-white);
}

.option__input::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c-purple);
  transform: scale(0);
  transition: transform 0.2s var(--ease-spring);
}

.option__input:checked {
  border-color: var(--c-purple);
}

.option__input:checked::before {
  transform: scale(1);
}

/* Several answers: square box with a tick */
.option--multi .option__input {
  border-radius: 6px;
}

.option--multi .option__input::before {
  width: 12px;
  height: 12px;
  border-radius: 0;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
}

.option__input:focus-visible {
  outline: none;
}

.option__text {
  overflow-wrap: anywhere;
}

/* Inline feedback */
.feedback {
  padding: 14px 18px;
  border-radius: var(--r-sm);
  font-weight: 500;
}

.feedback--wrong {
  background: #ffe8f1;
  color: #b0124f;
  animation: shake 0.45s ease-in-out;
}

.feedback--info {
  background: var(--c-lavender);
  color: var(--c-ink);
}

.task__form.is-wrong .options,
.task__form.is-wrong .input {
  animation: shake 0.45s ease-in-out;
}

/* ---------- Result (correct / counted / closed) ---------- */

.result {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.result__badge {
  display: grid;
  place-items: center;
}

.result__badge > * {
  grid-area: 1 / 1;
}

.result__icon {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--c-pink);
  color: var(--c-white);
  animation: pop 0.6s var(--ease-spring);
}

.result__icon svg {
  width: 38px;
  height: 38px;
}

.result--muted .result__icon {
  background: var(--c-lavender);
  color: var(--c-ink-soft);
}

.result__title {
  font-family: var(--f-head);
  font-size: 26px;
  font-weight: 700;
  --lh: 1.2;
}

.result__text {
  color: var(--c-ink-soft);
}

.result__explanation {
  justify-self: stretch;
  padding: 16px 18px;
  border-radius: var(--r-sm);
  background: var(--c-lavender);
  text-align: left;
  overflow-wrap: anywhere;
}

.result__source {
  margin-top: 6px;
  color: var(--c-ink-soft);
  font-size: 13px;
}

.result__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

/* Snowflake burst around the result icon */
.burst__flake {
  width: 14px;
  height: 14px;
  color: var(--c-purple);
  opacity: 0;
  pointer-events: none;
  animation: flake-burst 1.1s var(--ease-out) forwards;
  animation-delay: calc(var(--d, 0) * 1ms);
}

.burst__flake:nth-child(3n) {
  color: var(--c-pink);
}

/* ---------- Rules dialog ---------- */

.rules {
  display: grid;
  gap: 12px;
  font-size: 15px;
}

.rules h3 {
  margin-top: 8px;
  font-size: 17px;
}

.rules ul {
  display: grid;
  gap: 6px;
  padding-left: 20px;
  list-style: disc;
}

/* ---------- Keyframes ---------- */

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.94);
  }
}

@keyframes modal-out {
  to {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  0% {
    transform: scale(0.3);
  }

  70% {
    transform: scale(1.12);
  }
}

@keyframes flake-burst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.4) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translate(var(--x), var(--y)) scale(1) rotate(180deg);
  }
}
