/* KeyExchange.Org Primary Stylesheet */
:root {
  --bg-primary: #07090e;
  --bg-secondary: #0f131f;
  --bg-tertiary: #171d2d;
  --bg-card: rgba(18, 23, 38, 0.75);
  --bg-card-hover: rgba(26, 33, 54, 0.9);
  --border-color: rgba(99, 102, 241, 0.2);
  --border-bright: rgba(56, 189, 248, 0.4);
  --accent-cyan: #38bdf8;
  --accent-indigo: #818cf8;
  --accent-gold: #fbbf24;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Cinzel", Georgia, serif;
  --font-mono: "Fira Code", Menlo, Monaco, Consolas, monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.15);
  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #edf2f7;
  --bg-tertiary: #e2e8f0;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --border-color: rgba(99, 102, 241, 0.2);
  --border-bright: rgba(56, 189, 248, 0.6);
  --accent-cyan: #0284c7;
  --accent-indigo: #6366f1;
  --accent-gold: #d97706;
  --accent-emerald: #059669;
  --accent-rose: #e11d48;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 25px rgba(2, 132, 199, 0.15);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  background-image: 
    radial-gradient(circle at 10% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 90% 85%, rgba(56, 189, 248, 0.1) 0%, transparent 45%);
}

/* Cosmic Header */
header.portal-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(20px);
  background: rgba(7, 9, 14, 0.85);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 24px;
}

[data-theme="light"] header.portal-header {
  background: rgba(248, 250, 252, 0.85);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}

.brand-emblem {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.portal-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: var(--transition);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.nav-link:hover, .nav-link.active {
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
}

.theme-toggle-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
}

/* Hero Section */
.hero-section {
  max-width: 1200px;
  margin: 50px auto 40px;
  padding: 0 24px;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  background: rgba(251, 191, 36, 0.12);
  color: var(--accent-gold);
  border: 1px solid rgba(251, 191, 36, 0.3);
  margin-bottom: 20px;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  line-height: 1.15;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #ffffff 40%, var(--accent-cyan) 75%, var(--accent-indigo) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .hero-title {
  background: linear-gradient(135deg, #0f172a 40%, var(--accent-cyan) 80%, var(--accent-indigo) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-tagline {
  font-size: 1.35rem;
  color: var(--accent-cyan);
  font-weight: 600;
  margin-bottom: 20px;
}

.hero-exposition {
  max-width: 900px;
  margin: 0 auto 35px;
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1.8;
  text-align: left;
  background: var(--bg-card);
  padding: 32px 36px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-subtle);
  backdrop-filter: blur(12px);
}

.hero-exposition p {
  margin-bottom: 18px;
}

.hero-exposition p:last-child {
  margin-bottom: 0;
}

.paradox-quote {
  border-left: 4px solid var(--accent-gold);
  padding-left: 20px;
  margin: 20px 0;
  font-style: italic;
  color: var(--text-main);
  background: rgba(251, 191, 36, 0.05);
  padding: 16px 20px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Main Container */
main.portal-container {
  max-width: 1400px;
  margin: 0 auto 80px;
  padding: 0 24px;
}

/* Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin: 50px 0 25px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  flex-wrap: wrap;
  gap: 15px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Content Filter & Search Controls */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 16px 12px 42px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.pill-btn:hover, .pill-btn.active {
  background: var(--accent-cyan);
  color: #07090e;
  border-color: var(--accent-cyan);
  font-weight: 600;
}

/* Modules Grid */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 28px;
}

.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  backdrop-filter: blur(12px);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-subtle);
  position: relative;
  overflow: hidden;
}

.module-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-bright);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-glow);
}

.module-badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: inline-block;
  margin-bottom: 14px;
}

.module-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  line-height: 1.3;
  margin-bottom: 8px;
  color: var(--text-main);
}

.module-subtitle {
  font-size: 0.9rem;
  color: var(--accent-indigo);
  margin-bottom: 14px;
}

.module-summary {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 20px;
  flex-grow: 1;
}

.module-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.tag-badge {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--text-dim);
}

.module-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.open-module-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.open-module-btn:hover {
  gap: 10px;
}

/* Fullscreen Module Modal Viewer */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-container {
  width: 95vw;
  height: 92vh;
  background: var(--bg-primary);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.modal-header {
  padding: 14px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--accent-cyan);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition);
  text-decoration: none;
}

.modal-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-cyan);
}

.modal-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: var(--bg-primary);
}

/* Provenance Footer */
footer.portal-footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  padding: 40px 24px 60px;
  margin-top: 80px;
}

.footer-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .hero-title { font-size: 2.2rem; }
  .modules-grid { grid-template-columns: 1fr; }
  .controls-bar { flex-direction: column; align-items: stretch; }
  .portal-nav { display: none; }
}

/* Seeker Identity & Cloudflare Authentication Modal */
#seeker-identity-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition-fast);
}

#seeker-identity-badge:hover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
}

#seeker-identity-badge.logged-in {
  border-color: rgba(34, 197, 94, 0.4);
}

.identity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.identity-dot.verified {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.identity-dot.pending {
  background: #f59e0b;
}

.identity-status-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

.auth-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 22, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.auth-modal-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.auth-modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  position: relative;
  overflow: hidden;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.auth-modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.auth-modal-close:hover {
  color: var(--text-main);
}

.auth-modal-header {
  padding: 28px 28px 16px;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
}

.auth-logo-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.1);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
}

.auth-modal-header h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.auth-tagline {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.auth-modal-body {
  padding: 24px 28px 28px;
  max-height: 75vh;
  overflow-y: auto;
}

.social-logins-group {
  margin-bottom: 20px;
}

.social-login-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-align: center;
}

.social-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-main);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-social:hover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}

.auth-divider span {
  padding: 0 10px;
}

.turnstile-container {
  margin: 16px 0;
  padding: 10px;
  border-radius: var(--radius-md);
  background: rgba(34, 197, 94, 0.05);
  border: 1px dashed rgba(34, 197, 94, 0.3);
}

.turnstile-mock-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #22c55e;
}

.auth-status-msg {
  margin-top: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: center;
}

.auth-status-msg.info { color: var(--accent-cyan); }
.auth-status-msg.success { color: #22c55e; }
.auth-status-msg.error { color: #ef4444; }

.profile-details-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 20px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.88rem;
}

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

.profile-label {
  color: var(--text-muted);
}

.profile-val {
  color: var(--text-main);
  font-weight: 500;
}

.profile-val.mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.badge-provider {
  text-transform: uppercase;
  font-size: 0.75rem;
  padding: 2px 8px;
  background: rgba(147, 51, 234, 0.15);
  color: #c084fc;
  border-radius: 4px;
}

.status-verified {
  color: #22c55e;
  font-weight: 600;
}

.status-pending {
  color: #f59e0b;
  font-weight: 600;
}

.otp-verification-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.otp-verification-box label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.otp-input-group {
  display: flex;
  gap: 8px;
}

.otp-input-group input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
}

.auth-actions-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.danger-zone-card {
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
  border-radius: var(--radius-md);
  padding: 16px;
}

.danger-zone-card h3 {
  color: #ef4444;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.danger-zone-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid #ef4444;
  color: #fca5a5;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: #ef4444;
  color: #ffffff;
}

