/* The feedback button and its form (public/js/feedback-button.js). Quiet on purpose: the letter tiles stay the
   one bold thing, so the tab is panel-coloured, not gold. Phones get a round button in the corner and
   the form as a sheet from the bottom; computers get a tab on the right edge and a panel beside it. */

.fb-tab { position: fixed; z-index: 40; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; cursor: pointer; background: var(--panel-hi); color: var(--ink); font: 700 15px var(--body);
  transition: padding 0.15s, background 0.15s; }
.fb-tab .icon { width: 22px; height: 22px; color: var(--accent-ink); }
.fb-tab:hover { background: var(--line); }
:root[data-theme="sketchbook"] .fb-tab:hover { background: var(--panel-hi); }

/* Phones and tablets: a round button in the bottom right corner, clear of the home indicator. */
.fb-tab { right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); width: 52px; height: 52px;
  border-radius: 50%; box-shadow: 0 6px 18px rgb(0 0 0 / 0.35); }
.fb-tab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Room for it under the last thing on the page, so it never sits on top of a button at the end (only
   while it shows: not during a game). */
body:not(.embed):not(:has(#game:not([hidden]), #tutorial:not([hidden]))) { padding-bottom: 76px; }

/* Computers: a tab on the right edge, halfway down, that slides out a little on hover. */
@media (min-width: 760px) and (hover: hover) {
  .fb-tab { top: 50%; bottom: auto; right: 0; width: auto; height: auto; padding: 16px 10px; border-radius: 12px 0 0 12px;
    writing-mode: vertical-rl; transform: translateY(-50%) rotate(180deg); box-shadow: none; }
  .fb-tab:hover { padding-right: 14px; }
  .fb-tab { flex-direction: row-reverse; } /* the icon at the top, reading upwards */
  .fb-tab .icon { transform: rotate(180deg); } /* upright again inside the turned tab */
  .fb-tab span { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  body:not(.embed):not(:has(#game:not([hidden]), #tutorial:not([hidden]))) { padding-bottom: 0; }
}

/* Never during a game, the guided first move, on a page inside another site, or while the form is open. */
body:has(#game:not([hidden]), #tutorial:not([hidden]), .fb-panel[open]) .fb-tab, body.embed .fb-tab { display: none; }

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

.fb-panel { padding: 0; border: 0; background: transparent; color: var(--ink); max-height: 100dvh; overflow: visible; }
.fb-panel::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
:root:has(.fb-panel[open]) { overflow: hidden; }
.fb-box { background: var(--screen); border: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); }

/* Phones: a sheet from the bottom, the whole width. */
.fb-panel { margin: auto 0 0; width: 100%; max-width: 100%; }
.fb-box { border-radius: 22px 22px 0 0; border-bottom: 0; max-height: calc(100dvh - 24px); animation: fb-up 0.22s ease-out; }
@keyframes fb-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Computers and tablets: a panel by the right edge, where the tab was. */
@media (min-width: 760px) {
  .fb-panel { margin: auto 24px auto auto; width: 420px; }
  .fb-box { border-radius: 20px; border-bottom: 1px solid var(--line); max-height: calc(100dvh - 48px); padding: 24px; animation: fb-in 0.2s ease-out; }
  @keyframes fb-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}

.fb-form, .fb-done { display: flex; flex-direction: column; gap: 14px; }
.fb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fb-head h2, .fb-done h2 { margin: 0; font-size: 1.5em; }
.fb-close { display: inline-grid; place-items: center; width: 44px; height: 44px; margin: -8px -10px -8px 0; border: 0; border-radius: 12px;
  background: none; color: var(--muted); cursor: pointer; }
.fb-close:hover { background: var(--panel-hi); color: var(--ink); }
.fb-close .icon { width: 22px; height: 22px; }
.fb-lead { margin: -6px 0 0; color: var(--chain); }

.fb-field { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.fb-field legend, .fb-legend { padding: 0; margin-bottom: 8px; font-weight: 700; }
label.fb-field { margin-bottom: -8px; }
.fb-optional { margin-left: 4px; color: var(--muted); font-weight: 400; font-size: 0.85em; }

/* What it's about: four choices, two by two. */
.fb-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fb-chip { position: relative; display: flex; flex-direction: column; gap: 2px; min-height: 64px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--panel); cursor: pointer; line-height: 1.25; }
.fb-chip b { font-size: 0.95em; }
.fb-chip small { color: var(--muted); font-size: 0.8em; }
.fb-chip:hover { background: var(--panel-hi); }
.fb-chip input, .fb-rate input { position: absolute; opacity: 0; pointer-events: none; }
.fb-chip:has(input:checked) { background: var(--gold); color: var(--on-accent); }
.fb-chip:has(input:checked) small { color: var(--on-accent); }
.fb-chip:has(input:focus-visible), .fb-rate:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

.fb-form textarea { width: 100%; box-sizing: border-box; min-height: 104px; resize: vertical; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 2px solid var(--line); background: var(--panel); color: var(--ink); font: 400 16px/1.45 var(--body); }
.fb-form textarea::placeholder { color: var(--muted); opacity: 1; }
.fb-form textarea:focus { outline: none; border-color: var(--ring); }
.fb-count { margin: -8px 0 0; color: var(--muted); font-size: 0.85em; text-align: right; }

/* The rating: five numbers in a row, the ends explained underneath. */
.fb-rates { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.fb-rate { position: relative; display: grid; place-items: center; min-height: 44px; border-radius: var(--radius-sm); background: var(--panel);
  font-weight: 700; cursor: pointer; }
.fb-rate:hover { background: var(--panel-hi); }
.fb-rate:has(input:checked) { background: var(--gold); color: var(--on-accent); }
.fb-ends { display: flex; justify-content: space-between; margin: -2px 0 0; color: var(--muted); font-size: 0.8em; }

.fb-fine { margin: 0; color: var(--muted); font-size: 0.85em; }
.fb-error { margin: 0; color: var(--bad); font-weight: 700; }
.fb-error:empty { display: none; }
.fb-actions { display: flex; align-items: center; gap: 16px; }
.fb-actions .btn { flex: 1; }

/* Sent: the mascot cheers. */
.fb-done { align-items: center; text-align: center; padding: 8px 0 4px; outline: none; }
.fb-done .fb-lead { margin: 0; }
.fb-done .btn { width: 100%; }
.fb-buddy { width: 64px; height: 90px; }
.fb-buddy svg { width: 100%; height: 100%; }
.fb-buddy .m-arm-l { transform-origin: 50px 70px; animation: fb-wave 0.5s ease-in-out 3 alternate; }
@keyframes fb-wave { from { transform: rotate(0); } to { transform: rotate(-60deg); } }

/* Sketchbook (the light look): ink outlines, like its other panels. */
:root[data-theme="sketchbook"] :is(.fb-box, .fb-tab, .fb-chip, .fb-rate) { box-shadow: 0 0 0 2px var(--line); }
:root[data-theme="sketchbook"] .fb-box { border: 0; }
