/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #1a1a1a;
  color: #1d1d1f;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
}

/* Background image lives in ::before so we can fade its opacity independently */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('assets/htsm_small.jpg');
  background-size: cover;
  background-position: center;
  opacity: 0.10;
  transition: opacity 1.2s ease;
  z-index: -1;
}
/* Reveal background more once user has submitted or poll is closed */
body.bg-reveal::before { opacity: 0.30; }

#app { width: 100%; max-width: 640px; }

/* ── Screens ── */
.screen { display: flex; flex-direction: column; gap: 1.25rem; }
.hidden { display: none !important; }

/* ── Status / spinner ── */
#status-screen { align-items: center; gap: 1rem; }
.spinner {
  width: 40px; height: 40px;
  border: 4px solid #d1d1d6;
  border-top-color: #0071e3;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Poll card ── */
#poll-screen {
  background: #fff;
  border-radius: 18px;
  padding: 2rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

h1 { font-size: 1.5rem; font-weight: 600; line-height: 1.3; }

/* ── Timer (poll screen + submitted screen) ── */
#timer-wrap, #submitted-timer-wrap {
  display: flex; flex-direction: column; gap: 0.35rem;
}
#timer-bar, #timer-bar-submitted {
  width: 100%; height: 8px;
  background: #e5e5ea; border-radius: 4px; overflow: hidden;
}
#timer-fill, #timer-fill-submitted {
  height: 100%; background: #0071e3; border-radius: 4px;
  transition: width 1s linear, background-color 0.5s;
}
#timer-fill.warning, #timer-fill-submitted.warning { background: #ff9f0a; }
#timer-fill.danger,  #timer-fill-submitted.danger  { background: #ff3b30; }
#timer-label, #timer-label-submitted {
  font-size: 0.85rem; color: #6e6e73; text-align: right;
}
#submitted-timer-wrap { width: 100%; margin-top: 0.5rem; }

/* ── Options ── */
#options-wrap { display: flex; flex-direction: column; gap: 0.6rem; }

.option-label {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 2px solid #e5e5ea; border-radius: 12px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
  font-size: 1rem;
  user-select: none; /* prevent text highlight on fast clicks */
}
.option-label:hover { border-color: #0071e3; background: #f0f7ff; }
.option-label input[type="radio"],
.option-label input[type="checkbox"] {
  accent-color: #0071e3; width: 18px; height: 18px;
  cursor: pointer; pointer-events: none; /* div handles clicks */
}

/* Selected state */
.option-label.selected { border-color: #0071e3; background: #e8f0fe; }

textarea#freeform {
  width: 100%; min-height: 120px;
  padding: 0.85rem 1rem;
  border: 2px solid #e5e5ea; border-radius: 12px;
  font-size: 1rem; font-family: inherit; resize: vertical;
  outline: none; transition: border-color 0.15s;
}
textarea#freeform:focus { border-color: #0071e3; }

/* ── Submit button ── */
#submit-btn {
  margin-top: 0.5rem;
  padding: 0.85rem 2rem;
  background: #0071e3; color: #fff;
  border: none; border-radius: 980px;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  align-self: flex-start;
}
#submit-btn:hover { background: #0077ed; }
#submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Submitted / closed / waiting ── */
#submitted-screen, #closed-screen, #waiting-screen {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 18px;
  padding: 2.5rem 2rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}
.check {
  font-size: 3rem;
  color: #34c759;
}
h2 { font-size: 1.4rem; font-weight: 600; }

/* ── Book quote (submitted screen) ── */
#book-quote-wrap, #book-quote-wrap-closed {
  width: 100%;
  animation: fadeIn 0.6s ease both;
  animation-delay: 0.3s;
  opacity: 0;
}
@keyframes fadeIn { to { opacity: 1; } }

.book-quote-divider {
  width: 48px; height: 1px;
  background: #d1d1d6;
  margin: 1.25rem auto;
}
#book-quote-text, #book-quote-text-closed {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.95rem;
  font-style: italic;
  line-height: 1.65;
  color: #3a3a3c;
  margin: 0 0 0.5rem;
  quotes: "\201C" "\201D";
}
#book-quote-text::before,
#book-quote-text-closed::before { content: open-quote; }
#book-quote-text::after,
#book-quote-text-closed::after  { content: close-quote; }
#book-quote-attr, #book-quote-attr-closed {
  font-size: 0.75rem;
  color: #8e8e93;
  margin: 0 0 0.6rem;
}
#book-quote-next, #book-quote-next-closed {
  background: none; border: none;
  color: #0071e3; font-size: 0.78rem;
  cursor: pointer; padding: 0;
  letter-spacing: 0.02em;
  transition: opacity 0.15s;
}
#book-quote-next:hover,
#book-quote-next-closed:hover { opacity: 0.7; }
