/* =====================================================================
   Sign-in screen.

   Loaded only by this page, so nothing here can affect the application
   proper. Split layout: the brand on the left, the form on the right, and
   the two stack on a narrow screen.

   The movement is three slow-drifting blurred shapes. They animate on
   transform and opacity only, so the work stays on the compositor and the
   page does not repaint; and they stop entirely for anyone who has asked
   their system to reduce motion.
   ===================================================================== */

/* This page loads instead of app.css, not alongside it, so it needs its own
   reset. Without border-box a padded input is wider than its container,
   which is how the form came to overflow the screen on a phone. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img { max-width: 100%; }

.login-page {
  --ink:        #0b1f33;
  --ink-2:      #10364a;
  --accent:     #14b8a6;
  --accent-2:   #0f766e;
  --field:      #ffffff;
  --field-line: #d6dee7;
  --text:       #0f172a;
  --muted:      #64748b;
  --panel:      #ffffff;

  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  font-family: "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--panel);
  overflow: hidden;
}

/* ---------------------------------------------------------------- brand side */
.login-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2.2rem;
  padding: 3.2rem clamp(2rem, 5vw, 4.5rem);
  background: linear-gradient(150deg, var(--ink) 0%, var(--ink-2) 55%, #0d4f4a 100%);
  color: #e2e8f0;
  isolation: isolate;
}

/* a faint grid, so the panel reads as a surface rather than flat colour */
.login-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 80% 70% at 30% 40%, #000 40%, transparent 100%);
  z-index: -1;
  pointer-events: none;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(58px);
  opacity: .42;
  z-index: -2;
  will-change: transform;
}
.login-orb.a { width: 30rem; height: 30rem; background: #0d9488; top: -9rem;  left: -7rem;
               animation: orb-a 22s ease-in-out infinite; }
.login-orb.b { width: 24rem; height: 24rem; background: #155e75; bottom: -9rem; left: 20%;
               animation: orb-b 27s ease-in-out infinite; }
.login-orb.c { width: 20rem; height: 20rem; background: #0d9488; top: 30%; right: -6rem;
               animation: orb-c 19s ease-in-out infinite; }

@keyframes orb-a {
  0%, 100% { transform: translate3d(0, 0, 0)         scale(1); }
  50%      { transform: translate3d(4rem, 3rem, 0)   scale(1.12); }
}
@keyframes orb-b {
  0%, 100% { transform: translate3d(0, 0, 0)         scale(1); }
  50%      { transform: translate3d(-3.5rem, -3rem, 0) scale(1.18); }
}
@keyframes orb-c {
  0%, 100% { transform: translate3d(0, 0, 0)         scale(1.05); }
  50%      { transform: translate3d(-3rem, 4rem, 0)  scale(.9); }
}

.login-mark {
  display: inline-flex;
  align-items: baseline;
  gap: .55rem;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #fff;
}
.login-mark .dot {
  width: .42rem; height: .42rem; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, .22);
  transform: translateY(-.15rem);
}

