/* Rate page chrome. The product identity arrives from the bye folder's tokens.css (one
   source of tokens per product) and the mark from bye/icon-128.png; what this sheet adds
   is the same card the bye page draws, plus the star row. Every var() carries a real
   fallback: token availability across the seventeen products was measured, not assumed,
   and depth here is authored rather than borrowed from product shells. */

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

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

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

  --rate-pad: clamp(1.25rem, 0.9rem + 1.6vw, 2rem);
  --rate-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(--rate-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;
}

.rate {
  width: min(100%, var(--rate-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(--rate-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(--rate-group);
  animation: rate-in 380ms var(--rate-ease) both;
}

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

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

/* One left edge for the whole card. The mark and the product name form a lockup; the stars
   and the question sit back on the card's own edge with the labels. */
.rate-head {
  display: flex;
  flex-direction: column;
  gap: var(--rate-pair);
}

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

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

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

/* The chosen rating, restated in the product's own colour. Decorative to the eye, named for
   the reader who cannot see it. */
.stars {
  display: flex;
  gap: var(--space-1, 4px);
  margin-top: var(--rate-pair);
}

.stars .star {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.stars .star path {
  fill: var(--border, #e7e2da);
  transition: fill var(--duration-fast, 120ms) var(--rate-ease);
}

.stars .star.is-filled path {
  fill: var(--primary, #2f6f9f);
}

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

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

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

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

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

textarea,
input[type='text'] {
  width: 100%;
  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;
}

textarea {
  min-height: 5.5rem;
  resize: vertical;
}

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

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

#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(--rate-ease);
  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));
}

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

/* Ring inside the border, never beside it: an outer ring plus a border reads as two frames.
   One visible focus frame at a time is the whole contract. */
#send:focus-visible,
textarea:focus-visible,
input[type='text']: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(--rate-lead);
  color: var(--muted-foreground, #5c5f66);
}

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

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

#thanks[hidden] {
  display: none;
}

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

@media (max-width: 26rem) {
  .rate {
    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) {
  .rate {
    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;
  }
}
