/* BPA — Keycloak login theme
   ==========================================================================================
   Loads after keycloak.v2/css/styles.css (theme.properties orders it that way), so equal-
   specificity rules here win on cascade order without needing !important, except where noted.

   VALUES ARE BPA's real design tokens, copied by hand from packages/ui/src/styles.css — this
   file is plain CSS served by Keycloak, not Tailwind, so there is no @theme to import from.
   Keeping the two in sync is a manual discipline, not a build step; if the palette in
   packages/ui/src/styles.css moves, this file does not move with it automatically.

   STRATEGY: PatternFly v5 themes almost entirely off its own --pf-v5-global--* custom
   properties (verified against the actual patternfly.min.css served by this stack — e.g. a
   primary button's default/hover/focus/active backgrounds all resolve through
   --pf-v5-global--primary-color--100/200/300, and an alert's border through
   --pf-v5-global--danger-color--100). Overriding the globals here reaches every component
   keycloak.v2 uses across every page in the flow — login, OTP, WebAuthn, reset password,
   the OAuth grant screen, every error page — not just the one screen fetched while writing
   this. A handful of keycloak.v2-specific selectors (confirmed from its own styles.css) are
   overridden directly below that.
   ========================================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,opsz,wght@0,6..12,400;0,6..12,600;0,6..12,700;1,6..12,400&display=swap");

:root,
:where(.pf-v5-theme-dark) {
  /* Text and links */
  --pf-v5-global--FontFamily--text: "Nunito Sans", -apple-system, "Avenir Next", "Segoe UI", sans-serif;
  --pf-v5-global--FontFamily--heading: "Nunito Sans", -apple-system, "Avenir Next", "Segoe UI", sans-serif;
  --pf-v5-global--Color--100: #1a2b44; /* navy — primary text */
  --pf-v5-global--Color--200: #6b7480; /* fg-muted — secondary text, helper text */
  --pf-v5-global--link--Color: #0e6b6b; /* accent */
  --pf-v5-global--link--Color--hover: #0b5757; /* accent-hover */
  --pf-v5-global--link--Color--visited: #0e6b6b;

  /* Primary (accent teal) — covers the login button's default/hover/focus/active states,
     all of which resolve through these three PatternFly cascades it, not a per-state
     override each. */
  --pf-v5-global--primary-color--100: #0e6b6b;
  --pf-v5-global--primary-color--200: #0b5757; /* hover */
  --pf-v5-global--primary-color--300: #094848; /* active/focus */
  --pf-v5-global--primary-color--400: #0e6b6b;

  /* A form error (wrong password, expired code) is a recoverable input mistake, not an
     irreversible action — bpa-ui reserves --brick/#9A3412 for "this cannot be undone" and
     asks "can this be taken back?" before every use. It can be, here, so this maps to the
     design system's --warn family instead of red. */
  --pf-v5-global--danger-color--100: #b45309;
  --pf-v5-global--danger-color--200: #92400a;

  --pf-v5-global--BackgroundColor--100: #ffffff; /* card */
  --pf-v5-global--BackgroundColor--150: #f5f8f8;
  --pf-v5-global--BackgroundColor--200: #fcf2e4; /* warn-soft, alert fill */
  --pf-v5-global--BorderColor--100: #e4e8ec;
  --pf-v5-global--BorderColor--200: #eef1f4;
  --pf-v5-global--BorderRadius--sm: 8px;
  --pf-v5-global--BorderRadius--lg: 14px;
}

/* ── Page background — the same navy as the rail on BPA's own /connexion page (the one the
   browser was just on, and returns to on error or cancel), so arriving here reads as a
   continuation, not a handoff to a different product. ────────────────────────────────── */
:root {
  --keycloak-bg-logo-url: none;
  --keycloak-card-top-color: #0e6b6b; /* accent — the 4px rule keycloak.v2 paints above the card */
}

/* Same static dot texture as bpa-auth-rail in apps/web/app/[locale]/global.css — 1.1px
   dots, 56px pitch, 8% white — copied by hand for the same reason the palette above is:
   this is plain CSS, not the Tailwind layer that file lives in. The pointer-following glow
   the web app also carries (useProjecteurGrille) is JS-driven and left out — this page is
   visited too rarely to earn a mouse-tracking script, and the static pattern alone is most
   of the effect. */
.login-pf body,
#keycloak-bg {
  background-color: #1a2b44 !important;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.08) 1.1px, transparent 1.1px) !important;
  background-position: left top !important;
  background-size: 56px 56px !important;
}

/* ── Brand — the same logo file the product's own sign-in rail uses
   (apps/web/public/logo-bpa-complet-blanc.webp), not a redrawn wordmark. The realm's
   displayName text stays in the DOM for anything that reads text rather than paints
   pixels; text-indent moves it off-canvas rather than hiding it from assistive tech. */
#kc-header-wrapper {
  /* `ON41` — CENTRED ABOVE THE CARD, not the head of a left column. See the layout block
     below for why the column went. `188px` rather than 220: the mark is chrome here, and at
     the old width it competed with the heading immediately under it. */
  width: 188px;
  height: 61px; /* the source asset's own 960:310 ratio, at 188px width */
  margin: 0 auto 24px;
  background-image: url("../img/logo-bpa-complet-blanc.webp");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  text-indent: -9999px;
  overflow: hidden;
  white-space: nowrap;
}

