/* ============================================================================
   WAIVER SHEET — shared waiver *document* presentation
   ----------------------------------------------------------------------------
   The signer-facing waiver document look, scoped entirely under `.waiver-page`
   so it is safe to load app-wide. Loaded by BOTH the public page
   (`waiver.html`) and the main app (`index.html`), exactly like
   `price-list-sheet.css` is scoped under `.pl-page` and shared between the
   public embed and the Settings admin preview.

   This is the SSOT for "how the waiver looks." The admin WYSIWYG editor
   (`tab/waiver-template-editor.js`) wraps its preview in a `.waiver-page` so it
   renders pixel-identically to the signing page.

   Public-page-only chrome that the admin preview never shows — the body/global
   reset, loading + error states, the initials *drawing* modal, validation
   `.field-error` states, the confirmation screen, and the address autocomplete
   dropdown — stays in `waiver.css` (loaded only by `waiver.html`).
   ============================================================================ */

.waiver-page *,
.waiver-page *::before,
.waiver-page *::after { box-sizing: border-box; }

/* Layout */
.waiver-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.waiver-page .waiver-header {
  background: #333;
  color: #fff;
  padding: 20px 20px 16px;
  text-align: center;
}

.waiver-page .waiver-header h1 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.waiver-page .waiver-address {
  margin: 4px 0 0;
  font-size: 0.75rem;
  opacity: 0.7;
}

.waiver-page .waiver-contact {
  margin: 2px 0 0;
  font-size: 0.75rem;
  opacity: 0.7;
}

.waiver-page .waiver-header .subtitle {
  margin: 10px 0 0;
  font-size: 0.8125rem;
  opacity: 0.9;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.2);
}

.waiver-page .waiver-content {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* Group event banner — sits above the waiver form when the page is opened
   via ?group=TOKEN and the linked group has Square event metadata. */
.waiver-page .waiver-group-banner {
  background: #f1f5fb;
  border: 1px solid #d8e3f0;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 24px;
}

.waiver-page .waiver-group-banner-when {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a2e;
  line-height: 1.3;
}

.waiver-page .waiver-group-banner-where {
  font-size: 0.875rem;
  color: #64748b;
  margin-top: 4px;
}

/* ============================================================================
   SIGNER TYPE — SCENARIO CARDS
   ============================================================================ */

.waiver-page .scenario-cards {
  display: flex;
  flex-direction: row;
  gap: 10px;
}

.waiver-page .scenario-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(8px, 2vw, 12px);
  flex: 1;
  padding: clamp(12px, 3vw, 20px) clamp(8px, 2vw, 16px);
  border: 2px solid #d1d9e0;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.waiver-page .scenario-card:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.waiver-page .scenario-card.selected {
  border-color: #0d6efd;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

.waiver-page .scenario-badge {
  width: clamp(48px, 10vw, 64px);
  height: clamp(48px, 10vw, 64px);
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 0;
  font-size: clamp(0.6875rem, 2vw, 0.875rem);
  font-weight: 800;
  line-height: 1.15;
  color: #475569;
  transition: all 0.2s;
}

.waiver-page .badge-sub {
  font-size: clamp(0.5rem, 1.5vw, 0.625rem);
  font-weight: 600;
  opacity: 0.7;
}

.waiver-page .scenario-card.selected .scenario-badge {
  background: #0d6efd;
  color: #fff;
}

.waiver-page .scenario-card.selected .badge-sub {
  opacity: 0.85;
}

.waiver-page .scenario-both-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.waiver-page .scenario-plus {
  font-size: clamp(0.875rem, 2.5vw, 1.125rem);
  font-weight: 700;
  color: #94a3b8;
}

.waiver-page .scenario-card.selected .scenario-plus {
  color: #1d4ed8;
}

.waiver-page .scenario-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.waiver-page .scenario-title {
  font-size: clamp(0.8125rem, 2.5vw, 1.0625rem);
  font-weight: 700;
  color: #0f172a;
}

.waiver-page .scenario-card.selected .scenario-title {
  color: #1d4ed8;
}

.waiver-page .scenario-desc {
  font-size: clamp(0.6875rem, 2vw, 0.8rem);
  color: #64748b;
  line-height: 1.4;
}

.waiver-page .scenario-card.selected .guardian-emphasis {
  color: #dc3545;
}

/* ============================================================================
   WAIVER SECTIONS (legal text + initials)
   ============================================================================ */

.waiver-page .waiver-section {
  background: #fff;
  border: 1px solid #d1d9e0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.waiver-page .waiver-section-title {
  font-size: 0.9375rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: #0f172a;
}

.waiver-page .waiver-section-body {
  font-size: 0.8125rem;
  color: #334155;
  line-height: 1.6;
  margin-bottom: 16px;
  border: 1px solid #eaeef2;
  border-radius: 4px;
  padding: 12px;
  background: #f8fafc;
}

.waiver-page .waiver-section-summary {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #0f172a;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 6px;
  line-height: 1.5;
}

.waiver-page .waiver-initials-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid #eaeef2;
}

.waiver-page .waiver-initials-row label {
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Initials button (tap to open modal) */
.waiver-page .initials-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  height: 56px;
  box-sizing: border-box;
  border: none;
  border-radius: 6px;
  background: #dc3545;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  transition: background 0.2s, opacity 0.2s;
}

.waiver-page .initials-btn:hover {
  background: #c82333;
}

