/* The questionnaire's card (apps/feedback): bottom right, a knitted band of hearts on top.
   States on .fb[data-state]: ask (the invitation) · form (the three questions) · thanks · pill (folded:
   phones, and the editor until it is asked for). Colours are the site's tokens; the band and the hearts
   are drawn once as knitted stitches (draw.py), in Alpine green and wool cream. */

.fb { position: fixed; right: 20px; bottom: 20px; z-index: 85; font-family: var(--font-sans); color: var(--ink);
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.fb[hidden] { display: none; }

.fb-card { position: relative; width: 372px; max-width: calc(100vw - 32px); max-height: calc(100vh - 40px);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-3); overflow: hidden; transform-origin: 100% 100%;
  animation: fb-in .46s cubic-bezier(.2, .9, .3, 1.12) both; }
.fb.is-leaving .fb-card, .fb.is-leaving .fb-tab { animation: fb-out .22s ease-in both; }

.fb-band { flex: none; height: 54px; background: #13261f url("band.svg") repeat-x 0 0 / auto 100%; }
.fb-card .fb-band { animation: fb-knit 1.1s cubic-bezier(.2, .7, .2, 1) both; }

.fb-x { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 50%; border: 0;
  display: grid; place-items: center; cursor: pointer; color: var(--c-ink, #10201a);
  background: color-mix(in srgb, #fff 88%, transparent); box-shadow: 0 1px 3px rgba(0,0,0,.18);
  transition: transform .15s, background .15s; }
.fb-x:hover { background: #fff; transform: rotate(90deg); }
.fb-x:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.fb-body { padding: 20px 22px 22px; overflow-y: auto; overscroll-behavior: contain; }
.fb-title { font-family: var(--font-display); font-weight: 500; font-size: 22px; line-height: 1.2;
  letter-spacing: -.01em; margin: 0 0 8px; color: var(--ink); text-wrap: balance; }
.fb-lede { margin: 0 0 18px; color: var(--ink-2); font-size: 15px; line-height: 1.55; text-wrap: pretty; }
.fb-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fb .btn, .fb-page .btn { height: 38px; padding: 0 16px; font-size: 14px; }     /* the editor sets a smaller rem */

/* the states */
.fb-form, .fb-thanks { display: none; }
.fb[data-state="form"] .fb-form { display: block; animation: fb-fade .3s ease-out both; }
.fb[data-state="form"] .fb-ask .fb-lede, .fb[data-state="form"] .fb-ask .fb-actions { display: none; }
.fb[data-state="form"] .fb-ask .fb-title { font-size: 18px; margin-bottom: 16px; padding-right: 8px; }
.fb[data-state="thanks"] .fb-ask, .fb[data-state="thanks"] .fb-form { display: none; }
.fb[data-state="thanks"] .fb-thanks { display: block; }
.fb[data-state="pill"] .fb-card { display: none; }
.fb-tab[hidden] { display: none; }

/* the questions */
.fb-q { margin: 0 0 18px; padding: 0; border: 0; min-width: 0; }
.fb-label { display: flex; gap: 9px; align-items: flex-start; margin: 0 0 8px; padding: 0;
  font-size: 14px; font-weight: 600; line-height: 1.35; color: var(--ink); }
.fb-label.sm { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.fb-n { flex: none; width: 20px; height: 20px; margin-top: -1px; border-radius: 50%; display: inline-grid;
  place-items: center; background: var(--primary-soft); color: var(--primary-ink); font-size: 11.5px; font-weight: 700; }
.fb-input { display: block; width: 100%; box-sizing: border-box; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r); padding: 9px 12px;
  transition: border-color .14s, box-shadow .14s; }
.fb-input::placeholder { color: var(--ink-3); font-size: 14px; }
.fb-input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
textarea.fb-input { min-height: 78px; resize: vertical; line-height: 1.45; }
.fb-hint { margin: -2px 0 9px; font-size: 13px; color: var(--ink-3); }
.fb-email .fb-hint { margin: 6px 0 0; }

.fb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-chip { position: relative; display: inline-flex; }
.fb-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.fb-chip span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border-2); background: var(--surface); color: var(--ink-2); font-size: 13px; line-height: 1.3;
  cursor: pointer; user-select: none; transition: background .14s, border-color .14s, color .14s, transform .1s; }
.fb-chip span:hover { border-color: var(--ink-3); color: var(--ink); }
.fb-chip span:active { transform: scale(.97); }
.fb-chip input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.fb-chip input:checked + span::before { content: ""; flex: none; width: 9px; height: 5px; margin-top: -3px;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); }
.fb-chip input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 2px; }

