/* =========================================================================
   ROSIE — Auth screens (login, access denied, loading)
   ========================================================================= */

/* Full-viewport overlay — sits on top of the app until auth resolves. */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 2rem;
}
.auth-overlay[hidden] { display: none; }

/* Author styles have higher priority than the UA [hidden] rule, so `display`
   declarations on .auth-card would otherwise show hidden panels. This rule
   restores the expected behaviour for any element inside the auth overlay. */
.auth-overlay [hidden] { display: none !important; }

/* Card container — a branded navy panel in BOTH themes, so the white ROSIE
   lockup reads on it. Redefining the neutral tokens on the card flips its whole
   interior (title, notice, buttons) to light-on-navy with no per-element rules.
   Teal/red accents are theme-independent and stay as-is. */
.auth-card {
  --text:           #F4F6F9;
  --text-dim:       #C6D2E0;
  --text-muted:     #9FB1C6;
  --surface:        rgba(255, 255, 255, 0.05);
  --surface-hover:  rgba(255, 255, 255, 0.07);
  --surface-raised: rgba(255, 255, 255, 0.12);
  --border:         rgba(255, 255, 255, 0.10);
  --border-emph:    rgba(255, 255, 255, 0.18);

  background: var(--app-nav);
  border: 1px solid var(--border-emph);
  border-radius: var(--radius);
  padding: 2.5rem 2.5rem 2rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow);
}

.auth-logo {
  height: 52px;
  width: auto;
  opacity: 0.88;
  margin-bottom: 0.25rem;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
}

.auth-subtitle {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: -0.25rem;
}

.auth-cycle {
  width: 210px;
  height: auto;
  color: var(--teal);
}

.auth-notice {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.45rem 0.9rem;
  font-family: var(--font-mono);
}

/* Google sign-in button — neutral, theme-aware */
.btn-google-signin {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border-emph);
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.6rem;
  font-family: var(--font-body);
  font-size: 0.93rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background var(--dur-micro) var(--ease),
    border-color var(--dur-micro) var(--ease);
  white-space: nowrap;
  letter-spacing: 0;
}
.btn-google-signin:hover {
  background: var(--surface-raised);
  border-color: var(--border-emph);
}
.btn-google-signin:active { background: var(--surface); }
.btn-google-signin svg { flex-shrink: 0; }

/* Access denied */
.auth-denied-email {
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--teal);
  word-break: break-all;
}

.auth-denied-msg {
  font-size: 0.87rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.btn-auth-retry {
  background: var(--teal-soft);
  color: var(--teal);
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.4rem;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease);
}
.btn-auth-retry:hover { background: rgba(60, 165, 154, 0.22); }

/* Loading spinner */
.auth-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-emph);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: auth-spin 0.75s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* ── User avatar menu in app header ──────────────────────────────────────── */
.auth-user-menu {
  position: relative;
  flex-shrink: 0;
  margin-left: auto;
}

/* Round avatar button */
.auth-avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-emph);
  padding: 0;
  cursor: pointer;
  background: var(--surface);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--dur-micro) var(--ease);
  flex-shrink: 0;
}
.auth-avatar-btn:hover { border-color: var(--teal); }
.auth-avatar-btn[aria-expanded="true"] { border-color: var(--teal); }

.auth-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* Photo vs. initials visibility is toggled in JS (core/app.js) once the photo
   has actually loaded or failed — CSS cannot tell a broken image from a good
   one. An explicit [hidden] rule is required to beat the display: block above,
   which otherwise outranks the UA stylesheet's [hidden] { display: none }. */
.auth-avatar-img[hidden],
.auth-avatar-initials[hidden] { display: none; }

/* Initials fallback — shown when the photo is absent or fails to load */
.auth-avatar-initials {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--teal);
  text-transform: uppercase;
  line-height: 1;
  letter-spacing: 0;
  pointer-events: none;
}

/* Dropdown panel */
.auth-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border-emph);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 1000;
}

.auth-dropdown-user {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.9rem 1rem;
}

.auth-dropdown-name {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-dropdown-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

.auth-dropdown-signout {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-micro) var(--ease), color var(--dur-micro);
}
.auth-dropdown-signout:hover {
  background: var(--red-soft);
  color: var(--red);
}
