/* ST.RANAC Keycloak login theme — mirrors ui/app/components/auth (LoginForm/RegisterForm).
   Design tokens copied from ui/app/app.css; Poppins + cover images served by nginx /static. */

@font-face { font-family:'Poppins'; font-style:normal; font-weight:400; font-display:swap; src:url('/static/fonts/poppins-v24-latin-regular.woff2') format('woff2'); }
@font-face { font-family:'Poppins'; font-style:normal; font-weight:500; font-display:swap; src:url('/static/fonts/poppins-v24-latin-500.woff2') format('woff2'); }
@font-face { font-family:'Poppins'; font-style:normal; font-weight:600; font-display:swap; src:url('/static/fonts/poppins-v24-latin-600.woff2') format('woff2'); }
@font-face { font-family:'Poppins'; font-style:normal; font-weight:700; font-display:swap; src:url('/static/fonts/poppins-v24-latin-700.woff2') format('woff2'); }

:root {
  --radius: 0.625rem;
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --primary: oklch(0.5699 0.1122 13.24);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.5296 0.1179 275.33);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
}

/* dark mode — applied when the app's `theme` cookie is "dark" (tokens from ui/app/app.css) */
.dark {
  --background: oklch(13% 0.028 261.692);
  --foreground: oklch(0.985 0 0);
  --primary: oklch(0.48 0.1122 13.24);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.45 0.1179 275.33);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Poppins', ui-sans-serif, system-ui, sans-serif;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- shell / split card ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* wraps the back link + card so the link sits above the card, aligned to its left edge */
.auth-shell {
  width: 100%;
  max-width: 64rem;        /* matches the card */
  display: flex;
  flex-direction: column;
}

.auth-card {
  position: relative;
  display: flex;
  flex-direction: row;
  width: 100%;
  max-width: 64rem;        /* max-w-5xl */
  min-height: 37.5rem;     /* min-h-150 */
  background: var(--background);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: 1rem;     /* rounded-2xl */
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  overflow: hidden;
}

/* one-click escape back to the storefront (the OAuth redirect chain makes
   browser-back cycle through redirects, so offer a clean exit). Sits above the
   card, aligned to its left edge; styled as a compact pill that echoes the
   outline social buttons. */
.auth-back {
  align-self: flex-start;
  margin-bottom: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4rem 0.75rem 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--background);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: background-color .15s, color .15s, border-color .15s;
}
.auth-back:hover { background: var(--accent); color: var(--foreground); }
.auth-back svg { width: 14px; height: 14px; }

.auth-form-col {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 2.75rem;   /* md:py-12 md:px-11 */
}

.auth-form-inner {
  width: 100%;
  max-width: 22.5rem;      /* max-w-90 */
  margin: 0 auto;
}

/* ---------- header ---------- */
.auth-header { margin-bottom: 1.375rem; }
.auth-title {
  margin: 0 0 0.4375rem;
  font-size: 25px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.auth-sub {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--muted-foreground);
}

/* ---------- alerts (Keycloak message.summary) ---------- */
.auth-alert {
  margin-bottom: 1.25rem;
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  border: 1px solid var(--border);
}
.auth-alert-error { border-color: color-mix(in oklch, var(--destructive) 40%, transparent); background: color-mix(in oklch, var(--destructive) 8%, transparent); color: var(--destructive); }
.auth-alert-success { border-color: color-mix(in oklch, var(--secondary) 40%, transparent); background: color-mix(in oklch, var(--secondary) 8%, transparent); }
.auth-alert-warning, .auth-alert-info { background: var(--muted); color: var(--foreground); }

/* ---------- social ---------- */
.auth-social { display: grid; gap: 0.625rem; }
.auth-social-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  height: 2.875rem;        /* h-11.5 */
  width: 100%;
  border: 1px solid var(--border);
  background: var(--background);
  border-radius: 0.5rem;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  color: var(--foreground);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.auth-social-btn:hover { background: var(--accent); }
.auth-social-btn svg { width: 17px; height: 17px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin: 1.375rem 0;
}
.auth-divider span.line { height: 1px; flex: 1; background: var(--border); }
.auth-divider span.label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

/* ---------- form / floating fields ---------- */
.auth-fields { display: flex; flex-direction: column; }

.ff { padding-bottom: 1.25rem; }            /* base spacing */
.ff--hint { padding-bottom: 2rem; }         /* extra room so a persistent hint clears the next field */
.ff--error { padding-bottom: 2.5rem; }      /* extra room so an error message clears the next field */
.ff-control { position: relative; }         /* positioning context = input height, so the resting label centers on the input */
.ff-input {
  width: 100%;
  height: 3rem;            /* h-12 */
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--foreground);
  background: transparent;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);  /* rounded-md */
  outline: none;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  transition: border-color .15s, box-shadow .15s;
}
.ff-input:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--secondary) 30%, transparent);
}
.ff-input[aria-invalid="true"] {
  border-color: var(--destructive);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--destructive) 20%, transparent);
}
.ff-input.has-toggle { padding-right: 2.75rem; }

.ff-label {
  position: absolute;
  left: 0.5rem;
  top: 0.5rem;
  padding: 0 0.5rem;
  background: var(--background);
  color: #9ca3af;          /* text-gray-400 */
  font-size: 0.875rem;
  line-height: 1;
  transform: translateY(-1rem) scale(0.75);
  transform-origin: left;
  transition: all .2s ease;
  pointer-events: none;
}
/* resting state: empty + unfocused -> centered, full size */
.ff-input:placeholder-shown:not(:focus) + .ff-label {
  top: 50%;
  transform: translateY(-50%) scale(1);
  background: transparent;
}
.ff-input:focus + .ff-label { color: var(--secondary); }
.ff-input[aria-invalid="true"] + .ff-label { color: var(--destructive); }

