/* The bottom sheet that carries the task (task.md section 9.4). */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgb(43 29 69 / 45%);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}

.scrim--visible {
  opacity: 1;
}

.sheet {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  padding: var(--space-3) var(--space-4) var(--space-4);
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform var(--dur-base) var(--ease-out);
  overscroll-behavior: contain;
}

.sheet--open {
  transform: translateY(0);
}

.sheet__grip {
  width: 44px;
  height: 5px;
  margin: 0 auto var(--space-3);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--ink) 18%, transparent);
  flex: none;
}

/* The slot is the scrolling column between the grip and the bottom of the
   sheet. It needs min-height: 0 or a flex item refuses to shrink below its
   content and the panel grows past the screen. */
.sheet__slot {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.sheet__body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.sheet__head {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sheet__title {
  font-size: var(--text-lg);
}

.sheet__sub {
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sheet__task {
  font-size: var(--text-md);
  white-space: pre-line;
  color: var(--ink);
}

/* The action row sticks to the bottom of the panel: a long answer history must
   never push the button she needs off the screen. */
.sheet__footer {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-2);
  padding-bottom: var(--space-1);
  background: var(--surface);
}

/* --- answer form -------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__label {
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field__row {
  display: flex;
  gap: var(--space-2);
}

.input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: var(--space-3) var(--space-4);
  border: 2px solid color-mix(in srgb, var(--ink) 12%, transparent);
  border-radius: var(--radius-md);
  background: var(--paper);
  font-size: var(--text-sm);
  font-weight: 600;
}

.input::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, transparent);
}

.input:focus-visible {
  border-color: var(--violet);
}

.input--error {
  border-color: var(--rose);
  background: var(--rose-soft);
  animation: shake 300ms var(--ease-out);
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

.sheet__error {
  min-height: 1.5em;
  font-size: var(--text-sm);
  font-weight: 800;
  color: var(--rose);
}

.sheet__note {
  font-size: var(--text-sm);
  color: var(--muted);
}

.sheet__success {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--gold-soft);
  font-size: var(--text-md);
}

/* --- locked node -------------------------------------------------------- */

.sheet__locked {
  text-align: center;
  padding: var(--space-5) 0;
  color: var(--muted);
  font-size: var(--text-md);
}

.sheet__media {
  width: 100%;
  border-radius: var(--radius-md);
  background: var(--paper);
}

/* A congratulation clip is opened from a plain button (`.clip__open`, styled as
   a `.btn`), never previewed inline: a static round thumbnail said nothing. */

/* --- desktop: the sheet docks to the right ------------------------------- */

@media (min-width: 900px) {
  .scrim {
    background: none;
  }

  .sheet {
    top: 0;
    left: auto;
    right: max(var(--space-5), calc(50vw - var(--content-max) / 2 - 320px));
    width: 380px;
    max-height: none;
    height: 100dvh;
    border-radius: 0;
    box-shadow: var(--shadow-lg);
    transform: translateX(110%);
    padding: var(--space-5) var(--space-4);
    padding-right: var(--space-5);
  }

  .sheet__grip {
    display: none;
  }
}
