/* ============================================================
   UPSIDE PROPERTY — Sign-up / sign-in gate
   ============================================================ */

/* --- the gate hides the site before first paint ------------------------- */
html.auth-pending body > *:not(#authScreen):not(.chat-bubble):not(.chat-panel) {
  visibility: hidden !important;
}
html.auth-pending {
  background: var(--ink);
}
html.auth-pending body {
  background: var(--ink);
  overflow: hidden;
}

/* ============================================================
   Shell
   ============================================================ */
.auth {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0px, 2.4vw, 34px);
  background:
    radial-gradient(120% 90% at 12% 8%, #1d1d1f 0%, #0a0a0a 58%, #050505 100%);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: authIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes authIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth.is-leaving {
  opacity: 0;
  transform: scale(1.01);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}

.auth__panel {
  width: 100%;
  max-width: 1180px;
  height: min(760px, calc(100vh - 68px));
  min-height: min(640px, calc(100vh - 68px));
  display: grid;
  grid-template-columns: 1.02fr 0.98fr;
  background: var(--paper);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.55);
}

/* ============================================================
   Brand side
   ============================================================ */
.auth__brand {
  position: relative;
  isolation: isolate;
  padding: clamp(28px, 3.2vw, 46px);
  display: flex;
  color: #fff;
  overflow: hidden;
}

.auth__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}

.auth__bg-scrim {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(8, 8, 8, 0.62) 0%, rgba(8, 8, 8, 0.34) 38%, rgba(8, 8, 8, 0.88) 100%),
    linear-gradient(90deg, rgba(8, 8, 8, 0.5) 0%, rgba(8, 8, 8, 0.1) 70%);
}

.auth__brand-inner {
  display: flex;
  flex-direction: column;
  gap: clamp(26px, 4vw, 46px);
  width: 100%;
}

.auth__pitch { margin-top: auto; }

.auth__pitch-title {
  font-family: var(--f-display);
  font-size: clamp(1.7rem, 2.7vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.06;
  margin-bottom: 14px;
}

.auth__pitch-sub {
  font-size: 0.92rem;
  line-height: 1.62;
  color: rgba(255, 255, 255, 0.82);
  max-width: 38ch;
  margin-bottom: 26px;
}

.auth__perks {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.auth__perks li {
  display: flex;
  gap: 11px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
}

.auth__tick {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  display: grid;
  place-items: center;
  flex: none;
  margin-top: 1px;
}

.auth__tick svg { width: 12px; height: 12px; }

.auth__quote {
  font-family: var(--f-serif);
  font-style: italic;
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  color: rgba(255, 255, 255, 0.72);
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  padding-top: 20px;
}

/* ============================================================
   Form side
   ============================================================ */
.auth__form-col {
  padding: clamp(24px, 2.8vw, 40px);
  display: flex;
  /* stretch (not center) so this column is height-constrained by the panel
     rather than by the length of the form; the form scrolls inside it. */
  align-items: stretch;
  justify-content: center;
  background: var(--paper);
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
}

.auth__form-inner {
  width: 100%;
  max-width: 420px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth__head { display: flex; flex-direction: column; gap: 8px; }

.auth__title {
  font-family: var(--f-display);
  font-size: clamp(1.6rem, 2.3vw, 2.05rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.auth__sub { font-size: 0.88rem; color: var(--tx-2); line-height: 1.55; }

/* tabs */
.auth__tabs {
  display: flex;
  gap: 4px;
  background: var(--mist);
  border-radius: var(--r-pill);
  padding: 4px;
}

.auth__tab {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--r-pill);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--tx-2);
  transition: background 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
}

.auth__tab:hover { color: var(--tx); }
.auth__tab.is-on {
  background: #fff;
  color: var(--tx);
  box-shadow: 0 2px 8px rgba(10, 10, 10, 0.08);
}

/* google button */
.auth__google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--r-pill);
  background: #fff;
  border: 1px solid var(--line-2);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--tx);
  transition: box-shadow 0.24s ease, transform 0.24s ease, border-color 0.24s ease;
}

