/* =========================================================================
   MAESTROX — Login screen
   Full-bleed cinematic video background · floating glass card · brand chrome

   Page-scoped: only loaded by views/layouts/auth.ejs. The universal reset
   below is therefore safe — it doesn't touch the rest of the portal.
   Tokens come from /public/maestrox/tokens.css (linked in the layout, not
   @imported here, so it can download in parallel with this file).
   ========================================================================= */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #050402;
  color: var(--fg-on-dark);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* =========================================================================
   STAGE — the full-viewport canvas with letterbox crop
   ========================================================================= */

.stage {
  position: fixed;
  inset: 0;
  background: #050402;
  overflow: hidden;
}

/* Letterbox bars top + bottom — gives the page cinema framing */
.stage::before,
.stage::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 5vh;
  background: #050402;
  z-index: 4;
  pointer-events: none;
}
.stage::before { top: 0; }
.stage::after  { bottom: 0; }

/* =========================================================================
   VIDEO BACKDROP
   ========================================================================= */

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  /* Drop saturation; the gold tint overlay does the color work */
  filter: brightness(0.55) contrast(1.15) saturate(0.4);
  /* Promote to its own compositor layer so the tint/vignette/grain overlays
     and the card's backdrop-filter composite against a cached texture instead
     of forcing a full re-raster of the moving video every frame. Fixes the
     background-video stutter on the login page. */
  transform: translateZ(0);
  will-change: transform;
}

/* Placeholder fallback — sits behind the video and shows when it fails to load */
.bg-placeholder {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 40% 50% at 65% 45%, rgba(200, 169, 94, 0.18) 0%, transparent 70%),
    radial-gradient(ellipse 60% 80% at 30% 70%, rgba(122, 31, 36, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse 100% 100% at 50% 50%, #1a0f08 0%, #050402 80%);
  animation: drift 20s ease-in-out infinite alternate;
}
@keyframes drift {
  0%   { background-position: 0% 0%, 0% 0%, 50% 50%; transform: scale(1.02); }
  100% { background-position: 8% -4%, -4% 6%, 50% 50%; transform: scale(1.08); }
}

/* Gold-screen tint over the video to bring it into brand palette */
.tint {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(135deg, rgba(200, 169, 94, 0.22) 0%, rgba(122, 31, 36, 0.15) 100%);
  mix-blend-mode: screen;
  pointer-events: none;
}

/* Vignette + sheen — hard edge darkening so the card has somewhere quiet to live */
.vignette {
  position: absolute;
  inset: 0;
  z-index: 3;
  background:
    radial-gradient(ellipse 90% 70% at 50% 50%, transparent 35%, rgba(5, 4, 2, 0.6) 75%, rgba(5, 4, 2, 0.95) 100%),
    linear-gradient(180deg, rgba(5, 4, 2, 0.4) 0%, transparent 25%, transparent 75%, rgba(5, 4, 2, 0.6) 100%);
  pointer-events: none;
}

/* Subtle film grain (CSS-only — no extra HTTP request) */
.grain {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  /* Normal blending (was mix-blend-mode: overlay). At 0.06 opacity the grain
     reads the same, but a blend mode forces a full-screen composite pass over
     the moving video every frame — a real cost for a near-invisible texture. */
  opacity: 0.05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* =========================================================================
   CHROME — top-left lockup, bottom-left tagline, bottom-right audio toggle
   ========================================================================= */

.chrome {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  padding: calc(5vh + 32px) 48px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr auto;
}
.chrome > * { pointer-events: auto; }

.brand-top {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
  display: flex; align-items: center; gap: 14px;
  opacity: 0;
  animation: fade-up 1200ms var(--ease, cubic-bezier(.2,.7,.2,1)) 200ms forwards;
}
.brand-top img {
  height: 28px;
  width: auto;
  opacity: 0.85;
}
.brand-top .divider {
  width: 1px; height: 22px;
  background: rgba(200, 169, 94, 0.35);
}
.brand-top .imprint {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(200, 169, 94, 0.7);
}
/* Text fallback when a white-label agency has no uploaded logo — a cream
   display wordmark sized to sit where the logo would. */
.brand-top .brand-name-text {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--fg-on-dark);
  opacity: 0.9;
}

.tagline {
  grid-column: 1 / 2;
  grid-row: 3 / 4;
  align-self: end;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 16px;
  letter-spacing: 0.02em;
  color: rgba(243, 234, 212, 0.5);
  max-width: 320px;
  line-height: 1.4;
  opacity: 0;
  animation: fade-up 1200ms var(--ease, cubic-bezier(.2,.7,.2,1)) 800ms forwards;
}
/* Headline line of the tagline ("Festina lente.") — picks up the gold
   that the old "House Motto" kicker used, but stays in line with the
   rest of the tagline's display-italic styling (no kicker chrome). */
.tagline-headline {
  color: var(--gold);
}

.audio-toggle {
  grid-column: 2 / 3;
  grid-row: 3 / 4;
  align-self: end;
  justify-self: end;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: rgba(10, 8, 5, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(200, 169, 94, 0.25);
  border-radius: 999px;
  color: rgba(243, 234, 212, 0.7);
  font-family: var(--font-body);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  animation: fade-up 1200ms var(--ease, cubic-bezier(.2,.7,.2,1)) 1000ms forwards;
  transition: color 200ms, border-color 200ms;
}
.audio-toggle:hover { color: var(--gold); border-color: var(--gold-soft); }
.audio-toggle svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* =========================================================================
   THE CARD — glass form floating right-of-center
   ========================================================================= */

.card-anchor {
  position: absolute;
  z-index: 20;
  top: 50%;
  right: 8vw;
  transform: translateY(-50%);
}

.card {
  width: 420px;
  max-width: calc(100vw - 36px);   /* never exceed a phone's width */
  padding: 48px 44px 40px;
  /* Bumped opacity 0.62 -> 0.68 so the card still reads as a solid glass plate
     with a lighter blur. blur(28px) over a *moving* video was the single most
     expensive per-frame GPU op on this page (backdrop-filter re-samples the
     video every frame); 16px keeps the frosted look at a fraction of the cost. */
  background: rgba(15, 12, 8, 0.68);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(200, 169, 94, 0.18);
  border-radius: 4px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 10px 30px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  position: relative;
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  animation: card-in-anchor 1100ms var(--ease, cubic-bezier(.2,.7,.2,1)) 400ms forwards;
}

/* Inner gold hairline ring for that 'plate' feeling */
.card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 0.5px solid rgba(200, 169, 94, 0.18);
  pointer-events: none;
  border-radius: 2px;
}

.card-mark {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 28px;
}
.card-mark .brand-lockup {
  width: 240px;
  height: auto;
  opacity: 0;
  animation: fade-up 1000ms var(--ease, cubic-bezier(.2,.7,.2,1)) 700ms forwards;
}
/* Text fallback (white-label agency, no uploaded logo) — a cream display
   wordmark in the card's brand slot, same fade-up as the lockup. */
.card-mark .card-name-text {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--fg-on-dark);
  text-align: center;
  opacity: 0;
  animation: fade-up 1000ms var(--ease, cubic-bezier(.2,.7,.2,1)) 700ms forwards;
}

