/* =============================================================================
   signin.css — awwwards split-screen sign-in for the admin CRM (/crm/login/)
   and the client portal (/portal/). FULLY scoped under .si-shell / .si-* so it
   never leaks onto the reset-password page (shared admin-auth layout) or the
   shared .login-* pages. Theme-aware: palette flips via the same
   [data-theme="light"], .light-mode selector tokens.css uses. The film panel
   stays dark in both themes (it's video).
   ============================================================================= */

/* Heading display face — self-hosted subset (mirrors the Montserrat pattern) */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/assets/fonts/fraunces-v38-latin-var.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122, U+2212;
}

/* ---- Shell + tokens (dark defaults) ---- */
.si-shell {
  position: relative;
  display: flex;
  min-height: 100dvh;
  width: 100%;
  overflow: hidden;
  isolation: isolate;

  /* Apple-spring easing palette (awwwards-motion) */
  --si-spring-snappy: linear(
    0,
    0.009,
    0.035 2.1%,
    0.141 4.4%,
    0.723 12.9%,
    0.938 16.7%,
    1.017 19.4%,
    1.067 22.5%,
    1.089 26%,
    1.079 30.3%,
    1.049 36%,
    1.024 42.6%,
    1.011 50.3%,
    1.004 59.2%,
    1.001 69.3%,
    1
  );
  --si-spring-bouncy: linear(
    0,
    0.014,
    0.055 1.8%,
    0.218 3.7%,
    0.867 8.5%,
    1.085 10.7%,
    1.212 12.9%,
    1.264 15%,
    1.262 17%,
    1.217 19.5%,
    1.098 24%,
    1.035 28.5%,
    0.993 33%,
    0.981 38%,
    0.988 45%,
    0.998 55%,
    1.001 68%,
    1
  );
  --si-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --si-ease-snap: cubic-bezier(0.22, 1, 0.36, 1);
  --si-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* Palette — dark */
  --si-bg: #0a0a0a;
  --si-ink: #f5f5f5;
  --si-ink-2: rgba(245, 245, 245, 0.62);
  --si-ink-3: rgba(245, 245, 245, 0.4);
  --si-field: rgba(255, 255, 255, 0.04);
  --si-field-focus: rgba(255, 255, 255, 0.06);
  --si-line: rgba(255, 255, 255, 0.1);
  --si-line-strong: rgba(255, 255, 255, 0.22);
  --si-glow: rgba(110, 168, 254, 0.1);
  --si-grain-op: 0.045;
  --si-on-accent: #06121f;

  font-family: 'Montserrat', Arial, sans-serif;
  background: var(--si-bg);
  color: var(--si-ink);
}

#portal-login-view.si-shell {
  min-height: calc(100dvh - var(--portal-topbar-height, 32px));
}

/* Palette — light (matches tokens.css light selector) */
[data-theme='light'] .si-shell,
.light-mode .si-shell {
  --si-bg: #fafaf9;
  --si-ink: #1a1a1a;
  --si-ink-2: rgba(26, 26, 26, 0.6);
  --si-ink-3: rgba(26, 26, 26, 0.4);
  --si-field: #f3f3f1;
  --si-field-focus: #ffffff;
  --si-line: rgba(0, 0, 0, 0.09);
  --si-line-strong: rgba(0, 0, 0, 0.16);
  --si-glow: rgba(250, 235, 215, 0.55);
  --si-grain-op: 0.03;
  --si-on-accent: #ffffff;
}

/* Film-grain overlay (felt, not seen) */
.si-shell::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: var(--si-grain-op);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* ---- Logo, top-left corner ---- */
.si-brand {
  position: absolute;
  top: 26px;
  left: 30px;
  z-index: 4;
  width: 42px;
  height: 42px;
  color: var(--si-ink);
  display: grid;
  place-items: center;
}
.si-brand svg {
  width: 100%;
  height: 100%;
}

/* ---- Left: form pane ---- */
.si-form-pane {
  position: relative;
  flex: 1 1 46%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  overflow-y: auto;
}
.si-form-pane::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 55% at 30% 22%, var(--si-glow) 0%, transparent 60%);
  pointer-events: none;
}
.si-form-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
}

.si-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(2.6rem, 4.4vw, 3.6rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 0.98;
  margin: 0 0 16px;
  color: var(--si-ink);
}
.si-lede {
  color: var(--si-ink-2);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 34px;
  max-width: 34ch;
}

