/* === Reset & Base === */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

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

:root {
  --bg: #040308;
  --surface: #0e0c14;
  --surface-hover: #16131f;
  --border: #1e1a2a;
  --text: #e4e6ed;
  --text-muted: #7b7d8e;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --success: #00b894;
  --success-dim: rgba(0, 184, 148, 0.12);
  --warning: #fdcb6e;
  --danger: #e17055;
  --focus-bg: #120e22;
  --answered-bg: rgba(0, 184, 148, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
}

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
}

/* === Particles Canvas === */
#particles-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

/* === Hero / Header === */
.hero {
  text-align: center;
  padding: 48px 0 32px;
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: -1px;
}

.accent {
  color: var(--accent-light);
}

.amp {
  color: #fff;
}

/* === Footer === */
.site-footer {
  text-align: center;
  padding: 32px 0 16px;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
  opacity: 0.5;
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--accent-light);
}

.tagline {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-top: 8px;
}

header#session-header {
  padding: 24px 0 16px;
}

header#session-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.speaker-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.speaker-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.speaker-name {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

/* Badge-label: non-interactive label (not a button) */
.badge-label {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: none;
}

/* === Cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
}

/* === Forms === */
label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

input[type="text"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.char-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* === Image upload === */
.image-upload {
  margin-bottom: 16px;
}

.image-upload-area {
  display: flex;
  align-items: center;
  gap: 16px;
}

.image-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface-hover);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color 0.2s;
}

