/* ============================================================
   Employee sign-in (my-ess/login.php) — EYB + galaxy skin
   ============================================================
   Rendered by includes/ess_login_view.php. Standalone on purpose: the page
   loads neither Bootstrap nor app.css, so nothing here has to out-specify
   them, and the back-office door (login.php + auth.css) is untouched.

   EYB's speech bubble carries every message the page has — server errors,
   flashes, ?reason= notices and the per-view hints — so there is no alert
   box anywhere else. */

:root {
  --ess-void:   #050302;
  --ess-ember:  #FF7A1A;
  --ess-core:   #FFD9A0;
  --ess-cream:  #F1E6D3;
  --ess-soot:   #2A211B;
  --ess-muted:  #BFAE99;
  --ess-line:   rgba(241,230,211,.16);
  --ess-danger: #FF9C8A;

  --ess-display: "Gabarito", system-ui, sans-serif;
  --ess-body:    "Figtree", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body.ess-login {
  margin: 0; overflow-x: hidden;
  font: 400 1rem/1.5 var(--ess-body);
  color: var(--ess-cream);
  background: var(--ess-void) url("../img/ess-login-galaxy.jpg") center 42% / cover no-repeat fixed;
  -webkit-font-smoothing: antialiased;
}
.ess-login [hidden] { display: none !important; }

.ess-stage {
  position: relative; min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 25rem);
  grid-template-rows: auto 1fr auto;
  column-gap: 3rem;
  padding: 1.75rem clamp(1.25rem, 5vw, 5rem);
}

/* ── Brand ─────────────────────────────────────────────────── */
.ess-brand {
  grid-column: 1 / -1; position: relative; z-index: 2;
  display: flex; align-items: center; gap: .7rem;
  font: 700 1.15rem/1 var(--ess-display); letter-spacing: -.01em;
}
.ess-brand img { height: 2.4rem; width: auto; display: block; border-radius: .2rem; }
.ess-brand-mark {
  width: 1.9rem; height: 1.9rem; display: grid; place-items: center;
  border: 1.5px solid var(--ess-cream); border-radius: .2rem;
  font: 600 1.05rem/1 var(--ess-display);
}

/* ── EYB and his speech bubble ─────────────────────────────── */
.ess-crew {
  grid-column: 1; grid-row: 2 / 4;
  position: relative; align-self: stretch;
  display: flex; align-items: flex-end;
  margin-bottom: -1.75rem;            /* stand on the viewport's bottom edge */
  pointer-events: none;
}
/* EYB and his bubble share one box the size of the image, so the bubble is
   placed against his helmet rather than the column: the column grows with the
   screen while EYB stops at 46rem. */
.ess-eyb-wrap {
  position: relative; flex: none;
  height: min(78vh, 46rem); aspect-ratio: 800 / 861;
}
.ess-eyb {
  display: block; width: 100%; height: 100%;
  object-fit: contain; object-position: bottom left;
  filter: drop-shadow(0 0 40px rgba(255,122,26,.35)) drop-shadow(0 20px 30px rgba(0,0,0,.6));
  transform-origin: 70% 100%;
  animation: ess-rise 1s cubic-bezier(.2,.9,.25,1.15) .15s both;
}
@keyframes ess-rise { from { transform: translateY(40%); opacity: 0; } to { transform: none; opacity: 1; } }
.ess-eyb.cheer { animation: ess-cheer .7s cubic-bezier(.3,1.6,.5,1); }
@keyframes ess-cheer { 30% { transform: translateY(-4%) rotate(-2deg); } 60% { transform: translateY(-1%) rotate(1.5deg); } }
.ess-eyb.shake { animation: ess-shake .45s ease-in-out; }
@keyframes ess-shake { 20%, 60% { transform: translateX(-1.2%); } 40%, 80% { transform: translateX(1.2%); } }

