/* Mobile-first styles for the ECG cath-lab activation quiz */

* { box-sizing: border-box; }

html, body { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f6f8;
  color: #1a1a1a;
  min-height: 100vh;
  min-height: 100dvh;
  font-size: 16px;
}

a { color: #2b6cb0; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.hidden { display: none !important; }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem 1rem;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  box-shadow: 0 2px 16px rgba(0,0,0,0.06);
}

h1 {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  line-height: 1.25;
}
.subhead {
  margin: 1.25rem 0 0.35rem;
  font-size: 1rem;
  color: #2a3340;
}
.lede { color: #2a3340; line-height: 1.5; margin: 0.25rem 0 1rem; }
.small { font-size: 0.92rem; color: #4a5560; line-height: 1.45; }
.citation {
  font-size: 0.85rem; color: #4a5560; line-height: 1.5;
  border-left: 3px solid #2b6cb0; padding: 0.3rem 0 0.3rem 0.75rem;
  margin: 0.5rem 0 1.25rem; background: #f8fafc;
}
.paper-thumb {
  display:block; width:100%; max-width:100%; height:auto;
  border-radius:8px; margin: 0.25rem 0 0.75rem;
  border:1px solid #e3e8ee;
}

/* ---------- Forms ---------- */
form label {
  display: block;
  margin: 0.85rem 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: #2a3340;
}

input, select, button {
  font-family: inherit;
}

input, select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.75rem 0.8rem;
  border: 1px solid #cfd6de;
  border-radius: 8px;
  font-size: 16px; /* prevents iOS zoom on focus */
  background: #fff;
}

input:focus, select:focus {
  outline: none;
  border-color: #2b6cb0;
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

button {
  padding: 0.85rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: #2b6cb0;
  color: #fff;
  transition: background 0.15s;
  min-height: 44px;           /* iOS tap target */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:hover { background: #234e7f; }
button.secondary { background: #6b7683; }
button.secondary:hover { background: #4f5864; }

form button[type=submit] {
  width: 100%;
  margin-top: 1rem;
  padding: 0.95rem;
}

/* ---------- Consent screen ---------- */
/* Scrollable body + footer pinned to viewport bottom */
#consent {
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
#consent .card {
  flex: 1 1 auto;
  overflow-y: auto;
  margin: 0.75rem auto;
  padding: 1.25rem 1rem calc(1.25rem + 90px); /* leave room for sticky footer */
  border-radius: 12px;
  width: calc(100% - 1rem);
  max-width: 760px;
}
#consent ul {
  color: #4a5560;
  line-height: 1.5;
  padding-left: 1.2rem;
  margin: 0.25rem 0 0.75rem;
}
.sticky-footer {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e3e8ee;
  padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom, 0));
  box-shadow: 0 -4px 18px rgba(0,0,0,0.06);
  z-index: 10;
}
.sticky-footer .checkbox { margin: 0 0 0.65rem; }
label.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: #2a3340;
  font-size: 0.95rem;
  line-height: 1.35;
}
label.checkbox input {
  width: auto;
  margin: 0.2rem 0 0;
  transform: scale(1.2);
  flex-shrink: 0;
}
#consent-continue {
  width: 100%;
  min-height: 48px;
  font-size: 1rem;
}
#consent-continue:disabled {
  background: #a6b0bb;
  cursor: not-allowed;
}

@media (min-width: 640px) {
  #consent .card {
    margin: 1.25rem auto;
    padding: 2rem 2rem calc(2rem + 90px);
    width: 100%;
  }
  .sticky-footer {
    padding: 1rem 1.5rem calc(1rem + env(safe-area-inset-bottom, 0));
  }
  .sticky-footer #consent-continue {
    max-width: 760px;
    margin: 0 auto;
    display: block;
  }
}

/* ---------- Quiz screen ---------- */
.quiz-header {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 0.75rem;
}
.progress {
  font-size: 0.9rem;
  color: #4a5560;
  margin-bottom: 0.4rem;
}
.progress-bar {
  width: 100%;
  height: 6px;
  background: #e3e8ee;
  border-radius: 3px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  background: #2b6cb0;
  width: 0%;
  transition: width 0.3s;
}

.ecg-wrap {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 0.75rem;
  background: #fff;
  border-radius: 12px;
  padding: 0.5rem;
  box-shadow: 0 2px 16px rgba(0,0,0,0.06);
  display: flex;
  justify-content: center;
  overflow: hidden;
}

/* Image: fit-to-width, never overflow viewport height */
#ecg-img {
  max-width: 100%;
  max-height: calc(100vh - 260px);
  max-height: calc(100dvh - 260px);
  height: auto;
  width: auto;
  display: block;
  object-fit: contain;
  touch-action: pinch-zoom;   /* allow pinch to zoom in */
}

/* (Legacy PDF iframe — no longer used; kept hidden for robustness) */
#ecg-pdf { display: none !important; }

.prompt {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 16px rgba(0,0,0,0.06);
  text-align: center;
  position: sticky;
  bottom: 0;
  z-index: 5;
}
.question {
  font-size: 1rem;
  font-weight: 500;
  margin: 0 0 0.75rem;
  color: #1a1a1a;
  line-height: 1.4;
}
.answer-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  justify-content: center;
}
.answer-buttons button {
  width: 100%;
  padding: 0.95rem 0.5rem;
  font-size: 1rem;
}
.btn-yes { background: #2f855a; }
.btn-yes:hover { background: #22603f; }
.btn-no  { background: #c53030; }
.btn-no:hover  { background: #942121; }

/* ---------- Submit / misc ---------- */
#submit-status { margin-top: 1rem; font-size: 0.95rem; }
#send-link-btn { width: 100%; padding: 0.95rem; }
#summary { color: #4a5560; margin: 1rem 0 1.5rem; }
#results button { margin-right: 0.5rem; }

/* ---------- Tablet / desktop refinements ---------- */
@media (min-width: 640px) {
  .screen { padding: 1.5rem 1rem; }
  .card   { padding: 2rem; }
  h1 { font-size: 1.6rem; }
  .ecg-wrap { padding: 1rem; }
  #ecg-img {
    max-height: calc(100vh - 280px);
    max-height: calc(100dvh - 280px);
  }
  .answer-buttons { gap: 1rem; }
  .answer-buttons button { min-width: 180px; }
  .prompt {
    position: static;
    padding: 1.25rem 1.5rem;
    max-width: 760px;              /* tighter than the ECG above on desktop */
  }
  .question { font-size: 1.1rem; }
}

/* ---------- Landscape phones: compress vertical space ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  .quiz-header { margin-bottom: 0.4rem; }
  .progress { font-size: 0.8rem; margin-bottom: 0.25rem; }
  .ecg-wrap { padding: 0.25rem; margin-bottom: 0.4rem; }
  .prompt { padding: 0.5rem 0.75rem; }
  .question { font-size: 0.9rem; margin-bottom: 0.4rem; }
  .answer-buttons button { padding: 0.6rem 0.5rem; min-height: 40px; }
  #ecg-img {
    max-height: calc(100vh - 160px);
    max-height: calc(100dvh - 160px);
  }
}
