/* ===================================================
   Digital Footprint Assessment — Shared Styles
   Mobile-first, system font stack
   =================================================== */

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

:root {
  --primary: #1a56db;
  --primary-dark: #1341b0;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);

  /* Dashboard dark theme vars */
  --dash-bg: #0f172a;
  --dash-card: #1e293b;
  --dash-text: #f1f5f9;
  --dash-muted: #94a3b8;
  --dash-border: #334155;
  --dash-highlight: #38bdf8;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* =====================
   Layout
   ===================== */

.container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
}

.page-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.page-header .container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.logo-mark {
  width: 28px;
  height: 28px;
  background: var(--primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.logo-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.main-content {
  padding: 24px 0 60px;
}

/* =====================
   Cards
   ===================== */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

/* =====================
   Privacy Policy / ToS
   ===================== */

.policy-wrapper {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}

.policy-intro {
  padding: 20px 20px 0;
}

.policy-intro h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.policy-intro p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.policy-scroll-area {
  max-height: 55vh;
  overflow-y: auto;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: #374151;
  line-height: 1.7;
  -webkit-overflow-scrolling: touch;
}

.policy-scroll-area::-webkit-scrollbar {
  width: 4px;
}
.policy-scroll-area::-webkit-scrollbar-track {
  background: var(--bg);
}
.policy-scroll-area::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.policy-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.policy-section:last-child {
  border-bottom: none;
}

.policy-section h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}

.policy-section h2.section-num {
  display: flex;
  align-items: center;
  gap: 6px;
}

.policy-section h2.section-num::before {
  content: attr(data-num);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--border);
  border-radius: 50%;
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
  flex-shrink: 0;
}

.policy-section p {
  margin-bottom: 8px;
}

.policy-section p:last-child {
  margin-bottom: 0;
}

.policy-section ul {
  padding-left: 18px;
  margin: 6px 0;
}

.policy-section ul li {
  margin-bottom: 3px;
}

/* Research clause — looks the same as other sections (no highlighting) */
.policy-section.research-clause {
  /* deliberately unstyled — same as every other section */
}

/* Consent footer */
.policy-footer {
  padding: 16px 20px;
}

.consent-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.consent-checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.consent-checkbox-row label {
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1.5;
}

