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

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background:
    radial-gradient(circle at 18% 8%, rgba(15, 82, 186, 0.22), transparent 42%),
    radial-gradient(circle at 85% 82%, rgba(255, 255, 255, 0.08), transparent 40%),
    var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

@media (max-width: 960px) {
  html,
  body {
    overflow: auto;
    min-height: 100dvh;
  }
}

/* ---------- VARIABLES (DARK DEFAULT) ---------- */
:root {
  --bg: #05070c;
  --surface: rgba(0, 0, 0, 0.46);
  --panel: rgba(0, 0, 0, 0.46);
  --panel-light: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.18);

  --text: #ffffff;
  --text-dim: #c9d1e3;
  --text-primary: #ffffff;
  --text-secondary: #c9d1e3;

  --accent: #0F52BA;
  --accent-glow: rgba(15, 82, 186, 0.42);
  --accent-secondary: #000000;
  --accent-alert: #ffffff;
  --gradient-primary: linear-gradient(135deg, rgba(15, 82, 186, 0.44) 0%, rgba(11, 58, 132, 0.4) 52%, rgba(0, 0, 0, 0.34) 100%);
  --gradient-accent: linear-gradient(135deg, rgba(255, 255, 255, 0.24) 0%, rgba(170, 179, 196, 0.22) 52%, rgba(0, 0, 0, 0.3) 100%);

  --radius: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
}

/* Sapphire / Monochrome Shift Animation */
@keyframes rainbow-shift {
  0% {
    filter: saturate(1) brightness(1);
  }
  50% {
    filter: saturate(1.08) brightness(1.06) contrast(1.02);
  }
  100% {
    filter: saturate(1) brightness(1);
  }
}

/* Apply rainbow animation to body */
html, body {
  animation: rainbow-shift 50s linear infinite;
}

/* Typography */
h1, h2, h3 {
  font-weight: 600;
  color: var(--text-primary);
}

p {
  line-height: 1.6;
  color: var(--text-secondary);
}

.site-footer {
  margin-top: 40px;
  padding: 24px 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.site-footer-content {
  max-width: 820px;
  margin: 0 auto;
  text-align: center;
}

.site-footer-content p {
  margin: 0 0 10px;
}

.site-footer-content p:last-child {
  margin-bottom: 0;
}

.site-footer-rights {
  font-size: 13px;
  color: var(--text-dim);
}

.site-footer a {
  color: var(--text-primary);
}

/* ------------------------------
   CHAT-SPECIFIC STYLES
---------------- */

.page {
  --site-transition-ms: 140ms;
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--site-transition-ms) ease-out, transform var(--site-transition-ms) ease-out;
  animation: page-enter var(--site-transition-ms) ease-out;
}

/* Respect reduced-motion users */
@media (prefers-reduced-motion: reduce) {
  .page,
  .page.page-leave {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }

  .page-transition {
    animation: none !important;
  }
}

.page.page-leave {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.page.page-no-motion,
.page.page-no-motion.page-leave {
  transition: none !important;
  animation: none !important;
  transform: none !important;
  opacity: 1 !important;
}

@keyframes page-enter {
  from {
    transform: translateY(6px);
    opacity: 0.96;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ---------- GLOBAL SAPPHIRE THEME OVERRIDES ---------- */
.btn-primary,
.hero-btn-primary,
#send-btn,
.mode-badge,
.nav-link.active,
.settings-toast-success {
  background: var(--gradient-primary) !important;
  color: #ffffff !important;
}

.btn-secondary,
.hero-btn-secondary,
.btn-danger,
.settings-toast-error,
.settings-toast-info {
  background: var(--gradient-accent) !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.38) !important;
}

.mode-content h4,
.tech-item strong,
.home-footer a,
.site-footer a,
.feature-spec-text,
.use-case-tag,
.setting-label,
.section-title,
.logo {
  color: #ffffff !important;
}

.mode-section,
.settings-section,
.mode-card,
.feature-spec,
.home-intro,
.modes-footer,
.home-footer,
.site-footer,
#chat-area,
#sidebar,
.chat-dropdown,
.settings-dropdown-menu {
  border-color: rgba(255, 255, 255, 0.22) !important;
}

.mode-section:hover,
.mode-card:hover,
.settings-section:hover,
.use-case-tag:hover,
.chat-dropdown-item.is-active,
.settings-dropdown-item.is-active {
  border-color: rgba(15, 82, 186, 0.5) !important;
  box-shadow: 0 0 18px rgba(15, 82, 186, 0.24) !important;
}

.divider,
#mode-indicator {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, rgba(15, 82, 186, 0.46) 36%, rgba(84, 132, 207, 0.5) 58%, rgba(255, 255, 255, 0.34) 78%, rgba(0, 0, 0, 0) 100%) !important;
}

body.page-high-contrast {
  --text: #ffffff;
  --text-dim: #f5f8ff;
  --text-primary: #ffffff;
  --text-secondary: #f0f4ff;
  --border: rgba(255, 255, 255, 0.34);
}

body.page-high-contrast .mode-section,
body.page-high-contrast .settings-section,
body.page-high-contrast .mode-card,
body.page-high-contrast .feature-spec,
body.page-high-contrast .home-intro,
body.page-high-contrast .modes-footer,
body.page-high-contrast .home-footer,
body.page-high-contrast .site-footer,
body.page-high-contrast #chat-area,
body.page-high-contrast #sidebar,
body.page-high-contrast .chat-dropdown,
body.page-high-contrast .settings-dropdown-menu {
  border-color: rgba(255, 255, 255, 0.34) !important;
}

body.page-reduce-glass .mode-section,
body.page-reduce-glass .settings-section,
body.page-reduce-glass .mode-card,
body.page-reduce-glass .feature-spec,
body.page-reduce-glass .home-intro,
body.page-reduce-glass .modes-footer,
body.page-reduce-glass .home-footer,
body.page-reduce-glass .site-footer,
body.page-reduce-glass #chat-area,
body.page-reduce-glass #sidebar,
body.page-reduce-glass .chat-dropdown,
body.page-reduce-glass .settings-dropdown-menu {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body.age-gate-locked {
  overflow: hidden !important;
}

.age-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 6, 18, 0.9);
  backdrop-filter: blur(10px);
}

.age-gate-modal {
  width: min(560px, 96vw);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(6, 10, 22, 0.94);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  padding: 24px;
}

.age-gate-modal h2 {
  margin: 0 0 8px;
  color: var(--text-primary);
  font-size: 24px;
}

.age-gate-copy {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 14px;
}

.age-gate-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.age-gate-wheel {
  display: grid;
  gap: 6px;
}

.age-gate-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.age-gate-wheel select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text-primary);
  padding: 10px;
}

.age-gate-turnstile {
  grid-column: 1 / -1;
  min-height: 66px;
  display: flex;
  align-items: center;
}

.age-gate-challenge {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.age-human-prompt {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}

#age-human-answer {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text-primary);
  padding: 10px;
}

.age-gate-status {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--text-dim);
  min-height: 20px;
}

.age-gate-submit {
  grid-column: 1 / -1;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  background: var(--gradient-primary);
  color: #fff;
  font-weight: 600;
  padding: 12px 14px;
  cursor: pointer;
}

.age-gate-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .age-gate-form {
    grid-template-columns: 1fr;
  }
}