/* ============================================================
   Signals — Keycloak login theme (direction 3c)
   Constellation / integrity-graph motif · glass sign-in card
   Extends keycloak.v2 · light default, dark via html.pf-v5-theme-dark
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&display=swap");

/* Display font: Helvetica Neue (neutral, matches the origin; no web font needed).
   Swap this one var to try Schibsted Grotesk etc. */
:root {
  --rs-display: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* ---- Tokens (light default) ---- */
:root {
  color-scheme: light;
  --rs-green: #73B25A;
  --rs-red: #DB453B;
  --rs-amber: #E3B23C;

  --rs-bg: #f4f8ff;
  --rs-ink: #152234;
  --rs-muted: #5b6577;
  --rs-title: #14314d;
  --rs-accent: #2f6299;
  --rs-field: #ffffff;
  --rs-fborder: rgba(36, 71, 109, 0.20);
  --rs-glass: rgba(255, 255, 255, 0.86);
  --rs-border: rgba(36, 71, 109, 0.14);
  --rs-btn1: #24476d;
  --rs-btn2: #3a6aa5;
  --rs-glow: rgba(47, 95, 149, 0.14);
}

/* ---- Tokens (dark — the reference default) ---- */
html.pf-v5-theme-dark {
  color-scheme: dark;
  --rs-bg: #0a1526;                    /* deep navy (bluer than neutral #070a10) */
  --rs-ink: #e9ecf1;
  --rs-muted: #96a3bc;
  --rs-title: #f4f7ff;
  --rs-accent: #86adf0;
  --rs-field: rgba(255, 255, 255, 0.05);
  --rs-fborder: rgba(255, 255, 255, 0.16);
  --rs-glass: rgba(14, 23, 40, 0.60);
  --rs-border: rgba(255, 255, 255, 0.10);
  --rs-btn1: #2f5f95;
  --rs-btn2: #4179bd;
  --rs-glow: rgba(60, 110, 180, 0.24);
}

/* ---- Page ---- */
html,
body {
  min-height: 100%;
}

body#keycloak-bg {
  margin: 0;
  min-height: 100vh;
  position: relative;
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--rs-ink);
  background-color: var(--rs-bg);
  background-image: radial-gradient(circle at 22% 42%, var(--rs-glow), transparent 55%);
}

/* Constellation canvas is injected by js/constellation.js */
#signals-constellation {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ---- Layout: hero (left) + card (right) ---- */
.pf-v5-c-login {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  /* Top-align the container; its fixed min-height (below) makes it fill the
     viewport, so this reads as centered while pinning the top edge — if the
     register form ever overflows the viewport, the card grows downward and the
     page scrolls instead of the whole grid re-centering and shifting the hero. */
  align-items: flex-start;
  justify-content: center;
  /* Symmetric vertical padding so the grid row's centre lands on the viewport
     centre (asymmetric padding shifts the hero off-centre). 104px each side
     clears the fixed top-left logo and the fixed legal footer. NO horizontal
     padding: the grid must reach both screen edges so each 1fr column is a TRUE
     half of the screen — side breathing room comes from the centered,
     max-width'd content inside each column, not page padding. */
  padding: 104px 0;
  box-sizing: border-box;
}

.pf-v5-c-login__container {
  width: 100%;
  /* Override PatternFly's 500px container cap and DON'T re-cap: the grid must
     span the full width so each 1fr column is a TRUE half of the screen. Any
     finite max-width centers the container and pushes the card off-centre within
     the screen's right half (which is exactly the bug on wide monitors). The
     trade-off is that on ultra-wide displays the hero and card each sit centred
     in their own half, so they're far apart — which is the intended symmetry. */
  max-width: none;
  margin: 0 auto;
  /* Kill PatternFly's base `padding-inline: 6.125rem` (98px) on this element —
     it insets the grid so the columns are halves of the inset area, not the
     screen, pushing the card ~50px left of the true right-half centre. */
  padding: 0;
  display: grid;
  /* Two equal halves so each column's content centres within its own half. */
  grid-template-columns: 1fr 1fr;
  /* FIXED row height tied to the viewport (100vh minus the 104+104 padding), NOT
     min-height and NOT the card. A fixed track never grows when the register
     form expands, so both columns stay centred against the viewport and the
     hero never shifts. A taller-than-viewport card overflows/scrolls instead. */
  grid-template-rows: max(480px, calc(100vh - 208px));
  /* PatternFly pins #kc-header to `grid-area: header` and the card to
     `grid-area: main`; base keycloak.v2 declares `grid-template-areas:
     "header" "main"` (single column, stacked). Override the areas to put
     them side by side — overriding grid-template-columns alone is not enough. */
  grid-template-areas: "header main";
  gap: 0;
  /* centre each column's content on BOTH axes within its half */
  place-items: center;
}

