/* ==========================================================================
   PomoMed — feedback form ("Ajude a melhorar o PomoMed")
   Owner: FEEDBACK. Rendered by /assets/js/feedback.js into section#feedback,
   which gets the .surface context (white panel / dark panel in dark theme).
   Builds on the tokens and .btn / .input / .textarea classes in app.css.
   ========================================================================== */

.fb {
  --fb-err: #b91c1c;
  --fb-warn: #b45309;
  --fb-ok: var(--mode-solid);
  --fb-accent: var(--mode-solid);
  position: relative;
  padding: 8px 0 48px;
  color: var(--surface-text);
  line-height: 1.5;
}
body[data-theme="dark"] .fb {
  --fb-err: #fca5a5;
  --fb-warn: #fbbf24;
  --fb-ok: var(--mode-light);
  --fb-accent: var(--mode-light);
}

.fb__inner {
  max-width: calc(640px + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.fb__card {
  position: relative;
  padding: 22px 20px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-border);
  background:
    radial-gradient(110% 120% at 0% 0%, color-mix(in srgb, var(--mode-solid) 9%, transparent), transparent 55%),
    var(--surface-2);
  transition: background-color var(--mode-transition);
}

/* ---------- header ---------- */
.fb__head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}
.fb__badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--mode-solid) 14%, transparent);
  color: var(--fb-accent);
}
.fb__head-text { min-width: 0; }
.fb__title {
  margin: 2px 0 4px;
  font-size: clamp(1.25rem, 4.2vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -.025em;
  color: var(--surface-text);
}
.fb__lead {
  margin: 0;
  color: var(--surface-muted);
  font-size: .9375rem;
}
/* Public-beta call to action, right under the heading. */
.fb__beta {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 6px;
  /* Ink text (AA over the tinted card corner on every skin); the accent lives on the dot. */
  color: var(--surface-text);
  font-size: .875rem;
  font-weight: 700;
}
.fb__beta::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  margin-top: calc(.75em - 3.5px); /* centred on the first line (line-height 1.5) */
  border-radius: 50%;
  background: var(--fb-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fb-accent) 24%, transparent);
}

/* ---------- form layout ---------- */
.fb__form { display: grid; gap: 14px; }
.fb__body,
.fb__types {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.fb__body { display: grid; gap: 18px; }
.fb__label {
  display: block;
  margin: 0 0 8px;
  padding: 0;
  font-size: .875rem;
  font-weight: 700;
  color: var(--surface-text);
}
.fb__optional { font-weight: 500; color: var(--surface-muted); }
.fb__optional[data-required="1"] { font-weight: 700; color: var(--fb-accent); }
.fb__field { display: grid; min-width: 0; }
.fb__field .fb__label { margin-bottom: 6px; }
.fb__hint {
  font-size: .8125rem;
  color: var(--surface-muted);
}
.fb__field > .fb__hint { margin-top: 6px; }

/* ---------- type: segmented control (native radios) ----------
   4 options: one row of stacked icon/label tiles from 600px, a 2×2 grid below. */
.fb__seg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
}
.fb__seg-opt { position: relative; display: block; min-width: 0; cursor: pointer; }
.fb__seg-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.fb__seg-face {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 6px 8px;
  border-radius: 10px;
  color: var(--surface-muted);
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  transition: background-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.fb__seg-face svg { flex: none; }
.fb__seg-face > span { min-width: 0; overflow-wrap: break-word; }
@media (min-width: 600px) {
  .fb__seg { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fb__seg-face { flex-direction: column; gap: 5px; min-height: 64px; padding: 8px 6px; font-size: .8125rem; }
}
.fb__seg-opt:hover .fb__seg-input:not(:checked) + .fb__seg-face {
  background: color-mix(in srgb, var(--surface-text) 6%, transparent);
  color: var(--surface-text);
}
.fb__seg-input:checked + .fb__seg-face {
  background: var(--primary-bg);
  color: var(--primary-text);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--mode-solid) 35%, transparent);
}
.fb__seg-input:focus-visible + .fb__seg-face {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--ring) 22%, transparent);
}
.fb__seg-input:disabled,
.fb__seg-input:disabled + .fb__seg-face { cursor: not-allowed; }