.card-welcome {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.005em;
  color: var(--fg-on-dark);
  margin-bottom: 6px;
  opacity: 0;
  animation: fade-up 900ms var(--ease, cubic-bezier(.2,.7,.2,1)) 1000ms forwards;
}
.card-welcome em { font-style: italic; color: var(--gold); font-weight: 300; }

.card-sub {
  font-size: 12.5px;
  color: rgba(243, 234, 212, 0.55);
  line-height: 1.5;
  margin-bottom: 32px;
  opacity: 0;
  animation: fade-up 900ms var(--ease, cubic-bezier(.2,.7,.2,1)) 1100ms forwards;
}

/* Banners — danger (login failure / validation) and success (after
   password reset or invite accept). Both inherit the fade-up cadence
   so they don't appear out of nowhere. Sit between .card-sub and the
   first .field so they read as page-level state, not field-level. */
.auth-banner {
  margin-bottom: 20px;
  padding: 10px 14px;
  border-radius: 2px;
  font-size: 11px;
  letter-spacing: 0.04em;
  line-height: 1.5;
  opacity: 0;
  animation: fade-up 700ms var(--ease, cubic-bezier(.2,.7,.2,1)) 1150ms forwards;
}
.auth-banner--danger {
  background: rgba(122, 31, 36, 0.25);
  border: 1px solid rgba(122, 31, 36, 0.55);
  color: #f5d4c8;
}
.auth-banner--success {
  background: rgba(200, 169, 94, 0.12);
  border: 1px solid rgba(200, 169, 94, 0.35);
  color: rgba(243, 234, 212, 0.85);
}

.field {
  margin-bottom: 18px;
  opacity: 0;
  animation: fade-up 900ms var(--ease, cubic-bezier(.2,.7,.2,1)) forwards;
}
.field:nth-of-type(1) { animation-delay: 1200ms; }
.field:nth-of-type(2) { animation-delay: 1280ms; }

.field-label {
  display: block;
  font-family: var(--font-body);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(200, 169, 94, 0.85);
  margin-bottom: 8px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(5, 4, 2, 0.5);
  border: 1px solid rgba(200, 169, 94, 0.22);
  border-radius: 2px;
  color: var(--fg-on-dark);
  font-family: var(--font-body);
  font-size: 14px;
  letter-spacing: 0.01em;
  outline: none;
  transition: border-color 180ms, background 180ms, box-shadow 180ms;
}
.field input:focus {
  border-color: var(--gold);
  background: rgba(5, 4, 2, 0.7);
  box-shadow: 0 0 0 3px rgba(200, 169, 94, 0.12);
}
/* iOS Safari autofill paints a neon yellow background. Override with a
   long inset shadow that masks the autofill swatch. */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px rgba(5, 4, 2, 0.85) inset;
  -webkit-text-fill-color: var(--fg-on-dark);
  caret-color: var(--fg-on-dark);
  transition: background-color 5000s ease-in-out 0s;
}

