/*
 * Dao Oracle account access.
 * Shares the nocturnal navy / antique-gold language of the Dao Oracle
 * reading flow: star chart ground, silk panel, cinnabar seal, hairline gold.
 * Authentication behaviour is owned by auth.js and is not styled here.
 */

:root {
  color-scheme: dark;
  --dao-ink: #06111f;
  --dao-ink-soft: #0a1b2c;
  --dao-panel: #0c1e31;
  --dao-panel-raised: #102741;
  --dao-gold: #d9bc85;
  --dao-gold-bright: #f0d7a4;
  --dao-gold-deep: #a98a52;
  --dao-cream: #f6ead6;
  --dao-muted: #a9bccf;
  --dao-faint: #8ba0b6;
  --dao-cinnabar: #9d3b31;
  --dao-danger: #ffb7a6;
  --dao-border: rgba(217, 188, 133, 0.26);
  --dao-border-strong: rgba(217, 188, 133, 0.48);
  --dao-line: rgba(217, 188, 133, 0.14);
  font-family: "Segoe UI", "Helvetica Neue", system-ui, -apple-system, sans-serif;
  background: var(--dao-ink);
  color: var(--dao-cream);
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  background: var(--dao-ink);
  color: var(--dao-cream);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Ground: star chart, night sky, mist ---------- */

.auth-page {
  position: relative;
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  padding:
    max(20px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  isolation: isolate;
  background:
    radial-gradient(ellipse at 50% 34%, rgba(33, 62, 92, 0.55), transparent 62%),
    linear-gradient(180deg, #081829 0%, #06111f 62%, #040c16 100%);
}

.auth-page::before {
  position: fixed;
  z-index: -2;
  inset: 0;
  background-image:
    linear-gradient(180deg, rgba(6, 17, 31, 0.52) 0%, rgba(6, 17, 31, 0.82) 62%, rgba(4, 12, 22, 0.94) 100%),
    url('/realtime-call/assets/dao-oracle/scenes/decor-star-scroll.webp');
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  content: "";
  pointer-events: none;
}

.auth-page::after {
  position: fixed;
  z-index: -1;
  inset: 0;
  background: radial-gradient(ellipse 62% 58% at 50% 46%, transparent 30%, rgba(4, 12, 22, 0.72) 100%);
  content: "";
  pointer-events: none;
}

.auth-ambient {
  position: fixed;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 14% 18%, rgba(240, 215, 164, 0.8), transparent 60%),
    radial-gradient(1px 1px at 26% 34%, rgba(246, 234, 214, 0.55), transparent 60%),
    radial-gradient(1.5px 1.5px at 78% 14%, rgba(240, 215, 164, 0.7), transparent 60%),
    radial-gradient(1px 1px at 86% 42%, rgba(246, 234, 214, 0.5), transparent 60%),
    radial-gradient(1px 1px at 8% 62%, rgba(240, 215, 164, 0.45), transparent 60%),
    radial-gradient(1.5px 1.5px at 66% 74%, rgba(240, 215, 164, 0.4), transparent 60%);
  opacity: 0.75;
}

.auth-halo {
  position: absolute;
  top: -22vw;
  left: 50%;
  width: min(92vw, 780px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 188, 133, 0.16), transparent 66%);
  transform: translateX(-50%);
}

.auth-cloud {
  position: absolute;
  width: 320px;
  height: 150px;
  border-radius: 50%;
  background: rgba(150, 178, 203, 0.16);
  filter: blur(34px);
}

.auth-cloud-left {
  bottom: 2%;
  left: -140px;
}

.auth-cloud-right {
  top: 14%;
  right: -150px;
}

/* ---------- Silk panel ---------- */

.auth-card {
  position: relative;
  z-index: 1;
  width: min(100%, 470px);
  padding: 30px 34px 28px;
  border: 1px solid var(--dao-border);
  border-radius: 14px;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(217, 188, 133, 0.1), transparent 62%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.014) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, rgba(16, 39, 65, 0.94), rgba(8, 23, 38, 0.96));
  box-shadow:
    0 30px 90px rgba(1, 6, 14, 0.62),
    0 2px 0 rgba(246, 234, 214, 0.04) inset,
    0 0 0 1px rgba(4, 12, 22, 0.6);
  backdrop-filter: blur(8px);
}