.fb-contact { margin: 4px 0 18px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); }
.fb-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.4; color: var(--ink); cursor: pointer; }
.fb-check input { flex: none; width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--primary); }
.fb-email { display: none; margin-top: 12px; }
.fb-contact:has(input[name="contact_ok"]:checked) .fb-email { display: block; animation: fb-fade .25s ease-out both; }
.fb-err { margin: 0 0 12px; color: var(--danger); font-size: 13px; line-height: 1.4; }
.fb-email .fb-err { margin: 6px 0 0; }
.fb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.fb-send.is-busy { opacity: .7; pointer-events: none; }
.fb-card .fb-form .fb-actions { position: sticky; bottom: -22px; z-index: 1; margin: 0 -22px -22px; padding: 12px 22px 18px;
  background: var(--surface); border-top: 1px solid var(--border); }

/* thanks */
.fb-thanks { text-align: center; padding: 6px 4px 2px; }
.fb-thanks .fb-actions { justify-content: center; }
.fb-heart { display: block; margin: 4px auto 16px; width: 76px; height: 76px; border-radius: 50%;
  background: url("heart-light.svg") no-repeat 50% 56% / 46px auto, #2b5344;
  box-shadow: 0 0 0 6px var(--primary-soft), var(--sh-2); animation: fb-pop .6s cubic-bezier(.2, .9, .3, 1.4) both; }

/* folded: a small green tab with a knitted heart, and a × to put it away */
.fb-tab { position: relative; display: inline-flex; animation: fb-in .4s cubic-bezier(.2, .9, .3, 1.12) both; }
.fb-tab-x { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border-2);
  display: grid; place-items: center; padding: 0; cursor: pointer; background: var(--surface); color: var(--ink-2); box-shadow: var(--sh-1);
  opacity: 0; transition: opacity .15s; }
.fb-tab:hover .fb-tab-x, .fb-tab-x:focus-visible { opacity: 1; }
@media (hover: none) { .fb-tab-x { opacity: 1; } }
.fb-pill { display: inline-flex; align-items: center; gap: 9px; height: 42px; padding: 0 16px 0 12px; border: 0;
  border-radius: var(--r-pill); background: var(--primary); color: var(--on-primary); font: inherit; font-size: 14px;
  font-weight: 600; box-shadow: var(--sh-3); cursor: pointer;
  transition: transform .15s, background .15s; }
.fb-pill:hover { transform: translateY(-1px); background: color-mix(in srgb, var(--primary) 86%, #000); }
.fb-pill:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.fb-pill-heart { width: 22px; height: 18px; background: url("heart-light.svg") no-repeat center / contain; }

/* the editor: the inspector is on the right, so the card sits over the canvas, next to the tools */
.fb[data-place="editor"] { right: auto; left: 64px; bottom: 44px; align-items: flex-start; }
.fb[data-place="editor"] .fb-card { transform-origin: 0 100%; }

/* phones: the card becomes a sheet from the bottom edge */
@media (max-width: 640px) {
  .fb { right: 12px; bottom: 12px; }
  .fb[data-place="editor"] { left: 12px; bottom: 12px; }
  .fb:not([data-state="pill"]) { left: 0; right: 0; bottom: 0; align-items: stretch; }
  .fb:not([data-state="pill"]) .fb-card { width: 100%; max-width: none; max-height: 88vh; border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: 0; transform-origin: 50% 100%; }
}

/* the questions on their own page (/feedback/) */
.fb-page { max-width: 620px; margin: var(--sp-6) auto var(--sp-7); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--sh-2); overflow: hidden; }
.fb-page .fb-band { height: 64px; }
.fb-page .fb-body { padding: 28px 32px 32px; overflow: visible; }
.fb-page .fb-title { font-size: 30px; margin-bottom: 10px; }
.fb-page .fb-form { display: block; }
.fb-page .fb-thanks { display: block; padding: 12px 0 4px; }
@media (max-width: 640px) { .fb-page { margin: var(--sp-4) 0; } .fb-page .fb-body { padding: 22px 18px 24px; } }

@keyframes fb-in { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fb-out { to { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes fb-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes fb-pop { 0% { opacity: 0; transform: scale(.5); } 65% { opacity: 1; transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes fb-knit { from { background-position: -120px 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .fb-card, .fb-tab, .fb-heart, .fb-card .fb-band, .fb-form, .fb-email, .fb.is-leaving .fb-card { animation: none !important; }
}
