/* ============================================================
   FamilyReady App — Chapter/Quest UI
   Self-contained design tokens (overrides slideshow theme.css)
   ============================================================ */

/* App-specific design tokens — override slideshow defaults */
:root {
  --bg: #ffffff;
  --bg-alt: #f5f5f5;
  --fg: #1a1a18;
  --fg-muted: #5c5a54;
  --fg-faint: #9a958c;
  --accent: #1a3a2f;
  --accent-hover: #244d41;
  --border: #e0e0e0;
  --white: #ffffff;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Source Sans 3', system-ui, sans-serif;
}

/* ===================== RESET ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; height: auto; overflow: auto; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  height: auto;
  overflow: auto;
  cursor: default;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ===================== LAYOUT ===================== */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.app-nav__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.app-nav__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--fg);
  font-weight: 600;
  font-size: 1rem;
}
.app-nav__logo span { font-family: var(--font-display); font-weight: 600; }
.app-nav__links {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.app-nav__progress {
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-weight: 600;
  background: var(--bg-alt);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ===================== APP CONTENT ===================== */
.app-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ===================== CHAPTER HEADER ===================== */
.chapter-header {
  text-align: center;
  margin-bottom: 56px;
}
.chapter-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: #e8f5f0;
  padding: 5px 14px;
  border-radius: 20px;
  margin-bottom: 20px;
}
.chapter-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 600;
  color: var(--accent);
  line-height: 1.15;
  margin-bottom: 16px;
}
.chapter-header p {
  font-size: 1.05rem;
  color: var(--fg-muted);
  max-width: 520px;
  margin: 0 auto;
}

/* ===================== PROGRESS BAR ===================== */
.progress-track {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 48px;
}
.progress-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.progress-step__dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--fg-faint);
  transition: all 0.3s ease;
}
.progress-step--done .progress-step__dot {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}
.progress-step--active .progress-step__dot {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
  box-shadow: 0 0 0 4px #e8f5f0;
}
.progress-step__label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--fg-faint);
  text-align: center;
  max-width: 70px;
}
.progress-step--done .progress-step__label,
.progress-step--active .progress-step__label { color: var(--fg-muted); }

/* Connector line between steps */
.progress-step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: calc(50% + 16px);
  top: 15px;
  width: calc(100% - 32px);
  height: 2px;
  background: var(--border);
}
.progress-step { position: relative; }

/* ===================== QUEST GRID ===================== */
.quest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.quest-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
}
.quest-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  border-color: #e8f5f0;
}
.quest-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.quest-card__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--fg);
}
.quest-card__desc {
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.5;
}
.quest-card__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.quest-card__status {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fg-faint);
  display: flex;
  align-items: center;
  gap: 4px;
}
.quest-card--done .quest-card__status { color: var(--accent); }
.quest-card--done .quest-card__icon { background: #e8f5f0; }

/* Check overlay for completed quests */
.quest-card--done::before {
  content: '';
  position: absolute;
  top: 16px;
  right: 16px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: 14px;
  background-repeat: no-repeat;
  background-position: center;
}

/* ===================== QUEST FORM VIEW ===================== */
.quest-view {
  max-width: 640px;
  margin: 0 auto;
}
.quest-view__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-decoration: none;
  margin-bottom: 32px;
  transition: color 0.15s;
}
.quest-view__back:hover { color: var(--fg); }
.quest-view__header {
  margin-bottom: 40px;
}
.quest-view__icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 20px;
}
.quest-view__title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
  line-height: 1.2;
}
.quest-view__subtitle {
  font-size: 1rem;
  color: var(--fg-muted);
}

