/* ==========================================================================
   CriticalQuant — Account & Access System (iPhone & Mobile-Optimized)
   ========================================================================== */

:root {
  --cq-bg: #07090b;
  --cq-surface: #0e1215;
  --cq-surface-hover: #13191d;
  --cq-surface-elevated: #161e23;
  --cq-border: rgba(255, 255, 255, 0.08);
  --cq-border-gold: rgba(231, 198, 106, 0.28);
  --cq-gold: #e7c66a;
  --cq-gold-hover: #edd68d;
  --cq-mint: #79d9b2;
  --cq-text: #edf3ef;
  --cq-muted: #8d9c95;
  --cq-subtle: #56645f;
  --cq-danger: #ff7569;
}

/* Modal Container Overlay */
.cq-account-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cq-account-modal[hidden] {
  display: none !important;
}

.cq-account-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 6, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1;
}

/* Modal Window */
.cq-modal-panel {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 400px;
  background: var(--cq-surface);
  border: 1px solid var(--cq-border);
  border-radius: 22px;
  padding: 24px 20px;
  color: var(--cq-text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.04);
  animation: cqPanelAppear 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: auto;
  overflow: hidden;
}

@media (min-width: 480px) {
  .cq-modal-panel {
    padding: 30px 26px;
    border-radius: 24px;
    max-width: 420px;
  }
}

@keyframes cqPanelAppear {
  0% { opacity: 0; transform: scale(0.96) translateY(8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Close Button */
.cq-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--cq-muted);
  font-size: 15px;
  display: grid;
  place-items: center;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s ease;
  touch-action: manipulation;
  -webkit-appearance: none;
}

.cq-modal-close:hover, .cq-modal-close:active {
  color: var(--cq-text);
  background: rgba(255, 255, 255, 0.12);
}

/* --------------------------------------------------------------------------
   AUTH VIEW (Sign Up / Sign In)
   -------------------------------------------------------------------------- */
.cq-auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.cq-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--cq-gold), var(--cq-mint));
  color: #050607;
  font-weight: 800;
  font-size: 13px;
  display: grid;
  place-items: center;
  font-family: ui-monospace, Menlo, monospace;
}

.cq-brand-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--cq-text);
}

.cq-auth-header {
  margin-bottom: 20px;
}

.cq-auth-header h2 {
  margin: 0 0 6px;
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: #fff;
  line-height: 1.2;
}

.cq-auth-header p {
  margin: 0;
  font-size: 13px;
  color: var(--cq-muted);
  line-height: 1.45;
}

.cq-form-stack {
  display: grid;
  gap: 14px;
}

.cq-input-group {
  display: grid;
  gap: 6px;
}

.cq-input-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cq-muted);
}

/* Text Inputs: 16px font-size prevents iOS Safari automatic viewport zooming */
.cq-text-input {
  width: 100%;
  height: 46px;
  box-sizing: border-box;
  background: var(--cq-bg);
  border: 1px solid var(--cq-border);
  border-radius: 12px;
  padding: 0 14px;
  color: #fff;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: all 0.15s ease;
  -webkit-appearance: none;
  touch-action: manipulation;
}

.cq-text-input:focus {
  border-color: var(--cq-gold);
  box-shadow: 0 0 0 3px rgba(231, 198, 106, 0.18);
  background: #090c0e;
}

.cq-text-input::placeholder {
  color: var(--cq-subtle);
  font-size: 14px;
}

.cq-primary-btn {
  width: 100%;
  height: 46px;
  border-radius: 999px;
  background: var(--cq-gold);
  color: #07090b;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  margin-top: 4px;
  font-family: inherit;
  touch-action: manipulation;
  -webkit-appearance: none;
}

