/*
 * GSMA login theme styles.
 *
 * Skins the (unstyled) base-theme login markup with the same visual language as
 * the SPA (frontend/src/styles/tokens.css + app.css): the two-tier brand band,
 * card surfaces, input and button treatments, and GOV.UK interaction discipline
 * - plain single-column layout, sentence case, colour never the sole signal, a
 * strong visible focus state. Selectors target the base template's element ids
 * because the `kc*Class` style hooks are intentionally empty under `parent=base`.
 * Token values here must stay in sync with the frontend's tokens.css (the theme
 * cannot import it).
 */

/* Inter, self-hosted from the theme (variable weight axis covers 400–700). */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/inter-var-latin.woff2') format('woff2');
}

/* --- Tokens (mirroring frontend/src/styles/tokens.css) --- */
:root {
  /* Brand - Hero Red is reserved for the primary CTA, brand marks and inline links only. */
  --gsma-hero-red: #dc002b;
  --gsma-hero-red-hover: #b30022;
  --gsma-hero-red-active: #8f001b;

  /* Neutrals */
  --colour-text: #0b0c0c;
  --colour-text-secondary: #575756;
  --colour-border: #b1b4b6;
  --colour-border-strong: #0b0c0c;
  --colour-surface-muted: #f3f2f1;
  --colour-white: #ffffff;

  /* Functional status - kept separate from brand red so "failed" never reads
     as "primary action". */
  --status-fail: #b10e1e;
  --status-fail-bg: #fbecec;

  /* Header band (tier 1 of the SPA's two-tier header). */
  --header-surface: #0b0c0c;
  --header-ink: #ffffff;
  --header-keyline: var(--gsma-hero-red);

  /* Card surface. */
  --surface-raised: #ffffff;
  --border-card: #d8d7d5;
  --shadow-card: 0 1px 2px rgba(11, 12, 12, 0.06);
  --shadow-cta: 0 1px 2px rgba(220, 0, 43, 0.3);

  /* GSMA black focus ring, 3px offset 3px (not GOV.UK yellow). */
  --focus-ring: #0b0c0c;

  --radius: 4px;
  --radius-card: 8px;
  --chrome-max-width: 72rem;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* --- Page shell --- */
html {
  box-sizing: border-box;
}
*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--colour-surface-muted);
  color: var(--colour-text);
  font-family: var(--font-sans);
  font-size: 1rem;
  /* Body copy stays at ~1.5 for readability (documented deviation from the
     addendum's 1.15, on accessibility grounds). */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Gentle hover transitions; skipped for users who prefer reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  a,
  button,
  input[type='submit'] {
    transition:
      color 150ms ease,
      background-color 150ms ease,
      border-color 150ms ease,
      box-shadow 150ms ease;
  }
}

/* --- Header / brand band (mirrors the SPA's tier-1 band) --- */
#kc-header {
  width: 100%;
  background-color: var(--header-surface);
  border-bottom: 4px solid var(--header-keyline);
}

#kc-header-wrapper {
  max-width: var(--chrome-max-width);
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#kc-brand-logo {
  /* Match the SPA header sizing; brand rule is min 40px high. The asset carries
     its own Hero Red background, so no extra framing is applied. */
  height: 40px;
  width: auto;
  display: block;
}

/* Service name in the band's ink, matching the SPA's .stp-logo__service. */
#kc-brand-service {
  color: var(--header-ink);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* --- Content column (the div between band and footer) --- */
body > div {
  width: 100%;
  max-width: 30rem;
  margin: 2.5rem auto 3rem;
  padding: 0 1rem;
}

/* --- Card (the login wrapper's first div; kcFormCardClass is empty under base) --- */
body > div > div {
  background-color: var(--surface-raised);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 2rem 2rem 2.25rem;
  box-shadow: var(--shadow-card);
}

/* --- Page title + service byline --- */
#kc-page-title {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 700;
  /* Tighter leading on large headings (addendum), still comfortable. */
  line-height: 1.15;
  color: var(--colour-text);
}

#kc-intro {
  margin: 0 0 1.5rem;
  color: var(--colour-text-secondary);
  font-size: 0.9375rem;
}

/* --- Form layout --- */
#kc-form-login {
  display: flex;
  flex-direction: column;
}