/* ===================== FORM FIELDS ===================== */
.fields { display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg);
}
.field__hint { font-weight: 400; color: var(--fg-muted); }
.field input,
.field textarea,
.field select {
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--fg);
  background: var(--white);
  transition: border-color 0.15s;
  outline: none;
}
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 100px; }
.field input::placeholder,
.field textarea::placeholder { color: var(--fg-faint); }
.field--error input,
.field--error textarea { border-color: #c0392b; }
.field__error { font-size: 0.8rem; color: #c0392b; }

/* Checkbox group */
.checkbox-group { display: flex; flex-direction: column; gap: 10px; }
.checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.checkbox-item:hover { border-color: #e8f5f0; background: var(--bg-alt); }
.checkbox-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}
.checkbox-item__text { font-size: 0.95rem; color: var(--fg); line-height: 1.5; }
.checkbox-item__hint { font-size: 0.82rem; color: var(--fg-muted); margin-top: 2px; }

/* ===================== FORM SECTION HEADERS ===================== */
.form-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}
.form-section + .form-section { margin-top: 16px; }
.form-section__title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}
.form-section__desc {
  font-size: 0.88rem;
  color: var(--fg-muted);
  margin-bottom: 20px;
}

/* ===================== FORM ACTIONS ===================== */
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
  flex-wrap: wrap;
}
.form-actions--sticky {
  position: sticky;
  bottom: 20px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: var(--white);
}
.btn-primary:hover { background: #122620; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--bg-alt);
  color: var(--fg);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-alt); color: var(--fg); }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-lg { padding: 16px 32px; font-size: 1.05rem; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: var(--fg);
  color: var(--white);
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.toast--visible { opacity: 1; transform: translateY(0); }
.toast--success { background: var(--accent); }
.toast--error { background: #c0392b; }

/* ===================== MODAL ===================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal--open { display: flex; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26,26,24,0.5);
  backdrop-filter: blur(2px);
}
.modal__panel {
  position: relative;
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.15);
  animation: modal-in 0.2s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal__header {
  padding: 24px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal__title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
}
.modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--fg-muted);
  line-height: 1;
  padding: 4px;
}
.modal__close:hover { color: var(--fg); }
.modal__body { padding: 20px 24px; }
.modal__desc { font-size: 0.9rem; color: var(--fg-muted); margin-bottom: 20px; }
.modal__footer {
  padding: 0 24px 24px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.modal__body .field + .field { margin-top: 12px; }
.modal__footer { padding-top: 0; }
.modal__footer .btn { flex: 1; }

/* ===================== PENDING INVITES ===================== */
.pending-list {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.pending-list h4 { font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-faint); margin-bottom: 10px; }
.pending-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.pending-item:last-child { border-bottom: none; }
.pending-item__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.pending-item__name { font-size: 0.9rem; font-weight: 600; }
.pending-item__email { font-size: 0.8rem; color: var(--fg-muted); }

/* ===================== COMPLETION BANNER ===================== */
.completion-banner {
  background: linear-gradient(135deg, var(--accent) 0%, #244d41 100%);
  color: var(--white);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  margin-bottom: 32px;
}
.completion-banner__icon {
  font-size: 3rem;
  margin-bottom: 16px;
}
.completion-banner__title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.completion-banner__desc {
  font-size: 1rem;
  opacity: 0.85;
  margin-bottom: 24px;
}
.completion-banner .btn {
  background: var(--white);
  color: var(--accent);
}
.completion-banner .btn:hover { background: var(--bg-alt); }

/* ===================== COMPLETION SUMMARY ===================== */
.completion-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.summary-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
}
.summary-card__icon { font-size: 1.5rem; margin-bottom: 8px; }
.summary-card__count {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}
.summary-card__label { font-size: 0.82rem; color: var(--fg-muted); margin-top: 4px; }

/* ===================== EMPTY / LOADING STATES ===================== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}
.empty-state__icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state__title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}
.empty-state__desc { font-size: 0.95rem; color: var(--fg-muted); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 640px) {
  .app-nav__links .app-nav__progress { display: none; }
  .quest-grid { grid-template-columns: 1fr; }
  .form-section { padding: 20px; }
  .form-actions--sticky { bottom: 0; border-radius: 0; border-top: 1px solid var(--border); }
  .modal__panel { border-radius: 16px 16px 0 0; position: absolute; bottom: 0; left: 0; right: 0; max-width: 100%; }
  .app-container { padding: 32px 16px 80px; }
}