/* ─── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #dbeafe;
  --success:       #16a34a;
  --success-light: #dcfce7;
  --error:         #dc2626;
  --error-light:   #fee2e2;
  --warning:       #d97706;
  --warning-light: #fef3c7;
  --gray-50:       #f9fafb;
  --gray-100:      #f3f4f6;
  --gray-200:      #e5e7eb;
  --gray-400:      #9ca3af;
  --gray-600:      #4b5563;
  --gray-700:      #374151;
  --gray-900:      #111827;
  --radius:        12px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,.12);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.16);
  --transition:    200ms ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.page {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 20px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 24px;
}

.app-logo {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -.5px;
}

.app-logo span { color: var(--gray-700); font-weight: 400; }


/* ─── Session heading ─────────────────────────────────────────────────────── */
.session-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}

.session-desc {
  color: var(--gray-600);
  margin-bottom: 24px;
  font-size: .95rem;
}

.vote-instruction {
  font-size: .9rem;
  color: var(--gray-600);
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--gray-100);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}

/* ─── Candidate cards – list (thesis) ────────────────────────────────────── */
.candidates-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.candidate-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #fff;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.candidate-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.candidate-card:active { transform: scale(.98); }

.candidate-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.candidate-card .check-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--gray-400);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}

.candidate-card.selected .check-icon {
  background: var(--primary);
  border-color: var(--primary);
}

.candidate-card.selected .check-icon::after {
  content: '';
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
  display: block;
}

.candidate-card .card-body { flex: 1; min-width: 0; }

.candidate-card .card-name {
  font-weight: 600;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.candidate-card .card-desc {
  font-size: .82rem;
  color: var(--gray-600);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Photo grid ──────────────────────────────────────────────────────────── */
.candidates-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

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

.photo-card {
  position: relative;
  background: #fff;
  border: 3px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  aspect-ratio: 1;
  -webkit-tap-highlight-color: transparent;
}

.photo-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.photo-card:active { transform: scale(.97); }

.photo-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.3);
  grid-column: span 2;
  aspect-ratio: auto;
}

.photo-card .photo-img-wrap {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  position: relative;
}

.photo-card.selected .photo-img-wrap {
  aspect-ratio: 4/3;
}

.photo-card .photo-img-wrap img,
.photo-card .photo-img-wrap .photo-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-card-desc {
  display: none;
  padding: 8px 10px;
  font-size: .8rem;
  color: var(--gray-600);
  text-align: center;
}

.photo-card.selected .photo-card-desc { display: block; }

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-card .photo-placeholder {
  width: 100%;
  height: 100%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  color: var(--gray-400);
  text-align: center;
  padding: 8px;
}

.photo-card .photo-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  padding: 20px 8px 6px;
  text-align: center;
}

.photo-card .selected-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: var(--primary);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}

.photo-card.selected .selected-badge { display: flex; }

.photo-card .selected-badge::after {
  content: '';
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
  display: block;
}

/* ─── Vote button ─────────────────────────────────────────────────────────── */
.vote-action {
  position: sticky;
  bottom: 16px;
  z-index: 10;
}

.btn-vote {
  width: 100%;
  padding: 16px 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-vote:hover:not(:disabled) { background: var(--primary-dark); }
.btn-vote:active:not(:disabled) { transform: scale(.98); }
.btn-vote:disabled { opacity: .5; cursor: not-allowed; }

.btn-vote.hidden { display: none; }


/* ─── Success screen ─────────────────────────────────────────────────────── */
.success-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem 24px 24px;
  text-align: center;
}

.success-screen.hidden { display: none; }

.success-icon {
  width: 80px;
  height: 80px;
  background: var(--success-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  animation: scaleIn .4s cubic-bezier(.175,.885,.32,1.275);
}

.success-icon svg { color: var(--success); }

.success-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}

.success-subtitle {
  color: var(--gray-600);
  font-size: 1rem;
  max-width: 280px;
}

.success-candidate {
  margin-top: 16px;
  padding: 10px 20px;
  background: var(--success-light);
  color: var(--success);
  border-radius: 8px;
  font-weight: 600;
  font-size: .9rem;
}

/* ─── Error / info banner ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 16px;
}

.alert-error {
  background: var(--error-light);
  color: var(--error);
  border-left: 3px solid var(--error);
}

.alert-warning {
  background: var(--warning-light);
  color: var(--warning);
  border-left: 3px solid var(--warning);
}

/* ─── Loading state ──────────────────────────────────────────────────────── */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  gap: 16px;
  color: var(--gray-600);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ─── Landing page ────────────────────────────────────────────────────────── */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
}

.landing-logo {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.landing-subtitle {
  color: var(--gray-600);
  font-size: 1rem;
  margin-bottom: 48px;
}

.landing-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 360px;
}

.landing-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: #fff;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--gray-900);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
}

.landing-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.landing-card .card-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.landing-card .card-text { text-align: left; }

.landing-card .card-text strong {
  display: block;
  font-size: 1rem;
  font-weight: 700;
}

.landing-card .card-text span {
  font-size: .82rem;
  color: var(--gray-600);
}

.landing-instruction {
  margin-top: 32px;
  font-size: .85rem;
  color: var(--gray-400);
  max-width: 300px;
}

/* ─── Animations ──────────────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.08); opacity: .8; }
}

@keyframes scaleIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

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

.fade-in { animation: fadeIn .3s ease both; }
