/**
 * Auth page styles. Standalone — only depends on the design tokens
 * from styles.css (--ink, --bg, --g50..g700, --hairline, --ease).
 *
 * Visual: floating glass modal over an ambient colored backdrop.
 * Three blurred color blobs drift behind the card; the card itself
 * uses backdrop-filter so what's behind it blurs *through* the card,
 * producing the iOS-style frosted glass effect — same treatment
 * Apple uses for menus + Linear uses for command palettes.
 *
 * No protected content is in the page; the backdrop is pure CSS.
 */

.auth-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: var(--g50);
  color: var(--ink);
  font-family: "Google Sans Flex", -apple-system, BlinkMacSystemFont,
    "system-ui", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -------------------------------------------------------------------
   Ambient backdrop — three soft colored blobs drift behind the modal.
   The card's backdrop-filter blurs whatever sits underneath it; with
   color shapes here the blur reads as a frosted-glass tint. Without
   them, backdrop-filter has nothing visible to blur and the card
   looks flat against a solid color.
   ------------------------------------------------------------------- */
.auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.auth-backdrop-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.55;
  will-change: transform;
}

.auth-backdrop-blob--a {
  top: -10%;
  left: -10%;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, #d6c5e8 0%, transparent 70%);
  animation: auth-drift-a 22s ease-in-out infinite alternate;
}

.auth-backdrop-blob--b {
  bottom: -15%;
  right: -10%;
  width: 540px;
  height: 540px;
  background: radial-gradient(circle, #c5dde8 0%, transparent 70%);
  animation: auth-drift-b 28s ease-in-out infinite alternate;
}

.auth-backdrop-blob--c {
  top: 30%;
  right: 25%;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, #f0d5c1 0%, transparent 70%);
  animation: auth-drift-c 24s ease-in-out infinite alternate;
}

@keyframes auth-drift-a {
  from { transform: translate(0, 0); }
  to   { transform: translate(40px, 60px); }
}
@keyframes auth-drift-b {
  from { transform: translate(0, 0); }
  to   { transform: translate(-50px, -40px); }
}
@keyframes auth-drift-c {
  from { transform: translate(0, 0); }
  to   { transform: translate(30px, -50px); }
}

/* -------------------------------------------------------------------
   Page wrapper + card
   ------------------------------------------------------------------- */
.auth-page {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  z-index: 1;
}

/* The frosted-glass modal. backdrop-filter blurs whatever sits behind
   the card (the colored blobs) — that's what gives the modal the
   "frosted" feel. The semi-transparent background lets the blurred
   color come through. Falls back to opaque on browsers without
   backdrop-filter support. */
.auth-card {
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 22px;
  padding: 32px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 24px 60px -16px rgba(15, 23, 42, 0.18);
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .auth-card {
    background: rgba(255, 255, 255, 0.96);
  }
}

.auth-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--g700);
}

.auth-eyebrow::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink);
}

.auth-title {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.012em;
  color: var(--ink);
  margin: 0 0 10px;
}

.auth-blurb {
  font-size: 14px;
  line-height: 1.55;
  color: var(--g700);
  margin: 0 0 24px;
}

/* -------------------------------------------------------------------
   Form
   ------------------------------------------------------------------- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--g500);
}

.auth-field {
  position: relative;
}

.auth-form input[type="password"],
.auth-form input[type="text"] {
  display: block;
  width: 100%;
  /* Right padding leaves room for the eye toggle button (40px wide
     including its inner padding, sitting 6px from the field's right
     edge). */
  padding: 12px 48px 12px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    background 0.18s var(--ease);
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

.auth-form input[type="password"]::placeholder,
.auth-form input[type="text"]::placeholder {
  color: var(--g400);
}

.auth-form input[type="password"]:hover,
.auth-form input[type="text"]:hover {
  border-color: rgba(0, 0, 0, 0.22);
}

.auth-form input[type="password"]:focus-visible,
.auth-form input[type="text"]:focus-visible {
  border-color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 3px rgba(22, 21, 19, 0.08);
}

/* -------------------------------------------------------------------
   Eye toggle inside the field. Square button absolutely positioned
   on the right edge; default shows the "open eye" (= currently
   hidden, click to show). When .is-showing is on, swap to the
   "closed eye" icon (= currently showing, click to hide).
   ------------------------------------------------------------------- */
.auth-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--g500);
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
}

.auth-toggle:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.04);
}

.auth-toggle:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  color: var(--ink);
}

.auth-toggle-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Default state (password hidden): show the open-eye icon, hide the
   crossed-eye one. .is-showing inverts. */
.auth-toggle .auth-toggle-icon--hide {
  display: none;
}

.auth-toggle.is-showing .auth-toggle-icon--show {
  display: none;
}

.auth-toggle.is-showing .auth-toggle-icon--hide {
  display: inline;
}

/* -------------------------------------------------------------------
   Error + submit + footer
   ------------------------------------------------------------------- */