.auth__google svg { width: 19px; height: 19px; flex: none; }
.auth__google:hover {
  box-shadow: 0 8px 26px rgba(10, 10, 10, 0.12);
  transform: translateY(-1px);
  border-color: var(--line-inv-2);
}
.auth__google:active { transform: none; }
.auth__google[disabled] { opacity: 0.7; pointer-events: none; }

.auth__google.is-busy::after {
  content: "";
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(10, 10, 10, 0.2);
  border-top-color: var(--ink);
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* divider */
.auth__divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--tx-3);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth__divider::before,
.auth__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* form */
.auth__form { display: flex; flex-direction: column; gap: 13px; }

.field--auth { gap: 6px; }
.field--auth input,
.field--auth select { padding: 12px 14px; font-size: 0.9rem; }

.field--auth.is-bad input,
.field--auth.is-bad select {
  border-color: #d4483b;
  box-shadow: 0 0 0 3px rgba(212, 72, 59, 0.1);
}

.field__err {
  font-size: 0.73rem;
  color: #c0392b;
  min-height: 0;
  line-height: 1.4;
}

.field__err:empty { display: none; }

/* password field with toggle + meter */
.auth__pw { position: relative; }
.auth__pw input { padding-right: 60px; width: 100%; }

.auth__pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tx-3);
  padding: 7px 10px;
  border-radius: var(--r-xs);
}
.auth__pw-toggle:hover { color: var(--tx); background: rgba(10, 10, 10, 0.05); }

.auth__meter {
  display: flex;
  gap: 5px;
  margin-top: 7px;
}
.auth__meter i {
  flex: 1;
  height: 3px;
  border-radius: 3px;
  background: var(--line-2);
  transition: background 0.3s ease;
}
.auth__meter[data-score="1"] i:nth-child(-n+1) { background: #d4483b; }
.auth__meter[data-score="2"] i:nth-child(-n+2) { background: #e0a23c; }
.auth__meter[data-score="3"] i:nth-child(-n+3) { background: #7fb069; }
.auth__meter[data-score="4"] i { background: #4c9a52; }

/* checkboxes */
.auth__check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--tx-2);
  cursor: pointer;
}

.auth__check input {
  appearance: none;
  width: 17px;
  height: 17px;
  flex: none;
  margin-top: 1px;
  border: 1.5px solid var(--line-2);
  border-radius: 5px;
  background: #fff;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.auth__check input:checked {
  background: var(--ink);
  border-color: var(--ink);
}

.auth__check input:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg);
}

.auth__check--stay { font-size: 0.8rem; color: var(--tx); }

.auth__submit { width: 100%; justify-content: center; margin-top: 2px; }
.auth__submit[disabled] { opacity: 0.65; pointer-events: none; }

.auth__note {
  font-size: 0.68rem;
  line-height: 1.6;
  color: var(--tx-3);
}
.auth__note a { text-decoration: underline; text-underline-offset: 2px; }
.auth__note a:hover { color: var(--tx); }

/* status message */
.auth__status {
  display: none;
  align-items: center;
  gap: 9px;
  font-size: 0.83rem;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  background: var(--mist);
  color: var(--tx-2);
}
.auth__status.is-on { display: flex; }
.auth__status.is-err {
  background: rgba(212, 72, 59, 0.08);
  color: #a5322a;
  border: 1px solid rgba(212, 72, 59, 0.25);
}

/* guest + demo note */
.auth__skip {
  font-size: 0.8rem;
  color: var(--tx-3);
  text-decoration: underline;
  text-underline-offset: 3px;
  align-self: center;
}
.auth__skip:hover { color: var(--tx); }

.auth__demo-note {
  font-size: 0.68rem;
  line-height: 1.55;
  color: var(--tx-3);
  background: var(--accent-soft);
  border: 1px solid rgba(217, 149, 92, 0.35);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}
.auth__demo-note code {
  font-size: 0.68rem;
  background: rgba(10, 10, 10, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ============================================================
   Signed-in chip in the header
   ============================================================ */
.account { position: relative; }

.account__btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--r-pill);
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 8px 28px rgba(10, 10, 10, 0.08);
  transition: background 0.2s ease;
}
.account__btn:hover { background: #fff; }

.account__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
}

