/*
 * Login screen (layouts/login): glass card in front of a slowly waving
 * backdrop in the Taktsoft Energy colours. Dark is the default; the class
 * "login-light" on <html> switches to the light card, "login-staging" on
 * <body> marks the staging environment. The slats of the backdrop are
 * created by the login-screen Stimulus controller.
 */

.login-screen {
  --login-accent: #008086;
  --login-accent-hover: #00969d;
  --login-text: #0f172a;
  --login-muted: #475569;
  --login-navy: #2D2D5A;
  --login-cyan: #00AFB7;
  --login-teal: #008086;
  --login-night: #0b0b17;
  --login-orange: #f07d00;

  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: var(--login-text);
  background: var(--login-night);
}

/* Backdrop: slats with a gradient in CD colours, filling the whole viewport */
.login-art {
  position: fixed; inset: 0;
  overflow: hidden;
  background: var(--login-night);
}
/*
 * Each slat is 40% taller than the backdrop (20% above, 20% below) and moves
 * up and down as a whole. Animating transform instead of the gradient stops
 * keeps the wave on the compositor: no restyle or repaint per frame.
 * Stops are given in backdrop percent (--base) and converted to slat percent:
 * (p + 20%) / 1.4. The ±11.43% shift equals ±16% of the backdrop height.
 * The keyframes trace an ease-in-out (cosine) curve, because steps() replaces
 * the timing function.
 */
.login-slat {
  position: absolute; top: -20%; bottom: -20%;
  background: linear-gradient(to bottom,
    var(--login-night) 0%,
    var(--login-night) calc((var(--base) - 2%) / 1.4),
    var(--login-navy) calc((var(--base) + 20%) / 1.4),
    var(--login-teal) calc((var(--base) + 36%) / 1.4),
    var(--login-cyan) calc((var(--base) + 48%) / 1.4),
    color-mix(in srgb, var(--login-cyan) 80%, #fff) calc((var(--base) + 64%) / 1.4));
  will-change: transform;
  /* 30 fps are plenty for this slow wave and halve the GPU load of the
     blurred card above it: steps(18) per 0.6s keyframe segment. */
  animation: login-wave 6s steps(18) infinite alternate;
}
@keyframes login-wave {
    0% { transform: translateY(-11.43%); }
   10% { transform: translateY(-10.87%); }
   20% { transform: translateY(-9.25%); }
   30% { transform: translateY(-6.72%); }
   40% { transform: translateY(-3.53%); }
   50% { transform: translateY(0%); }
   60% { transform: translateY(3.53%); }
   70% { transform: translateY(6.72%); }
   80% { transform: translateY(9.25%); }
   90% { transform: translateY(10.87%); }
  100% { transform: translateY(11.43%); }
}

.login-main {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px 16px;
}

/* Glass card: slightly transparent, blurs the backdrop */
.login-card {
  position: relative;
  width: 100%; max-width: 400px;
  padding: 40px 36px 32px;
  border-radius: 20px;
  color: #fff;
  background: rgba(12, 13, 28, .68);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.55), 0 0 90px -20px rgba(0,175,183,.4);
  animation: login-rise .7s cubic-bezier(.2,.8,.2,1) both;
  transition: background .3s, color .3s;
}
/* soft light cone from the top */
.login-card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background:
    radial-gradient(70% 45% at 50% 0%, rgba(255,255,255,.12), rgba(255,255,255,0) 70%),
    radial-gradient(60% 50% at 0% 60%, rgba(0,175,183,.14), rgba(0,175,183,0) 70%);
}
/* 1px edge, bright at the top, turquoise at the bottom right */
.login-card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  padding: 1px;
  background: linear-gradient(165deg, rgba(255,255,255,.30), rgba(255,255,255,.07) 35%, rgba(255,255,255,.05) 55%, rgba(0,175,183,.75));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
}
.login-card > * { position: relative; z-index: 1; }
@keyframes login-rise {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.login-card h1 {
  text-align: center; margin: 0 0 6px;
  font-size: 22px; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em;
}
.login-subtitle {
  text-align: center; margin: 0 0 28px;
  font-size: 14px; color: rgba(255,255,255,.6);
}
.login-flash { margin-bottom: 20px; }

/* Card footer: logo on the left, light/dark toggle on the right */
.login-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 28px;
}
.login-card-foot .logo { display: block; height: 20px; width: auto; }