/* ---- Hero (repurposed #kc-header) ---- */
#kc-header {
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* centre the whole hero block (title + subline) in its row, so its midpoint —
     not the top of the title — lands at the vertical centre */
  align-self: center;
  gap: 22px;
  min-height: auto;
  /* Base keycloak sets `margin-block-start: 4rem` on .pf-v5-c-login__header;
     align-self centres the MARGIN box, so that top margin would push the hero
     ~32px below centre. Zero all margins so the content box itself is centred. */
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
}

#kc-header::before,
#kc-header::after {
  position: static;
  width: auto;
  height: auto;
  inset: auto;
  filter: none;
  border-radius: 0;
}

/* Wordmark "Signals." — real brand logo (green i-dot + red period baked in as
   vector paths), pinned to the page's top-left corner like the mockup. */
#kc-header-wrapper {
  position: fixed;
  /* Match the app header logo's viewport offset so the wordmark doesn't jump
     when navigating from the app to the login page. In frontend/src/index.css
     the logo sits at: top = .app-header margin-top(16) + surface border(1) +
     surface padding-top(12) = 29px; left = 2*--rs-page-gutter(16) + border(1) =
     33px. The SVG fills the box height under `contain`, so the box's top-left is
     the glyph's top-left. Left drops to 21px at <=768px (gutter -> 10px). */
  top: 29px;
  left: 33px;
  z-index: 4;
  width: 234px;
  height: 64px;
  margin: 0;
  padding: 0;
  font-size: 0;               /* hide Keycloak's realm display name */
  text-transform: none;
  background: url("../img/signals-logo-white-path.svg") left center / contain no-repeat;
}

#kc-header-wrapper img {
  display: none;
}

/* The realm's displayNameHtml wraps the name in a link to the app home page
   (per-env value, set post-import — README step 2b). The wrapper's font-size:0
   hides the text, so stretch the anchor over the whole logo box so the logo
   itself is the hit area. */
#kc-header-wrapper a {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
}

#kc-header-wrapper a:focus-visible {
  outline: 2px solid var(--rs-accent);
  outline-offset: 4px;
}

/* light mode uses the dark-blue logo variant so it stays legible */
html:not(.pf-v5-theme-dark) #kc-header-wrapper {
  background-image: url("../img/signals-logo-blue-path.svg");
}

/* Hero headline */
#kc-header::after {
  order: 2;
  content: "Evaluate the world's research";
  max-width: 15ch;
  font-family: var(--rs-display);
  font-weight: 700;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--rs-title);
}

/* Hero subline */
#kc-header::before {
  order: 3;
  content: "Signals helps researchers, sleuths, publishers, and institutions to evaluate the trustworthiness of published research. We do this via the Signals Integrity Graph, a networked database of the world's research.";
  max-width: 40ch;
  color: var(--rs-muted);
  font-size: 0.95rem;
  line-height: 1.65;
}

/* ---- Sign-in card (glass) ---- */
.pf-v5-c-login__main {
  position: relative;
  z-index: 1;
  width: 100%;
  /* Cap the card and center it within its (now half-width) column, so it sits
     centered in the right half rather than filling it. */
  max-width: 380px;
  /* Centre the card horizontally in its (true screen-half) column. margin-inline
     auto + justify-self both center it — auto margins win even if some base rule
     ever sets justify-self, so this is robust. */
  justify-self: center;
  margin-inline: auto;
  /* Base PatternFly sets `.pf-v5-c-login__main { align-self: start }`, which
     pins the card to the top of the grid row and overrides the container's
     `place-items: center`. Re-center it vertically here (item-level wins). */
  align-self: center;
  border: 1px solid var(--rs-fborder);
  border-radius: 22px;
  background: var(--rs-glass);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.40);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
}

.pf-v5-c-login__main-header,
.pf-v5-c-login__main-body,
.pf-v5-c-login__main-footer {
  background: transparent;
}

.pf-v5-c-login__main-header {
  display: block;
  padding: 20px 28px 2px;
  /* base keycloak.v2 adds a 4px blue border-top (--keycloak-card-top-color) */
  border-top: 0;
}

.pf-v5-c-login__main-body {
  padding: 0 28px 18px;
}

/* Hide the "* Required fields" subtitle note on the register form. keycloak.v2's
   template.ftl renders it (when displayRequiredFields=true) as `.subtitle`, and
   that class is used nowhere else in the theme, so this is fully scoped. */
.pf-v5-c-login .subtitle {
  display: none;
}

.pf-v5-c-title.pf-m-3xl,
#kc-page-title {
  margin: 0;
  color: var(--rs-title);
  font-family: var(--rs-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-size: 1.3rem;                    /* ~21px, matches the mockup card title */
}

/* ---- Form fields ---- */
.pf-v5-c-form__group {
  margin-bottom: 8px;
}

.pf-v5-c-form__label {
  color: var(--rs-ink);
  font-weight: 600;
  font-size: 13px;
}

.pf-v5-c-form-control,
.pf-v5-c-input-group > .pf-v5-c-form-control {
  border: 1px solid var(--rs-fborder);
  border-radius: 12px;
  background: var(--rs-field);
  color: var(--rs-ink);
}

