/* Sign-in page. Tokens come from styles.css. Every class here is prefixed sg- so the shared
   stylesheet's older signin rules cannot leak in. */

.sg-page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
}

/* ---------------- starfield ---------------- */
/* Written as body.sg-page > canvas.sg-stars so it beats styles.css, which gives every direct child
   of body position: relative and z-index: 1 and would otherwise pull the canvas into the layout. */
body.sg-page > canvas.sg-stars {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.sg-page > *:not(.sg-stars) {
  position: relative;
  z-index: 1;
}

/* ---------------- top bar ---------------- */
.sg-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 32px;
}

.sg-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
}

.sg-brand img {
  border-radius: 7px;
}

.sg-home {
  color: #c4c4d2;
  text-decoration: none;
  font-size: 0.9375rem;
  transition: color 0.2s ease;
}

.sg-home:hover {
  color: var(--text);
}

/* ---------------- layout ---------------- */
.sg-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  align-items: center;
  justify-items: stretch;
  gap: 72px;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 32px 96px;
}

.sg-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sg-heading {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sg-heading h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.25rem, 4vw, 3.1rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  color: var(--text);
}

.sg-heading p {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--text);
  max-width: 34ch;
}

/* ---------------- primary action ---------------- */
.sg-discord {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
  padding: 16px 28px;
  border-radius: 10px;
  background: #7c3aed;
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.005em;
  text-decoration: none;
  /* --mx and --my are set by signin.js when the pointer is over the button. */
  transform: translate(var(--mx, 0px), var(--my, 0px));
  transition: background 0.2s ease, transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.sg-discord:hover {
  background: #8b5cf6;
  color: #ffffff;
}

.sg-discord:active {
  background: #6d28d9;
}

.sg-status:empty {
  display: none;
}

.sg-status {
  margin: 0;
  font-size: 1rem;
  color: var(--text-muted);
}

.sg-status.error {
  color: #f4b4b4;
}

.sg-note {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
  color: #c4c4d2;
  max-width: 44ch;
}

/* ---------------- preview: the dashboard the visitor is signing in to ---------------- */
.sg-preview {
  background: var(--bg-elevated);
  border-radius: 14px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* Tilt follows the pointer; signin.js sets the two variables. */
  transform: perspective(1200px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
  transform-style: preserve-3d;
}

.sg-preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px 18px;
}

.sg-preview-head strong {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
}

.sg-preview-head span {
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.sg-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sg-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 16px;
  padding: 18px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--bg-card);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.25s ease;
}

.sg-item:hover {
  background: #141424;
  transform: translateX(3px);
}

.sg-item.is-active {
  background: rgba(139, 92, 246, 0.16);
}

.sg-item:active {
  transform: translateX(1px) scale(0.995);
}

.sg-item-title {
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--text);
}

.sg-item-state {
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.sg-item.is-active .sg-item-state {
  color: var(--accent-soft);
}

.sg-item-meta {
  grid-column: 1 / -1;
  font-size: 1rem;
  line-height: 1.5;
  color: #c4c4d2;
}

/* ---------------- footer ---------------- */
.sg-footer {
  border-top: 0;
  background: transparent;
  padding: 0 0 40px;
}

.sg-footer .footer-inner {
  max-width: 1120px;
  padding: 0 32px;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  text-align: left;
  gap: 16px 32px;
}

.sg-footer .footer-brand {
  color: var(--text);
}

.sg-footer .footer-links {
  gap: 24px;
}

.sg-footer .footer-links a {
  color: #c4c4d2;
  font-size: 0.9375rem;
}

.sg-footer .footer-copy {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ---------------- motion ---------------- */
@keyframes sg-rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sg-heading h1,
.sg-heading p,
.sg-discord,
.sg-status,
.sg-note,
.sg-preview,
.sg-preview-head,
.sg-list li {
  /* backwards, not both: the finished state must not hold transforms that hover and tilt set. */
  animation: sg-rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
}

.sg-heading p {
  animation-delay: 0.08s;
}

.sg-discord {
  animation-delay: 0.16s;
}

.sg-note {
  animation-delay: 0.3s;
}

.sg-preview {
  animation-delay: 0.12s;
}

.sg-preview-head {
  animation-delay: 0.2s;
}

.sg-list li:nth-child(1) {
  animation-delay: 0.26s;
}

.sg-list li:nth-child(2) {
  animation-delay: 0.34s;
}

.sg-list li:nth-child(3) {
  animation-delay: 0.42s;
}

.sg-list li:nth-child(4) {
  animation-delay: 0.5s;
}

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
  .sg-main {
    grid-template-columns: minmax(0, 1fr);
    gap: 48px;
    padding: 16px 24px 72px;
  }

  .sg-preview {
    order: 2;
  }
}

@media (max-width: 560px) {
  .sg-top {
    padding: 22px 24px;
  }

  .sg-main {
    padding: 8px 24px 56px;
    gap: 40px;
  }

  .sg-heading h1 {
    font-size: 2.1rem;
  }

  .sg-discord {
    width: 100%;
    min-width: 0;
    align-self: stretch;
  }

  .sg-preview {
    padding: 20px;
  }

  .sg-list li:nth-child(n + 4) {
    display: none;
  }

  .sg-footer {
    padding: 0 24px 32px;
  }

  .sg-footer .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sg-heading h1,
  .sg-heading p,
  .sg-discord,
  .sg-status,
  .sg-note,
  .sg-preview,
  .sg-preview-head,
  .sg-list li {
    animation: none;
  }

  .sg-discord:hover {
    transform: none;
  }
}
