/* ---------- Tokens ---------- */

:root {
  --ink: #05060d;
  --text: #eceef6;
  --text-muted: #a4a9be;
  --line: rgb(236 238 246 / 0.12);
  --line-strong: rgb(236 238 246 / 0.2);
  --focus: #a594ff;
  --danger: #ff9aa8;

  /* Aurora colors as RGB triplets so alpha can vary per use. */
  --violet: 123 92 255;
  --teal: 30 201 176;
  --rose: 240 96 158;
  --blue: 47 85 255;

  --font-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --font-ui: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;

  --gutter: 16px;
  --edge: clamp(var(--gutter), 4vw, 40px);

  color-scheme: dark;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--text);
  font: 400 1rem/1.6 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Aurora background ---------- */

/* Blobs are soft radial gradients (no filter: blur). aurora.js only writes
   their transform, so each frame is composite-only. */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  contain: strict;
  pointer-events: none;
}

.blob {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  margin: calc(var(--size) / -2) 0 0 calc(var(--size) / -2);
  background: radial-gradient(
    closest-side,
    rgb(var(--c) / var(--a)),
    rgb(var(--c) / calc(var(--a) * 0.55)) 38%,
    rgb(var(--c) / calc(var(--a) * 0.18)) 68%,
    rgb(var(--c) / 0)
  );
  will-change: transform;
}

.blob--violet { --c: var(--violet); --a: 0.55; --x: 20%; --y: 26%; --size: 64vmax; }
.blob--teal   { --c: var(--teal);   --a: 0.42; --x: 82%; --y: 20%; --size: 52vmax; }
.blob--rose   { --c: var(--rose);   --a: 0.40; --x: 76%; --y: 84%; --size: 58vmax; }
.blob--blue   { --c: var(--blue);   --a: 0.50; --x: 24%; --y: 90%; --size: 66vmax; }

/* Static noise, painted once. Hides gradient banding. */
.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
}

/* ---------- Buttons ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: 500 0.9375rem/1 var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s, border-color 0.2s;
}

.btn--primary {
  background: var(--text);
  color: var(--ink);
}

.btn--primary:hover {
  background: #fff;
}

.btn--ghost {
  border-color: var(--line-strong);
}

.btn--ghost:hover {
  border-color: rgb(236 238 246 / 0.34);
  background: rgb(255 255 255 / 0.06);
}

.btn--small {
  height: 40px;
  padding: 0 18px;
  font-size: 0.875rem;
}

.btn--block {
  width: 100%;
}

.btn__spinner {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  visibility: hidden;
}

.btn.is-pending {
  cursor: progress;
}

.btn.is-pending .btn__label {
  visibility: hidden;
}

.btn.is-pending .btn__spinner {
  visibility: visible;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(1turn); }
}

/* ---------- Top bar ---------- */

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px var(--edge);
}

.wordmark {
  color: var(--text);
  font: 400 1.75rem/1 var(--font-display);
  letter-spacing: 0.01em;
  text-decoration: none;
}

/* ---------- Hero ---------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 92vh;
  min-height: 92svh;
  padding: 112px var(--gutter) 64px;
  text-align: center;
}

.hero__tag {
  margin: 0 0 28px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.03);
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.hero__title {
  margin: 0;
  font: 400 clamp(2.75rem, 1.4rem + 6.4vw, 7rem)/0.98 var(--font-display);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

/* One sentence per line. */
.hero__title span {
  display: block;
}

.hero__text {
  max-width: 32rem;
  margin: 28px 0 0;
  color: var(--text-muted);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.1875rem);
  text-wrap: pretty;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 40px;
}

/* ---------- Features ---------- */

.features {
  padding: 24px var(--edge) 96px;
  scroll-margin-top: 24px;
}

.features__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

/* Glass look without backdrop-filter: translucent fill, hairline border,
   top highlight. Blurring over a moving background would repaint every frame. */
.feature {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.06), rgb(255 255 255 / 0.015) 55%),
    rgb(10 12 22 / 0.55);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08);
}

.feature__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.feature h3 {
  margin: 0 0 8px;
  font: 500 1.0625rem/1.3 var(--font-ui);
}

.feature p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ---------- Footer ---------- */

.footer {
  padding: 32px var(--gutter) 40px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  text-align: center;
}

/* ---------- Login modal ---------- */

/* The dialog covers the viewport and centers the card, so a click that lands
   on the dialog itself is a click outside the card. */
.modal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: var(--gutter);
  border: 0;
  background: none;
  color: var(--text);
  overflow: auto;
}

.modal[open] {
  display: grid;
  place-items: center;
  animation: modal-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal::backdrop {
  background: rgb(3 4 10 / 0.66);
}

.modal[open]::backdrop {
  animation: fade-in 0.2s ease-out;
}

.modal__card {
  position: relative;
  width: min(100%, 400px);
  padding: 36px 32px 32px;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.07), rgb(255 255 255 / 0) 45%),
    #0e101c;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.1),
    0 40px 100px -30px rgb(0 0 0 / 0.8);
}

.modal__card.is-shaking {
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.modal__close:hover {
  background: rgb(255 255 255 / 0.07);
  color: var(--text);
}

.modal__title {
  margin: 0 0 8px;
  font: 400 2rem/1.1 var(--font-display);
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.field label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgb(255 255 255 / 0.04);
  color: var(--text);
  font: 400 1rem var(--font-ui);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(165 148 255 / 0.22);
}

.input:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  box-shadow: inset 0 0 0 100px #16182a;
}

.input:-webkit-autofill:focus {
  box-shadow: inset 0 0 0 100px #16182a, 0 0 0 3px rgb(165 148 255 / 0.22);
}

.password {
  position: relative;
}

.password .input {
  padding-right: 48px;
}

.password__toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

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

.password__toggle .icon-eye-off,
.password__toggle[aria-pressed="true"] .icon-eye {
  display: none;
}

.password__toggle[aria-pressed="true"] .icon-eye-off {
  display: block;
}

.modal__error {
  min-height: 1.5em;
  margin: 14px 0 6px;
  color: var(--danger);
  font-size: 0.875rem;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
  .modal[open],
  .modal[open]::backdrop,
  .modal__card.is-shaking {
    animation: none;
  }

  .btn.is-pending .btn__spinner {
    animation-duration: 1.6s;
  }
}