.account__name {
  font-size: 0.82rem;
  font-weight: 600;
  max-width: 12ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account__caret { width: 15px; height: 15px; opacity: 0.6; flex: none; }

.account__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 260px;
  background: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  z-index: 90;
}

.account.is-open .account__menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.account__head {
  padding: 12px 12px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.account__head b { font-size: 0.88rem; letter-spacing: -0.01em; }
.account__head span { font-size: 0.75rem; color: var(--tx-3); }
.account__provider {
  margin-top: 5px;
  font-size: 0.66rem !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-deep) !important;
}

.account__menu a,
.account__menu button {
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--r-xs);
  font-size: 0.84rem;
  color: var(--tx);
  width: 100%;
}
.account__menu a:hover,
.account__menu button:hover { background: var(--mist); }
.account__menu [data-signout] {
  color: #b0402f;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--r-xs) var(--r-xs);
  padding-top: 12px;
}

/* ============================================================
   Welcome toast after signing up
   ============================================================ */
.welcome {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 130%);
  z-index: 250;
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--r-pill);
  padding: 12px 22px 12px 14px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: calc(100vw - 32px);
}
.welcome.is-on { transform: translate(-50%, 0); }

.welcome__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 0.74rem;
  font-weight: 700;
  flex: none;
}
.welcome b { display: block; font-size: 0.86rem; letter-spacing: -0.01em; }
.welcome span { font-size: 0.74rem; color: var(--tx-inv-2); }

/* ============================================================
   Inline auth link inside the mobile drawer
   ============================================================ */
.drawer__account {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-inv);
}
.drawer__account .account__avatar { width: 38px; height: 38px; font-size: 0.76rem; }
.drawer__account-info { display: flex; flex-direction: column; }
.drawer__account-info b { font-size: 0.9rem; color: #fff; }
.drawer__account-info span { font-size: 0.76rem; color: var(--tx-inv-3); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 980px) {
  .auth { padding: 0; align-items: stretch; }
  .auth__panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    max-width: none;
    height: auto;
    min-height: 100%;
    border-radius: 0;
  }
  .auth__form-col { align-items: flex-start; justify-content: flex-start; overflow-y: visible; }
  .auth__brand {
    min-height: 260px;
    padding: 26px var(--gut) 30px;
  }
  .auth__perks { display: none; }
  .auth__quote { display: none; }
  .auth__pitch { margin-top: auto; }
  .auth__form-col { align-items: flex-start; padding: 28px var(--gut) 44px; }
  .auth__form-inner { max-width: 460px; }
}

@media (max-width: 560px) {
  /* keep the sign-up button above the fold on small phones */
  .auth__brand { min-height: 118px; padding: 16px var(--gut) 18px; }
  .auth__brand-inner { gap: 12px; }
  .auth__pitch-title { font-size: 1.25rem; margin-bottom: 6px; }
  .auth__pitch-sub { font-size: 0.8rem; margin-bottom: 0; }
  .auth__form-col { padding: 18px var(--gut) 30px; }
  .auth__form-inner { gap: 10px; }
  .auth__form { gap: 9px; }
  .auth__head { gap: 5px; }
  .auth__title { font-size: 1.4rem; }
  .auth__sub { font-size: 0.82rem; }
  .auth__google { padding: 11px 16px; }
  .auth__check { font-size: 0.68rem; line-height: 1.45; }
  .auth__tabs { padding: 3px; }
  .auth__tab { padding: 9px 12px; font-size: 0.8rem; }
  .auth__divider { font-size: 0.66rem; }
  .field--auth input,
  .field--auth select { padding: 11px 13px; font-size: 0.88rem; }
  .auth__meter { display: none; }
  .auth__pw-toggle { font-size: 0.68rem; padding: 6px 9px; }
  .auth__tabs { font-size: 0.8rem; }
  .account__name { display: none; }
  .account__btn { padding: 5px; }
  .welcome { left: 16px; right: 16px; transform: translateY(130%); }
  .welcome.is-on { transform: translateY(0); }
}