#kc-form-login > div {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 600;
  color: var(--colour-text);
}

/* --- Inputs (2px strong border, matching the SPA's .stp-input) --- */
input[type='text'],
input[type='email'],
input[type='password'] {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--colour-text);
  background-color: var(--colour-white);
  border: 2px solid var(--colour-border-strong);
  border-radius: var(--radius);
}

/* GSMA focus: 3px black outline, offset 3px - applied to every interactive element. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[data-password-toggle]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

/* --- Password field + show/hide toggle --- */
/* The input-group wrapper (kcInputGroup) is empty under base; lay it out inline. */
#password {
  /* Leave room so the toggle button never overlaps the value. */
  padding-right: 4.5rem;
}

div:has(> #password) {
  position: relative;
  display: block;
}

button[data-password-toggle] {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  padding: 0 0.75rem;
  border: none;
  background: transparent;
  color: var(--gsma-hero-red);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

button[data-password-toggle]:hover {
  text-decoration: underline;
  color: var(--gsma-hero-red-hover);
}

/* Render a text label for the toggle since base ships no icon font. */
.stp-pw-toggle::after {
  font-style: normal;
}
.stp-pw-show::after {
  content: 'Show';
}
.stp-pw-hide::after {
  content: 'Hide';
}

/* --- Primary button (matches the SPA's .stp-button--primary) --- */
#kc-form-buttons {
  margin-top: 0.5rem;
}

#kc-login,
input[type='submit'] {
  display: block;
  width: 100%;
  padding: 0.75rem 1.25rem;
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--colour-white);
  background-color: var(--gsma-hero-red);
  border: 2px solid var(--gsma-hero-red);
  border-radius: var(--radius);
  box-shadow: var(--shadow-cta);
  cursor: pointer;
}

#kc-login:hover,
input[type='submit']:hover {
  background-color: var(--gsma-hero-red-hover);
  border-color: var(--gsma-hero-red-hover);
}

#kc-login:active,
input[type='submit']:active {
  background-color: var(--gsma-hero-red-active);
  border-color: var(--gsma-hero-red-active);
  box-shadow: none;
}

/* --- Links (Hero Red, underlined so a red link stays distinct from the red button) --- */
a {
  color: var(--gsma-hero-red);
  text-decoration: underline;
}
a:hover {
  color: var(--gsma-hero-red-hover);
}

/* Form options row (forgot password) spacing. */
#kc-form-options,
#kc-form-options + div {
  font-size: 0.9375rem;
}

/* --- Alert / server message (functional error red, never Hero Red) --- */
[class^='alert-'],
[class*=' alert-'] {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--colour-text-secondary);
  background-color: var(--colour-surface-muted);
  font-size: 0.9375rem;
}

.alert-error {
  border-left-color: var(--status-fail);
  background-color: var(--status-fail-bg);
  color: var(--status-fail);
}

/* Pair colour with a text prefix so status never relies on colour alone. */
.alert-error .pf-c-alert__icon::before {
  content: 'Error: ';
  font-weight: 700;
}

/* --- Field-level validation --- */
input[aria-invalid='true'] {
  border-color: var(--status-fail);
  box-shadow: inset 0 0 0 1px var(--status-fail);
}

#input-error {
  display: block;
  margin-top: 0.375rem;
  color: var(--status-fail);
  font-size: 0.9375rem;
  font-weight: 600;
}

/* --- Registration / info footer --- */
#kc-info {
  margin-top: 1.5rem;
  font-size: 0.9375rem;
}

/* --- Help line under the card --- */
#kc-help {
  margin: 1rem 0 0;
  font-size: 0.9375rem;
  color: var(--colour-text-secondary);
}

/* --- Page footer (mirrors the SPA's footer) --- */
#kc-page-footer {
  margin-top: auto;
  border-top: 1px solid var(--colour-border);
}

#kc-page-footer-inner {
  max-width: var(--chrome-max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem;
  font-size: 0.9375rem;
  color: var(--colour-text-secondary);
}

/* --- Small screens --- */
@media (max-width: 32rem) {
  body > div > div {
    padding: 1.5rem 1.25rem 1.75rem;
  }
  #kc-page-title {
    font-size: 1.5rem;
  }
}