.si-field {
  margin-bottom: 18px;
}
.si-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--si-ink-2);
  margin-bottom: 9px;
  text-transform: none;
}
.si-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--si-field);
  border: 1px solid var(--si-line);
  border-radius: 14px;
  transition:
    border-color 0.4s var(--si-ease-snap),
    background 0.4s var(--si-ease-snap),
    box-shadow 0.4s var(--si-ease-snap);
}
.si-input-wrap:focus-within {
  background: var(--si-field-focus);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.si-lead-icon {
  position: absolute;
  left: 15px;
  color: var(--si-ink-3);
  display: grid;
  place-items: center;
  pointer-events: none;
  transition: color 0.4s var(--si-ease-snap);
}
.si-input-wrap:focus-within .si-lead-icon {
  color: var(--accent);
}
.si-input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  padding: 15px 15px 15px 44px;
  font-family: 'Montserrat', Arial, sans-serif;
  /* 16px is a FLOOR, not a taste call: iOS Safari force-zooms the viewport on
     focus for any field under 16px, and there is no way back out on a page that
     disables user scaling. Never lower this. */
  font-size: 16px;
  color: var(--si-ink);
  border-radius: 14px;
}
.si-input--eye {
  padding-right: 46px;
}
.si-input::placeholder {
  color: var(--si-ink-3);
}

/* Reuse the existing eye toggle mechanism; fully re-position over .login-eye */
.si-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--si-ink-3);
  padding: 8px;
  margin: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  width: auto;
  height: auto;
  transition: color 0.3s var(--si-ease-snap);
}
.si-eye:hover {
  color: var(--si-ink);
}

.si-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin: 6px 0 26px;
  font-size: 13px;
}

/* Link-style buttons (forgot password) with a sliding underline */
.si-link {
  position: relative;
  color: var(--si-ink-2);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.3s var(--si-ease-snap);
}
.si-link::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 1.5px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.4s var(--si-ease-snap);
}
.si-link:hover {
  color: var(--si-ink);
}
.si-link:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* Method wrapper — carries data-login-method; hosts the "Last used" badge so a
   button innerHTML/textContent swap during loading can't delete it. */
.si-method {
  position: relative;
  margin-top: 0;
}

.si-method--hint {
  margin-top: 16px;
}

.si-btn-primary {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: var(--si-on-accent);
  border: 0;
  border-radius: 14px;
  padding: 16px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 22px var(--accent-glow);
  transition:
    transform 0.55s var(--si-spring-snappy),
    box-shadow 0.4s var(--si-ease-snap),
    filter 0.3s var(--si-ease-snap);
  will-change: transform;
}
.si-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 34px var(--accent-glow);
  filter: brightness(1.04);
}
.si-btn-primary:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 0.1s;
  transition-timing-function: var(--si-ease-snap);
}
.si-btn-primary:disabled {
  opacity: 0.7;
  cursor: default;
}
.si-btn-primary svg {
  transition: transform 0.5s var(--si-spring-bouncy);
}
.si-btn-primary:hover:not(:disabled) svg {
  transform: translateX(3px);
}

.si-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 26px 0;
  color: var(--si-ink-3);
  font-size: 12px;
  letter-spacing: 0.04em;
}
.si-divider::before,
.si-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--si-line);
}

/* Google sign-in. GIS renders its own button (an iframe) into #admin-google-btn,
   so this block only positions it — it cannot be restyled from here. */
#admin-google-wrap [data-login-method='google'] {
  display: flex;
  justify-content: center;
}

#admin-google-btn {
  width: 100%;
  max-width: 320px;
}

/* The passkey block carries its own "or continue with" divider. When both blocks
   are shown, the second divider is redundant. */
#admin-passkey-wrap:not(.hidden) + #admin-google-wrap > .si-divider {
  display: none;
}

.si-btn-secondary {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--si-field);
  color: var(--si-ink);
  border: 1px solid var(--si-line);
  border-radius: 14px;
  padding: 15px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    transform 0.5s var(--si-spring-snappy),
    background 0.3s var(--si-ease-snap),
    border-color 0.3s var(--si-ease-snap);
}
.si-btn-secondary:hover {
  background: var(--si-field-focus);
  border-color: var(--si-line-strong);
  transform: translateY(-1px);
}
.si-btn-secondary:active {
  transform: scale(0.985);
  transition-duration: 0.1s;
}

/* "Last used" badge — injected into .si-method by login-last-used.js */
.si-last-used-badge {
  position: absolute;
  top: -9px;
  left: 16px;
  z-index: 2;
  padding: 2px 9px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
  color: var(--accent);
  background: var(--si-bg);
  border: 1px solid var(--accent);
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
}

.si-magic-hint {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--si-ink-3);
  text-align: center;
}

