/* Bye page chrome. Product tokens arrive via tokens.css and carry the identity: colour, face, radius,
   border, focus ring. What the page adds is its own display step and its own spacing rhythm, because a
   product scale that stops at --text-lg 16px and --space-4 16px is built for dense app UI and leaves this
   surface with no hierarchy at all.

   Token availability across the seventeen products was measured, not assumed: the core below exists in
   all of them; --radius, --space-6 and --ease exist in sixteen; shadows differ in intent from product to
   product, so depth here is authored rather than borrowed. Every var() therefore carries a real fallback.
   One trap worth naming: in merge-images --page is 24px, a spacing value, not a colour. Do not reach for it. */

:root {
  /* One column, never wider than comfortable for a single decision. */
  --bye-measure: 27rem;

  /* The page's own type steps. Product tokens stay for body and captions. */
  --bye-display: clamp(1.5rem, 1.18rem + 1.4vw, 1.875rem);
  --bye-lead: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
  --bye-label: 0.6875rem;

  /* Rhythm: tight inside a pair, generous between groups, most generous before the decision. */
  --bye-pair: 0.375rem;
  --bye-inner: 0.625rem;
  --bye-group: 1.5rem;
  --bye-decide: 1.75rem;

  --bye-pad: clamp(1.25rem, 0.9rem + 1.6vw, 2rem);
  --bye-ease: var(--ease, cubic-bezier(0.2, 0, 0, 1));
}

