﻿/* Bootstrap bridge — redefines Bootstrap's own classes in our tokens, at Bootstrap's own
   specificity, so it wins purely on load order. Loaded after app.css (see App.razor): app.css
   still carries an older --brand-accent palette for .btn-primary and a shared focus rule, and this
   file supersedes both in the same commit that adds it — two sources of truth for one button is how
   a palette drifts back.

   Scope is deliberately narrow: .btn and its variants, .form-control/.form-select/.form-check-input/
   .form-label/.form-floating > label, .alert and its variants, .text-danger/.validation-message, and
   .table. Bootstrap's grid, dropdowns, modals and utilities are untouched — restyling what nothing
   renders is how a shim grows into a fork.

   Contrast: every pair this file puts on screen is checked in
   bullxwinkles.tests/BootstrapBridgeContrastTests.cs against WCAG AA. */

/* ---------------------------------------------------------------------------------------------
   Buttons
   .btn takes the geometry of .bx-btn (base.css): min-height, pill-free control radius, weight 600,
   focus-visible ring. Variants only change fill/ink so the shape never drifts between them.
--------------------------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: var(--bx-r-control);
  border: 1px solid transparent;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: transform var(--bx-t-fast) ease, box-shadow var(--bx-t-fast) ease,
              background-color var(--bx-t-fast) ease, border-color var(--bx-t-fast) ease;
}
.btn:focus {
  box-shadow: none;
}
.btn:focus-visible {
  outline: 3px solid var(--bx-focus);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--bx-teal);
  border-color: var(--bx-teal);
  color: var(--bx-teal-ink);
}
.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--bx-teal);
  border-color: var(--bx-teal);
  color: var(--bx-teal-ink);
  box-shadow: var(--bx-glow-teal);
}
.btn-primary:active {
  background-color: var(--bx-teal);
  border-color: var(--bx-teal);
  color: var(--bx-teal-ink);
  transform: translateY(1px);
}
.btn-primary:disabled,
.btn-primary.disabled {
  background-color: var(--bx-teal);
  border-color: var(--bx-teal);
  color: var(--bx-teal-ink);
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--bx-teal-border);
  color: var(--bx-text);
}
.btn-secondary:hover,
.btn-secondary:focus {
  background-color: color-mix(in srgb, var(--bx-teal) 8%, transparent);
  border-color: var(--bx-teal-border);
  color: var(--bx-text);
}
.btn-secondary:active {
  background-color: color-mix(in srgb, var(--bx-teal) 14%, transparent);
  border-color: var(--bx-teal-border);
  color: var(--bx-text);
}

/* Destructive action. Red stays red here — teal must never stand in for .btn-danger. */
.btn-danger {
  background-color: var(--bx-danger);
  border-color: var(--bx-danger);
  color: var(--bx-teal-ink);
}
.btn-danger:hover,
.btn-danger:focus {
  background-color: var(--bx-danger);
  border-color: var(--bx-danger);
  color: var(--bx-teal-ink);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--bx-danger) 22%, transparent);
}
.btn-danger:active {
  background-color: var(--bx-danger);
  border-color: var(--bx-danger);
  color: var(--bx-teal-ink);
  transform: translateY(1px);
}

.btn-link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--bx-teal);
  text-decoration: underline;
  font-weight: 600;
}
.btn-link:hover,
.btn-link:focus {
  color: var(--bx-teal-border);
}

.btn-sm {
  min-height: 44px;
  padding: 0 16px;
  font-size: 14px;
}