.ff-toggle {
  position: absolute;
  top: 50%;                /* vertical center of the input */
  right: 0.375rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.125rem;
  height: 2.125rem;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}
.ff-toggle:hover { color: var(--foreground); }
.ff-error {
  position: absolute;
  left: 0.125rem;
  top: 100%;
  margin-top: 0.375rem;
  display: flex;
  gap: 0.375rem;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--destructive);
}
.ff-error .bang { font-weight: 700; }

/* hint under a field (register password rule) */
.ff-hint {
  position: absolute;
  left: 0.125rem;
  top: 100%;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--muted-foreground);
}

/* ---------- forgot / submit / switch ---------- */
.auth-forgot {
  display: flex;
  justify-content: flex-end;
  margin-top: -0.375rem;
  margin-bottom: 0.5rem;
}
.auth-forgot a {
  font-size: 13px;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: color .15s;
}
.auth-forgot a:hover { color: var(--secondary); }

.auth-submit {
  height: 2.875rem;        /* h-11.5 */
  width: 100%;
  border: 0;
  border-radius: var(--radius);   /* rounded-lg */
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background-color .15s;
}
.auth-submit:hover { background: color-mix(in oklch, var(--primary) 90%, black); }
.auth-submit:disabled { opacity: 0.6; cursor: default; }
/* Allow an <a> to render as the primary button (e.g. the verify-email resend link). */
a.auth-submit { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

/* Secondary action shown alongside the primary button (restart flow, review profile, cancel). */
.auth-submit-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.875rem;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--background);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--foreground);
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s;
}
.auth-submit-secondary:hover { background: var(--accent); }

/* Vertical button/action stack for pages without form fields. */
.auth-stack { display: flex; flex-direction: column; gap: 0.75rem; }

.auth-terms {
  margin: 0.875rem 0 0;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted-foreground);
}
.auth-terms a { color: var(--secondary); text-decoration: none; }
.auth-terms a:hover { text-decoration: underline; }

.auth-info { margin-top: 1.375rem; }
.auth-switch {
  margin: 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--muted-foreground);
}
.auth-switch a { color: var(--primary); font-weight: 500; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ---------- brand panel ---------- */
.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex: 0 0 42%;           /* md:basis-[42%] */
  padding: 2.5rem;         /* p-10 */
  background-color: #0c0a09;  /* stone-950 */
  background-size: cover;
  background-position: center 28%;
  color: #fafaf9;          /* stone-50 */
}
.auth-brand-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(18,15,17,.93) 14%, rgba(18,15,17,.22) 54%, rgba(18,15,17,.5) 100%);
}
.auth-brand-text { position: relative; }
.auth-brand-statement {
  margin: 0 0 0.875rem;
  max-width: 13ch;
  font-size: 27px;
  line-height: 1.28;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.auth-brand-sub {
  margin: 0;
  max-width: 30ch;
  font-size: 13.5px;
  line-height: 1.6;
  opacity: 0.8;
}

/* ---------- mobile ---------- */
.auth-mobile-hero { display: none; }

@media (max-width: 768px) {
  /* Top-align on mobile: every page should start from the top (back link, then
     card right after) instead of being vertically centered on the screen. */
  .auth-wrap { align-items: flex-start; }
  .auth-shell { max-width: 28rem; }     /* match the mobile card so the back link aligns */
  .auth-card {
    flex-direction: column;
    max-width: 28rem;
    min-height: 0;
    border: 0;
    box-shadow: none;
    border-radius: 0;
  }
  /* No top padding so the card content sits right under "Back to store"
     (the mobile hero / header is the first thing, flush to the card top). */
  .auth-form-col { padding: 0 1rem 2.5rem; }
  .auth-brand { display: none; }

  .auth-mobile-hero {
    position: relative;
    display: block;
    height: 11.5rem;        /* h-46 */
    margin-bottom: 1.5rem;
    border-radius: 18px;
    overflow: hidden;
    background-color: #0c0a09;
    background-size: cover;
    background-position: center 30%;
    color: #fafaf9;
  }
  .auth-mobile-hero .scrim {
    position: absolute; inset: 0;
    background: linear-gradient(to top, rgba(20,17,19,.9) 6%, rgba(20,17,19,.12) 52%, rgba(20,17,19,.42) 100%);
  }
  .auth-mobile-hero .text { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 1rem; }
  .auth-mobile-hero .h { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
  .auth-mobile-hero .s { margin-top: 0.125rem; font-size: 12.5px; opacity: 0.8; }

  /* Always reserve two lines for the password hint so the layout doesn't shift
     when it wraps on narrow phones. Wider phones (hint fits on one line):
     vertically centered in the two-line box. Narrower phones (needs both lines):
     fills them top-down. */
  .ff--hint { padding-bottom: 3rem; }
  .ff-hint {
    right: 0.125rem;         /* span the field width so wrapping is predictable */
    min-height: 2rem;        /* two lines at line-height 1rem */
    display: flex;
    align-items: center;
  }

  /* Errors get the same two-line reservation as hints — the email-allowlist
     message is long enough to wrap on phones. */
  .ff--error { padding-bottom: 3rem; }
  .ff-error {
    right: 0.125rem;
    min-height: 2rem;
    align-items: center;
  }
}
