/* ============================================================
   QUICK TICKET — Design System
   Modern, clean SaaS aesthetic. White + emerald green.
   ============================================================ */

/* ---- Tokens ---------------------------------------------- */
:root {
  /* Color */
  --bg:           #F5F5F5;
  --surface:      #FFFFFF;
  --surface-alt:  #F0FAF4;
  --border:       #E5E7EB;
  --border-focus: #10B981;

  --ink:          #111827;
  --ink-secondary:#6B7280;
  --ink-tertiary: #9CA3AF;

  --green:        #10B981;
  --green-hover:  #059669;
  --green-light:  #D1FAE5;
  --green-glow:   rgba(16, 185, 129, 0.12);

  --red:          #EF4444;
  --red-light:    #FEE2E2;
  --gold:         #F59E0B;
  --gold-light:   #FEF3C7;

  /* Type */
  --font-display: 'Plus Jakarta Sans', -apple-system, system-ui, sans-serif;
  --font-body:    'Plus Jakarta Sans', -apple-system, system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', 'Courier New', monospace;

  /* Scale */
  --s-1:  0.25rem;
  --s-2:  0.5rem;
  --s-3:  0.75rem;
  --s-4:  1rem;
  --s-5:  1.5rem;
  --s-6:  2rem;
  --s-7:  3rem;
  --s-8:  4rem;
  --s-9:  6rem;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 9999px;

  /* Shadow */
  --shadow-sm:    0 1px 2px rgba(0,0,0,0.04);
  --shadow-card:  0 1px 3px rgba(0,0,0,0.06), 0 4px 16px -2px rgba(0,0,0,0.06);
  --shadow-lg:    0 4px 24px -4px rgba(0,0,0,0.10);
  --shadow-green: 0 4px 14px -3px rgba(16,185,129,0.35);
}

/* ---- Reset ----------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-weight: 400;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green); text-decoration: none; font-weight: 500; transition: color 0.15s ease; }
a:hover { color: var(--green-hover); }

/* ---- Typography ------------------------------------------ */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.mono { font-family: var(--font-mono); letter-spacing: 0.02em; }
.label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-secondary);
}

/* ---- Layout ---------------------------------------------- */
.shell {
  max-width: 64rem;
  margin: 0 auto;
  padding: var(--s-5) var(--s-4);
}
@media (min-width: 768px) { .shell { padding: var(--s-7) var(--s-5); } }

/* ---- Card ------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  box-shadow: var(--shadow-card);
}
@media (min-width: 768px) { .card { padding: var(--s-7); } }

/* ---- Divider --------------------------------------------- */
.divider {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: var(--s-5) 0;
}

/* ---- Badge ----------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: var(--r-full);
  text-transform: uppercase;
}
.badge--green {
  background: var(--green-light);
  color: var(--green-hover);
}
.badge--gray {
  background: var(--bg);
  color: var(--ink-secondary);
  border: 1px solid var(--border);
}
.badge--live {
  background: var(--green-light);
  color: var(--green-hover);
}
.badge--live::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.4); }
}

/* ---- Buttons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-sm);
  transition: all 0.15s ease;
  user-select: none;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--green);
  color: #FFFFFF;
  box-shadow: var(--shadow-green);
}
.btn--primary:hover {
  background: var(--green-hover);
  box-shadow: 0 4px 18px -3px rgba(16,185,129,0.45);
}

.btn--secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--border);
}
.btn--secondary:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--surface-alt);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-secondary);
}
.btn--ghost:hover { color: var(--green); background: var(--surface-alt); }

.btn--danger {
  background: transparent;
  color: var(--red);
  border: 1.5px solid var(--red-light);
}
.btn--danger:hover { background: var(--red-light); }

.btn--block { width: 100%; }
.btn--lg { padding: var(--s-4) var(--s-6); font-size: 1rem; }

/* Option buttons (poll/quiz voting) */
.btn--option {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--border);
  text-align: left;
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  font-weight: 500;
  width: 100%;
}
.btn--option:hover {
  border-color: var(--green);
  background: var(--surface-alt);
}
.btn--option.selected {
  border-color: var(--green);
  background: var(--surface-alt);
  color: var(--green-hover);
  box-shadow: 0 0 0 3px var(--green-glow);
}

/* Activity type selector pills */
.btn--type {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  flex: 1;
  min-width: 100px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-secondary);
}
.btn--type:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--surface-alt);
}
.btn--type.selected {
  border-color: var(--green);
  background: var(--surface-alt);
  color: var(--green-hover);
  box-shadow: 0 0 0 3px var(--green-glow);
}
.btn--type .type-icon { font-size: 1.75rem; }

