/* ============================================================================
 * ANUSHKA — A PRIVATE DIGITAL WORLD
 * Public Authentication & Frosted-Glass Surface Architecture
 * ============================================================================ */

:root {
  /* Core Warm Neutral Palette */
  --ivory: #F6F2EB;
  --linen: #E8DFD2;
  --porcelain: #FBF9F5;
  --cream: #F1E9DE;
  --sand: #D9CBBB;
  --taupe: #B8A795;
  --dusty-beige: #C8B6A3;
  --clay: #A68D78;
  --ink: #302D29;
  --espresso: #42372F;
  --mocha: #625448;
  --walnut: #74675B;
  --accent: #9B806C;
  --border: #D8CEC0;
  --white: #FFFFFF;

  /* Supporting Tonal Variations */
  --muted-sage: #A7AAA0;
  --smoky-rose: #B99F99;
  --muted-mauve: #8E7775;

  /* Typography */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Dynamic pointer light coordinates (updated subtly via JS) */
  --card-light-x: 50%;
  --card-light-y: 22%;
  --card-tilt-x: 0deg;
  --card-tilt-y: 0deg;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--ivory);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================
 * WebGL Background Canvas & Atmosphere Veil
 * ============================================================================ */
#webgl-world-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: none;
}

#organic-world-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.atmosphere-veil {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(246, 242, 235, 0.0) 35%,
    rgba(217, 203, 187, 0.16) 100%
  );
}

/* ============================================================================
 * Viewport Stage & Centered Card Wrapper
 * ============================================================================ */
.viewport-stage {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  perspective: 1200px;
}

.auth-card-wrapper {
  width: 100%;
  max-width: 388px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition:
    opacity 1.85s cubic-bezier(0.22, 1, 0.36, 1),
    transform 1.95s cubic-bezier(0.22, 1, 0.36, 1),
    filter 1.85s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Dissolve state triggered on successful authentication */
.auth-card-wrapper.is-dissolving {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.045) translateY(-10px);
  filter: blur(18px);
}

/* ============================================================================
 * Warm Frosted-Glass Authentication Card
 * Genuine translucency so evolving WebGL forms remain visible through the card
 * ============================================================================ */
.auth-glass-card {
  position: relative;
  width: 100%;
  border-radius: 26px;
  padding: 2.35rem 2.15rem 1.95rem;
  /* Translucent layered warm glass — NOT an opaque white rectangle */
  background:
    radial-gradient(
      130% 110% at var(--card-light-x) var(--card-light-y),
      rgba(251, 249, 245, 0.42) 0%,
      rgba(246, 242, 235, 0.24) 48%,
      rgba(232, 223, 210, 0.18) 100%
    );
  backdrop-filter: blur(22px) saturate(128%) contrast(102%);
  -webkit-backdrop-filter: blur(22px) saturate(128%) contrast(102%);
  border: 1px solid rgba(255, 255, 255, 0.46);
  box-shadow:
    0 24px 56px -14px rgba(48, 45, 41, 0.13),
    0 8px 22px -6px rgba(66, 55, 47, 0.08),
    inset 0 1px 1px 0 rgba(255, 255, 255, 0.62),
    inset 0 -1px 1px 0 rgba(166, 141, 120, 0.16);
  transform: rotateX(var(--card-tilt-y)) rotateY(var(--card-tilt-x));
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.6s ease,
    border-color 0.6s ease;
  overflow: hidden;
}

/* Subtle internal border ring */
.glass-rim-highlight {
  position: absolute;
  inset: 0;
  border-radius: 26px;
  pointer-events: none;
  border: 1px solid rgba(216, 206, 192, 0.42);
  mask-image: linear-gradient(165deg, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.2) 60%, rgba(0,0,0,0.6) 100%);
  -webkit-mask-image: linear-gradient(165deg, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.2) 60%, rgba(0,0,0,0.6) 100%);
}

/* Localized atmospheric fog / diffused ivory haze behind text for crisp legibility
 * without making the whole card opaque or blurring the typography */