/* ---------- privacy / LGPD notice (shown when that type is selected) ---------- */
.fb__notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: -6px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--fb-accent) 35%, var(--surface-border));
  background: color-mix(in srgb, var(--mode-solid) 7%, var(--surface));
  color: var(--surface-text);
  font-size: .875rem;
}
.fb__notice[hidden] { display: none; }
.fb__notice-icon { flex: none; display: grid; place-items: center; margin-top: 1px; color: var(--fb-accent); }
.fb__notice-text { min-width: 0; }
.fb__notice-text p { margin: 0; }
.fb__notice-title { font-weight: 750; margin-bottom: 2px !important; }

/* ---------- message + counter ---------- */
.fb__textarea {
  min-height: 120px;
  max-height: 50vh;
  resize: vertical;
  overflow-wrap: anywhere;
}
.fb .textarea[aria-invalid="true"],
.fb .input[aria-invalid="true"] { border-color: var(--fb-err); }
.fb__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}
.fb__count {
  flex: none;
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--surface-muted);
}
.fb__count[data-state="warn"] { color: var(--fb-warn); }
.fb__count[data-state="max"] { color: var(--fb-err); font-weight: 800; }

/* ---------- honeypot (kept off-screen, out of the a11y tree) ---------- */
.fb__hp {
  position: absolute !important;
  left: -10000px !important;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- actions ---------- */
.fb__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}
.fb__submit { min-height: 46px; padding: 0 22px; }
.fb__shortcut { font-size: .75rem; color: var(--surface-muted); }
@media (hover: none) { .fb__shortcut { display: none; } }

.fb__spinner {
  display: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  animation: fb-spin .7s linear infinite;
}
.fb__card.is-busy .fb__spinner { display: inline-block; }
.fb__body:disabled { opacity: .85; }
.fb__body:disabled .fb__submit { opacity: 1; cursor: progress; }
@keyframes fb-spin { to { transform: rotate(360deg); } }

/* ---------- status + privacy ---------- */
.fb__status {
  margin: 0;
  font-size: .9375rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.fb__status:empty { display: none; }
.fb__status[data-state="error"] {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--fb-err);
  background: color-mix(in srgb, var(--fb-err) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--fb-err) 30%, transparent);
}
.fb__privacy {
  margin: 0;
  font-size: .8125rem;
  color: var(--surface-muted);
}
.fb__privacy a { text-decoration: underline; }
.fb__privacy a {
  color: var(--fb-accent);
  font-weight: 650;
  /* ≥40px tap height without changing the line box (inline padding) */
  padding-block: 14px;
}

/* ---------- success ---------- */
.fb__done {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 18px 8px 8px;
  text-align: center;
}
.fb__done:focus,
.fb__done:focus-visible { outline: none; } /* focused only to announce the result; not interactive */
.fb__done-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary-text);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--mode-solid) 14%, transparent);
}
.fb__done-title {
  margin: 6px 0 0;
  font-size: 1.1875rem;
  font-weight: 800;
  color: var(--surface-text);
}
.fb__done-text {
  max-width: 42ch;
  margin: 0 0 10px;
  color: var(--surface-muted);
}
.fb__card.is-done .fb__head { margin-bottom: 4px; }

@media (prefers-reduced-motion: no-preference) {
  .fb__card.is-done .fb__done-icon { animation: fb-pop .45s var(--ease-spring); }
  @keyframes fb-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
  .fb__notice:not([hidden]) { animation: fb-reveal .18s ease-out; }
  @keyframes fb-reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
  /* app.css shortens animations globally; a frozen half-ring would look broken, so hide it. */
  .fb__card.is-busy .fb__spinner { display: none; }
}

/* ---------- small screens ---------- */
@media (max-width: 420px) {
  .fb__card { padding: 18px 14px 14px; }
  .fb__head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px 12px;
  }
  .fb__head-text { display: contents; }
  .fb__title { margin: 0; }
  .fb__beta,
  .fb__lead { grid-column: 1 / -1; }
  .fb__beta { margin: 0; }
  .fb__badge { width: 40px; height: 40px; border-radius: 12px; }
  .fb__seg-face { gap: 6px; min-height: 48px; padding: 6px; font-size: .8125rem; }
  .fb__notice { padding: 10px 12px; }
  .fb__submit { width: 100%; }
}

/* ---------- content pages (body.pg) ---------- */
body.pg .fb { padding-top: 40px; }
body.pg .fb__inner { max-width: calc(720px + 2 * var(--gutter)); }

@media (forced-colors: active) {
  .fb__seg-input:checked + .fb__seg-face { border: 2px solid Highlight; }
  .fb__card { border: 1px solid CanvasText; }
  .fb__notice { border: 1px solid CanvasText; }
}

@media print {
  .fb { display: none !important; }
}