.login-theme-toggle {
  position: relative;
  flex: none;
  width: 58px; height: 30px; padding: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
  color: rgba(255,255,255,.55);
  cursor: pointer;
}
.login-theme-toggle:hover { background: rgba(255,255,255,.12); }
.login-theme-toggle:focus-visible { outline: 2px solid var(--login-cyan); outline-offset: 2px; }
.login-theme-toggle svg {
  position: absolute; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  transition: color .2s;
}
.login-theme-toggle .sun  { left: 8px; }
.login-theme-toggle .moon { right: 8px; color: var(--login-navy); z-index: 1; }
.login-theme-toggle .knob {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff;
  transform: translateX(28px);   /* dark: knob on the right next to the moon */
  transition: transform .25s cubic-bezier(.2,.8,.2,1), background .2s;
}

.login-card label { display: block; font-size: 13px; font-weight: 500; color: rgba(255,255,255,.75); margin-bottom: 6px; }
.login-field { margin-bottom: 16px; }
.login-field + .login-submit { margin-top: 8px; }
.login-card input[type=text], .login-card input[type=password] {
  width: 100%; padding: 11px 14px;
  font: inherit; font-size: 14px; color: #fff;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s;
}
.login-card input::placeholder { color: rgba(255,255,255,.35); }
.login-card input:focus { border-color: var(--login-cyan); }

.login-submit {
  width: 100%;
  display: inline-flex; justify-content: center; align-items: center; gap: 8px;
  padding: 12px 16px;
  font: inherit; font-size: 14px; font-weight: 600; color: #fff;
  background: var(--login-accent);
  border: 0; border-radius: 10px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.login-submit:hover { background: var(--login-accent-hover); }
.login-submit:active { transform: translateY(1px); }

/* Secondary actions on the MFA pages: switch method, recovery codes */
.login-secondary {
  width: 100%;
  display: flex; justify-content: center; align-items: center; gap: 8px;
  padding: 11px 16px;
  font-size: 14px; font-weight: 600; color: #fff; text-decoration: none;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
  transition: background .15s, border-color .15s;
}
.login-secondary + .login-secondary { margin-top: 8px; }
.login-secondary:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.28); }
.login-links { margin-top: 16px; text-align: center; }
.login-link { font-size: 13px; color: var(--login-cyan); text-decoration: none; }
.login-link:hover { text-decoration: underline; }
.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.45);
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px; background: rgba(255,255,255,.14);
}
.login-info {
  margin-bottom: 16px; padding: 12px 14px;
  font-size: 13px; line-height: 1.5; color: rgba(255,255,255,.85);
  background: rgba(0,175,183,.12);
  border: 1px solid rgba(0,175,183,.35);
  border-radius: 10px;
}
.login-error:not(:empty) { margin-top: 12px; font-size: 13px; color: #fca5a5; }

/* Password reset: read-only e-mail, password field with reveal button, errors */
.login-label { display: block; font-size: 13px; font-weight: 500; color: rgba(255,255,255,.75); margin-bottom: 6px; }
.login-readonly {
  padding: 11px 14px;
  font-size: 14px; color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.03);
  border: 1px dashed rgba(255,255,255,.14);
  border-radius: 10px;
  overflow-wrap: anywhere;
}
.login-input-row { display: flex; gap: 8px; }
.login-input-row input { flex: 1; min-width: 0; }
/* Rails wraps invalid fields in div.field_with_errors; that wrapper must grow */
.login-input-row > .field_with_errors { flex: 1; min-width: 0; display: flex; }
.login-card .field_with_errors input { border-color: rgba(239,68,68,.6); }
.login-icon-button {
  flex: none;
  display: grid; place-items: center;
  width: 44px; padding: 0;
  color: rgba(255,255,255,.7);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  cursor: pointer;
}
.login-icon-button:hover { background: rgba(255,255,255,.12); }
.login-icon-button:focus-visible { outline: 2px solid var(--login-cyan); outline-offset: 2px; }
.login-errors {
  margin-bottom: 16px; padding: 12px 14px;
  font-size: 13px; line-height: 1.5; color: #fecaca;
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.4);
  border-radius: 10px;
}
.login-errors p { margin: 0 0 4px; font-weight: 600; }
.login-errors ul { margin: 0; padding-left: 18px; }
.login-error-detail { display: block; font-size: 12px; overflow-wrap: anywhere; }