/* Message alerts (ids toggled by the page JS via .hidden / .portal-hidden) */
.si-alert {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.si-alert-error {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.si-alert-info {
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid transparent;
}
[data-theme='light'] .si-alert-error,
.light-mode .si-alert-error {
  color: #b91c1c;
}

.si-legal {
  margin: 20px 0 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--si-ink-3);
  text-align: center;
}
.si-legal a {
  color: var(--si-ink-2);
  text-decoration: underline;
}
.si-copyright {
  margin-top: 34px;
  text-align: center;
  font-size: 11px;
  color: var(--si-ink-3);
  letter-spacing: 0.03em;
}

/* ---- Right: cinematic film (dark in both themes) ---- */
.si-hero {
  flex: 1 1 54%;
  position: relative;
  padding: 18px;
  display: none;
}
.si-hero-frame {
  position: absolute;
  inset: 18px;
  border-radius: 28px;
  overflow: hidden;
  background: #060606;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.si-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.6s var(--si-ease-out);
}
.si-slide.is-active {
  opacity: 1;
}
.si-slide video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Poster fallback: first slide visible when no video plays */
.si-hero[data-static='true'] .si-slide:first-child {
  opacity: 1;
}
.si-hero[data-static='true'] .si-slide:first-child video {
  background-size: cover;
  background-position: center;
}
.si-hero-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      to top,
      rgba(6, 6, 6, 0.72) 0%,
      rgba(6, 6, 6, 0.05) 46%,
      rgba(6, 6, 6, 0.28) 100%
    ),
    radial-gradient(120% 80% at 50% 120%, rgba(110, 168, 254, 0.12) 0%, transparent 55%);
}
.si-hero-caption {
  position: absolute;
  left: 34px;
  right: 34px;
  bottom: 30px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.si-hero-mark {
  width: 24px;
  height: 24px;
  color: #fff;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 1px 8px rgba(0, 0, 0, 0.5));
}
.si-hero-mark svg {
  width: 100%;
  height: 100%;
}
.si-dots {
  display: flex;
  gap: 8px;
}
.si-hero[data-static='true'] .si-dots {
  display: none;
}
.si-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.38);
  border: 0;
  padding: 0;
  cursor: pointer;
  transition:
    width 0.4s var(--si-spring-snappy),
    background 0.3s var(--si-ease-snap);
}
.si-dot.is-active {
  width: 26px;
  border-radius: 5px;
  background: #fff;
}

/* ---- Entry motion ---- */
@keyframes si-enter-up {
  from {
    opacity: 0;
    transform: translateY(22px);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}
.si-enter {
  opacity: 0;
  animation: si-enter-up 0.8s var(--si-ease-out) both;
  animation-delay: var(--si-d, 0ms);
}
@keyframes si-slide-in-right {
  from {
    opacity: 0;
    transform: translateX(40px);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
    filter: blur(0);
  }
}
.si-hero .si-hero-frame {
  opacity: 0;
  animation: si-slide-in-right 1s var(--si-ease-out) 0.15s both;
}

/* word-by-word masked heading reveal */
.si-word-wrap {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  padding-bottom: 0.12em;
}
.si-word {
  display: inline-block;
  transform: translateY(110%);
  animation: si-word-rise 0.95s var(--si-spring-snappy) both;
  animation-delay: var(--si-wd, 0ms);
}
@keyframes si-word-rise {
  to {
    transform: translateY(0);
  }
}

/* ---- Responsive: below 900px the film panel hides, form centers ---- */
@media (min-width: 900px) {
  .si-hero {
    display: block;
  }
}

/* ---- Mobile (<900px): compact the stack so it fits one viewport, and CAP the
   shell to the viewport so any residual overflow scrolls INSIDE the form pane
   (min-height:0 unlocks the flex-child scroll) — the page itself never scrolls. */
@media (max-width: 899px) {
  .si-shell {
    height: 100dvh;
  }
  #portal-login-view.si-shell {
    height: calc(100dvh - var(--portal-topbar-height, 32px));
  }
  .si-brand {
    width: 36px;
    height: 36px;
    top: 20px;
    left: 22px;
  }
  .si-form-pane {
    min-height: 0;
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 62px 22px 28px; /* top clears the corner logo */
  }
  .si-title {
    font-size: clamp(2.1rem, 10vw, 2.9rem);
    margin-bottom: 8px;
  }
  .si-lede {
    margin-bottom: 16px;
  }
  .si-field {
    margin-bottom: 12px;
  }
  .si-row {
    margin: 4px 0 14px;
  }
  .si-divider {
    margin: 12px 0;
  }
  .si-copyright {
    margin-top: 16px;
  }
  .si-legal {
    margin-top: 10px;
  }
  .si-magic-hint {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .si-enter,
  .si-hero .si-hero-frame {
    animation: none;
    opacity: 1;
    transform: none;
    filter: none;
  }
  .si-word {
    animation: none;
    transform: none;
  }
  .si-slide {
    transition: opacity 0.3s;
  }
}