.signin {
  position: relative;
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 14px 18px;
  background: var(--gold);
  color: var(--fg-on-gold);
  border: 0;
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  cursor: pointer;
  overflow: hidden;
  transition: background 180ms;
  opacity: 0;
  animation: fade-up 900ms var(--ease, cubic-bezier(.2,.7,.2,1)) 1380ms forwards;
}
.signin:hover { background: var(--gold-hover); }

/* Smaller, secondary "Sign in with Face ID" — sits below the primary password
   sign-in. Revealed by biometric-login.js only in the app when a credential is
   enrolled, so it shows immediately (no fade-up) and [hidden] must truly hide it. */
.biometric-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin: 14px auto 0;
  padding: 9px 16px;
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-soft);
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: .07em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 1;
  animation: none;
  transition: color 200ms, background 200ms, border-color 200ms;
}
.biometric-signin:hover { color: var(--fg-on-gold); background: var(--gold); border-color: var(--gold); }
.biometric-signin[hidden] { display: none !important; }
.biometric-signin svg { flex: 0 0 auto; }

/* Persisted background-audio mute checkbox (below Forgot password). */
.mute-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 12px;
  letter-spacing: .03em;
  color: rgba(243, 234, 212, 0.55);
  cursor: pointer;
}
.mute-box input { accent-color: var(--gold); width: 14px; height: 14px; cursor: pointer; }

/* "sign up" link in the card subtitle. */
.card-sub-link { color: var(--gold); text-decoration: none; border-bottom: 1px solid var(--gold-soft); }
.card-sub-link:hover { border-bottom-color: var(--gold); }

/* Conductor's baton sweep on hover */
.signin::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -100%;
  width: 100%;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  transition: left 700ms cubic-bezier(.7, 0, .2, 1);
}
.signin:hover::after { left: 100%; }

/* Loading state — gets set by public/js/login.js on submit. Replaces
   the label text with an inline spinner glyph; brief calls for a
   subtle button state that doesn't fight the fade-up choreography. */
.signin.is-loading {
  cursor: progress;
  color: transparent;
}
.signin.is-loading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(26, 18, 9, 0.35);
  border-top-color: var(--fg-on-gold);
  border-radius: 50%;
  animation: signin-spin 700ms linear infinite;
}
@keyframes signin-spin { to { transform: rotate(360deg); } }

.forgot {
  display: block;
  text-align: center;
  margin-top: 18px;
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: rgba(200, 169, 94, 0.75);
  text-decoration: none;
  opacity: 0;
  animation: fade-up 900ms var(--ease, cubic-bezier(.2,.7,.2,1)) 1500ms forwards;
}
.forgot:hover { color: var(--gold); }

.card-footer {
  position: absolute;
  bottom: -32px;
  left: 0; right: 0;
  text-align: center;
  font-family: var(--font-body);
  font-size: 9.5px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(243, 234, 212, 0.25);
  opacity: 0;
  animation: fade-up 900ms var(--ease, cubic-bezier(.2,.7,.2,1)) 1700ms forwards;
}
/* Terms · Privacy — muted gold to match the login palette (not default blue). */
.card-footer a {
  color: rgba(200, 169, 94, 0.62);
  text-decoration: none;
  border-bottom: 1px solid rgba(200, 169, 94, 0.26);
  padding-bottom: 1px;
  transition: color 160ms var(--ease, ease), border-color 160ms var(--ease, ease);
}
.card-footer a:hover { color: var(--gold); border-bottom-color: rgba(200, 169, 94, 0.55); }

/* =========================================================================
   ANIMATIONS
   ========================================================================= */

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes card-in-anchor {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================================================================
   RESPONSIVE — re-center on mobile, lose the chrome
   ========================================================================= */

@media (max-width: 880px) {
  .stage::before, .stage::after { height: 2vh; }
  .chrome { padding: calc(2vh + 16px) 20px; }
  .brand-top img { height: 22px; }
  .brand-top .imprint { font-size: 8.5px; }
  .tagline { display: none; }
  .audio-toggle { padding: 8px 12px; font-size: 9px; }
  .card-anchor {
    right: 0; left: 0; top: auto; bottom: 0;
    transform: none;
    padding: 0 20px 24px;
  }
  .card {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: 36px 28px 32px;
  }
  .card-welcome { font-size: 26px; }
  /* Bottom footer line collides with iOS home indicator on mobile;
     pull it back inside the card so it isn't lost. */
  .card-footer { position: static; margin-top: 18px; }
}

/* =========================================================================
   REDUCED MOTION
   Respects users who've asked the OS to dial back animation. Kills the
   video autoplay + drift gradient + fade-up choreography but keeps the
   visual design — they still see a fully-rendered cinematic login, just
   without movement.
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  .bg-video { display: none; }
  .bg-placeholder { animation: none; transform: none; }
  .card, .card *, .brand-top, .tagline, .audio-toggle, .auth-banner {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
  }
  .signin::after { transition: none; }
  .signin.is-loading::before { animation: none; }
}