.btn-lg {
  min-height: 52px;
  padding: 0 28px;
  font-size: 18px;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Provider buttons. Moved from app.css unchanged in behaviour — they render as Google's and
   Facebook's own brand marks, not our palette, so they keep their real brand colours rather than
   our tokens. They still inherit the 44px min-height and focus-visible ring from .btn above,
   because the markup is always class="btn btn-google" / "btn btn-facebook". */
.btn-google {
  background: #fff;
  color: #444;
  border: 1px solid #ddd;
  font-weight: 500;
  padding: 0.5rem 1.5rem;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s, color 0.2s;
}
.btn-google:hover {
  background: #f7f7f7;
  color: #222;
}

.btn-facebook {
  /* Facebook's own #1877F3 puts white text at 4.22:1, under AA — it failed before this slice and
     axe flags it on every sign-in page. One step darker clears the bar at 5.24:1 and still reads
     unmistakably as the Facebook button. Worth showing the designer: this is a deliberate step off
     the brand colour, taken because the alternative is a contrast failure on the page every player
     meets first. */
  background: #1868d8;
  color: #fff;
  font-weight: 500;
  padding: 0.5rem 1.5rem;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  transition: background 0.2s, color 0.2s;
}
.btn-facebook:hover {
  background: #145db2;
  color: #fff;
}

/* Make external login buttons uniform and full-width (moved from app.css, unchanged). */
.btn-google,
.btn-facebook {
  width: 100%;
  justify-content: center;
  border-radius: 0.75rem;
  padding: 0.65rem 1rem;
  font-weight: 600;
}

/* ---------------------------------------------------------------------------------------------
   Fields
--------------------------------------------------------------------------------------------- */

.form-control,
.form-select {
  min-height: 44px;
  background-color: var(--bx-panel-solid);
  border: 1px solid var(--bx-teal-border);
  border-radius: var(--bx-r-control);
  color: var(--bx-text);
}
.form-control::placeholder {
  color: var(--bx-text-muted);
  opacity: 1;
}
.form-control:focus,
.form-select:focus {
  background-color: var(--bx-panel-solid);
  border-color: var(--bx-teal);
  color: var(--bx-text);
  box-shadow: none;
}
.form-control:focus-visible,
.form-select:focus-visible {
  outline: 3px solid var(--bx-focus);
  outline-offset: 2px;
}
.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
  background-color: var(--bx-panel-solid);
  color: var(--bx-text-muted);
  opacity: 0.7;
}

.form-check-input {
  background-color: var(--bx-panel-solid);
  border: 1px solid var(--bx-teal-border);
  accent-color: var(--bx-teal);
}
.form-check-input:focus {
  box-shadow: none;
}
.form-check-input:focus-visible {
  outline: 3px solid var(--bx-focus);
  outline-offset: 2px;
}

.form-label,
.form-floating > label {
  color: var(--bx-text-muted);
}

/* ---------------------------------------------------------------------------------------------
   Messages
--------------------------------------------------------------------------------------------- */

.alert {
  border: 1px solid var(--bx-teal-border);
  border-radius: var(--bx-r-control);
  background-color: var(--bx-panel-solid);
  color: var(--bx-text);
}
.alert-danger {
  border-color: var(--bx-danger);
  background-color: color-mix(in srgb, var(--bx-danger) 16%, var(--bx-panel-solid));
  color: var(--bx-text);
}
.alert-success {
  border-color: var(--bx-teal);
  background-color: color-mix(in srgb, var(--bx-teal) 16%, var(--bx-panel-solid));
  color: var(--bx-text);
}
.alert-warning {
  border-color: var(--bx-gold);
  background-color: color-mix(in srgb, var(--bx-gold) 16%, var(--bx-panel-solid));
  color: var(--bx-text);
}
.alert-info {
  border-color: var(--bx-teal-border);
  background-color: color-mix(in srgb, var(--bx-teal-border) 16%, var(--bx-panel-solid));
  color: var(--bx-text);
}

/* .validation-message is Blazor's own class and takes the token the ordinary way. .text-danger is
   Bootstrap's, and Bootstrap declares it !important — so this rule never applied, and every
   .text-danger on the site was still painting Bootstrap's #DC3545. Measured live on
   /Account/Lockout and /Account/AccessDenied, where a 16px paragraph in that red on the auth card
   comes to 3.82:1: the colour-contrast violation axe reported on both pages. Under the token it is
   5.75:1.

   Worth being precise about, because the spec recorded this pair as a documented near-miss at
   4.43:1 and it was never that: that figure was --bx-danger on --bx-panel-solid, a combination
   these pages do not render. The failure was a colour we thought we had already replaced.

   The heading beside it is 24px at weight 800, which is large text and passes either way — which
   is why only one node per page was flagged and the pages did not look obviously wrong. */
.text-danger { color: var(--bx-danger-text) !important; }
.validation-message { color: var(--bx-danger-text); }

/* ---------------------------------------------------------------------------------------------
   Tables
--------------------------------------------------------------------------------------------- */

.table {
  color: var(--bx-text);
  border-color: color-mix(in srgb, var(--bx-teal-border) 45%, transparent);
}
.table th {
  color: var(--bx-text-muted);
  background-color: var(--bx-panel-solid);
  border-color: color-mix(in srgb, var(--bx-teal-border) 45%, transparent);
  font-weight: 600;
}
/* Bootstrap paints cells through `.table>:not(caption)>*>*`, which is (0,1,1) — the same as
   `.table th`, so the header wins on source order, but `.table td` only set a border. Body cells
   therefore kept --bs-table-bg (white) and --bs-table-color (black): a dark header strip over
   white rows on /Account/Manage/ExternalLogins, the app's only Bootstrap table. Matching
   Bootstrap's own selector is what reaches them. */