.image-preview:hover {
  border-color: var(--accent);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-placeholder {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
  line-height: 1.3;
}

.image-upload input[type="file"] {
  display: none;
}

.image-upload-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #5a4bd6;
  box-shadow: 0 0 16px rgba(108, 92, 231, 0.25);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-small {
  padding: 8px 14px;
  font-size: 0.85rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.btn-small:active {
  transform: scale(0.96);
}

.btn-text {
  background: none;
  color: var(--text-muted);
  padding: 8px 0;
  font-size: 0.9rem;
  margin-top: 12px;
}

.btn-text:hover {
  color: var(--text);
}

.btn-large {
  padding: 14px 32px;
  font-size: 1.1rem;
}

/* === Links section === */
.session-title-display {
  color: var(--accent-light);
  font-size: 1.05rem;
  margin-bottom: 20px;
}

.link-group {
  margin-bottom: 16px;
}

.link-group label {
  font-size: 0.85rem;
}

.hint {
  color: var(--text-muted);
  font-weight: 400;
}

.link-box {
  display: flex;
  gap: 8px;
}

.link-box input {
  flex: 1;
  margin-bottom: 0;
  font-size: 0.85rem;
}

.link-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.help-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.link-actions a {
  flex: 1;
}

/* === QR Code === */
/* QR card slide animation */
.qr-card {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  border-color: transparent;
  transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.3s ease,
              padding 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              margin-bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.3s ease;
}

.qr-card.qr-open {
  max-height: 400px;
  opacity: 1;
  padding: 24px;
  margin-bottom: 20px;
  border-color: var(--border);
}

.qr-section {
  text-align: center;
  margin: 24px 0 16px;
  padding: 24px;
  background: #fff;
  border-radius: var(--radius);
}

.qr-section canvas {
  display: block;
  margin: 0 auto;
}

.qr-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 12px;
}

/* === Questions List === */
.questions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.question-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.question-card.slide-in {
  animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.question-card.question-focused {
  border-color: var(--accent);
  background: var(--focus-bg);
}

.question-card.question-answered {
  opacity: 0.5;
  background: var(--answered-bg);
  border-color: var(--success);
  border-style: dashed;
}

.question-card.question-hidden {
  opacity: 0.4;
}

.question-content {
  flex: 1;
  min-width: 0;
}

.question-text {
  font-size: 1rem;
  line-height: 1.5;
  word-break: break-word;
}

.question-answered .question-text {
  text-decoration: line-through;
  text-decoration-color: var(--success);
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.question-nickname {
  font-weight: 600;
  color: var(--accent-light);
}

.upvote-count-inline {
  color: var(--success);
  font-weight: 600;
}

.question-count {
  color: var(--text-muted);
  font-weight: 400;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 1rem;
}

/* === Answered check === */
.answered-check {
  color: var(--success);
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* === Upvote Button === */
.upvote-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  min-width: 48px;
  flex-shrink: 0;
  font-family: inherit;
}

.upvote-btn:hover:not(.upvoted) {
  border-color: var(--success);
  color: var(--success);
}

.upvote-btn.upvoted {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-dim);
  cursor: default;
  animation: upvoteBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.upvote-icon {
  font-size: 0.85rem;
  transition: transform 0.2s;
}

.upvote-btn:not(.upvoted):hover .upvote-icon {
  transform: translateY(-2px);
}

.upvote-count {
  font-size: 0.9rem;
  font-weight: 700;
}

/* === Speaker Actions === */
.speaker-card {
  flex-wrap: wrap;
}

.question-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.btn-action {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-action:active {
  transform: scale(0.94);
}

.btn-focus {
  border-color: var(--accent);
  color: var(--accent-light);
}

.btn-focus:hover {
  background: var(--accent);
  color: #fff;
}

.btn-unfocus {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn-answer {
  border-color: var(--success);
  color: var(--success);
}

.btn-answer:hover {
  background: var(--success);
  color: #fff;
}

.btn-hide {
  border-color: var(--warning);
  color: var(--warning);
}

.btn-hide:hover {
  background: var(--warning);
  color: var(--bg);
}

.btn-restore {
  border-color: var(--success);
  color: var(--success);
}

.btn-restore:hover {
  background: var(--success);
  color: #fff;
}

.btn-delete {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-delete:hover {
  background: var(--danger);
  color: #fff;
}

/* === Status Badges === */
.status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-active {
  background: rgba(0, 184, 148, 0.15);
  color: var(--success);
}

.status-focused {
  background: rgba(108, 92, 231, 0.2);
  color: var(--accent-light);
}

.status-answered {
  background: var(--success-dim);
  color: var(--success);
}

.status-hidden {
  background: rgba(253, 203, 110, 0.15);
  color: var(--warning);
}

/* === Filter Bar === */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-filter {
  padding: 6px 16px;
  font-size: 0.85rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-filter.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-filter:hover:not(.active) {
  border-color: var(--accent);
  color: var(--accent-light);
}

/* === Focus Overlay (Speaker) === */
.focus-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 32px;
  animation: fadeIn 0.4s ease;
}

.focus-content {
  text-align: center;
  max-width: 900px;
}

.focus-question-text {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 24px;
  color: var(--text);
}

/* Typewriter cursor for focus mode */
.focus-question-text .typewriter-cursor {
  display: inline-block;
  width: 3px;
  height: 1em;
  background: var(--accent-light);
  margin-left: 4px;
  animation: blink 0.7s step-end infinite;
  vertical-align: text-bottom;
}

.focus-meta {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 40px;
  animation: fadeIn 0.6s ease 0.3s both;
}

.focus-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  animation: fadeIn 0.6s ease 0.5s both;
}

/* === Focused Banner (Audience) === */
.focused-banner {
  background: var(--focus-bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  text-align: center;
  animation: pulse 2s infinite;
}

.focused-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-light);
  margin-bottom: 8px;
}

.focused-text {
  font-size: 1.2rem;
  font-weight: 600;
}

.focused-author {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* === Nickname & Error === */
.nickname-display {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 12px;
}

.nickname-display strong {
  color: var(--accent-light);
}

.error-message {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 10px;
  padding: 10px;
  background: rgba(225, 112, 85, 0.1);
  border-radius: var(--radius-sm);
  animation: fadeIn 0.3s ease;
}

.question-form-card {
  margin-bottom: 20px;
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes upvoteBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.2) translateY(-4px); }
  50% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(108, 92, 231, 0); }
}

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

/* === Swipe-to-edit/delete (audience) === */
.swipe-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: 0;
}

.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.swipe-bg-delete {
  justify-content: flex-end;
  background: var(--danger);
  color: #fff;
}

.swipe-bg-edit {
  justify-content: flex-start;
  background: var(--accent);
  color: #fff;
}

.swipe-wrapper .question-card {
  position: relative;
  z-index: 1;
  transition: transform 0.05s linear;
  touch-action: pan-y;
  margin-bottom: 0;
  will-change: transform;
}

.swipe-wrapper .question-card.snapping {
  transition: transform 0.45s cubic-bezier(0.22, 1.8, 0.50, 1);
}

.swipe-wrapper .question-card.swiped-away {
  transition: transform 0.3s ease-in, opacity 0.3s ease-in;
  opacity: 0;
}

/* Swipe hint */
.swipe-hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.6;
  padding: 6px 0 2px;
  animation: fadeIn 0.5s ease 1s both;
}

.swipe-hint .hint-arrows {
  display: inline-block;
  animation: swipeHintPulse 2s ease-in-out 1.5s 3;
}

@keyframes swipeHintPulse {
  0%, 100% { transform: translateX(0); opacity: 0.6; }
  25% { transform: translateX(-4px); opacity: 1; }
  75% { transform: translateX(4px); opacity: 1; }
}

/* Inline edit mode */
.question-card.editing .question-content {
  flex: 1;
}

.edit-area {
  width: 100%;
  min-height: 60px;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 8px;
  line-height: 1.5;
}

.edit-area:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.3);
}

.edit-actions {
  display: flex;
  gap: 8px;
}

.edit-actions .btn {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.edit-vote-warning {
  font-size: 0.75rem;
  color: var(--warning);
  margin-top: 4px;
}

/* === Desktop/Projector === */
@media (min-width: 768px) {
  .container {
    padding: 24px;
  }

  .hero {
    padding: 64px 0 40px;
  }

  .hero h1 {
    font-size: 3.2rem;
  }

  .question-actions {
    flex-shrink: 0;
    flex-wrap: nowrap;
  }

  .speaker-card {
    flex-wrap: nowrap;
  }
}

/* Speaker body - wider container for projector use */
.speaker-body .container {
  max-width: 900px;
}