/* ── Layout — ONE CARD, and the second column is gone.  `ON41`
   ------------------------------------------------------------------------------------------
   WHAT WAS HERE. A 280px navy rail beside a 400px form, inside one rounded 680px box, with the
   product's tagline generated onto the header's `::after`. It was built to stop the form
   reading as « adrift in open navy », and it did — at the cost of a second column that carries
   no information anybody needs while choosing a password, and that has to be maintained in CSS
   `content:` because there is no template hook to render a catalogue key through.

   WHAT REPLACES IT. The mark, centred, above a single card. The rail's job was to say « this is
   still BPA » across the handoff from the product's own screens, and the logo on the same navy
   ground does that without a column. `keycloak.v2` stacks header above main at every width by
   default, so this REMOVES a layout rather than adding one — the same page shape now serves 320
   px and 2560 px, and there is no breakpoint at which the two disagree.

   AND IT REACHES EVERY PAGE IN THE FLOW, which is the reason to prefer subtraction here: login,
   OTP, WebAuthn, update-password, the info and error pages after an action token, the OAuth
   grant screen. The old grid had to be right on all of them and could only be checked on some.
   ------------------------------------------------------------------------------------------ */
.pf-v5-c-login__container {
  /* `keycloak.v2`'s own container is a centred column; this bounds it. `padding-inline: 0`
     is not cosmetic — PatternFly puts 98px of horizontal padding here, and with the card as
     a content-box child that pushed a « 420px » card out to 544. Measured, not guessed. */
  max-width: 420px;
  width: 100%;
  /* `16px` and not `0`: at 390px the card ran edge to edge and the shadow had nothing to fall
     on. PatternFly's own 98px is what pushed a 420px card out to 544 (see the grid note below),
     so this replaces it rather than keeping it. */
  padding-inline: 16px;
  /* `minmax(0, 1fr)` AND NOT `1fr`. PatternFly makes this container a grid, and a grid track's
     default floor is `min-content` — so the card sized itself to its widest unbreakable child
     and overflowed a 420px container to 544px, with `max-width` applied and doing nothing.
     Measured: container w=420, main w=544, both padding 0. This is the line that binds them. */
  grid-template-columns: minmax(0, 1fr);
}

.pf-v5-c-login__main {
  margin: 0;
  /* NO PADDING HERE. PatternFly already pads `__main-header` and `__main-body` (48px each);
     adding a third layer on the card itself is what made the fields sit 80px from the edge.
     The padding is set once, below, where PatternFly puts it. */
  padding: 0;
  overflow: hidden; /* so the header's accent rule is clipped by the card's own radius */
  background-color: #ffffff;
  border: 1px solid #e4e8ec;
  border-radius: 14px;
  /* ONE shadow, not two. The old pair (a long ambient plus a tight contact) was doing the work
     of lifting a 680px composition off the page; a 420px card needs less. */
  box-shadow: 0 24px 56px -24px rgba(26, 43, 68, 0.45);
  max-width: none;
}

/* The heading and the body under it. `keycloak.v2` renders the page title as `3xl`, which on a
   420px card turns any sentence longer than three words into six stacked lines — visible on the
   info page after a password change, where the message is a full instruction. Sized to the
   product's own `text-24`, and balanced so a two-line title breaks evenly. */
.pf-v5-c-login__main-header,
.pf-v5-c-login__main-body,
.pf-v5-c-login__main-footer {
  padding-inline: 32px;
}

.pf-v5-c-login__main-header {
  padding-top: 28px;
  /* The heading needs air under it: PatternFly leaves 4px, which put « Connectez-vous à votre
     compte » 31px from the first field LABEL and made the two read as one block. */
  padding-bottom: 20px;
}

.pf-v5-c-login__main-body {
  padding-bottom: 32px;
}

.pf-v5-c-title.pf-m-3xl {
  color: #1a2b44;
  font-weight: 700;
  font-size: 24px;
  line-height: 1.25;
  text-wrap: balance;
}

/* Vertical rhythm: PatternFly's own spacing is built for a page rather than a card. */
#kc-content-wrapper {
  padding-top: 8px;
}

.pf-v5-c-login__main {
  background-color: #ffffff;
}

.pf-v5-c-login__main-header {
  /* `ON41` — the 4px accent rule `keycloak.v2` paints above the card is back ON: it made sense
     over a lone card, which is what this is again. */
  border-top-color: #0e6b6b;
}

/* ── Form controls — border and focus ring match bpa-ui's own :focus-visible treatment
   (2px accent outline, 1px offset) rather than PatternFly's default blue glow. ─────────── */
.pf-v5-c-form-control {
  border-radius: 8px;
  border-color: #dcdfe3;
}

.pf-v5-c-form-control:focus-within {
  outline: 2px solid #0e6b6b;
  outline-offset: 1px;
}

/* ── Buttons — radius only; colour already flows from the --pf-v5-global--primary-color--*
   overrides above. ───────────────────────────────────────────────────────────────────── */
.pf-v5-c-button {
  border-radius: 8px;
  font-weight: 700;
}

/* ── Alerts / inline errors — amber, not red, per the --danger-color override above; this
   rule covers the icon and border colour PatternFly does not resolve through the custom
   property on every variant. ──────────────────────────────────────────────────────────── */
.pf-v5-c-alert.pf-m-danger,
.pf-v5-c-helper-text__item-text.pf-m-error {
  color: #92400a;
}

.pf-v5-c-alert__icon {
  color: #b45309;
}
