/* ══════════════════════════════════════════════════════════════════
   Review composer — the shared "leave a review" component.

   Loaded by templates/rate.html (emailed one-tap link) AND the inline
   composer on templates/reviews.html so the two read as one feature.
   Standalone stylesheet — NOT part of _bundle.css, so no bundle
   rebuild. Uses only global --b-* tokens from booker-v3.css.
   ══════════════════════════════════════════════════════════════════ */

/* ── Star picker ────────────────────────────────────────────────── */
.rvc-rating {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.rvc-row {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
}

.rvc-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* The served bundle ships `label { display:block; color; margin-bottom } !important`
   (booker-v3 §forms). Every one of those has to be beaten explicitly here or the
   stars render as slate blocks with an 8px gutter. Same for the fill states below. */
.rvc-row label {
  display: grid !important;
  place-items: center;
  min-width: 3rem;
  min-height: 3rem;
  margin: 0 !important;
  padding: 0.25rem;
  border-radius: var(--b-r-md);
  cursor: pointer;
  color: var(--b-border-2) !important;
  -webkit-tap-highlight-color: transparent;
}

.rvc-row svg {
  width: clamp(2.15rem, 9vw, 2.75rem);
  height: clamp(2.15rem, 9vw, 2.75rem);
  fill: currentColor;
  transform: scale(0.88);
  transition:
    color var(--b-dur-base, 300ms) var(--b-ease),
    transform var(--b-dur-base, 300ms) var(--b-ease-bounce),
    filter var(--b-dur-base, 300ms) var(--b-ease);
}

/* Cascade the fill left→right so selecting reads as "filling up". */
.rvc-row label:nth-of-type(2) svg { transition-delay: 40ms; }
.rvc-row label:nth-of-type(3) svg { transition-delay: 80ms; }
.rvc-row label:nth-of-type(4) svg { transition-delay: 120ms; }
.rvc-row label:nth-of-type(5) svg { transition-delay: 160ms; }

/* Selected star + every star before it. `label:has(~ input:checked)`
   is the only way to reach PRECEDING siblings — the old row-reverse
   trick put the radio group in backwards DOM order, which sent arrow
   keys the wrong way. */
.rvc-row input:checked + label,
.rvc-row label:has(~ input:checked) {
  color: var(--b-warning) !important;
}

.rvc-row input:checked + label svg,
.rvc-row label:has(~ input:checked) svg {
  transform: scale(1);
  filter: drop-shadow(0 3px 10px rgba(245, 158, 11, 0.42));
}

.rvc-row input:focus-visible + label {
  outline: 2px solid var(--b-border-focus);
  outline-offset: 2px;
}

/* Hover preview — reset the whole row, then light up to the cursor. */
@media (hover: hover) and (pointer: fine) {
  .rvc-row:hover label { color: var(--b-border-2) !important; }
  .rvc-row:hover label svg {
    transform: scale(0.88);
    filter: none;
    transition-delay: 0ms;
  }
  .rvc-row label:hover,
  .rvc-row label:has(~ label:hover) { color: var(--b-warning) !important; }
  .rvc-row label:hover svg,
  .rvc-row label:has(~ label:hover) svg {
    transform: scale(1.04);
    filter: drop-shadow(0 3px 10px rgba(245, 158, 11, 0.42));
  }
}

.rvc-row label:active svg { transform: scale(0.94); }

/* ── Live caption — pure CSS, keyed off which radio is checked ──── */
.rvc-cap {
  margin: 0.85rem 0 0;
  min-height: 1.35rem;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--b-text-3);
  letter-spacing: var(--b-tracking-body, -0.01em);
}

.rvc-cap span { display: none; }
.rvc-cap .rvc-cap-hint { display: inline; }