.waiver-page .initials-btn.signed {
  background: #fff;
  border: 2px solid #8bc48b;
  color: #475569;
  font-weight: 500;
  width: 240px;
  flex-shrink: 0;
}

.waiver-page .initials-preview {
  display: none;
  height: 36px;
  flex: 1;
  max-width: 200px;
  object-fit: contain;
  border-radius: 3px;
}

.waiver-page .initials-confirmed {
  display: flex;
  align-items: center;
  font-size: 0.8125rem;
  color: #16a34a;
  font-weight: 500;
  padding: 8px 12px;
  height: 56px;
  box-sizing: border-box;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
}

/* ============================================================================
   FORM FIELDS
   ============================================================================ */

.waiver-page .form-section {
  margin-bottom: 24px;
}

.waiver-page .form-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #0d6efd;
  color: #0f172a;
}

.waiver-page .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.waiver-page .form-row.three-col {
  grid-template-columns: 1fr 1fr 1fr;
}

.waiver-page .form-row.three-col.has-age {
  grid-template-columns: 1fr 1fr 1fr auto;
}

.waiver-page .dob-age-badge {
  display: flex;
  align-items: center;
  align-self: end;
  padding: 6px 11px;
  height: 36.5px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #0d6efd;
  background: #fff;
  border: 1.5px solid #0d6efd;
  border-radius: 6px;
  white-space: nowrap;
}

/* Age violates the constraint for its field (signer under 18 / minor 18+):
   the badge goes red in lockstep with the DOB selects' `age-error` border. */
.waiver-page .dob-age-badge.invalid {
  color: #dc3545;
  border-color: #dc3545;
}

.waiver-page .form-group {
  display: flex;
  flex-direction: column;
}

.waiver-page .form-group.full-width {
  grid-column: 1 / -1;
}

.waiver-page .form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}

.waiver-page .form-group input,
.waiver-page .form-group select {
  padding: 8px 12px;
  border: 1.5px solid #e0a0a0;
  border-radius: 6px;
  font-size: 0.875rem;
  background: #fff;
  color: #0f172a;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.waiver-page .form-group input[required],
.waiver-page .form-group select[required] {
  border-color: #e0a0a0;
}

.waiver-page .form-group input[required].filled,
.waiver-page .form-group select[required].filled {
  border-color: #8bc48b;
}

.waiver-page .form-group input:not([required]) {
  border-color: #d1d9e0;
}

.waiver-page .form-group select:not([required]) {
  border-color: #d1d9e0;
}

.waiver-page .form-group input:focus,
.waiver-page .form-group select:focus {
  outline: none;
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.waiver-page .required {
  display: none;
}

.waiver-page .required-hint {
  font-size: 0.75rem;
  color: #94a3b8;
  text-align: right;
  margin-bottom: 16px;
  font-style: italic;
}

/* ============================================================================
   PARTICIPANTS (MINORS)
   ============================================================================ */

.waiver-page .participant-card {
  background: #f8fafc;
  border: 1px solid #d1d9e0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.waiver-page .participant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 0.875rem;
  color: #0f172a;
}

.waiver-page .btn-remove-participant {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #dc3545;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.waiver-page .btn-add-participant {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #fff;
  border: 1px dashed #94a3b8;
  border-radius: 6px;
  color: #475569;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.15s;
}

.waiver-page .btn-add-participant:hover:not(:disabled) {
  border-color: #0d6efd;
  color: #0d6efd;
}

.waiver-page .btn-add-participant:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================================
   SIGNATURE
   ============================================================================ */

.waiver-page .signature-canvas-wrapper {
  border: 2px solid #d1d9e0;
  border-radius: 8px;
  background: #fff;
  position: relative;
  overflow: hidden;
}

.waiver-page #signature-canvas {
  width: 100%;
  height: 150px;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.waiver-page .sig-clear-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  border: 1px solid #d1d9e0;
  border-radius: 4px;
  background: #fff;
  font-size: 0.6875rem;
  color: #475569;
  cursor: pointer;
}

.waiver-page .sig-clear-btn:hover {
  background: #f1f5f9;
}

/* ============================================================================
   ELECTRONIC CONSENT & SUBMIT
   ============================================================================ */

.waiver-page .consent-section {
  background: #fffbeb;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
}

.waiver-page .consent-section label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.8125rem;
  color: #334155;
  cursor: pointer;
}

.waiver-page .consent-section input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  accent-color: #0d6efd;
}

.waiver-page .submit-btn {
  width: 100%;
  padding: 14px;
  background: #0d6efd;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.waiver-page .submit-btn:hover:not(:disabled) {
  background: #0b5ed7;
}

.waiver-page .submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 600px) {
  .waiver-page .waiver-content {
    padding: 12px 12px 32px;
  }

  .waiver-page .form-row {
    grid-template-columns: 1fr;
  }

  .waiver-page .form-row.three-col,
  .waiver-page .form-row.three-col.has-age {
    grid-template-columns: 1fr;
  }

  .waiver-page .scenario-cards {
    gap: 6px;
  }

  .waiver-page .waiver-section {
    padding: 14px;
  }

  .waiver-page .waiver-section-body {
    font-size: 0.75rem;
  }

  .waiver-page .initials-btn {
    height: auto;
    width: 100%;
    justify-content: center;
  }

  .waiver-page .initials-btn.signed {
    width: 100%;
  }

  .waiver-page .waiver-initials-row {
    flex-direction: column;
    align-items: stretch;
  }
}