.auth-error {
  margin: 4px 0 0;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  color: #9a1c1c;
  background: rgba(192, 28, 28, 0.06);
  border: 1px solid rgba(192, 28, 28, 0.18);
  border-radius: 8px;
}

.auth-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  padding: 12px 18px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: transform 0.18s var(--ease), opacity 0.18s var(--ease);
  appearance: none;
  -webkit-appearance: none;
}

.auth-submit:hover {
  opacity: 0.92;
}

.auth-submit:active {
  transform: translateY(1px);
}

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

.auth-submit-arrow {
  width: 14px;
  height: 14px;
  transition: transform 0.18s var(--ease);
}

.auth-submit:hover .auth-submit-arrow {
  transform: translateX(2px);
}

.auth-fineprint {
  margin: 24px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--g500);
  text-align: center;
}

.auth-fineprint a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.2);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.18s var(--ease);
}

.auth-fineprint a:hover {
  text-decoration-color: var(--ink);
}

.auth-footer {
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--g500);
}

.auth-footer a {
  color: inherit;
  text-decoration: none;
  transition: color 0.18s var(--ease);
}

.auth-footer a:hover {
  color: var(--ink);
}

/* -------------------------------------------------------------------
   Reduced motion / mobile
   ------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .auth-backdrop-blob {
    animation: none;
  }
  .auth-form input[type="password"],
  .auth-form input[type="text"],
  .auth-toggle,
  .auth-submit,
  .auth-submit-arrow,
  .auth-fineprint a,
  .auth-footer a {
    transition: none;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 24px;
    border-radius: 18px;
  }
  .auth-title {
    font-size: 20px;
  }
  .auth-backdrop-blob--a,
  .auth-backdrop-blob--b,
  .auth-backdrop-blob--c {
    width: 320px;
    height: 320px;
  }
}

/* -------------------------------------------------------------------
   Overlay mode — same modal, but rendered as a layer over an existing
   page (the homepage). Reuses .auth-card and friends; only the wrapper
   + backdrop differ. The wrapper is fixed full-screen with high z-index;
   the backdrop dims and blurs whatever sits behind it (the homepage
   content), so the homepage reads as "frozen behind glass" rather than
   replaced by a new page.

   Lock <body> scroll while modal is open via .auth-overlay-open on
   <body>. JS adds/removes that class.
   ------------------------------------------------------------------- */
body.auth-overlay-open {
  overflow: hidden;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: "Google Sans Flex", -apple-system, BlinkMacSystemFont,
    "system-ui", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  animation: auth-overlay-fade 0.22s var(--ease) both;
}

@keyframes auth-overlay-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.auth-overlay.is-closing {
  animation: auth-overlay-fade-out 0.18s var(--ease) both;
}

@keyframes auth-overlay-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Backdrop: dims + blurs homepage content behind it. Click closes. */
.auth-overlay-backdrop {
  position: absolute;
  inset: 0;
  /* Dim is the primary lever — it's what makes content genuinely
     unreadable. Blur just softens edges so the dim doesn't read
     as a flat wash. Pushing blur past ~32px hits browser caps and
     wastes GPU time without changing the perceived obscurity. */
  background: rgba(15, 23, 42, 0.5);
  -webkit-backdrop-filter: blur(32px) saturate(140%);
  backdrop-filter: blur(32px) saturate(140%);
  cursor: pointer;
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .auth-overlay-backdrop {
    background: rgba(15, 23, 42, 0.78);
  }
}

/* The card itself in overlay mode. Sits above the backdrop with its
   own scale-in entrance so the modal feels like it lands on the page
   rather than fading uniformly with the backdrop. */
.auth-overlay .auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  /* In overlay mode the homepage already provides visual interest
     behind the card, so we don't need (and don't render) the colored
     blob backdrop. The card's backdrop-filter still blurs whatever
     sits underneath — in overlay mode that's the dimmed homepage. */
  animation: auth-card-pop 0.32s var(--ease) both;
}

.auth-overlay.is-closing .auth-card {
  animation: auth-card-pop-out 0.18s var(--ease) both;
}

@keyframes auth-card-pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes auth-card-pop-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
}

/* Close (×) button anchored to the card's top-right. Sits inside the
   card so it scales/animates with it. */
.auth-overlay-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 50%;
  cursor: pointer;
  color: var(--g700);
  transition: color 0.18s var(--ease), background 0.18s var(--ease),
    border-color 0.18s var(--ease);
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
}

.auth-overlay-close:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.12);
}

.auth-overlay-close:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.auth-overlay-close-icon {
  width: 14px;
  height: 14px;
}

/* Reduced motion: skip the entrance animations entirely. */
@media (prefers-reduced-motion: reduce) {
  .auth-overlay,
  .auth-overlay.is-closing,
  .auth-overlay .auth-card,
  .auth-overlay.is-closing .auth-card {
    animation: none;
  }
}