.rvc-rating:has(.rvc-row input:checked) .rvc-cap .rvc-cap-hint { display: none; }
.rvc-rating:has(.rvc-row input:nth-of-type(1):checked) .rvc-cap [data-v="1"],
.rvc-rating:has(.rvc-row input:nth-of-type(2):checked) .rvc-cap [data-v="2"],
.rvc-rating:has(.rvc-row input:nth-of-type(3):checked) .rvc-cap [data-v="3"],
.rvc-rating:has(.rvc-row input:nth-of-type(4):checked) .rvc-cap [data-v="4"],
.rvc-rating:has(.rvc-row input:nth-of-type(5):checked) .rvc-cap [data-v="5"] {
  display: inline;
  color: var(--b-text);
}

/* ── Comment field ──────────────────────────────────────────────── */
.rvc-field {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 6.5rem;
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--b-border);
  border-radius: var(--b-r-lg);
  background: var(--b-surface-2);
  color: var(--b-text);
  font-family: var(--b-font-main);
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  transition:
    border-color var(--b-dur-fast, 120ms) var(--b-ease),
    background var(--b-dur-fast, 120ms) var(--b-ease),
    box-shadow var(--b-dur-fast, 120ms) var(--b-ease);
}

.rvc-field::placeholder { color: var(--b-text-4); }

.rvc-field:focus {
  outline: none;
  background: var(--b-surface);
  border-color: var(--b-border-focus);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.16);
}

/* ── Submit ─────────────────────────────────────────────────────── */
.rvc-submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.95rem 1.25rem;
  border: 0;
  border-radius: var(--b-r-lg);
  background: var(--b-gradient);
  color: #fff;
  font-family: var(--b-font-display);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: var(--b-tracking-body, -0.01em);
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--b-shadow-blue, 0 10px 26px -10px rgba(14, 165, 233, 0.55));
  transition:
    transform var(--b-dur-fast, 120ms) var(--b-ease),
    box-shadow var(--b-dur-base, 300ms) var(--b-ease),
    filter var(--b-dur-base, 300ms) var(--b-ease);
}

.rvc-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--b-shadow-blue-lg, 0 16px 34px -12px rgba(14, 165, 233, 0.6));
}

.rvc-submit:active:not(:disabled) { transform: translateY(0); }

.rvc-submit:focus-visible {
  outline: 2px solid var(--b-border-focus);
  outline-offset: 3px;
}

.rvc-submit:disabled { cursor: default; }

/* Idle-but-invalid: the form is reachable, just not complete yet. */
.rvc-submit.is-idle {
  background: var(--b-surface-3);
  color: var(--b-text-4);
  box-shadow: none;
}

/* In-flight */
.rvc-submit.is-busy {
  filter: saturate(0.75);
  color: transparent;
}

.rvc-submit.is-busy::after {
  content: "";
  position: absolute;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: rvc-spin 0.7s linear infinite;
}

@keyframes rvc-spin { to { transform: rotate(360deg); } }

.rvc-legal {
  margin: 0.85rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--b-text-4);
}

/* ── Inline error ───────────────────────────────────────────────── */
.rvc-error {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0 0 0.9rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--b-error);
  border-radius: var(--b-r-md);
  background: var(--b-error-bg);
  color: var(--b-error);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.5;
}

.rvc-error svg { flex: 0 0 auto; width: 1.05rem; height: 1.05rem; margin-top: 1px; }
/* The class sets display:flex, which beats the UA's `[hidden] { display:none }`. */
.rvc-error[hidden] { display: none !important; }

/* ══════════════════════════════════════════════════════════════════
   Success state — the moment worth designing
   ══════════════════════════════════════════════════════════════════ */
.rvc-done {
  text-align: center;
  padding: 0.5rem 0 0.25rem;
  animation: rvc-rise 0.5s var(--b-ease) both;
}

@keyframes rvc-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.rvc-done-badge {
  display: grid;
  place-items: center;
  width: 5rem;
  height: 5rem;
  margin: 0 auto 1.25rem;
  border-radius: var(--b-r-2xl, 24px);
  background: var(--b-gradient);
  box-shadow: 0 18px 36px -14px rgba(13, 148, 136, 0.65);
  animation: rvc-pop 0.55s var(--b-ease-bounce) both;
}

