/* ══════════════════════════════════════════════════════════════════
   REAPER SQUAD — Survey Modal (F-08)
   Fullscreen inline overlay — no iframe, no page navigation.
   All selectors prefixed with sm- to prevent collisions.
   ══════════════════════════════════════════════════════════════════ */

/* ── Design tokens (mirrors survey.html :root) ─────────────────── */
#surveyModal {
  --sm-purple:       #7c6fff;
  --sm-purple-dark:  #5a4de6;
  --sm-purple-glow:  rgba(124,111,255,0.35);
  --sm-red:          #ff3c3c;
  --sm-gold:         #f5c842;
  --sm-bg:           #0a0a0f;
  --sm-bg2:          #0f0f1a;
  --sm-bg3:          #13131f;
  --sm-card:         #16162a;
  --sm-card2:        #1c1c33;
  --sm-text:         #e8e6ff;
  --sm-text-dim:     #7a78a0;
  --sm-border:       rgba(124,111,255,0.2);
  --sm-border-active:rgba(124,111,255,0.7);
}

/* ── Modal Shell ──────────────────────────────────────────────── */
#surveyModal {
  position: fixed;
  inset: 0;
  z-index: 99000; /* above everything except reaperSplash (99999) */
  background: var(--sm-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  /* Hidden by default */
  opacity: 0;
  pointer-events: none;
  transform: translateY(40px) scale(0.98);
  transition: opacity 0.45s cubic-bezier(.4,0,.2,1),
              transform 0.45s cubic-bezier(.4,0,.2,1);
}

#surveyModal.sm-visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

#surveyModal.sm-exit {
  opacity: 0;
  transform: translateY(-30px) scale(1.01);
  pointer-events: none;
}

/* ── Background layers (same as survey.html) ─────────────────── */
#surveyModal .sm-bg-layer {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 20% 10%, rgba(124,111,255,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 80%, rgba(90,77,230,0.06) 0%, transparent 70%);
}

#surveyModal .sm-skull-bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.03;
  display: flex; align-items: center; justify-content: center;
  font-size: 60vw; line-height: 1; user-select: none;
  animation: smSkullPulse 6s ease-in-out infinite;
}
@keyframes smSkullPulse { 0%,100%{opacity:.02} 50%{opacity:.05} }

#surveyModal .sm-grid-lines {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(124,111,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,111,255,0.04) 1px, transparent 1px);
  background-size: 50px 50px;
}

/* ── Scrollable inner area ────────────────────────────────────── */
#surveyModal .sm-scroll {
  position: relative; z-index: 1;
  width: 100%; height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 80px;
  box-sizing: border-box;
}

/* ── Header ───────────────────────────────────────────────────── */
#surveyModal .sm-survey-header {
  text-align: center; margin-bottom: 24px; padding-top: 16px;
  width: 100%; max-width: 600px;
}
#surveyModal .sm-skull-icon {
  font-size: 44px; display: block; margin-bottom: 8px;
  animation: smFloat 3s ease-in-out infinite;
}
@keyframes smFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }

#surveyModal .sm-survey-header h1 {
  font-family: 'Cinzel Decorative', cursive;
  font-size: clamp(16px, 5vw, 26px);
  color: var(--sm-purple);
  text-shadow: 0 0 20px var(--sm-purple-glow);
  letter-spacing: 2px; margin-bottom: 4px;
}
#surveyModal .sm-survey-header p {
  color: var(--sm-text-dim); font-size: 12px; letter-spacing: 1px;
  font-family: 'Share Tech Mono', monospace;
}