.localized-ivory-haze {
  position: absolute;
  inset: 6% 5% 8% 5%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(
      ellipse 88% 42% at 50% 24%,
      rgba(246, 242, 235, 0.68) 0%,
      rgba(241, 233, 222, 0.36) 58%,
      rgba(246, 242, 235, 0.0) 100%
    ),
    radial-gradient(
      ellipse 75% 28% at 50% 90%,
      rgba(246, 242, 235, 0.56) 0%,
      rgba(246, 242, 235, 0.0) 100%
    );
  filter: blur(10px);
}

.auth-card-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* ============================================================================
 * Editorial Display Typography & Form Controls
 * ============================================================================ */
.auth-heading {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.52rem, 3.6vw, 1.78rem);
  line-height: 1.26;
  letter-spacing: -0.01em;
  color: var(--ink);
  max-width: 19ch;
  margin-bottom: 1.55rem;
  text-shadow: 0 1px 10px rgba(251, 249, 245, 0.65);
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.78rem;
}

.input-field-group {
  width: 100%;
  position: relative;
}

.phrase-input {
  width: 100%;
  height: 46px;
  padding: 0 1.05rem;
  border-radius: 13px;
  border: 1px solid rgba(216, 206, 192, 0.82);
  background: rgba(251, 249, 245, 0.58);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  outline: none;
  box-shadow:
    inset 0 1px 2px rgba(48, 45, 41, 0.04),
    0 2px 8px rgba(48, 45, 41, 0.03);
  transition:
    background-color 0.28s ease,
    border-color 0.28s ease,
    box-shadow 0.28s ease;
}

.phrase-input::placeholder {
  color: var(--walnut);
  opacity: 0.68;
  letter-spacing: 0.01em;
}

.phrase-input:focus {
  background: rgba(251, 249, 245, 0.82);
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px rgba(155, 128, 108, 0.16),
    inset 0 1px 2px rgba(48, 45, 41, 0.03);
}

/* Dark Espresso Rounded Unlock Button */
.unlock-button {
  position: relative;
  width: 100%;
  height: 46px;
  border-radius: 13px;
  border: 1px solid rgba(66, 55, 47, 0.95);
  background: var(--espresso);
  color: var(--porcelain);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow:
    0 8px 20px -6px rgba(66, 55, 47, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition:
    background-color 0.25s ease,
    transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.25s ease,
    opacity 0.25s ease;
}

.unlock-button:hover:not(:disabled) {
  background: #382E27;
  box-shadow:
    0 10px 24px -6px rgba(48, 45, 41, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.unlock-button:active:not(:disabled) {
  transform: scale(0.992);
}

.unlock-button:disabled {
  cursor: default;
  opacity: 0.78;
}

.unlock-button-spinner {
  display: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.75px solid rgba(251, 249, 245, 0.3);
  border-top-color: var(--porcelain);
  animation: spin 0.8s linear infinite;
}

.unlock-button.is-loading .unlock-button-spinner {
  display: inline-block;
}

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

/* Subtle error / status feedback */
.auth-feedback {
  min-height: 1.25rem;
  margin-top: 0.65rem;
  font-family: var(--font-ui);
  font-size: 0.79rem;
  font-weight: 400;
  color: var(--muted-mauve);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.auth-feedback.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Bottom sanctity line */
.auth-sanctity-line {
  margin-top: 0.55rem;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 0.96rem;
  letter-spacing: 0.015em;
  color: var(--mocha);
  text-shadow: 0 1px 8px rgba(246, 242, 235, 0.75);
}

/* Gentle shake animation on invalid phrase */
@keyframes gentle-reject {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-5px); }
  45% { transform: translateX(4px); }
  70% { transform: translateX(-3px); }
  88% { transform: translateX(2px); }
}

.auth-glass-card.is-rejected {
  animation: gentle-reject 0.46s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* Protected world mount layer */
.protected-world-mount {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.protected-world-mount.is-active {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 480px) {
  .auth-card-wrapper {
    max-width: 348px;
  }
  .auth-glass-card {
    padding: 2.05rem 1.65rem 1.7rem;
    border-radius: 23px;
  }
}