/* =====================
   Buttons
   ===================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
}

/* Scroll hint */
.scroll-hint {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.scroll-hint .arrow {
  animation: bounce 1.5s infinite;
  display: inline-block;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

/* =====================
   Study Page
   ===================== */

.study-header {
  text-align: center;
  padding: 28px 0 20px;
}

.study-header .badge {
  display: inline-block;
  background: #dbeafe;
  color: #1e40af;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.study-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 8px;
}

.study-header p {
  font-size: 14px;
  color: var(--muted);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-box .stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  margin-bottom: 4px;
}

.stat-box .stat-label {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 18px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 6px;
  width: 10px;
  height: 10px;
  background: var(--primary);
  border-radius: 50%;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-item h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.timeline-item p {
  font-size: 13px;
  color: var(--muted);
}

.highlight-box {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13.5px;
  color: #92400e;
  margin-bottom: 16px;
}

.highlight-box strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

.clause-quote {
  background: #f0fdf4;
  border-left: 4px solid #059669;
  padding: 12px 14px;
  font-size: 13px;
  color: #065f46;
  font-style: italic;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 12px 0;
}

/* Submission loading */
.submitting-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =====================
   Dashboard
   ===================== */

body.dashboard-body {
  background: var(--dash-bg);
  color: var(--dash-text);
}

.dashboard-header {
  background: var(--dash-card);
  border-bottom: 1px solid var(--dash-border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.dashboard-header h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--dash-text);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(239,68,68,0.15);
  color: #f87171;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 20px;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: #ef4444;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.dashboard-content {
  padding: 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 600px) {
  .stats-strip {
    grid-template-columns: repeat(5, 1fr);
  }
}

.stat-card {
  background: var(--dash-card);
  border: 1px solid var(--dash-border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--dash-highlight);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card .label {
  font-size: 11px;
  color: var(--dash-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--dash-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  margin-top: 24px;
}

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

@media (min-width: 700px) {
  .participants-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1000px) {
  .participants-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.participant-card {
  background: var(--dash-card);
  border: 1px solid var(--dash-border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 12px;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.participant-card .p-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.participant-card .p-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--dash-highlight);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.participant-card .p-time {
  font-size: 10px;
  color: var(--dash-muted);
}

.data-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  gap: 8px;
}

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

.data-row .key {
  color: var(--dash-muted);
  flex-shrink: 0;
  font-size: 11px;
  width: 110px;
}

.data-row .val {
  color: var(--dash-text);
  font-size: 11px;
  text-align: right;
  word-break: break-all;
  min-width: 0;
}

.val.yes { color: #4ade80; }
.val.no  { color: #f87171; }
.val.warn { color: #fbbf24; }

/* Data group labels in cards */
.data-group-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dash-highlight);
  margin-top: 10px;
  margin-bottom: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--dash-border);
}

.data-group-label:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* Compact highlights row */
.p-highlights {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.p-hl {
  text-align: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--dash-border);
  border-radius: 6px;
  padding: 8px 4px;
}

.p-hl-val {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--dash-text);
  line-height: 1.2;
  margin-bottom: 2px;
  word-break: break-all;
}

.p-hl-val.yes { color: #4ade80; }
.p-hl-val.no  { color: #f87171; }

.p-hl-label {
  display: block;
  font-size: 9px;
  color: var(--dash-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Expand button */
.p-expand-btn {
  display: block;
  width: 100%;
  background: rgba(56,189,248,0.08);
  border: 1px solid rgba(56,189,248,0.2);
  border-radius: 6px;
  color: var(--dash-highlight);
  font-size: 11px;
  font-weight: 600;
  padding: 7px 0;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}

.p-expand-btn:hover {
  background: rgba(56,189,248,0.15);
}

.p-expand-arrow {
  font-size: 9px;
  margin-left: 4px;
}

/* Expanded detail area */
.p-detail {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--dash-border);
}

.participant-card.expanded {
  border-color: var(--dash-highlight);
}

/* Debrief panel */
.debrief-panel {
  background: var(--dash-card);
  border: 1px solid var(--dash-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 24px;
}

.debrief-panel .debrief-header {
  background: rgba(56,189,248,0.1);
  border-bottom: 1px solid var(--dash-border);
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--dash-highlight);
  display: flex;
  align-items: center;
  gap: 8px;
}

.debrief-panel .debrief-body {
  padding: 16px;
  font-size: 13px;
  color: var(--dash-muted);
  line-height: 1.7;
}

.debrief-panel .debrief-body h3 {
  color: var(--dash-text);
  font-size: 14px;
  margin-top: 16px;
  margin-bottom: 6px;
}

.debrief-panel .debrief-body h3:first-child {
  margin-top: 0;
}

.clause-highlight {
  background: rgba(251,191,36,0.1);
  border: 1px solid rgba(251,191,36,0.3);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: #fde68a;
  font-style: italic;
  line-height: 1.6;
  margin: 10px 0;
}

.clause-highlight mark {
  background: rgba(251,191,36,0.35);
  color: #fef3c7;
  padding: 1px 3px;
  border-radius: 2px;
}

.collected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.collected-tags .tag {
  background: rgba(56,189,248,0.1);
  border: 1px solid rgba(56,189,248,0.25);
  color: var(--dash-highlight);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--dash-muted);
}

.empty-state .empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 14px;
}

/* Password gate */
.password-gate {
  position: fixed;
  inset: 0;
  background: var(--dash-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.password-box {
  background: var(--dash-card);
  border: 1px solid var(--dash-border);
  border-radius: 12px;
  padding: 32px 28px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.password-box h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--dash-text);
  margin-bottom: 6px;
}

.password-box p {
  font-size: 13px;
  color: var(--dash-muted);
  margin-bottom: 20px;
}

.password-box input {
  width: 100%;
  background: var(--dash-bg);
  border: 1px solid var(--dash-border);
  border-radius: var(--radius);
  color: var(--dash-text);
  padding: 10px 14px;
  font-size: 15px;
  margin-bottom: 12px;
  text-align: center;
  letter-spacing: 0.1em;
  outline: none;
}

.password-box input:focus {
  border-color: var(--dash-highlight);
}

.password-box .btn-dash {
  width: 100%;
  background: var(--dash-highlight);
  color: var(--dash-bg);
  border: none;
  border-radius: var(--radius);
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.password-error {
  font-size: 12px;
  color: #f87171;
  margin-top: 8px;
  min-height: 16px;
}

/* =====================
   Utilities
   ===================== */

.text-muted { color: var(--muted); font-size: 13px; }
.mb-0 { margin-bottom: 0; }
.mt-8 { margin-top: 8px; }

@media (min-width: 480px) {
  .policy-scroll-area { max-height: 60vh; }
  .study-header h1 { font-size: 24px; }
}
