/* ============================================================================
   Flip
   --------------------------------------------------------------------------
   One control for a value that has exactly two states, where the reader has to
   see which state it is in AND be able to change it.

   The pattern it replaces is a badge beside a button: "Disabled  [Enable]".
   That is two controls saying one thing, it takes twice the width, and the two
   rows of a list disagree about their own shape — an active row shows one
   button, a disabled row shows a badge and a button. A flip is a single pill
   that reads as state and clicks as action.

   The knob is the state and the word is the state; the action lives in the
   title. Filled green means in effect. Sunken and grey means not.

   Markup — the button submits, so the flip is a form control and not a link:

     <form method="post" asp-page-handler="ToggleActive">
         <button type="submit" class="flip flip-sm flip-on"
                 role="switch" aria-checked="true" title="Disable this person">
             <span class="flip-knob"></span>
             <span class="flip-label">Enabled</span>
         </button>
     </form>

   Drop .flip-on and flip aria-checked for the other state. Both states carry the
   same border and the same padding, so the two differ only by the width of their
   word — right-align the cell and a column of them holds one edge.
   ========================================================================== */

.flip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-2) var(--space-5);
    border: var(--border-width) solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--neutral-soft);
    color: var(--neutral-on-soft);
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    line-height: var(--leading-snug);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.flip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--brand-ring);
}
.flip:hover { background: var(--surface-sunken); border-color: var(--text-subtle); }

/* The knob leads in the off state and trails in the on state. row-reverse moves
   it without a second rule for the label, and there is no transition to lose:
   the flip submits a form, so the state change arrives with a new document. */
.flip-knob {
    width: var(--space-6);
    height: var(--space-6);
    border-radius: var(--radius-circle);
    /* The knob takes the label's own colour, not the border's: --border-strong on --neutral-soft
       measures 1.41:1, and a dot that faint is decoration rather than the state it claims to be. */
    background: var(--neutral-on-soft);
    flex-shrink: 0;
    transition: background var(--transition);
}
.flip-label { white-space: nowrap; }

.flip-on {
    flex-direction: row-reverse;
    background: var(--success);
    border-color: var(--success);
    color: var(--text-inverse);
}
.flip-on:hover { background: var(--success-hover); border-color: var(--success-hover); }
.flip-on .flip-knob { background: var(--text-inverse); }

/* Row density: the same control inside a table cell, at the size the cells
   around it are set in. */
.flip-sm {
    gap: var(--space-3);
    padding: var(--space-1) var(--space-4);
    font-size: var(--text-xs);
}
.flip-sm .flip-knob { width: var(--space-5); height: var(--space-5); }

.flip[disabled], .flip:disabled { opacity: 0.5; cursor: not-allowed; }