.pf-v5-c-form-control > input,
.pf-v5-c-form-control > select {
  border: 0;
  background: transparent;
  color: var(--rs-ink);
}

/* PatternFly draws the field outline via ::before/::after pseudos; in dark mode
   only their bottom edge shows — that's the white underline under email/password.
   Drop the pseudo borders; the full border above replaces them cleanly. */
.pf-v5-c-form-control::before,
.pf-v5-c-form-control::after {
  border: 0;
}

.pf-v5-c-form-control:hover,
.pf-v5-c-form-control:focus-within,
.pf-v5-c-form-control > input:focus,
.pf-v5-c-form-control > select:focus,
.pf-v5-c-input-group > .pf-v5-c-form-control:focus-within {
  border-color: var(--rs-accent);
  box-shadow: 0 0 0 4px var(--rs-glow);
}

.pf-v5-c-form-control::placeholder,
input::placeholder {
  color: color-mix(in srgb, var(--rs-muted) 80%, transparent);
}

.pf-v5-c-input-group {
  gap: 8px;
}

.pf-v5-c-input-group > .pf-v5-c-input-group__item {
  border: 0;
}

/* ---- Buttons ---- */
.pf-v5-c-button {
  border-radius: 999px;
  font-weight: 600;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, color .18s ease;
}

.pf-v5-c-button.pf-m-primary,
.pf-v5-c-button.pf-m-block.pf-m-primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--rs-btn1), var(--rs-btn2));
  box-shadow: 0 12px 24px rgba(47, 95, 149, 0.30);
}

.pf-v5-c-button.pf-m-primary:hover,
.pf-v5-c-button.pf-m-primary:focus {
  transform: translateY(-1px);
}

.pf-v5-c-button.pf-m-secondary,
.pf-v5-c-button.pf-m-link,
.pf-v5-c-button.pf-m-control {
  border-color: var(--rs-fborder);
  background: transparent;
  color: var(--rs-ink);
}

/* PatternFly draws a bottom border on the password-toggle (eye) button via its
   ::after pseudo — that's the stray underline beneath the icon. Remove it so the
   toggle sits flush with the field. */
.pf-v5-c-button.pf-m-control::after {
  border: 0;
}

/* Tighten vertical rhythm so the card isn't overly tall */
.pf-v5-c-form__actions {
  margin-block-start: 6px;
}

.pf-v5-c-login__main-footer-band:first-child {
  margin-block-start: 10px;
}

/* ---- Links / options / info ---- */
#kc-form-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#kc-form-options .pf-v5-c-check__label,
#kc-form-options label,
#kc-registration,
#kc-info-wrapper {
  color: var(--rs-muted);
}

#kc-registration a,
#kc-info a,
#try-another-way,
.pf-v5-c-login a {
  color: var(--rs-accent);
  font-weight: 600;
  text-decoration: none;
}

#kc-registration a:hover,
#kc-info a:hover,
.pf-v5-c-login a:hover {
  text-decoration: underline;
}

/* ---- Alerts ---- */
.pf-v5-c-alert {
  margin-bottom: 16px;
  border: 1px solid var(--rs-border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--rs-red) 8%, transparent);
  color: var(--rs-ink);
}

.pf-v5-c-alert__title,
.pf-v5-c-helper-text__item-text,
.kc-feedback-text,
.pf-v5-c-form__helper-text {
  color: inherit;
}

/* ---- Minimal legal footer (injected by constellation.js) ---- */
.rs-legal {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  padding: 16px;
  text-align: center;
  color: var(--rs-muted);
  font-size: 0.8rem;
  pointer-events: none;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .pf-v5-c-login {
    align-items: flex-start;
    padding: 92px 24px 32px;
  }

  .pf-v5-c-login__container {
    grid-template-columns: 1fr;
    /* Undo the desktop fixed row + centring: stack the two rows at content
       height and let them flow from the top. */
    grid-template-rows: auto auto;
    grid-template-areas: "header" "main";
    gap: 32px;
    max-width: 440px;
    place-items: stretch start;
  }

  #kc-header {
    align-items: flex-start;
    text-align: left;
  }

  #kc-header::after {
    max-width: 100%;
  }

  /* Shrink the wordmark in lockstep with the app header logo
     (.app-header__logo img in frontend/src/index.css): 64 -> 48 -> 36 -> 30px
     at the same 1024/768/375 breakpoints. The box is height-bound under
     `contain`, so width scales with height (234/64 ratio) to keep it fitting. */
  #kc-header-wrapper {
    width: 176px;
    height: 48px;
  }

  /* On mobile the card scrolls, so the legal line must flow after it
     (not fixed over the content). */
  .rs-legal {
    position: static;
    margin-top: 26px;
    padding: 18px 0 6px;
  }
}

@media (max-width: 768px) {
  #kc-header-wrapper {
    /* app header gutter drops to 10px here, so its logo left = 2*10 + 1 = 21px */
    left: 21px;
    width: 132px;
    height: 36px;
  }
}

@media (max-width: 375px) {
  #kc-header-wrapper {
    width: 110px;
    height: 30px;
  }
}