.auth-card::before {
  position: absolute;
  z-index: 0;
  inset: 6px;
  border: 1px solid var(--dao-line);
  border-radius: 9px;
  content: "";
  pointer-events: none;
}

.auth-corner {
  position: absolute;
  z-index: 2;
  width: 16px;
  height: 16px;
  border: 0 solid var(--dao-gold);
  opacity: 0.75;
  pointer-events: none;
}

.auth-corner-tl { top: 12px; left: 12px; border-top-width: 1px; border-left-width: 1px; }
.auth-corner-tr { top: 12px; right: 12px; border-top-width: 1px; border-right-width: 1px; }
.auth-corner-bl { bottom: 12px; left: 12px; border-bottom-width: 1px; border-left-width: 1px; }
.auth-corner-br { bottom: 12px; right: 12px; border-bottom-width: 1px; border-right-width: 1px; }

.auth-header,
.email-auth-form,
.auth-mode-tabs,
.auth-separator,
.guest-entry-button,
.auth-status {
  position: relative;
  z-index: 1;
}

/* ---------- Brand lockup ---------- */

.auth-header {
  text-align: center;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
  text-align: left;
}

.auth-seal {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  place-items: center;
  border: 1px solid #c08f63;
  border-radius: 4px;
  background: linear-gradient(145deg, #a34437, #63291f);
  box-shadow:
    inset 0 0 0 2px rgba(255, 238, 205, 0.1),
    0 6px 16px rgba(2, 8, 16, 0.45);
  color: #f7e3bd;
  font-family: "Songti SC", "Noto Serif CJK SC", "SimSun", serif;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
}

.auth-brand-lockup {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.auth-brand-name {
  color: var(--dao-gold-bright);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.24em;
  line-height: 1.2;
  text-transform: uppercase;
}

.auth-brand-tagline {
  color: var(--dao-muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  line-height: 1.3;
}

.auth-kicker {
  margin: 0 0 5px;
  color: var(--dao-gold);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.auth-header h1 {
  margin: 0;
  color: var(--dao-cream);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(27px, 7vw, 33px);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.auth-introduction {
  margin: 8px 0 18px;
  color: var(--dao-muted);
  font-size: 15px;
  line-height: 1.55;
}

/* ---------- Mode tabs ---------- */

.auth-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid rgba(217, 188, 133, 0.18);
  border-radius: 9px;
  background: rgba(4, 12, 22, 0.55);
}

.auth-mode-tabs button {
  min-height: 46px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--dao-muted);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.auth-mode-tabs button[aria-selected="true"] {
  border-color: rgba(217, 188, 133, 0.34);
  background: linear-gradient(180deg, rgba(217, 188, 133, 0.16), rgba(217, 188, 133, 0.06));
  color: var(--dao-gold-bright);
}

/* ---------- Fields ---------- */

.email-auth-form {
  display: grid;
  gap: 14px;
}

.auth-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.auth-field label {
  color: var(--dao-cream);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.auth-field-hint {
  margin: -2px 0 0;
  color: var(--dao-faint);
  font-size: 13px;
  line-height: 1.45;
}

.auth-field input {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid rgba(169, 188, 207, 0.26);
  border-radius: 7px;
  outline: none;
  background: rgba(5, 16, 28, 0.82);
  color: var(--dao-cream);
  font-size: 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.auth-field input::placeholder {
  color: var(--dao-faint);
  opacity: 1;
}

.auth-field input:hover:not(:focus) {
  border-color: rgba(169, 188, 207, 0.4);
}

.auth-field input:focus {
  border-color: var(--dao-gold);
  background: rgba(6, 19, 33, 0.95);
  box-shadow: 0 0 0 3px rgba(217, 188, 133, 0.16);
}

.auth-field input[aria-invalid="true"] {
  border-color: #e08a76;
  box-shadow: 0 0 0 3px rgba(224, 138, 118, 0.12);
}

.code-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 10px;
}

/* ---------- Actions ---------- */

.send-code-button,
.auth-submit-button,
.return-login-button,
.guest-entry-button {
  min-height: 52px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

.send-code-button {
  padding: 0 10px;
  border: 1px solid var(--dao-border-strong);
  background: rgba(217, 188, 133, 0.06);
  color: var(--dao-gold-bright);
  font-size: 13px;
  white-space: nowrap;
}

.send-code-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.auth-submit-button {
  border: 1px solid #edd6a8;
  background: linear-gradient(180deg, #f2dbab 0%, #d9bc85 55%, #c3a468 100%);
  color: #16243a;
  box-shadow:
    inset 0 1px 0 rgba(255, 250, 236, 0.85),
    0 10px 24px rgba(2, 8, 16, 0.42);
}

.auth-submit-button:hover:not(:disabled) {
  background: linear-gradient(180deg, #f8e5bb 0%, #e2c793 55%, #cdaF73 100%);
}

.auth-submit-button:disabled {
  cursor: default;
  opacity: 0.62;
}

.return-login-button,
.guest-entry-button {
  border: 1px solid var(--dao-border-strong);
  background: rgba(8, 23, 38, 0.72);
  color: var(--dao-gold-bright);
}

.return-login-button:hover:not(:disabled),
.guest-entry-button:hover:not(:disabled) {
  border-color: var(--dao-gold);
  background: rgba(217, 188, 133, 0.1);
}

.guest-entry-button {
  width: 100%;
}

.sms-login-entry-button {
  width: 100%;
  border: 1px solid var(--dao-border-strong);
  background: rgba(217, 188, 133, 0.08);
  color: var(--dao-gold-bright);
  line-height: 1.4;
  padding: 8px 12px;
}

.first-use-panel {
  padding: 10px 12px;
  border: 1px solid var(--dao-border);
  border-radius: 8px;
  background: rgba(217, 188, 133, 0.06);
  text-align: center;
}

.first-use-panel p {
  margin: 5px 0 0;
  color: var(--dao-muted);
  font-size: 14px;
  line-height: 1.45;
}

.set-password-button {
  border: 1px solid #edd6a8;
  background: linear-gradient(180deg, #f2dbab, #c9a96f);
  color: #16243a;
}

.skip-password-button {
  border: 1px solid var(--dao-border-strong);
  background: rgba(8, 23, 38, 0.72);
  color: var(--dao-gold-bright);
}

.forgot-password-button {
  justify-self: end;
  min-height: 48px;
  max-width: 100%;
  margin-bottom: 0;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--dao-gold);
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  text-align: right;
  text-decoration: underline;
  text-decoration-color: rgba(217, 188, 133, 0.35);
  text-underline-offset: 4px;
  white-space: normal;
}

.forgot-password-button:hover {
  color: var(--dao-gold-bright);
  text-decoration-color: var(--dao-gold-bright);
}

/* ---------- Consent, errors, status ---------- */

.consent-row {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 10px;
  color: var(--dao-muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.45;
}

.consent-row label {
  cursor: pointer;
}

.consent-link {
  color: var(--dao-gold-bright);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.consent-link:hover {
  color: #f0d9a4;
}

.consent-checkbox {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  margin: 0;
  appearance: none;
  place-content: center;
  border: 1px solid rgba(217, 188, 133, 0.55);
  border-radius: 4px;
  background: rgba(5, 16, 28, 0.82);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.consent-checkbox::before {
  width: 10px;
  height: 10px;
  background: linear-gradient(180deg, #f2dbab, #c8a875);
  clip-path: polygon(14% 44%, 0 64%, 40% 100%, 100% 16%, 82% 0%, 39% 62%);
  content: "";
  transform: scale(0);
  transition: transform 120ms ease;
}

.consent-checkbox:checked {
  border-color: var(--dao-gold);
  background: rgba(217, 188, 133, 0.14);
}

.consent-checkbox:checked::before {
  transform: scale(1);
}

.auth-field-error {
  margin: 0;
  color: var(--dao-danger);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.consent-error {
  margin-top: -10px;
}

.auth-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--dao-faint);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-separator::before,
.auth-separator::after {
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, rgba(217, 188, 133, 0.24), transparent);
  content: "";
}

.auth-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--dao-gold);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
}

.password-setup-panel {
  padding: 22px 18px 18px;
  border: 1px solid var(--dao-border-strong);
  border-radius: 10px;
  background: rgba(9, 25, 41, 0.96);
  box-shadow: 0 14px 36px rgba(1, 6, 14, 0.5);
}

.password-setup-panel h2 {
  margin: 0;
  color: var(--dao-cream);
  font-family: Georgia, serif;
  font-size: 23px;
  font-weight: 400;
  text-align: center;
}

.password-setup-copy,
.password-setup-hint {
  margin: 10px 0 6px;
  color: var(--dao-muted);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.password-setup-hint {
  margin-bottom: 18px;
  color: var(--dao-faint);
}

.password-setup-form {
  display: grid;
  gap: 14px;
}

/* ---------- Focus and motion ---------- */

button:focus-visible,
.consent-row:has(input:focus-visible) {
  outline: 2px solid var(--dao-gold-bright);
  outline-offset: 2px;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 700px) {
  .auth-page::before {
    background-image:
      linear-gradient(180deg, rgba(6, 17, 31, 0.38) 0%, rgba(6, 17, 31, 0.7) 46%, rgba(6, 17, 31, 0.95) 82%, #040c16 100%),
      url('/realtime-call/assets/dao-oracle/scenes/decor-star-scroll.webp');
    background-position: center top;
    background-size: 100% auto;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 30%, transparent 50%);
    mask-image: linear-gradient(180deg, #000 0%, #000 30%, transparent 50%);
  }
}

@media (max-width: 430px) {
  .auth-page {
    padding-inline: 14px;
  }

  .auth-card {
    padding: 24px 20px 22px;
    border-radius: 12px;
  }

  .auth-brand {
    gap: 10px;
    margin-bottom: 14px;
  }

  .auth-seal {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    font-size: 24px;
  }

  .auth-brand-name {
    font-size: 15px;
    letter-spacing: 0.2em;
  }

  .auth-introduction {
    margin-bottom: 16px;
    font-size: 14px;
  }

  .email-auth-form {
    gap: 12px;
  }

  .code-input-row {
    grid-template-columns: minmax(0, 1fr) 108px;
    gap: 8px;
  }

  .send-code-button {
    font-size: 12px;
  }
}

@media (max-width: 360px) {
  .auth-page {
    padding-inline: 10px;
  }

  .auth-card {
    padding: 20px 16px 18px;
  }

  .code-input-row {
    grid-template-columns: minmax(0, 1fr) 96px;
  }

  .auth-brand-name {
    font-size: 14px;
    letter-spacing: 0.16em;
  }

  .auth-brand-tagline {
    font-size: 11px;
  }
}

@media (max-height: 860px) {
  .auth-page {
    place-items: start center;
    padding-block: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-bottom));
  }

  .auth-card {
    padding: 22px 26px 20px;
  }

  .auth-brand {
    margin-bottom: 12px;
  }

  .auth-seal {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    font-size: 22px;
  }

  .auth-header h1 {
    font-size: 27px;
  }

  .auth-introduction {
    margin: 5px 0 12px;
    font-size: 14px;
    line-height: 1.45;
  }

  .auth-mode-tabs {
    margin-bottom: 13px;
  }

  .auth-mode-tabs button {
    min-height: 44px;
  }

  .email-auth-form {
    gap: 9px;
  }

  .auth-field {
    gap: 4px;
  }

  .auth-field input,
  .auth-submit-button,
  .return-login-button,
  .guest-entry-button,
  .send-code-button {
    min-height: 48px;
  }

  .consent-row {
    min-height: 42px;
  }

  .auth-separator {
    margin: 11px 0;
  }

  .auth-status {
    margin-top: 6px;
  }
}

@media (max-height: 720px) {
  .auth-card {
    padding: 16px 20px 14px;
  }

  .auth-brand-tagline {
    display: none;
  }

  .auth-header h1 {
    font-size: 24px;
  }

  .auth-introduction {
    margin-bottom: 9px;
    font-size: 13px;
  }

  .email-auth-form {
    gap: 7px;
  }

  .auth-field-hint {
    font-size: 12px;
  }
}

@media (min-width: 900px) {
  .auth-page {
    padding-block: 44px;
  }
}

@media (min-width: 900px) and (min-height: 880px) {
  .auth-card {
    padding: 36px 40px 32px;
  }
}

@media (min-width: 900px) and (max-height: 820px) {
  .auth-page {
    padding-block: 18px;
  }

  .auth-card {
    padding: 22px 30px 20px;
  }
}