/* ---------- light glass card ---------- */
.login-light .login-card {
  color: var(--login-text);
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 30px 80px -24px rgba(17,17,42,.45);
}
.login-light .login-card::before {
  background: radial-gradient(70% 45% at 50% 0%, rgba(255,255,255,.6), rgba(255,255,255,0) 70%);
}
.login-light .login-card::after {
  background: linear-gradient(165deg, rgba(255,255,255,.95), rgba(255,255,255,.4) 40%, rgba(255,255,255,.3) 60%, rgba(0,175,183,.55));
}
.login-light .login-subtitle { color: var(--login-muted); }
.login-light .login-card label { color: #334155; }
.login-light .login-card input[type=text], .login-light .login-card input[type=password] {
  color: var(--login-text);
  background: rgba(255,255,255,.85);
  border-color: rgba(15,23,42,.14);
}
.login-light .login-card input::placeholder { color: #94a3b8; }
.login-light .login-card input:focus { border-color: var(--login-teal); }
/* logo in its original colours */
.login-light .logo .st0 { fill: var(--login-navy); }
.login-light .logo stop:first-child { stop-color: var(--login-navy) !important; }

.login-light .login-theme-toggle { background: rgba(15,23,42,.06); border-color: rgba(15,23,42,.14); color: #64748b; }
.login-light .login-theme-toggle .knob { transform: translateX(0); background: var(--login-navy); }
.login-light .login-theme-toggle .sun  { color: #fff; z-index: 1; }
.login-light .login-theme-toggle .moon { color: #64748b; z-index: 0; }

.login-light .login-secondary { color: var(--login-text); background: rgba(255,255,255,.7); border-color: rgba(15,23,42,.14); }
.login-light .login-secondary:hover { background: #fff; border-color: rgba(15,23,42,.24); }
.login-light .login-link { color: var(--login-teal); }
.login-light .login-divider { color: #94a3b8; }
.login-light .login-divider::before, .login-light .login-divider::after { background: rgba(15,23,42,.12); }
.login-light .login-info { color: #134e4a; background: rgba(0,175,183,.10); border-color: rgba(0,128,134,.30); }
.login-light .login-error:not(:empty) { color: #b91c1c; }
.login-light .login-label { color: #334155; }
.login-light .login-readonly { color: var(--login-text); background: rgba(255,255,255,.5); border-color: rgba(15,23,42,.18); }
.login-light .login-icon-button { color: #475569; background: rgba(255,255,255,.85); border-color: rgba(15,23,42,.14); }
.login-light .login-icon-button:hover { background: #fff; }
.login-light .login-errors { color: #991b1b; background: rgba(254,226,226,.8); border-color: rgba(220,38,38,.3); }

/* ---------- staging ---------- */
.login-staging .login-submit { background: var(--login-orange); }
.login-staging .login-submit:hover { background: #ff8f1f; }
.login-staging .logo path, .login-staging .logo polygon { fill: #fff !important; }
.login-light .login-staging .logo path, .login-light .login-staging .logo polygon { fill: #14162b !important; }
.login-stage-icon {
  display: grid; place-items: center;
  width: 52px; height: 52px; margin: 0 auto 16px;
  border-radius: 14px;
  color: var(--login-orange);
  background: rgba(240,125,0,.14);
  border: 1px solid rgba(240,125,0,.45);
}
.login-stage-icon svg { width: 26px; height: 26px; }
.login-hl-stage { color: var(--login-orange); }
/* a little darker for contrast on the light card */
.login-light .login-hl-stage { color: #d06a00; }

@media (prefers-reduced-motion: reduce) {
  .login-slat, .login-card { animation: none; }
  .login-card, .login-theme-toggle .knob { transition: none; }
}