/* ── Progress ─────────────────────────────────────────────────── */
#surveyModal .sm-progress-container {
  width: 100%; max-width: 600px; margin-bottom: 20px;
}
#surveyModal .sm-progress-info {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
#surveyModal .sm-progress-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; color: var(--sm-text-dim); letter-spacing: 1px;
}
#surveyModal .sm-progress-count {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; color: var(--sm-purple);
}
#surveyModal .sm-progress-track {
  width: 100%; height: 4px; background: var(--sm-card2);
  border-radius: 2px; overflow: hidden;
}
#surveyModal .sm-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sm-purple-dark), var(--sm-purple));
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
  position: relative;
}
#surveyModal .sm-progress-fill::after {
  content:''; position:absolute; right:0; top:50%;
  transform:translateY(-50%);
  width:8px; height:8px; border-radius:50%;
  background: var(--sm-purple);
  box-shadow: 0 0 10px var(--sm-purple);
}
#surveyModal .sm-progress-dots {
  display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap;
}
#surveyModal .sm-pdot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sm-card2); transition: all 0.3s;
}
#surveyModal .sm-pdot.sm-done   { background: var(--sm-purple); box-shadow: 0 0 6px var(--sm-purple-glow); }
#surveyModal .sm-pdot.sm-active { background: var(--sm-gold);   box-shadow: 0 0 6px rgba(245,200,66,0.5); animation: smDotPulse 1s infinite; }
@keyframes smDotPulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.4)} }

/* ── Step Card ────────────────────────────────────────────────── */
#surveyModal .sm-step-card {
  width: 100%; max-width: 600px;
  background: var(--sm-card);
  border: 1px solid var(--sm-border);
  border-radius: 16px;
  padding: 24px 20px;
  box-shadow: 0 0 40px rgba(124,111,255,0.08);
  position: relative; overflow: hidden;
}
#surveyModal .sm-step-card::before {
  content:''; position:absolute; top:0; left:0; right:0; height:2px;
  background: linear-gradient(90deg, transparent, var(--sm-purple), transparent);
}
@keyframes smSlideIn {
  from { opacity:0; transform:translateY(20px) scale(0.98); }
  to   { opacity:1; transform:translateY(0)    scale(1);    }
}

#surveyModal .sm-step-number {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px; color: var(--sm-purple); letter-spacing: 2px;
  margin-bottom: 6px; text-transform: uppercase;
}
#surveyModal .sm-step-q {
  font-family: 'Cinzel Decorative', cursive;
  font-size: clamp(13px, 3.5vw, 17px);
  color: var(--sm-text); margin-bottom: 6px; line-height: 1.4;
}
#surveyModal .sm-step-sub {
  font-size: 11px; color: var(--sm-text-dim); margin-bottom: 20px;
  font-family: 'Share Tech Mono', monospace; letter-spacing: 0.5px;
}

/* ── Input Styles ─────────────────────────────────────────────── */
#surveyModal .sm-input-unit {
  display: flex; align-items: center;
  background: var(--sm-bg2); border: 1px solid var(--sm-border);
  border-radius: 10px; overflow: hidden;
}
#surveyModal .sm-input-unit:focus-within {
  border-color: var(--sm-purple);
  box-shadow: 0 0 0 3px var(--sm-purple-glow);
}
#surveyModal .sm-unit-badge {
  padding: 0 14px; color: var(--sm-purple); font-size: 11px;
  font-family: 'Share Tech Mono', monospace; letter-spacing: 1px;
  border-left: 1px solid var(--sm-border);
  display: flex; align-items: center; align-self: stretch;
}
#surveyModal .sm-input-row { display: flex; gap: 12px; }
#surveyModal .sm-input-group { flex: 1; }
#surveyModal .sm-input-label {
  font-size: 10px; color: var(--sm-text-dim); letter-spacing: 1px;
  font-family: 'Share Tech Mono', monospace; margin-bottom: 5px; display: block;
}

/* ── Option Cards ─────────────────────────────────────────────── */
#surveyModal .sm-options-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
#surveyModal .sm-options-grid.sm-col2 { grid-template-columns: 1fr 1fr; }
#surveyModal .sm-opt-card {
  background: var(--sm-bg2); border: 1px solid var(--sm-border);
  border-radius: 12px; padding: 14px 12px;
  cursor: pointer; transition: all 0.2s; text-align: center;
  position: relative; overflow: hidden;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
