/* Prestige - Anonymous Verifiable Voting */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a24;
  --text-primary: #e8e8ed;
  --text-secondary: #8888a0;
  --text-muted: #7a7a90;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --border: #2a2a3a;
  --radius: 8px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

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

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

a {
  color: var(--accent);
  text-decoration: none;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

header .tagline {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card-header {
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.card-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

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

.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card);
}

.btn-block {
  width: 100%;
}

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

.btn-group {
  display: flex;
  gap: 0.5rem;
}

/* Choice List */
.choice-list {
  list-style: none;
}

.choice-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.choice-item:hover {
  border-color: var(--accent);
}

.choice-item.selected {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.choice-item input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
}

.choice-text {
  flex: 1;
}

/* Dynamic choice inputs */
.choices-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.choice-input-row {
  display: flex;
  gap: 0.5rem;
}

.choice-input-row input {
  flex: 1;
}

.choice-input-row .btn-remove {
  padding: 0.5rem 0.75rem;
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
}

.choice-input-row .btn-remove:hover {
  background: rgba(239, 68, 68, 0.1);
}

.btn-add-choice {
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

/* Results */
.result-bar-container {
  margin-bottom: 1rem;
}

.result-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.result-choice {
  font-weight: 500;
}

.result-count {
  color: var(--text-secondary);
}

.result-bar {
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.result-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.5s ease-out;
}

.result-bar-fill.winner {
  background: var(--success);
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  text-transform: uppercase;
}

.badge-voting {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent);
}

.badge-revealing {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.badge-finalized {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

/* Timer */
.timer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.timer-value {
  font-family: monospace;
  font-size: 1rem;
  color: var(--text-primary);
}

/* Verification */
.verification-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  text-align: center;
}

.verification-item {
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.verification-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.verification-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.alert-success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid var(--success);
  color: var(--success);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--warning);
  color: var(--warning);
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
}

.alert-info {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid var(--accent);
  color: var(--accent);
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.5rem;
}

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

/* Share URL */
.share-url {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.share-url input {
  flex: 1;
  font-family: monospace;
  font-size: 0.875rem;
}

.btn-copy {
  white-space: nowrap;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Gate Status */
.gate-info {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.gate-section {
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.gate-section h4 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.gate-type {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.gate-requirements {
  list-style: disc;
  margin-left: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.gate-status {
  margin-top: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.gate-status.status-allowed {
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

.gate-status.status-denied {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

/* Petition */
.petition-progress {
  margin-bottom: 1rem;
}

.progress-bar {
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.signatures-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
}

.signature-item {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.signature-item:last-child {
  border-bottom: none;
}

/* Petition status badge */
.badge-petition {
  background: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

/* Vote Type Label */
.vote-type-label {
  font-size: 0.875rem;
  color: var(--accent);
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: rgba(99, 102, 241, 0.1);
  border-radius: var(--radius);
  text-align: center;
}

/* Approval Voting */
.choice-item.approval-item input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
}

/* Ranked Choice Voting */
.ranked-instructions {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.ranked-available {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.ranked-choice {
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.ranked-choice:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.ranked-choice.hidden {
  display: none;
}

.ranked-selected-label {
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.ranked-selected {
  list-style: none;
  counter-reset: none;
  padding: 0;
}

.ranked-placeholder {
  padding: 1rem;
  background: var(--bg-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
}

.ranked-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.rank-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
}

.ranked-item .choice-text {
  flex: 1;
}

.rank-controls {
  display: flex;
  gap: 0.25rem;
}

.rank-btn {
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.rank-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.rank-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.rank-btn.remove:hover {
  border-color: var(--error);
  color: var(--error);
}

/* Score Voting */
.score-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
}

.score-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.score-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 2rem;
  text-align: right;
}

.score-slider {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  background: var(--bg-primary);
  border-radius: 4px;
  outline: none;
}

.score-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s;
}

.score-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.score-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.score-range {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Ranked Choice Results */
.rounds-container {
  margin-top: 1rem;
}

.round-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.round-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.round-title {
  font-weight: 600;
}

.round-eliminated {
  font-size: 0.75rem;
  color: var(--error);
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 1rem;
  }

  .verification-summary {
    grid-template-columns: 1fr;
  }

  .btn-group {
    flex-direction: column;
  }

  .ranked-available {
    flex-direction: column;
  }

  .ranked-choice {
    text-align: center;
  }
}

/* How Prestige Works (collapsible explainer card) */
.how-it-works-section summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0.25rem 0;
  list-style: none;
}

.how-it-works-section summary::-webkit-details-marker {
  display: none;
}

.how-it-works-section summary::before {
  content: "\25B6";
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.how-it-works-section[open] summary::before {
  transform: rotate(90deg);
}

.how-it-works-steps {
  margin: 1rem 0 0;
  padding-left: 1.25rem;
  counter-reset: how-step;
  list-style: none;
}

.how-it-works-steps li {
  position: relative;
  padding-left: 0.25rem;
  margin-bottom: 0.85rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.55;
  counter-increment: how-step;
}

.how-it-works-steps li::before {
  content: counter(how-step);
  position: absolute;
  left: -1.5rem;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 600;
}

.how-it-works-steps li:last-child {
  margin-bottom: 0;
}

.how-it-works-steps strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* First-run identity notice dismiss button */
#identity-notice {
  display: flex;
  align-items: flex-start;
}

#identity-notice.hidden {
  display: none !important;
}

/* Prevent images from overflowing narrow screens */
img {
  max-width: 100%;
  height: auto;
}

/* Keyboard focus rings — :focus-visible keeps mouse clicks ring-free */
.btn:focus-visible,
.rank-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Inline error text (attached by ui.showInlineError) */
.prestige-inline-error {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 0.4rem;
}

/* Inline banner dismiss button (shared with toast close button) */
.prestige-inline-banner .toast-close,
.toast .toast-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
  opacity: 0.7;
}

.prestige-inline-banner .toast-close:hover,
.toast .toast-close:hover {
  opacity: 1;
}

/* Toasts */
.toast-container {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: calc(100vw - 1.5rem);
  width: 22rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.toast-container.toast-container-visible {
  opacity: 1;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.6);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.45;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(1rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast.toast-leaving {
  opacity: 0;
  transform: translateX(1rem);
}

.toast-message {
  flex: 1;
}

.toast-info {
  border-color: var(--accent);
}

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

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

.toast-error {
  border-color: var(--error);
}

/* Stack toasts full-width on small screens */
@media (max-width: 480px) {
  .toast-container {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
  }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