.table td {
  border-color: color-mix(in srgb, var(--bx-teal-border) 25%, transparent);
}
.table > :not(caption) > * > * {
  color: var(--bx-text);
  background-color: transparent;
}
.table > thead > tr > th {
  color: var(--bx-text-muted);
  background-color: var(--bx-panel-solid);
}


/* ── Found by the review of this file, after it shipped ─────────────────────────────────────── */

/* Bootstrap gives .link-secondary an !important colour, so the login page's own scoped rule never
   won and the "Create an account" and "Forgot password?" links rendered at 3.63:1 — under AA, and
   the one real contrast failure axe reported on that page. !important is the only thing that
   answers !important; every use of it in this file is against a Bootstrap declaration that
   carries one, and nowhere else. */
.link-secondary {
  color: var(--bx-text-2) !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-secondary:hover,
.link-secondary:focus { color: var(--bx-text) !important; }
.link-secondary:focus-visible { outline: 3px solid var(--bx-focus); outline-offset: 2px; border-radius: 4px; }

/* The class census missed these two. They are used by the back office and the support chat —
   .btn-success on the KYC review, redemptions and weekly-winners screens, .btn-warning on the
   users page and the conversations list — so without them those pages keep Bootstrap's own green
   and amber, which is exactly the drift this bridge exists to stop. */
.btn-success {
  background: var(--bx-teal);
  border-color: var(--bx-teal);
  color: var(--bx-teal-ink);
}
.btn-success:hover,
.btn-success:focus { background: var(--bx-teal); border-color: var(--bx-teal); color: var(--bx-teal-ink); filter: brightness(1.08); }

/* Amber keeps its meaning: a warning must not become the house teal just because teal is nearer. */
.btn-warning {
  background: var(--bx-gold-bright);
  border-color: var(--bx-gold-bright);
  color: var(--bx-bg-950);
}
.btn-warning:hover,
.btn-warning:focus { background: var(--bx-gold-bright); border-color: var(--bx-gold-bright); color: var(--bx-bg-950); filter: brightness(1.08); }


/* ── Found by reading computed values off live pages, not by reading the palette ──────────────
   After .text-danger turned out never to have applied, every class this file claims was sampled
   on a rendered page and compared against the token it is supposed to set. These are what that
   census turned up. Both were invisible to axe. */

/* Bootstrap floats the label using three-part selectors — `.form-floating > .form-control:focus ~
   label` and friends — which outrank this file's two-part `.form-floating > label`. So the bridge
   only ever coloured a label while its field sat empty and unfocused. The moment a field was
   filled, focused or disabled, the label reverted to Bootstrap's own: rgba(33, 37, 41, .65) when
   filled, #6c757d when disabled. On this palette that measures 1.11:1 and 2.84:1 — the first is
   not legible at all.

   The selectors below are Bootstrap's, character for character, so source order settles it and no
   !important is needed. The -moz and -webkit variants are kept in rules of their own on purpose:
   a browser that does not understand one pseudo-class discards the entire selector list it
   appears in, which would take the working selectors down with it. */
.form-floating > .form-control-plaintext ~ label,
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label,
.form-floating > .form-select ~ label,
.form-floating > .form-control:disabled ~ label,
.form-floating > :disabled ~ label {
  color: var(--bx-text-muted);
}
.form-floating > .form-control:not(:-moz-placeholder-shown) ~ label { color: var(--bx-text-muted); }
.form-floating > .form-control:-webkit-autofill ~ label { color: var(--bx-text-muted); }

/* The floated label sits across the field's top edge, and Bootstrap hides the border behind it
   with a block of --bs-body-bg — white, which nothing in this project ever changed. On a dark form
   that reads as a sticky note stuck to the input, which is exactly how /Account/Manage/Email
   looked. The patch has to be the colour of the field it is patching. */
.form-floating > .form-control-plaintext ~ label::after,
.form-floating > .form-control:focus ~ label::after,
.form-floating > .form-control:not(:placeholder-shown) ~ label::after,
.form-floating > .form-select ~ label::after,
.form-floating > .form-control:disabled ~ label::after,
.form-floating > :disabled ~ label::after {
  background-color: var(--bx-panel-solid);
}
.form-floating > .form-control:not(:-moz-placeholder-shown) ~ label::after { background-color: var(--bx-panel-solid); }

/* The addon chip welded to an input — the confirmed-email tick on /Account/Manage/Email is one.
   Bootstrap gives it a light grey fill, so it rendered as a white box beside a dark field. */
.input-group-text {
  background-color: var(--bx-panel-solid);
  border-color: var(--bx-teal-border);
  color: var(--bx-text);
}

/* Same shape as .text-danger: a Bootstrap utility that carries !important, so the token never
   reached it. The tick it colours is a success mark, which is teal here. */
.text-success { color: var(--bx-teal) !important; }


/* ── Found by the whole-branch review, 2026-09-29 ────────────────────────────────────────────
   Three more of the same shape: a bridge rule that loses to Bootstrap, or wins too hard. */

/* This file's own .btn sets `border: 1px solid transparent`, which is (0,1,0) and lands after
   Bootstrap's `border: … var(--bs-btn-border-color)`. For the solid variants that is harmless —
   each one names its own border-color right after. For the outline variants it is not: their
   whole design is the border, and the bridge never set `color` on .btn either, so
   .btn-outline-secondary came out as transparent fill, transparent border and Bootstrap's #6c757d
   text — 3.88:1 on the page background, under AA at the 14px .btn-sm uses. That is how the "☰",
   "Manage tags" and "Load older messages" controls on /admin/support render today: bare grey
   glyphs with no button around them. The class census in this file's header listed only the solid
   variants and missed these entirely. */
.btn-outline-secondary,
.btn-outline-primary,
.btn-outline-success,
.btn-outline-danger,
.btn-outline-light,
.btn-outline-dark {
  background-color: transparent;
  border-color: var(--bx-teal-border);
  color: var(--bx-text);
}
.btn-outline-secondary:hover,
.btn-outline-primary:hover,
.btn-outline-success:hover,
.btn-outline-danger:hover,
.btn-outline-light:hover,
.btn-outline-dark:hover {
  background-color: rgba(39, 229, 186, 0.10);
  border-color: var(--bx-teal);
  color: var(--bx-text);
}
/* Red has to stay red even in outline form — this is the only variant whose meaning differs. */
/* Text, so the lifted red; the border is the fill colour and stays. Nothing renders
   this variant today, which is why it was free to put the rejected token back. */
.btn-outline-danger { border-color: var(--bx-danger); color: var(--bx-danger-text); }
.btn-outline-danger:hover {
  background-color: color-mix(in srgb, var(--bx-danger) 14%, transparent);
  border-color: var(--bx-danger);
  color: var(--bx-danger-text);
}

/* Bootstrap's `.btn:disabled, .btn.disabled, fieldset:disabled .btn` is (0,2,0) and beats the
   bridge's (0,1,0) variants, so a disabled .btn-danger reverted to Bootstrap's #dc3545 and a
   disabled .btn-success to #198754. .btn-primary already had its (0,2,0) pair — the pattern was
   known and applied to exactly one variant. The visible symptom: on /admin/redemptions every
   button flips from house colours to Bootstrap's for as long as a fulfilment call is in flight,
   then flips back. */
.btn-danger:disabled,
.btn-danger.disabled {
  background-color: var(--bx-danger);
  border-color: var(--bx-danger);
  color: var(--bx-teal-ink);
}
.btn-success:disabled,
.btn-success.disabled {
  background-color: var(--bx-teal);
  border-color: var(--bx-teal);
  color: var(--bx-teal-ink);
}
.btn-warning:disabled,
.btn-warning.disabled {
  background-color: var(--bx-gold-bright);
  border-color: var(--bx-gold-bright);
  color: var(--bx-bg-950);
}
.btn-secondary:disabled,
.btn-secondary.disabled {
  background-color: transparent;
  border-color: var(--bx-teal-border);
  color: var(--bx-text);
}

/* .form-check-input is painted with `appearance: none` plus a background-image, so the
   `accent-color` this file set for it was inert, and `.form-check-input:checked` is (0,2,0)
   against the bridge's (0,1,0) — a ticked checkbox stayed Bootstrap blue on a dark form. */
.form-check-input:checked {
  background-color: var(--bx-teal);
  border-color: var(--bx-teal);
}
.form-check-input:checked[type="checkbox"] {
  /* Bootstrap's own tick, re-drawn in the ink colour that reads on teal. */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%2304211A' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
}
.form-check-input:focus {
  border-color: var(--bx-teal);
  box-shadow: none;
}
.form-check-input:focus-visible {
  outline: 3px solid var(--bx-focus);
  outline-offset: 2px;
}