@keyframes rvc-pop {
  from { transform: scale(0.42); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.rvc-done-badge svg {
  width: 2.6rem;
  height: 2.6rem;
  color: #fff;
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  animation: rvc-draw 0.5s 0.24s var(--b-ease) forwards;
}

@keyframes rvc-draw { to { stroke-dashoffset: 0; } }

.rvc-done-stars {
  display: flex;
  justify-content: center;
  gap: 0.2rem;
  margin-bottom: 0.9rem;
  color: var(--b-warning);
}

.rvc-done-stars svg { width: 1.05rem; height: 1.05rem; fill: currentColor; }

.rvc-done-title {
  margin: 0 0 0.5rem;
  font-family: var(--b-font-display);
  font-size: clamp(1.5rem, 5vw, 1.85rem);
  font-weight: 800;
  letter-spacing: var(--b-tracking-header, -0.04em);
  color: var(--b-text);
}

.rvc-done-sub {
  margin: 0 auto;
  max-width: 34ch;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--b-text-3);
}

.rvc-done-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1.5rem;
  padding: 0.8rem 1.6rem;
  border-radius: var(--b-r-full, 9999px);
  border: 1px solid var(--b-border-2);
  background: var(--b-surface);
  color: var(--b-primary) !important;
  font-family: var(--b-font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  text-decoration: none;
  transition:
    transform var(--b-dur-fast, 120ms) var(--b-ease),
    border-color var(--b-dur-base, 300ms) var(--b-ease),
    box-shadow var(--b-dur-base, 300ms) var(--b-ease);
}

.rvc-done-cta:hover {
  transform: translateY(-1px);
  border-color: var(--b-border-focus);
  box-shadow: var(--b-shadow-sm);
}

.rvc-done-cta svg { width: 1rem; height: 1rem; }

/* ── Confetti-lite ──────────────────────────────────────────────── */
.rvc-confetti {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  pointer-events: none;
}

.rvc-confetti i {
  position: absolute;
  top: -1.5rem;
  width: 8px;
  height: 13px;
  border-radius: 1px;
  opacity: 0.92;
  animation: rvc-fall linear forwards;
}

@keyframes rvc-fall {
  to { transform: translateY(108vh) rotate(560deg); opacity: 0; }
}

/* ── Motion budget ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .rvc-row svg,
  .rvc-submit,
  .rvc-field,
  .rvc-done-cta { transition-duration: 1ms !important; transition-delay: 0ms !important; }
  .rvc-done,
  .rvc-done-badge,
  .rvc-done-badge svg { animation: none !important; }
  .rvc-done-badge svg { stroke-dashoffset: 0; }
  .rvc-submit.is-busy::after { animation-duration: 1.4s; }
  .rvc-confetti { display: none; }
}

/* ── Dark ───────────────────────────────────────────────────────── */
[data-theme="dark"] .rvc-row label { color: var(--b-surface-3) !important; }
[data-theme="dark"] .rvc-field { background: var(--b-surface-3); }
[data-theme="dark"] .rvc-field:focus { background: var(--b-surface-2); }
[data-theme="dark"] .rvc-submit.is-idle { color: var(--b-text-4); }
/* booker-v3 gives dark mode a --b-error-bg but no lightened --b-error, so the
   foreground is a literal (red-300, ~7:1 on the navy surface) — the same
   exception the credits/reviews dark-contrast overrides already make. */
[data-theme="dark"] .rvc-error { color: #fca5a5; border-color: rgba(248, 113, 113, 0.4); }
[data-theme="dark"] .rvc-done-cta { background: var(--b-surface-2); }

@media (hover: hover) and (pointer: fine) {
  [data-theme="dark"] .rvc-row:hover label { color: var(--b-surface-3) !important; }
}