#surveyModal .sm-opt-card:active { transform: scale(0.97); }
#surveyModal .sm-opt-card.sm-selected {
  border-color: var(--sm-purple);
  background: rgba(124,111,255,0.12);
  box-shadow: 0 0 0 1px var(--sm-purple), 0 0 20px var(--sm-purple-glow);
}
#surveyModal .sm-opt-icon  { font-size: 26px; margin-bottom: 5px; display: block; }
#surveyModal .sm-opt-label { font-family: 'Rajdhani', sans-serif; font-size: 12px; font-weight: 700; color: var(--sm-text); letter-spacing: 0.5px; }
#surveyModal .sm-opt-sub   { font-size: 9px; color: var(--sm-text-dim); margin-top: 2px; font-family: 'Share Tech Mono', monospace; }
#surveyModal .sm-opt-card.sm-selected .sm-opt-label { color: var(--sm-purple); }
#surveyModal .sm-opt-check {
  position: absolute; top: 6px; right: 6px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--sm-purple); display: none;
  align-items: center; justify-content: center;
  font-size: 9px; color: white;
}
#surveyModal .sm-opt-card.sm-selected .sm-opt-check { display: flex; }

/* ── Multi-select tags ────────────────────────────────────────── */
#surveyModal .sm-tag-grid { display: flex; flex-wrap: wrap; gap: 8px; }
#surveyModal .sm-tag {
  padding: 8px 13px; border-radius: 8px;
  background: var(--sm-bg2); border: 1px solid var(--sm-border);
  font-size: 12px; font-weight: 600; color: var(--sm-text-dim);
  cursor: pointer; transition: all 0.2s; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#surveyModal .sm-tag.sm-selected {
  background: rgba(124,111,255,0.15);
  border-color: var(--sm-purple); color: var(--sm-purple);
}

/* ── Slider ───────────────────────────────────────────────────── */
#surveyModal .sm-slider-container { padding: 8px 0; }
#surveyModal .sm-rs-slider {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 3px; outline: none; cursor: pointer;
  background: var(--sm-card2);
}
#surveyModal .sm-rs-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--sm-purple); cursor: pointer;
  box-shadow: 0 0 10px var(--sm-purple-glow);
  border: 2px solid var(--sm-bg);
}
#surveyModal .sm-slider-labels {
  display: flex; justify-content: space-between; margin-top: 8px;
}
#surveyModal .sm-slider-labels span {
  font-family: 'Share Tech Mono', monospace; font-size: 9px; color: var(--sm-text-dim);
}
#surveyModal .sm-slider-value {
  text-align: center; margin-top: 12px;
  font-family: 'Cinzel Decorative', cursive; font-size: 22px; color: var(--sm-purple);
  text-shadow: 0 0 15px var(--sm-purple-glow);
}

/* ── Toggle ───────────────────────────────────────────────────── */
#surveyModal .sm-toggle-row {
  display: flex; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--sm-border);
}
#surveyModal .sm-toggle-opt {
  flex: 1; padding: 14px; text-align: center; cursor: pointer;
  background: var(--sm-bg2); transition: all 0.2s; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#surveyModal .sm-toggle-opt:first-child { border-radius: 11px 0 0 11px; }
#surveyModal .sm-toggle-opt:last-child  { border-radius: 0 11px 11px 0; }
#surveyModal .sm-toggle-opt.sm-selected { background: var(--sm-purple); color: white; font-weight: 700; }
#surveyModal .sm-t-icon  { font-size: 18px; display: block; margin-bottom: 3px; }
#surveyModal .sm-t-label { font-size: 12px; font-weight: 700; letter-spacing: 1px; }

/* ── Days picker ──────────────────────────────────────────────── */
#surveyModal .sm-days-picker {
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
}
#surveyModal .sm-day-btn {
  flex: 0 0 calc(14% - 4px); min-width: 38px; aspect-ratio: 1;
  border-radius: 9px; background: var(--sm-bg2);
  border: 1px solid var(--sm-border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; cursor: pointer;
  transition: all 0.2s; user-select: none; -webkit-tap-highlight-color: transparent;
  color: var(--sm-text);
}
#surveyModal .sm-day-btn.sm-selected {
  background: rgba(124,111,255,0.15);
  border-color: var(--sm-purple); color: var(--sm-purple);
  box-shadow: 0 0 12px var(--sm-purple-glow);
}

