/* ============================================================
   Feedback widget (web/templates/partials/feedback_widget.html).
   The button, the warning, the note field, the CJI attestation and the
   actions are design-system components; this sheet owns only the widget's
   own geometry: the fixed round launcher, the panel that slides up from the
   bottom edge, and its backdrop.
   Structure in @layer layout, paint in @layer design. Tokens only.

   The root renders hidden; feedback.js removes [hidden] and toggles
   [data-open]. The root is display: contents so it adds no row to
   the body grid; its children are all fixed.
   ============================================================ */

@layer layout {
  .feedback:not([hidden]) { display: contents; }

  .feedback-open {
    position: fixed;
    inset-block-end: var(--t-space-4);
    inset-inline-end: var(--t-space-4);
    z-index: var(--mea-z-top);
    /* Only the panel slides. The button never animates, so it is always
       still enough to click. */
    transition: none;
    animation: none;
  }

  /* The button that opens the feedback dialog shows only the life buoy
     icon, so it is round: the same padding on every side. */
  .feedback > :is(button, .button).feedback-open {
    padding: var(--t-space-3);
  }

  .feedback-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--mea-z-top);
    visibility: hidden;
    opacity: 0;
  }

  .feedback-panel {
    position: fixed;
    inset-block-end: 0;
    inset-inline-end: 0;
    z-index: var(--mea-z-top);
    display: grid;
    gap: var(--t-space-3);
    inline-size: min(100%, 28rem);
    max-block-size: 90vh;
    overflow-y: auto;
    padding: var(--t-space-5);
    padding-block-end: max(var(--t-space-5), env(safe-area-inset-bottom));
    visibility: hidden;
    transform: translateY(100%);
  }

  .feedback[data-open] .feedback-panel {
    visibility: visible;
    transform: translateY(0);
  }

  .feedback[data-open] .feedback-backdrop {
    visibility: visible;
    opacity: 1;
  }

  /* The form and the thank-you view take turns in the panel's grid. */
  .feedback-form:not([hidden]), .feedback-thanks:not([hidden]) { display: contents; }

  .feedback-heading, .feedback-status, .feedback-thanks-body { margin: 0; }
  .feedback-status:empty { display: none; }
  /* The callout draws itself as a grid, which beats the UA's [hidden];
     the error box stays out of sight until the script shows it. */
  .feedback .callout[hidden] { display: none; }

  /* The page's last content scrolls clear of the button. */
  body:has(.feedback:not([hidden])) .appfooter {
    padding-block-end: calc(var(--t-target-min-size) + var(--t-space-8));
  }

  /* The officer dashboard pins #primary-actions to the bottom of a narrow
     screen (web.css); the button rides above that bar. */
  @media (max-width: 48rem) {
    body:has(#primary-actions) .feedback-open {
      inset-block-end: calc(var(--t-target-min-size) + var(--t-space-4) * 3);
    }
  }

  /* Opening flips visibility at once, so focus can land in the panel on the
     same tick; closing holds it visible until the slide down finishes. */
  @media (prefers-reduced-motion: no-preference) {
    .feedback-panel {
      transition: transform 0.25s ease, visibility 0s linear 0.25s;
    }
    .feedback-backdrop {
      transition: opacity 0.25s ease, visibility 0s linear 0.25s;
    }
    .feedback[data-open] .feedback-panel,
    .feedback[data-open] .feedback-backdrop {
      transition-delay: 0s;
    }
  }
}

@layer design {
  .feedback-backdrop { background: var(--mea-scrim); }

  .feedback-panel {
    border-start-start-radius: var(--t-radius-lg);
    border-start-end-radius: var(--t-radius-lg);
  }

  .feedback-heading { font-size: var(--t-font-size-lg); }

}