html {
  box-sizing: border-box;
  /* The caret and the selection are part of the design even though nobody drew them. */
  caret-color: var(--primary, #2f6f9f);
  scrollbar-color: var(--border, #e7e2da) transparent;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

::selection {
  background: color-mix(in srgb, var(--primary, #2f6f9f) 22%, transparent);
  color: var(--foreground, #1f2328);
}

html,
body {
  margin: 0;
  background: var(--background, #ffffff);
  color: var(--foreground, #1f2328);
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: var(--bye-lead);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* The card sits in the middle of the viewport instead of hanging from the top edge. `safe` keeps it
   reachable when a phone keyboard shrinks the box below the card's own height. */
body {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: safe center;
  padding: clamp(1rem, 4vh, 3rem) 1rem;
}

.bye {
  width: min(100%, var(--bye-measure));
  background: var(--card, #faf8f4);
  color: var(--card-foreground, var(--foreground, #1f2328));
  border: var(--border-width, 1px) solid var(--border, #e7e2da);
  border-radius: var(--radius, var(--radius-sm, 12px));
  padding: var(--bye-pad);
  /* Offset plus soft blur, twice: a close contact shadow and a wide soft one. Not a halo. */
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.05),
    0 20px 44px -24px rgb(0 0 0 / 0.24);
  display: flex;
  flex-direction: column;
  gap: var(--bye-group);
  animation: bye-in 380ms var(--bye-ease) both;
}

@keyframes bye-in {
  from {
    opacity: 0.55;
    transform: translateY(6px);
  }
}

/* ---------- head ---------- */

/* One left edge for the whole card. The mark and the title form a lockup; the question sits back on the
   card's own edge with the chips and the labels, instead of hanging off the title's indent. */
.bye-head {
  display: flex;
  flex-direction: column;
  gap: var(--bye-pair);
}

.bye-lockup {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
}

.bye-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm, 8px);
  flex: 0 0 auto;
}

h1 {
  margin: 0;
  font-size: var(--bye-display);
  font-weight: 640;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
  color: var(--foreground, #1f2328);
}

.question {
  margin: 0;
  color: var(--muted-foreground, #5c5f66);
  text-wrap: pretty;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

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

form {
  display: flex;
  flex-direction: column;
  gap: var(--bye-group);
}

.chips {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2, 8px);
}

/* The chips are the task: someone who has already left gives one tap, or nothing. They get the product's
   own radius rather than a forced pill, so seventeen products do not all wear the same badge. */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--target-min, 44px);
  padding: 0 0.875rem;
  border: var(--border-width, 1px) solid var(--border, #e7e2da);
  border-radius: var(--radius-sm, 8px);
  background: var(--background, #ffffff);
  color: var(--foreground, #1f2328);
  cursor: pointer;
  font: inherit;
  font-size: var(--text-base, 14px);
  transition: background-color var(--duration-fast, 120ms) var(--bye-ease),
    border-color var(--duration-fast, 120ms) var(--bye-ease);
}

.chip:hover {
  background: var(--muted, #f1eee8);
  border-color: var(--border-strong, var(--muted-foreground, #5c5f66));
}

.chip:has(input:checked) {
  background: var(--primary, #2f6f9f);
  color: var(--primary-foreground, #ffffff);
  border-color: var(--primary, #2f6f9f);
}

/* Ring inside the border, never beside it: an outer ring plus a border reads as two frames. */
.chip:focus-within {
  outline: 2px solid var(--ring, var(--primary, #2f6f9f));
  outline-offset: calc(-1 * var(--border-width, 1px));
}

.chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.text-field {
  display: flex;
  flex-direction: column;
  gap: var(--bye-inner);
}

.text-label {
  color: var(--muted-foreground, #5c5f66);
  font-size: var(--bye-label);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 5.5rem;
  resize: vertical;
  padding: 0.75rem 0.875rem;
  border: var(--border-width, 1px) solid var(--border, #e7e2da);
  border-radius: var(--radius-sm, 8px);
  background: var(--background, #ffffff);
  color: var(--foreground, #1f2328);
  font: inherit;
  font-size: var(--text-base, 14px);
  line-height: 1.5;
}

/* Placeholders inherit a browser grey that fails contrast on a tinted card. Tint it from the palette. */
textarea::placeholder {
  color: var(--muted-foreground, #5c5f66);
  opacity: 0.85;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3, 12px);
  margin-top: calc(var(--bye-decide) - var(--bye-group));
}

#skip,
#send {
  min-height: var(--target-min, 44px);
  padding: 0 1.125rem;
  border-radius: var(--radius-sm, 8px);
  font: inherit;
  font-size: var(--text-base, 14px);
  font-weight: 560;
  cursor: pointer;
  transition: background-color var(--duration-fast, 120ms) var(--bye-ease);
}

#skip {
  border: var(--border-width, 1px) solid transparent;
  background: transparent;
  color: var(--muted-foreground, #5c5f66);
  padding-inline: 0.75rem;
}

#skip:hover {
  background: var(--muted, #f1eee8);
  color: var(--foreground, #1f2328);
}

#send {
  border: var(--border-width, 1px) solid var(--primary, #2f6f9f);
  background: var(--primary, #2f6f9f);
  color: var(--primary-foreground, #ffffff);
}

#send:hover {
  background: var(--primary-solid-hover, var(--primary, #2f6f9f));
}

/* Before a reason is picked the button is not broken, it is not its turn yet. A faded primary reads as a
   bug; a quiet filled control reads as waiting. Pointer events stay on so the cursor can say so. */
form:not(:has(input[name='reason']:checked)) #send {
  background: var(--muted, #f1eee8);
  border-color: var(--border, #e7e2da);
  color: var(--muted-foreground, #5c5f66);
  cursor: not-allowed;
}

#send[disabled] {
  background: var(--muted, #f1eee8);
  border-color: var(--border, #e7e2da);
  color: var(--muted-foreground, #5c5f66);
  cursor: progress;
}

#skip:focus-visible,
#send:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--ring, var(--primary, #2f6f9f));
  outline-offset: calc(-1 * var(--border-width, 1px));
}

/* ---------- thanks ---------- */

#thanks {
  margin: 0;
  font-size: var(--bye-lead);
  color: var(--muted-foreground, #5c5f66);
}

body.is-thanks form,
body.is-thanks .question {
  display: none;
}

body.is-thanks #thanks {
  display: block;
}

#thanks[hidden] {
  display: none;
}

/* ---------- edges ---------- */

@media (max-width: 26rem) {
  .bye {
    gap: var(--space-4, 16px);
  }

  .actions {
    margin-top: var(--space-3, 12px);
  }
}

/* A card lifted off a dark ground needs a hairline, not a heavier shadow. */
@media (prefers-color-scheme: dark) {
  .bye {
    box-shadow:
      0 1px 0 rgb(255 255 255 / 0.04) inset,
      0 24px 48px -28px rgb(0 0 0 / 0.6);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
