/* Sign-in. The page steps back, the block (tensor-scene.js, html.signin-open) moves beside the
   card and lights up, and the card floats over it like a pane of glass. */

.nav, main, .footer { transition: opacity 0.45s var(--ease); }
.signin-open .nav, .signin-open main, .signin-open .footer, .signin-open .tensor-labels, .signin-open .menu { opacity: 0; pointer-events: none; }

.signin {
  width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: transparent; color: var(--frost); overflow: auto; overscroll-behavior: contain;
}
.signin::backdrop { background: radial-gradient(90% 80% at 30% 50%, rgba(6, 10, 18, 0.08), rgba(6, 10, 18, 0.7)); }
.signin[open]::backdrop { animation: fade-in 0.45s ease; }
@keyframes fade-in { from { opacity: 0; } }
.signin-stage {
  min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px); align-items: center;
  gap: 4vw; padding: 5vh max(24px, 7vw) 5vh 4vw;
}
.signin-card {
  grid-column: 2; position: relative; padding: 34px 32px 28px; border-radius: 26px;
  background: linear-gradient(180deg, rgba(20, 31, 52, 0.74), rgba(9, 15, 27, 0.8));
  border: 1px solid rgba(232, 238, 246, 0.1);
  -webkit-backdrop-filter: blur(18px) saturate(140%); backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 50px 140px -40px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
/* Copper light along the upper edge, fading into a cool one below. */
.signin-card::before {
  content: ""; position: absolute; inset: -1px; padding: 1px; border-radius: inherit; pointer-events: none;
  background: linear-gradient(160deg, rgba(240, 196, 143, 0.6), rgba(240, 196, 143, 0) 36%, rgba(122, 176, 208, 0) 70%, rgba(122, 176, 208, 0.28));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.signin[open] .signin-card { animation: card-in 0.65s var(--ease) both; }
@keyframes card-in { from { opacity: 0; transform: translateX(32px) scale(0.98); } }
.signin-card.shake { animation: shake 0.45s var(--swing); }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.signin-close {
  position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; color: var(--mist);
}
.signin-close:hover { color: var(--frost); background: rgba(232, 238, 246, 0.07); }
.signin-close svg { width: 18px; height: 18px; }
.signin-logo { height: 40px; width: auto; margin: -4px 0 20px -3px; }
/* One card, two modes (auth.js): signing in, or making an account. */
.signin-card[data-mode="login"] .mode-register, .signin-card[data-mode="register"] .mode-login { display: none; }
.signin-card .mode { animation: mode-in 0.4s var(--ease) both; }
@keyframes mode-in { from { opacity: 0; transform: translateY(8px); } }
.signin h2 { margin-bottom: 6px; font-size: 2rem; letter-spacing: -0.03em; }
.signin-sub { margin-bottom: 22px; font-size: 0.9375rem; color: var(--mist); }

.oauth { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.oauth .btn { height: 48px; gap: 10px; padding: 0 14px; }
.oauth svg { width: 18px; height: 18px; flex: none; }
.or { display: flex; align-items: center; gap: 14px; margin: 20px 0 16px; font-size: 0.8125rem; color: var(--fog); }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }

.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 0.875rem; font-weight: 550; color: var(--mist); }
.field input {
  height: 50px; width: 100%; padding: 0 16px; border-radius: var(--r-m);
  background: rgba(232, 238, 246, 0.04); border: 1px solid var(--line-2); color: var(--frost);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.field input::placeholder { color: var(--fog); }
.field input:focus { outline: none; border-color: rgba(240, 196, 143, 0.6); box-shadow: 0 0 0 4px rgba(200, 144, 96, 0.16); background: rgba(232, 238, 246, 0.06); }
.pw { position: relative; }
.pw input { padding-right: 54px; }
.pw-toggle {
  position: absolute; top: 5px; right: 5px; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; color: var(--fog); transition: color 0.2s, background-color 0.2s;
}
.pw-toggle:hover { color: var(--frost); background: rgba(232, 238, 246, 0.06); }
.pw-toggle svg { width: 19px; height: 19px; }

.form-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 0 22px; font-size: 0.9rem; }
.check { display: inline-flex; align-items: center; gap: 10px; color: var(--mist); cursor: pointer; }
.check input {
  appearance: none; -webkit-appearance: none; flex: none; width: 20px; height: 20px; margin: 0; display: grid; place-items: center;
  border-radius: 6px; border: 1.5px solid var(--line-2); background: rgba(232, 238, 246, 0.04);
  transition: background-color 0.2s, border-color 0.2s;
}
.check input::after {
  content: ""; width: 10px; height: 5px; border: 2px solid var(--night); border-top: 0; border-right: 0;
  transform: translate(0, -1px) rotate(-45deg) scale(0); transition: transform 0.2s var(--ease);
}
.check input:checked { background: var(--copper-lite); border-color: var(--copper-lite); }
.check input:checked::after { transform: translate(0, -1px) rotate(-45deg) scale(1); }
.check input:focus-visible { outline: 2px solid var(--glacier); outline-offset: 3px; }
.link { color: var(--glacier); font-weight: 550; }
.link:hover { color: var(--frost); text-decoration: underline; text-underline-offset: 3px; }
.signin .btn-primary { width: 100%; height: 50px; }
.signin .btn-primary:disabled { opacity: 0.75; cursor: progress; }
#register-form .btn-primary { margin-top: 8px; }
.signin-foot { margin-top: 22px; text-align: center; font-size: 0.9rem; color: var(--mist); }

.notice {
  display: none; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: 18px;
  border-radius: var(--r-m); font-size: 0.9rem; line-height: 1.45;
}
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.notice.active, .notice.shown { display: flex; }
.notice-err { background: rgba(255, 110, 110, 0.1); border: 1px solid rgba(255, 138, 138, 0.3); color: #ffd0d0; }
.notice-ok { background: rgba(95, 212, 164, 0.1); border: 1px solid rgba(111, 217, 171, 0.3); color: #c9f5e1; }
.spin { width: 18px; height: 18px; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Without WebGL the still image of the block takes its place. */
.no-webgl .signin-stage::before { content: ""; grid-column: 1; align-self: stretch; background: url(../img/tensor-poster.webp) center / contain no-repeat; }

/* Where tensor-scene.js puts the block above (narrower than 900 px, or not wider than 23:20), the card sits below it. */
@media (max-width: 899px), (max-aspect-ratio: 23/20) {
  .signin-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: 30vh auto; align-items: start; gap: 0; padding: 0 16px 24px; }
  .signin-card { grid-column: 1; grid-row: 2; width: 100%; max-width: 480px; justify-self: center; padding: 28px 22px 22px; }
  .signin[open] .signin-card { animation-name: card-up; }
  @keyframes card-up { from { opacity: 0; transform: translateY(32px); } }
  .no-webgl .signin-stage::before { grid-row: 1; }
}
/* On a phone the card is the whole screen: no room above it for the block, which glows through
   the glass instead. The content keeps a readable width and clears the notch. */
@media (max-width: 599px), (max-height: 520px) {
  .signin-stage { display: block; min-height: 100%; padding: 0; }
  .signin-card {
    display: grid; align-content: center; width: 100%; max-width: none; min-height: 100%; min-height: 100dvh;
    padding: calc(60px + env(safe-area-inset-top)) max(22px, calc((100% - 440px) / 2)) calc(28px + env(safe-area-inset-bottom));
    border: 0; border-radius: 0;
  }
  .signin-card::before, .no-webgl .signin-stage::before { display: none; }
  .signin-close { top: calc(10px + env(safe-area-inset-top)); right: 10px; }
}
@media (max-width: 359px) { .oauth { grid-template-columns: minmax(0, 1fr); } }