/* ── Textarea ─────────────────────────────────────────────────── */
#surveyModal .sm-rs-textarea {
  width: 100%; background: var(--sm-bg2);
  border: 1px solid var(--sm-border); border-radius: 10px;
  padding: 14px 16px; color: var(--sm-text);
  font-family: 'Rajdhani', sans-serif; font-size: 15px; font-weight: 500;
  outline: none; resize: none; min-height: 80px;
  transition: border 0.2s, box-shadow 0.2s;
}
#surveyModal .sm-rs-textarea:focus {
  border-color: var(--sm-purple);
  box-shadow: 0 0 0 3px var(--sm-purple-glow);
}

/* ── Error ────────────────────────────────────────────────────── */
#surveyModal .sm-err-msg {
  font-family: 'Share Tech Mono', monospace; font-size: 10px;
  color: var(--sm-red); margin-top: 8px; letter-spacing: 1px;
  display: none;
}
#surveyModal .sm-err-msg.sm-show { display: block; animation: smShake 0.3s; }
@keyframes smShake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }

/* ── Nav Buttons ──────────────────────────────────────────────── */
#surveyModal .sm-nav-row {
  display: flex; gap: 12px; margin-top: 24px;
  width: 100%; max-width: 600px;
}
#surveyModal .sm-btn-back {
  padding: 13px 20px; border-radius: 10px;
  background: transparent; border: 1px solid var(--sm-border);
  color: var(--sm-text-dim); font-family: 'Rajdhani', sans-serif;
  font-size: 13px; font-weight: 700; letter-spacing: 1px;
  cursor: pointer; transition: all 0.2s; -webkit-tap-highlight-color: transparent;
}
#surveyModal .sm-btn-back:hover { border-color: var(--sm-purple); color: var(--sm-purple); }

#surveyModal .sm-btn-next {
  flex: 1; padding: 15px; border-radius: 10px;
  background: linear-gradient(135deg, var(--sm-purple-dark), var(--sm-purple));
  border: none; color: white;
  font-family: 'Cinzel Decorative', cursive;
  font-size: 12px; letter-spacing: 1px;
  cursor: pointer; transition: all 0.2s; -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 20px var(--sm-purple-glow);
  position: relative; overflow: hidden;
}
#surveyModal .sm-btn-next:hover { transform: translateY(-1px); box-shadow: 0 6px 25px rgba(124,111,255,0.5); }
#surveyModal .sm-btn-next:active { transform: scale(0.98); }

#surveyModal .sm-skip-link {
  text-align: center; margin-top: 8px;
  font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--sm-text-dim);
  cursor: pointer; letter-spacing: 1px; width: 100%; max-width: 600px;
}
#surveyModal .sm-skip-link:hover { color: var(--sm-purple); }

/* ── AI Loading ───────────────────────────────────────────────── */
#surveyModal .sm-ai-loading {
  display: none; text-align: center; padding: 40px 20px;
  width: 100%; max-width: 500px;
}
#surveyModal .sm-loading-skull {
  font-size: 56px; display: block; margin-bottom: 16px;
  animation: smFloat 2s ease-in-out infinite;
}
#surveyModal .sm-loading-text {
  font-family: 'Cinzel Decorative', cursive;
  font-size: 18px; color: var(--sm-text); margin-bottom: 6px; letter-spacing: 1px;
}
#surveyModal .sm-loading-sub {
  font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--sm-text-dim);
  letter-spacing: 1px; animation: smBlink 1.5s infinite;
}
@keyframes smBlink { 0%,100%{opacity:1} 50%{opacity:0.3} }
#surveyModal .sm-loading-bar {
  width: 180px; height: 3px; background: var(--sm-card2);
  border-radius: 2px; margin: 18px auto 0; overflow: hidden;
}
#surveyModal .sm-loading-bar-fill {
  height: 100%; background: var(--sm-purple);
  animation: smLoadFill 2s ease-in-out infinite;
}
@keyframes smLoadFill {
  0%   { width:0%;   margin-left:0 }
  50%  { width:100%; margin-left:0 }
  100% { width:0%;   margin-left:100% }
}