.ess-bubble {
  position: absolute; left: 80%; bottom: 88%;   /* tail lands just off the helmet's top-right */
  width: max-content; max-width: 17.5rem; padding: 1rem 1.15rem;
  background: var(--ess-cream); color: var(--ess-soot);
  border-radius: 1.4rem 1.4rem 1.4rem .35rem;
  font: 600 1.05rem/1.35 var(--ess-display);
  box-shadow: 0 18px 40px -12px rgba(0,0,0,.6);
  animation: ess-pop .45s cubic-bezier(.3,1.5,.5,1) 1s both;
  pointer-events: auto;
}
.ess-bubble::after {                     /* tail, pointing down at EYB */
  content: ""; position: absolute; left: -.55rem; bottom: -.55rem;
  width: 1.4rem; height: 1.4rem; background: inherit;
  clip-path: polygon(0 100%, 45% 0, 100% 55%);
}
.ess-bubble small { display: block; font: 400 .875rem/1.4 var(--ess-body); color: #6A5847; margin-top: .3rem; white-space: pre-line; }
.ess-bubble.bad  { background: #FFE4DC; }
.ess-bubble.good { background: var(--ess-core); }
@keyframes ess-pop { from { transform: scale(.6) translateY(10px); opacity: 0; transform-origin: 0 100%; } }

/* Second and later page loads in a session (a failed POST, the QR round trip)
   skip the entrance: EYB rising again on every reload reads as a glitch. */
.ess-seen .ess-eyb:not(.cheer):not(.shake),
.ess-seen .ess-bubble { animation: none; }

/* ── Panel ─────────────────────────────────────────────────── */
.ess-panel {
  grid-column: 2; grid-row: 2; align-self: center;
  position: relative; z-index: 2; margin: 2rem 0;
  padding: 2rem 1.9rem 1.75rem;
  background: rgba(18,11,6,.72);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  backdrop-filter: blur(18px) saturate(130%);
  border: 1px solid var(--ess-line); border-radius: 1.6rem;
  box-shadow: 0 30px 80px -24px rgba(0,0,0,.85), inset 0 1px 0 rgba(255,217,160,.08);
}
.ess-view { animation: ess-swap .3s ease-out; }
@keyframes ess-swap { from { opacity: 0; transform: translateY(6px); } }
.ess-panel h1 { margin: 0 0 .4rem; font: 800 2.1rem/1.05 var(--ess-display); letter-spacing: -.025em; }
.ess-lede { margin: 0 0 1.6rem; color: var(--ess-muted); }

.ess-btn {
  width: 100%; min-height: 3.25rem; border-radius: .9rem; cursor: pointer;
  font: 600 1rem var(--ess-body); padding: 0 1rem; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .65rem;
  transition: background .15s, border-color .15s, transform .06s;
}
.ess-btn:active { transform: scale(.985); }
.ess-btn-primary {
  border: 0; color: #1E1006;
  background: linear-gradient(180deg, #FF9A3D, var(--ess-ember));
  box-shadow: 0 10px 30px -10px rgba(255,122,26,.8);
}
.ess-btn-primary:hover { background: linear-gradient(180deg, #FFAA55, #FF8A2E); color: #1E1006; }
.ess-btn-primary[disabled] { cursor: progress; opacity: .85; }
.ess-lark-logo { background: #fff; border-radius: .4rem; padding: .2rem; display: grid; }
.ess-btn-ghost { background: transparent; color: var(--ess-cream); border: 1px solid var(--ess-line); }
.ess-btn-ghost:hover { background: rgba(241,230,211,.06); border-color: rgba(241,230,211,.3); color: var(--ess-cream); }
.ess-btn + .ess-btn { margin-top: .6rem; }
.ess-spinner {
  width: 1rem; height: 1rem; border-radius: 50%;
  border: 2px solid rgba(30,16,6,.25); border-top-color: #1E1006;
  animation: ess-spin .7s linear infinite;
}
.ess-spinner.light { border-color: rgba(241,230,211,.25); border-top-color: var(--ess-cream); }
@keyframes ess-spin { to { transform: rotate(360deg); } }

.ess-text-link {
  display: block; width: max-content; max-width: 100%; margin: 1.35rem auto 0; padding: .4rem .6rem;
  color: var(--ess-cream); font: 500 .95rem var(--ess-body); border-radius: .5rem; text-align: center;
  text-decoration: underline; text-decoration-color: var(--ess-ember);
  text-decoration-thickness: 2px; text-underline-offset: 4px;
}
.ess-text-link:hover { color: #fff; }
.ess-back {
  display: inline-flex; align-items: center; gap: .35rem;
  margin: 0 0 1rem -.6rem; padding: .4rem .6rem; border-radius: .5rem;
  color: var(--ess-muted); font: 500 .95rem var(--ess-body); text-decoration: none;
}
.ess-back:hover { color: var(--ess-cream); }
.ess-meta { margin-top: 1rem; font-size: .875rem; color: var(--ess-muted); text-align: center; }
.ess-meta a { color: var(--ess-cream); }

/* Help row under the password form */
.ess-help {
  display: flex; align-items: center; gap: .8rem;
  margin-top: 1.25rem; padding: .85rem 1rem;
  border: 1px solid var(--ess-line); border-radius: .9rem;
  background: rgba(241,230,211,.04);
  font-size: .875rem; line-height: 1.4;
}
.ess-help-icon {
  flex: none; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,122,26,.16); color: var(--ess-core);
}
.ess-help strong { display: block; font: 600 .95rem/1.3 var(--ess-display); color: var(--ess-cream); }
.ess-help span:not(.ess-help-icon) { color: var(--ess-muted); }

/* QR view — Lark's own widget renders its iframe into #larkQr */
.ess-qr-wrap { display: flex; flex-direction: column; align-items: center; }
.ess-qr {
  width: 276px; height: 276px; padding: 8px;
  background: #fff; border-radius: 1.1rem;
  box-shadow: 0 0 0 6px rgba(255,122,26,.18);
  overflow: hidden;
}
.ess-qr iframe { display: block; }
.ess-how { list-style: none; padding: 0; margin: 1.25rem 0 0; width: 100%; counter-reset: ess-how; }
.ess-how li {
  counter-increment: ess-how; display: flex; gap: .75rem; align-items: baseline;
  padding: .45rem 0; font-size: .95rem;
}
.ess-how li::before {
  content: counter(ess-how); flex: none;
  width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,122,26,.18); color: var(--ess-core);
  font: 700 .8rem var(--ess-display); transform: translateY(.15rem);
}

/* Password view */
.ess-field { margin-bottom: 1rem; }
.ess-field label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .4rem; }
.ess-input-box { position: relative; }
.ess-input {
  width: 100%; height: 3.1rem; padding: 0 1rem;
  font: inherit; color: var(--ess-cream);
  background: rgba(241,230,211,.06);
  border: 1px solid var(--ess-line); border-radius: .9rem;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.ess-input::placeholder { color: #8D7D6B; }
.ess-input:hover { border-color: rgba(241,230,211,.3); }
.ess-input:focus { outline: none; background: rgba(241,230,211,.09); border-color: var(--ess-ember); box-shadow: 0 0 0 4px rgba(255,122,26,.28); }
.ess-input[aria-invalid="true"] { border-color: var(--ess-danger); }
#password.ess-input { padding-right: 4.4rem; }
.ess-reveal {
  position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; color: var(--ess-muted);
  font: 500 .825rem var(--ess-body); padding: .45rem .65rem; border-radius: .55rem;
}
.ess-reveal:hover { color: var(--ess-cream); background: rgba(241,230,211,.08); }
.ess-hint { font-size: .8125rem; margin-top: .4rem; color: var(--ess-danger); }
.ess-hint.caps { color: var(--ess-core); }
.ess-submit { margin-top: .5rem; }

.ess-login button:focus-visible,
.ess-login a:focus-visible { outline: 2px solid var(--ess-ember); outline-offset: 3px; }

.ess-foot { grid-column: 2; grid-row: 3; position: relative; z-index: 2; font-size: .8125rem; color: var(--ess-muted); text-align: right; }

/* ── Inside the Lark app: signing in with nothing to tap ───── */
.ess-auto {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.25rem;
  padding: 2rem; text-align: center;
  background: rgba(5,3,2,.82);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.ess-auto img { width: 11rem; filter: drop-shadow(0 0 30px rgba(255,122,26,.4)); }
.ess-auto h2 { margin: 0; font: 700 1.5rem/1.2 var(--ess-display); }
.ess-auto p { margin: 0; color: var(--ess-muted); max-width: 22rem; }
.ess-auto .ess-row-center { display: flex; align-items: center; gap: .6rem; color: var(--ess-core); font-weight: 500; }

/* ── Phones: this door is mostly opened on a phone ─────────── */
@media (max-width: 900px) {
  body.ess-login { background-position: 30% 20%; background-size: auto 70vh; }
  .ess-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; padding: 1.25rem 1.25rem max(1.25rem, env(safe-area-inset-bottom)); }
  .ess-crew { grid-column: 1; grid-row: 2; margin: 1.25rem 0 -2.25rem; gap: .75rem; }
  .ess-eyb-wrap { display: contents; }
  .ess-eyb { width: auto; height: 9.5rem; max-width: none; }
  .ess-bubble::after { display: none; }
  .ess-bubble { position: relative; left: auto; bottom: auto; width: auto; margin-bottom: 3rem; font-size: .95rem; padding: .8rem .95rem; max-width: none; flex: 1; }
  .ess-panel { grid-column: 1; grid-row: 3; margin: 0; padding: 1.6rem 1.3rem 1.4rem; }
  .ess-panel h1 { font-size: 1.85rem; }
  .ess-qr { width: 100%; max-width: 276px; height: auto; aspect-ratio: 1; }
  .ess-foot { grid-column: 1; grid-row: 4; text-align: center; margin-top: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .ess-login *, .ess-login *::before, .ess-login *::after { transition: none !important; animation: none !important; }
}