/* ---- Form controls --------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-secondary);
}
.input, .select, .textarea {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--s-3) var(--s-4);
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
}
.input::placeholder { color: var(--ink-tertiary); }
.input--code {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
  padding: var(--s-4);
}

/* ---- Room code display ----------------------------------- */
.room-code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(2.5rem, 8vw, 5rem);
  letter-spacing: 0.15em;
  color: var(--ink);
  line-height: 1;
}
.room-code-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  margin-bottom: var(--s-1);
}

/* ---- Bar chart (poll/quiz results) ----------------------- */
.bar-item { margin-bottom: var(--s-4); }
.bar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--s-2);
}
.bar-label { font-weight: 500; font-size: 0.95rem; }
.bar-count {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-secondary);
}
.bar-track {
  height: 12px;
  background: var(--bg);
  border-radius: var(--r-full);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: var(--r-full);
  width: 0%;
  transition: width 0.5s cubic-bezier(.2,.8,.2,1);
}
.bar-fill--correct { background: var(--gold); }
.bar-fill--wrong   { background: var(--border); }

/* ---- Emoji reaction surface ------------------------------ */
.emoji-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-3);
  margin-top: var(--s-4);
}
.emoji-btn {
  font-size: 2.25rem;
  padding: var(--s-4) 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  transition: all 0.12s ease;
}
.emoji-btn:hover {
  background: var(--surface-alt);
  border-color: var(--green);
  transform: scale(1.05);
}
.emoji-btn:active { transform: scale(0.95); }

/* Floating reactions on host view */
.emoji-float {
  position: absolute;
  font-size: 3rem;
  pointer-events: none;
  animation: floatUp 2.4s ease-out forwards;
}
@keyframes floatUp {
  0%   { transform: translateY(0) scale(0.6); opacity: 0; }
  15%  { transform: translateY(-20px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-300px) scale(0.9); opacity: 0; }
}

/* ---- Confirmation / success state ------------------------ */
.check-circle {
  width: 64px; height: 64px;
  background: var(--green-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--s-4);
}
.check-circle svg {
  width: 32px; height: 32px;
  stroke: var(--green);
  stroke-width: 2.5;
  fill: none;
}

/* ---- Logo ------------------------------------------------ */
.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
}
.logo:hover { color: var(--ink); }
.logo-icon {
  width: 28px; height: 28px;
  background: var(--green);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 0.85rem;
}

/* ---- Page-load reveal ------------------------------------ */
.reveal { opacity: 0; transform: translateY(12px); animation: reveal 0.5s ease-out forwards; }
.reveal-1 { animation-delay: 0.05s; }
.reveal-2 { animation-delay: 0.12s; }
.reveal-3 { animation-delay: 0.2s; }
.reveal-4 { animation-delay: 0.3s; }
@keyframes reveal {
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Utility --------------------------------------------- */
.center      { text-align: center; }
.stack > * + * { margin-top: var(--s-4); }
.stack-lg > * + * { margin-top: var(--s-6); }
.row         { display: flex; gap: var(--s-3); align-items: center; }
.row--wrap   { flex-wrap: wrap; }
.spread      { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); }
.muted       { color: var(--ink-secondary); }
.caption     { color: var(--ink-tertiary); font-size: 0.85rem; }
.hidden      { display: none !important; }

/* ---- Projector mode -------------------------------------- */
@media (min-width: 1200px) {
  .projector .room-code { font-size: 6rem; }
  .projector .bar-label { font-size: 1.3rem; }
  .projector .bar-track { height: 20px; }
  .projector h1 { font-size: 3rem; }
}

/* ---- Mobile refinements ---------------------------------- */
@media (max-width: 480px) {
  .card { padding: var(--s-5); }
  .btn--lg { padding: var(--s-3) var(--s-5); font-size: 0.95rem; }
  .emoji-pad { gap: var(--s-2); }
  .emoji-btn { font-size: 1.75rem; padding: var(--s-3) 0; }
  .spread { flex-direction: column; align-items: stretch; }
  .room-code { font-size: 2.5rem; }
  .btn--type { min-width: 80px; padding: var(--s-3) var(--s-3); }
  .btn--type .type-icon { font-size: 1.4rem; }
}

/* ---- Loading spinner ------------------------------------- */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-6) 0;
}

