/* Mobile form, accessibility, and theme hardening for Mt. Pulaski Community Events. */

:root {
  color-scheme: light;
  --app-visual-height: 100dvh;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

.required-note {
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: var(--muted);
}

.required-marker {
  margin-left: 0.2em;
  color: #a61b1b;
  font-weight: 800;
}

html[data-theme="dark"] .required-marker,
body.theme-dark .required-marker {
  color: #ffb4ab;
}

.submit-event-form label.required-field > input,
.submit-event-form label.required-field > textarea,
.submit-event-form label.required-field > select {
  scroll-margin-top: 7rem;
  scroll-margin-bottom: 45vh;
}

.wizard-advanced-questions fieldset {
  display: grid;
  gap: 8px;
}

.wizard-advanced-questions fieldset > legend {
  margin-bottom: 6px;
}

.wizard-advanced-questions fieldset > label {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 8px 4px;
  line-height: 1.35;
  cursor: pointer;
}

.wizard-advanced-questions fieldset > label > input[type="checkbox"] {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
}

/* Keep the calendar palette intentional. Device dark mode must not auto-recolor it. */
html:not([data-theme="dark"]) .proper-calendar-shell,
html:not([data-theme="dark"]) .calendar-grid,
html:not([data-theme="dark"]) .calendar-weekdays,
html:not([data-theme="dark"]) .selected-day-panel {
  color-scheme: light;
}

@media (max-width: 760px) {
  #event-submit-modal.modal {
    align-items: flex-start;
    overflow: hidden;
    padding:
      max(8px, env(safe-area-inset-top))
      0
      max(8px, env(safe-area-inset-bottom));
  }

  #event-submit-modal .modal-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    height: calc(var(--app-visual-height, 100dvh) - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
    max-height: calc(var(--app-visual-height, 100dvh) - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom)));
    margin: 0;
    border-radius: 24px 24px 0 0;
    overflow: hidden;
  }

  #event-submit-modal .modal-header {
    flex: 0 0 auto;
    padding-right: 64px;
  }

  #event-submit-modal .modal-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scroll-padding-top: 24px;
    scroll-padding-bottom: max(42vh, 16rem);
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }

  #event-submit-modal .submit-event-form {
    padding-bottom: max(42vh, 16rem);
  }

  #event-submit-modal input,
  #event-submit-modal textarea,
  #event-submit-modal select,
  #event-submit-modal button {
    font-size: 16px;
  }

  .wizard-advanced-questions fieldset > label {
    padding: 10px 2px;
  }
}
