/* ==========================================================================
   The registration page, dressed like the platform's Keycloak login

   Mirrors the `sop` login theme in Athena:
     athena/services/iam-keycloak/themes/sop/login/resources/css/sop.css
   Section numbers ("sop.css §n") refer to that file. Ported from the platform's
   former sop-ui page (services/sop-ui/src/features/register/register-page.css),
   with the 2026-10-23 hover and focus fixes; the controls are plain HTML here,
   styled in the same palette. Dark mode follows the system setting.

   img/ holds byte-identical copies of Athena's sop-grid.svg, sop-reticle-red.svg,
   sop-reticle-grey.svg and offensive-platform-banner-{light,dark}.svg - a test in
   web_test.go compares them.
   ========================================================================== */

/* sop.css §1: palette and surfaces, light. */
:root {
  --sop-red-300: #ec706e;
  --sop-red-400: #e11f1d; /* Offensive Platform red: white text 4.75:1 */
  --sop-red-500: #b51917; /* hover: white text 6.7:1 */
  --sop-grey-200: #cbcbcd;
  --sop-grey-300: #b1b3b4;
  --sop-grey-500: #6f7173; /* hints and input edges: 4.9:1 on white */
  --page-bg: #f2f2f2;
  --page-bg-far: #e3e3e3;
  --hairline: var(--sop-grey-200);
  --card-bg: #ffffff;
  --ink: #1d1d1b;
  --muted: var(--sop-grey-500);
  --input-edge: var(--sop-grey-500);
  --error: #b51917;
  --focus: var(--sop-red-400);
  color-scheme: light;
}

/* sop.css §1 dark surfaces; the card is the brand's ink. */
@media (prefers-color-scheme: dark) {
  :root {
    --page-bg: #0f0f0e;
    --page-bg-far: #1b1b19;
    --hairline: #343431;
    --card-bg: #1d1d1b;
    --ink: #f2f2f2;
    --muted: var(--sop-grey-300);
    --error: var(--sop-red-300);
    --focus: var(--sop-red-300); /* 5.7:1 on the ink card */
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--page-bg);
}

/* sop.css §3: two corner reticles and a tiled grid over the gradient. */
.page {
  display: flex;
  min-height: 100svh;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem 1rem; /* the 16px gutter on a phone */
  background:
    url("img/sop-reticle-red.svg") no-repeat right top / min(42vw, 520px) auto fixed,
    url("img/sop-reticle-grey.svg") no-repeat left bottom / min(56vw, 680px) auto fixed,
    url("img/sop-grid.svg") repeat left top / 48px 48px fixed,
    radial-gradient(ellipse at 20% 0%, var(--page-bg) 0%, var(--page-bg-far) 100%) fixed;
}

/* Top-aligned, not centred: a centred card would move whenever its height changes,
   for instance on a language switch. A fixed top gap keeps it off the edge. */
@media (min-width: 640px) {
  .page { padding-top: 8vh; }
}

.column {
  display: flex;
  width: 100%;
  max-width: 34rem;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* sop.css §4: the lockup, 120px high, capped by the viewport on a phone. */
.banner {
  display: block;
  width: min(381px, 82vw);
  height: 120px;
  object-fit: contain;
}

/* sop.css §5: hairline, keycloak.v2's 3px brand-red top rule, 2px corners. */
.card {
  width: 100%;
  padding: 1.5rem;
  border: 1px solid var(--hairline);
  border-top: 3px solid var(--sop-red-400);
  border-radius: 2px;
  background: var(--card-bg);
  box-shadow: 0 12px 32px -12px rgb(0 0 0 / 22%);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

h1 { margin: 0; font-size: 1.35rem; line-height: 1.25; }
h2 { margin: 0.5rem 0; font-size: 1.15rem; }

.intro, .hint, .privacy { color: var(--muted); }
.intro { margin: 0.75rem 0 1.25rem; }
.hint { margin: 0.25rem 0 0; font-size: 0.85rem; }
.privacy { margin: 1rem 0 0; font-size: 0.85rem; }
.privacy a { color: inherit; }

/* The DE | EN switch on the card. */
.switch { display: flex; gap: 0.25rem; flex-shrink: 0; }
.switch button {
  min-width: 2.5rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--input-edge);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.switch button[aria-pressed="true"] {
  border-color: var(--sop-red-400);
  background: var(--sop-red-400);
  color: #ffffff;
}
.switch button[aria-pressed="true"]:hover { background: var(--sop-red-500); }

form { display: flex; flex-direction: column; gap: 1rem; }
.row { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 520px) {
  .row { grid-template-columns: 1fr 1fr; }
}

.field { display: flex; flex-direction: column; min-width: 0; }
label { font-weight: 600; margin-bottom: 0.3rem; font-size: 0.9rem; }

input, select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--input-edge);
  border-radius: 2px;
  background: var(--card-bg);
  color: var(--ink);
  font: inherit;
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--error); }

.error, .form-error { margin: 0.3rem 0 0; color: var(--error); font-size: 0.85rem; }
.form-error { margin: 0; font-size: 0.9rem; }
.notice { margin: 0.75rem 0; padding: 0.75rem; border: 1px solid var(--hairline); }

/* sop.css §2: the brand red, with the darker red on hover (6.7:1). */
button.primary {
  align-self: flex-start;
  padding: 0.6rem 1.1rem;
  border: 0;
  border-radius: 2px;
  background: var(--sop-red-400);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.primary:hover { background: var(--sop-red-500); }
button.primary:disabled { opacity: 0.6; cursor: progress; }

/* sop.css §8: a solid 2px outline, offset so it shows on the red buttons too. */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* sop.css §7: the footer under the card's content, a hairline above it, muted
   links that turn red on hover and focus. */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 1.25rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hairline);
  font-size: 0.85rem;
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover,
.footer a:focus-visible { color: var(--focus); text-decoration: underline; }

/* The honeypot: out of sight and out of the tab order. */
.honeypot {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

[hidden] { display: none !important; }

@media (prefers-contrast: more) {
  .card { border-color: var(--sop-grey-500); border-top-color: var(--sop-red-400); }
}

@media (prefers-reduced-motion: reduce) {
  .page { background-attachment: scroll, scroll, scroll, scroll; }
}