/* ---- Error state ----------------------------------------- */
.error-state {
  text-align: center;
  padding: var(--s-6) 0;
}
.error-icon {
  width: 56px; height: 56px;
  background: var(--red-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--s-4);
  font-size: 1.5rem;
}
.error-state h2 {
  font-size: 1.1rem;
  margin-bottom: var(--s-2);
}
.error-state p {
  color: var(--ink-secondary);
  margin-bottom: var(--s-5);
  max-width: 28ch;
  margin-inline: auto;
}

/* ---- Empty / waiting state ------------------------------- */
.empty-state {
  text-align: center;
  padding: var(--s-7) 0;
}
.empty-icon {
  width: 64px; height: 64px;
  background: var(--surface-alt);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--s-4);
  font-size: 1.75rem;
}
.empty-state p {
  color: var(--ink-secondary);
}

/* ---- QR Modal -------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
  padding: var(--s-4);
}
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s-7);
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: scaleIn 0.25s ease-out;
  position: relative;
}
.modal-close {
  position: absolute;
  top: var(--s-4);
  right: var(--s-4);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--ink-tertiary);
  transition: all 0.15s ease;
}
.modal-close:hover {
  background: var(--bg);
  color: var(--ink);
}
.qr-container {
  background: white;
  padding: var(--s-5);
  border-radius: var(--r-md);
  display: inline-block;
  margin: var(--s-4) 0;
}
.qr-container canvas, .qr-container img {
  display: block;
  margin: 0 auto;
}

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

/* ---- Vote option staggered reveal ------------------------ */
.vote-option-reveal {
  opacity: 0;
  transform: translateY(8px);
  animation: reveal 0.4s ease-out forwards;
}
.vote-option-reveal:nth-child(1) { animation-delay: 0.05s; }
.vote-option-reveal:nth-child(2) { animation-delay: 0.1s; }
.vote-option-reveal:nth-child(3) { animation-delay: 0.15s; }
.vote-option-reveal:nth-child(4) { animation-delay: 0.2s; }
.vote-option-reveal:nth-child(5) { animation-delay: 0.25s; }
.vote-option-reveal:nth-child(6) { animation-delay: 0.3s; }

/* ---- Confirmation animation ------------------------------ */
.confirm-reveal {
  animation: confirmPop 0.5s cubic-bezier(.2, .8, .2, 1.2) forwards;
}
@keyframes confirmPop {
  0% { opacity: 0; transform: scale(0.8); }
  60% { transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

/* ---- Session closed banner ------------------------------- */
.closed-banner {
  background: var(--ink);
  color: white;
  text-align: center;
  padding: var(--s-3) var(--s-4);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

/* ---- Copy button for room code --------------------------- */
.copy-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--green);
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  transition: all 0.15s ease;
}
.copy-btn:hover {
  background: var(--surface-alt);
}
.copy-btn.copied {
  color: var(--green-hover);
}

/* ---- Short answer response feed -------------------------- */
.response-feed {
  max-height: 500px;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.response-card {
  background: var(--bg);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin-bottom: var(--s-3);
  animation: slideIn 0.3s ease-out;
  position: relative;
}
.response-card--hidden {
  background: var(--bg);
  border: 1.5px dashed var(--border);
  color: var(--ink-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.response-card--hidden:hover {
  border-color: var(--green);
  background: var(--surface-alt);
}
.response-card--hidden .response-text {
  filter: blur(6px);
  user-select: none;
}
.response-text {
  font-size: 1rem;
  line-height: 1.5;
  word-break: break-word;
}
.response-meta {
  font-size: 0.75rem;
  color: var(--ink-tertiary);
  margin-top: var(--s-2);
}
.reveal-btn {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--green);
  margin-top: var(--s-2);
}
.reveal-btn:hover { color: var(--green-hover); }

.reveal-all-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-alt);
  border-radius: var(--r-sm);
}
.reveal-all-bar p {
  font-size: 0.85rem;
  color: var(--ink-secondary);
}

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

/* ---- Short answer text input (student side) -------------- */
.short-answer-area {
  position: relative;
}
.short-answer-input {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  font-size: 1rem;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.short-answer-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
}
.char-count {
  position: absolute;
  bottom: var(--s-3);
  right: var(--s-4);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-tertiary);
}
.char-count--warn { color: var(--red); }

/* ---- Create another button ------------------------------- */
.create-another {
  margin-top: var(--s-5);
  text-align: center;
}