/* ── Character Reveal ─────────────────────────────────────────── */
#surveyModal .sm-char-reveal {
  display: none; width: 100%; max-width: 600px;
  animation: smSlideIn 0.5s cubic-bezier(.4,0,.2,1);
}
#surveyModal .sm-char-card {
  background: var(--sm-card); border: 1px solid var(--sm-border);
  border-radius: 20px; padding: 28px 20px; text-align: center;
  position: relative; overflow: hidden;
}
#surveyModal .sm-char-card::before {
  content:''; position:absolute; inset:0;
  background: radial-gradient(ellipse at 50% 0%, rgba(124,111,255,0.15) 0%, transparent 70%);
  pointer-events: none;
}
#surveyModal .sm-char-avatar {
  width: 110px; height: 110px; border-radius: 50%;
  margin: 0 auto 18px;
  background: var(--sm-card2); border: 3px solid var(--sm-purple);
  display: flex; align-items: center; justify-content: center;
  font-size: 58px;
  box-shadow: 0 0 30px var(--sm-purple-glow);
  animation: smFloat 3s ease-in-out infinite;
}
#surveyModal .sm-char-emoji-row { font-size: 20px; margin-bottom: 8px; }
#surveyModal .sm-char-title {
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px; color: var(--sm-text-dim); letter-spacing: 3px; margin-bottom: 6px;
}
#surveyModal .sm-char-name {
  font-family: 'Cinzel Decorative', cursive;
  font-size: clamp(18px, 5vw, 24px); color: var(--sm-text);
  margin-bottom: 4px; text-shadow: 0 0 20px var(--sm-purple-glow);
}
#surveyModal .sm-char-archetype {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px; color: var(--sm-purple); letter-spacing: 3px; margin-bottom: 14px;
}
#surveyModal .sm-char-story {
  font-size: 13px; color: var(--sm-text-dim); line-height: 1.6;
  margin-bottom: 20px; font-style: italic;
}
#surveyModal .sm-char-stats {
  display: flex; gap: 10px; justify-content: center; margin-bottom: 16px;
}
#surveyModal .sm-stat-box {
  flex: 1; background: var(--sm-bg2);
  border: 1px solid var(--sm-border); border-radius: 10px; padding: 12px 8px; text-align: center;
}
#surveyModal .sm-stat-val {
  display: block; font-family: 'Cinzel Decorative', cursive;
  font-size: 18px; color: var(--sm-purple); text-shadow: 0 0 10px var(--sm-purple-glow);
}
#surveyModal .sm-stat-lbl {
  display: block; font-family: 'Share Tech Mono', monospace;
  font-size: 8px; color: var(--sm-text-dim); letter-spacing: 1px; margin-top: 4px;
}
#surveyModal .sm-char-trait { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 24px; }
#surveyModal .sm-trait-tag {
  padding: 5px 12px; border-radius: 6px;
  background: rgba(124,111,255,0.1); border: 1px solid var(--sm-border);
  font-size: 11px; color: var(--sm-purple); font-weight: 600;
}
#surveyModal .sm-btn-enter {
  width: 100%; padding: 17px; border-radius: 12px;
  background: linear-gradient(135deg, var(--sm-purple-dark), var(--sm-purple));
  border: none; color: white;
  font-family: 'Cinzel Decorative', cursive; font-size: 14px; letter-spacing: 2px;
  cursor: pointer; transition: all 0.2s;
  box-shadow: 0 4px 30px var(--sm-purple-glow);
}
#surveyModal .sm-btn-enter:hover { transform: translateY(-2px); box-shadow: 0 8px 35px rgba(124,111,255,0.55); }
#surveyModal .sm-btn-enter:active { transform: scale(0.98); }

/* ── Mobile tweaks ────────────────────────────────────────────── */
@media (max-width: 400px) {
  #surveyModal .sm-step-card { padding: 18px 14px; }
  #surveyModal .sm-options-grid { grid-template-columns: 1fr 1fr; }
  #surveyModal .sm-days-picker { gap: 4px; }
}