.login-lede {
  font-size: clamp(1.5rem, 2.4vw, 2.1rem);
  line-height: 1.25;
  font-weight: 300;
  color: #f1f5f9;
  max-width: 20ch;
  margin: 0;
}
.login-lede b { font-weight: 700; color: #5eead4; }

.login-points { list-style: none; margin: 0; padding: 0; display: grid; gap: .85rem; max-width: 34ch; }
.login-points li { display: flex; gap: .7rem; align-items: flex-start; font-size: .88rem; color: #cbd5e1; }
.login-points .tick {
  flex: 0 0 1.15rem; height: 1.15rem; margin-top: .1rem;
  border-radius: 50%;
  background: rgba(20, 184, 166, .16);
  color: #5eead4;
  display: grid; place-items: center;
  font-size: .7rem; font-weight: 700;
}
.login-points b { color: #e2e8f0; font-weight: 600; }

.login-foot {
  font-size: .7rem;
  color: #7c8ea3;
  letter-spacing: .12em;
  font-weight: 600;
}

/* ---------------------------------------------------------------- form side */
.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  background: var(--panel);
}
.login-card {
  width: 100%;
  max-width: 23rem;
  animation: card-in .5s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.login-card h2 { font-size: 1.35rem; margin: 0 0 .25rem; letter-spacing: -.015em; }
.login-card .sub { color: var(--muted); font-size: .85rem; margin: 0 0 1.6rem; }

.login-field { position: relative; margin-bottom: 1rem; }
.login-field > label {
  display: block;
  font-size: .74rem; font-weight: 600; letter-spacing: .02em;
  color: #475569; margin-bottom: .35rem;
}
.login-field input {
  width: 100%;
  padding: .72rem .85rem .72rem 2.4rem;
  font-size: .92rem; font-family: inherit; color: var(--text);
  background: var(--field);
  border: 1px solid var(--field-line);
  border-radius: 9px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.login-field input::placeholder { color: #a3aec0; }
.login-field input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, .15);
}
.login-field .ico {
  position: absolute;
  left: .8rem; bottom: .72rem;
  width: 1.1rem; text-align: center;
  color: #94a3b8; font-size: .95rem;
  pointer-events: none;
  transition: color .15s;
}
.login-field input:focus ~ .ico { color: var(--accent-2); }

.login-field .peek {
  position: absolute;
  right: .5rem; bottom: .45rem;
  background: none; border: 0; cursor: pointer;
  color: #94a3b8; font-size: .95rem; line-height: 1;
  padding: .3rem .4rem; border-radius: 6px;
}
.login-field .peek:hover { color: var(--accent-2); background: #f1f5f9; }
.login-field .peek:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }

.login-submit {
  width: 100%;
  margin-top: .4rem;
  padding: .78rem 1rem;
  font-size: .92rem; font-weight: 600; font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-2), #0e7490);
  border: 0; border-radius: 9px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(13, 148, 136, .28);
  transition: transform .12s, box-shadow .18s, filter .15s;
}
.login-submit:hover { filter: brightness(1.07); box-shadow: 0 9px 24px rgba(13, 148, 136, .34); }
.login-submit:active { transform: translateY(1px); }
.login-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.login-submit[aria-busy="true"] { pointer-events: none; opacity: .75; }
.login-submit[aria-busy="true"]::after {
  content: "";
  display: inline-block;
  width: .8em; height: .8em; margin-left: .55em;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -.1em;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-langs {
  display: flex; justify-content: center; gap: .3rem;
  margin-top: 1.5rem;
}
.login-langs a {
  padding: .3rem .7rem;
  font-size: .78rem; text-decoration: none;
  color: var(--muted); border-radius: 99px;
  transition: background .15s, color .15s;
}
.login-langs a:hover { background: #f1f5f9; color: var(--text); }
.login-langs a.on { background: rgba(20, 184, 166, .12); color: var(--accent-2); font-weight: 700; }

.login-version { text-align: center; margin-top: 1.1rem; font-size: .7rem; color: #a3aec0; }

/* flash messages, restyled for this page only */
.login-card .alert {
  display: flex; gap: .55rem; align-items: flex-start;
  padding: .65rem .8rem; border-radius: 9px;
  font-size: .84rem; margin-bottom: 1rem;
  border: 1px solid transparent;
}
.login-card .alert-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.login-card .alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.login-card .alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.login-card .alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 860px) {
  /* the brand takes only the room its words need; the form gets the rest */
  .login-page { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-brand {
    padding: 1.6rem 1.5rem;
    gap: .7rem;
    text-align: center;
    align-items: center;
    min-height: 0;
  }
  .login-mark { font-size: 1.4rem; }
  .login-brand .login-points,
  .login-brand .login-foot { display: none; }   /* the form is what matters on a phone */
  .login-lede { font-size: 1.1rem; max-width: none; }
  .login-orb.b, .login-orb.c { display: none; }
  .login-form-side { padding: 2rem 1.25rem 3rem; }
}

/* ---------------------------------------------------------------- dark */
@media (prefers-color-scheme: dark) {
  .login-page {
    --panel: #0f172a;
    --field: #1e293b;
    --field-line: #334155;
    --text: #e2e8f0;
    --muted: #94a3b8;
  }
  .login-field > label { color: #cbd5e1; }
  .login-field input::placeholder { color: #64748b; }
  .login-langs a:hover { background: #1e293b; }
  .login-field .peek:hover { background: #1e293b; }
}

/* ---------------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  .login-orb { animation: none; }
  .login-card { animation: none; }
  .login-submit { transition: none; }
}

/* ---------------------------------------------------------------- right to left
   The field icon leads the text, so it swaps sides with it; so does the
   reveal button. The brand panel keeps its position -- the grid columns are
   mirrored by the document direction on their own. */
html[dir="rtl"] .login-field input { padding: .72rem 2.4rem .72rem .85rem; }
html[dir="rtl"] .login-field .ico  { left: auto; right: .8rem; }
html[dir="rtl"] .login-field .peek { right: auto; left: .5rem; }
html[dir="rtl"] .login-field > label,
html[dir="rtl"] .login-card h2,
html[dir="rtl"] .login-card .sub { text-align: right; }
html[dir="rtl"] .login-brand { text-align: right; }
html[dir="rtl"] .login-points li { flex-direction: row-reverse; }
html[dir="rtl"] .login-lede,
html[dir="rtl"] .login-points { margin-inline-start: 0; margin-inline-end: auto; }
/* an address and a password are typed left to right whatever the interface language */
html[dir="rtl"] .login-field input { direction: ltr; text-align: right; }
html[dir="rtl"] .login-field input::placeholder { direction: ltr; }
