/* ==========================================================================
   Action panel — the bottom action panel on a record's page
   ==========================================================================
   From design_handoff_action_group (pattern 1b). One bounded panel at the end
   of a record's show page holding every verb for that record, in three
   explicit roles.

   NOT for cards. `.action-group` in list-blocks.css already means "a cluster
   of buttons inside .card-actions" — a plain flex row with no panel around
   it. This component is deliberately named apart from it: an index page's
   cards must never pick up the fill, border and padding below. Only
   ActionPanelHelper#action_panel emits these classes, and only record pages
   call it.

   Markup contract:

     <div class="action-panel">
       <a class="action-panel__action action-panel__action--primary"   href="…">Edit</a>
       <a class="action-panel__action action-panel__action--secondary" href="…">Archive</a>
       <span class="action-panel__divider" aria-hidden="true"></span>
       <form class="button_to">
         <button class="action-panel__action action-panel__action--destructive">Delete</button>
       </form>
     </div>

   Role comes from the modifier class, never from :first-child or source order:
   a template where Archive comes first, or where the primary action is
   policy-hidden, would otherwise silently promote the wrong control.

   On specificity: this file is alphabetically first, so it loads before
   utilities.css, whose `BUTTON:not(.editor-button)` (0,1,1) would otherwise
   paint every destructive button filled blue. The action rules are scoped
   under `.action-panel` to clear that, the way list-blocks.css and
   line-items.css do. Don't unscope them.
   ========================================================================== */

/* ---------- the panel --------------------------------------------------- */

.action-panel {
  margin-top: 1.5rem;        /* the mist fill is the only separator needed */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.625rem;
  padding: 1rem 1.125rem;
  background: var(--callout-box-background-color);
  border: 1.5px solid var(--nieve);
  border-radius: var(--radius-xl);
}

/* button_to wraps its button in a form. `contents` keeps the button itself as
   the flex item, so the ordering and auto-margin below work the same whether
   an action is a link or a form. */
.action-panel FORM.button_to {
  display: contents;
}

/* Desktop: constructive actions cluster left, destructive is exiled right,
   wherever it sits in the markup. */
.action-panel .action-panel__action--destructive {
  order: 1;
  margin-left: auto;
}

/* Only used on mobile, where "right" no longer exists. */
.action-panel__divider {
  display: none;
}

/* utilities.css puts margin-left on adjacent buttons and button_to forms; the
   flex gap already spaces the panel. Mirrors its selectors one level deeper. */
.action-panel A + A,
.action-panel A + FORM.button_to,
.action-panel BUTTON:not(.editor-button) + BUTTON:not(.editor-button),
.action-panel FORM.button_to + FORM.button_to {
  margin-left: 0;
}

/* ---------- the actions ------------------------------------------------- */

/* Geometry only — no color decisions here, so an action that somehow reaches
   the page without a role modifier has no fill and no border, and the mistake
   is visible in review. */
.action-panel .action-panel__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;              /* 48px — never `height`, labels wrap */
  padding: 0 1.5rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-family-base);
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  background: none;
  box-shadow: none;
  transition: background-color 0.3s linear, color 0.3s linear;
}

.action-panel .action-panel__action:focus-visible {
  outline: 2px solid var(--focus-ring-color);
  outline-offset: 2px;
}

/* Primary — one per panel, the only filled control on the page. */
.action-panel .action-panel__action--primary {
  background: var(--button-background-color);
  color: var(--button-color);
  box-shadow: var(--button-shadow);
}

.action-panel .action-panel__action--primary:hover,
.action-panel .action-panel__action--primary:focus-visible {
  background: var(--button-background-hover-color);
  color: var(--button-color);
}

/* Secondary — outlined in brisa, no shadow. */
.action-panel .action-panel__action--secondary {
  background: var(--nieve);
  color: var(--color-link);
  border-color: var(--brisa);
}

.action-panel .action-panel__action--secondary:hover,
.action-panel .action-panel__action--secondary:focus-visible {
  background: var(--nieve);
  color: var(--color-link-hover);
  border-color: var(--color-link-hover);
}

/* Destructive — tomate outline. Never filled here: the filled tomate belongs
   to the confirm step, so the only solid orange button anyone sees is the one
   that actually deletes. */
.action-panel .action-panel__action--destructive {
  background: transparent;
  color: var(--tomate);
  border-color: rgba(243, 81, 11, 0.35);
}

.action-panel .action-panel__action--destructive:hover,
.action-panel .action-panel__action--destructive:focus-visible {
  background: var(--nieve);
  color: var(--tomate);
  border-color: rgba(243, 81, 11, 0.6);
}

/* ---------- mobile ------------------------------------------------------ */

@media only screen and (max-width: 768px) {
  .action-panel {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.875rem;
  }

  .action-panel .action-panel__action {
    width: 100%;
  }

  /* "Right" is gone — a hairline does the separating instead. */
  .action-panel .action-panel__action--destructive {
    order: 1;
    margin-left: 0;
  }

  .action-panel__divider {
    display: block;
    order: 1;            /* sits directly above the destructive action */
    height: 1px;
    margin: 0.25rem 0;
    background: var(--brisa);
    opacity: 0.6;
  }
}

/* --------------------------------------------------------------------------
   The note under the panel.

   One case only: an admin who may delete this record, looking at a record that
   cannot be deleted yet. The panel holds verbs, and "why can't I?" is not one
   — but leaving nothing at all is what made a missing Delete read as a bug.
   So it sits below the panel, quiet, with the explanation one link away.
   -------------------------------------------------------------------------- */
.action-panel__note {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.action-panel__note a {
  color: inherit;
  text-underline-offset: 2px;
}