.cq-primary-btn:hover {
  background: var(--cq-gold-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(231, 198, 106, 0.25);
}

.cq-primary-btn:active {
  transform: scale(0.98);
}

.cq-primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.cq-auth-status {
  font-size: 12px;
  font-weight: 500;
  min-height: 18px;
  text-align: center;
  line-height: 1.4;
}

.cq-auth-status.error { color: var(--cq-danger); }
.cq-auth-status.success { color: var(--cq-mint); }
.cq-auth-status.loading { color: var(--cq-gold); }

.cq-auth-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--cq-border);
  text-align: center;
  font-size: 13px;
  color: var(--cq-muted);
}

.cq-link-btn {
  background: none;
  border: none;
  color: var(--cq-gold);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  font-family: inherit;
  touch-action: manipulation;
}

.cq-link-btn:hover, .cq-link-btn:active {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   PROFILE VIEW (Logged-In Member)
   -------------------------------------------------------------------------- */
.cq-profile-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--cq-bg);
  border: 1px solid var(--cq-border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.cq-profile-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cq-avatar-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--cq-surface-elevated);
  border: 1px solid rgba(231, 198, 106, 0.3);
  color: var(--cq-gold);
  font-weight: 750;
  font-size: 15px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.cq-user-details {
  min-width: 0;
}

.cq-username-text {
  font-size: 15px;
  font-weight: 750;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.cq-tier-pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cq-mint);
  margin-top: 1px;
}

/* Section Group */
.cq-section-group {
  margin-bottom: 18px;
}

.cq-section-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cq-subtle);
  margin: 0 0 8px;
}

.cq-access-list {
  background: var(--cq-bg);
  border: 1px solid var(--cq-border);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 12.5px;
}

.cq-access-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.cq-access-row:last-child {
  border-bottom: none;
}

.cq-access-label {
  color: var(--cq-text);
  font-weight: 500;
}

.cq-access-value {
  color: var(--cq-muted);
  font-size: 12px;
}

/* Account note */
.cq-account-note {
  font-size: 12px;
  color: var(--cq-muted);
  line-height: 1.5;
  margin: 0 0 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--cq-border-gold);
  border-radius: 14px;
}

/* Account Footer Actions */
.cq-profile-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--cq-border);
  gap: 12px;
}

.cq-btn-secondary {
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--cq-border);
  color: var(--cq-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  touch-action: manipulation;
  -webkit-appearance: none;
}

.cq-btn-secondary:hover, .cq-btn-secondary:active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.cq-btn-danger-link {
  background: none;
  border: none;
  color: var(--cq-danger);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0;
  font-family: inherit;
  touch-action: manipulation;
}

.cq-btn-danger-link:hover, .cq-btn-danger-link:active {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   NAVBAR BADGE & STAGE LOCK
   -------------------------------------------------------------------------- */
.btn-nav-account {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--cq-border);
  color: var(--cq-text);
  padding: 0 12px;
  height: 36px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-appearance: none;
}

@media (min-width: 480px) {
  .btn-nav-account {
    padding: 0 16px;
    height: 38px;
    font-size: 13px;
  }
}

.btn-nav-account:hover, .btn-nav-account:active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-nav-account.beta-active {
  border-color: rgba(231, 198, 106, 0.35);
  background: rgba(231, 198, 106, 0.06);
  color: var(--cq-gold);
}

/* In-Stage Lock Banner */
.cq-stage-lock {
  background: var(--cq-surface);
  border: 1px solid var(--cq-border);
  border-radius: 20px;
  padding: clamp(24px, 5vw, 40px) 20px;
  max-width: 440px;
  margin: 32px auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
  box-sizing: border-box;
}

.cq-lock-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(231, 198, 106, 0.1);
  border: 1px solid rgba(231, 198, 106, 0.3);
  color: var(--cq-gold);
  font-size: 18px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
}

.cq-stage-lock h2 {
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  color: #fff;
}

.cq-stage-lock p {
  font-size: 13px;
  color: var(--cq-muted);
  line-height: 1.5;
  margin: 0 0 20px;
}
