/**
 * Purpose: Defines reusable buttons, cards, navigation, notices, forms, and other shared SobrietyWorks interface components.
 * TODOs: None
 * Maintainer: John B.
 * Contact: john@sobriety.works
 */

/* Core layout, component, and interaction rules for this stylesheet's interface area. */
.sw-container {
  width: min(calc(100% - 2rem), 1720px);
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1100;
  transform: translateY(-150%);
  border: 1px solid var(--sw-color-text);
  border-radius: var(--sw-radius-control);
  padding: 0.7rem 1rem;
  background: var(--sw-color-surface);
  color: var(--sw-color-text);
  font-size: var(--font-size-control);
  font-weight: 600;
  line-height: var(--line-height-control);
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.sw-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 1px solid var(--sw-color-action);
  border-radius: var(--sw-radius-control);
  padding: 0.85rem 1.15rem;
  background: var(--sw-color-action);
  color: var(--sw-color-on-action);
  font-size: var(--font-size-control);
  font-weight: 600;
  line-height: var(--line-height-control);
  text-decoration: none;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

.sw-button svg {
  width: 18px;
  height: 18px;
  margin-left: 0.65rem;
  stroke-width: 1.8;
}

.sw-button:hover {
  border-color: var(--sw-color-action-hover);
  background: var(--sw-color-action-hover);
  color: var(--sw-color-on-action);
}

.sw-button--quiet {
  border-color: var(--sw-color-border-control);
  background: var(--sw-color-surface-muted);
  color: var(--sw-color-text);
}

.sw-button--quiet:hover {
  border-color: var(--sw-color-text-muted);
  background: color-mix(in srgb, var(--sw-color-surface-muted) 72%, var(--sw-color-border));
  color: var(--sw-color-text);
}

.sw-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.sw-text-action {
  display: inline-flex;
  margin-top: 1.5rem;
  color: var(--sw-color-action);
  font-weight: 600;
  text-underline-offset: 0.25em;
}

.sw-form-field {
  display: grid;
  gap: 0.5rem;
}

.sw-form-field label,
.sw-form-field legend {
  color: var(--sw-color-text);
  font-weight: 600;
}

.sw-form-field label span {
  color: var(--sw-color-text-muted);
  font-size: var(--font-size-small);
  font-weight: 400;
  line-height: var(--line-height-small);
}

.sw-form-field input[type="text"],
.sw-form-field input[type="email"],
.sw-form-field select,
.sw-form-field textarea {
  width: 100%;
  border: 1px solid var(--sw-color-border-control);
  border-radius: var(--sw-radius-control);
  padding: 0.8rem 0.9rem;
  background: var(--sw-color-surface);
  color: var(--sw-color-text);
}

.sw-form-field textarea {
  min-height: 130px;
  resize: vertical;
}

.sw-form-field input:focus,
.sw-form-field select:focus,
.sw-form-field textarea:focus {
  border-color: var(--sw-color-action);
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgb(var(--sw-rgb-action) / 0.18);
}

.sw-form-fieldset {
  margin: 0;
  border: 0;
  padding: 0;
}

.sw-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 1rem;
}

.sw-checkbox-grid label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  min-height: 44px;
  border: 1px solid var(--sw-color-border);
  border-radius: var(--sw-radius-control);
  padding: 0.7rem;
  background: var(--sw-color-surface);
  font-weight: 500;
}

.sw-checkbox-grid input {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.1rem;
  accent-color: var(--sw-color-action);
}

.sw-field-error {
  color: var(--sw-color-danger-text);
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: var(--line-height-small);
}

.sw-form-error-summary {
  max-width: 760px;
  margin-top: 2rem;
  border: 2px solid var(--sw-color-danger-border);
  border-radius: var(--sw-radius-panel);
  padding: 1.25rem;
  background: var(--sw-color-danger-surface);
  color: var(--sw-color-danger-text);
}

.sw-form-error-summary p,
.sw-form-error-summary ul {
  margin-top: 0.75rem;
}

.sw-form-error-summary a {
  color: var(--sw-color-danger-text);
}

.card,
.modal-content,
.dropdown-menu,
.alert {
  border-radius: var(--sw-radius-panel);
}

/* Native dialogs and Bootstrap modals share one steamed-glass layer so every
 * modal clearly suspends, but does not visually sever, the page beneath it. */
dialog::backdrop,
.modal-backdrop {
  background: var(--sw-steamed-glass-overlay);
  -webkit-backdrop-filter: var(--sw-steamed-glass-filter);
  backdrop-filter: var(--sw-steamed-glass-filter);
}

.modal-backdrop.show {
  opacity: 1;
}

.alert-success {
  --bs-alert-color: var(--sw-color-success-text);
  --bs-alert-bg: var(--sw-color-success-surface);
  --bs-alert-border-color: var(--sw-color-success-border);
  --bs-alert-link-color: var(--sw-color-success-text);
}

.alert-info {
  --bs-alert-color: var(--sw-color-info-text);
  --bs-alert-bg: var(--sw-color-info-surface);
  --bs-alert-border-color: var(--sw-color-info-border);
  --bs-alert-link-color: var(--sw-color-info-text);
}

.alert-warning {
  --bs-alert-color: var(--sw-color-warning-text);
  --bs-alert-bg: var(--sw-color-warning-surface);
  --bs-alert-border-color: var(--sw-color-warning-border);
  --bs-alert-link-color: var(--sw-color-warning-text);
}

.alert-danger {
  --bs-alert-color: var(--sw-color-danger-text);
  --bs-alert-bg: var(--sw-color-danger-surface);
  --bs-alert-border-color: var(--sw-color-danger-border);
  --bs-alert-link-color: var(--sw-color-danger-text);
}

.text-bg-success,
.text-bg-info,
.text-bg-warning,
.text-bg-danger {
  border: 1px solid;
}

.text-bg-success {
  border-color: var(--sw-color-success-border) !important;
  background: var(--sw-color-success-surface) !important;
  color: var(--sw-color-success-text) !important;
}

.text-bg-info {
  border-color: var(--sw-color-info-border) !important;
  background: var(--sw-color-info-surface) !important;
  color: var(--sw-color-info-text) !important;
}

.text-bg-warning {
  border-color: var(--sw-color-warning-border) !important;
  background: var(--sw-color-warning-surface) !important;
  color: var(--sw-color-warning-text) !important;
}

.text-bg-danger {
  border-color: var(--sw-color-danger-border) !important;
  background: var(--sw-color-danger-surface) !important;
  color: var(--sw-color-danger-text) !important;
}

.badge.text-bg-success,
.badge.text-bg-info,
.badge.text-bg-warning,
.badge.text-bg-danger {
  border-radius: var(--sw-radius-round);
}

.valid-feedback,
.valid-tooltip {
  color: var(--sw-color-success-text);
}

.invalid-feedback,
.invalid-tooltip {
  color: var(--sw-color-danger-text);
}

.form-control.is-valid,
.form-select.is-valid,
.was-validated .form-control:valid,
.was-validated .form-select:valid {
  border-color: var(--sw-color-success-border);
}

.form-control.is-invalid,
.form-select.is-invalid,
.was-validated .form-control:invalid,
.was-validated .form-select:invalid {
  border-color: var(--sw-color-danger-border);
}

.form-control.is-valid:focus,
.form-select.is-valid:focus,
.was-validated .form-control:valid:focus,
.was-validated .form-select:valid:focus {
  border-color: var(--sw-color-success-border);
  box-shadow: 0 0 0 0.25rem rgb(var(--sw-rgb-success) / 0.18);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus,
.was-validated .form-control:invalid:focus,
.was-validated .form-select:invalid:focus {
  border-color: var(--sw-color-danger-border);
  box-shadow: 0 0 0 0.25rem rgb(var(--sw-rgb-danger) / 0.18);
}

@media (min-width: 768px) {

  .sw-container {
    width: min(calc(100% - 3rem), 1720px);
  }
}

@media (min-width: 1440px) {

  .sw-container {
    width: min(calc(100% - 5rem), 1720px);
  }
}

@media (max-width: 575.98px) {

  .sw-container {
    width: min(calc(100% - 1.5rem), 1720px);
  }

  .sw-button {
    width: 100%;
  }
}

@media (max-width: 420px) {

  .sw-container {
    width: min(calc(100% - 1.25rem), 1720px);
  }
}
.sw-volunteer-info-assurance {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--sw-color-text);
  font-size: var(--font-size-small);
  line-height: var(--line-height-small);
}

.sw-volunteer-info-tooltip {
  position: relative;
  display: inline-flex;
}

.sw-volunteer-info-tooltip > button {
  display: inline-flex;
  width: 1.35rem;
  height: 1.35rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--sw-color-border-control);
  border-radius: 50%;
  padding: 0;
  background: var(--sw-color-surface);
  color: var(--sw-color-text);
  font: inherit;
  font-size: var(--font-size-small);
  font-weight: 600;
  line-height: 1;
}

.sw-volunteer-info-tooltip > button:focus {
  border-color: var(--sw-color-action);
  outline: 0;
  box-shadow: 0 0 0 3px rgb(var(--sw-rgb-action) / 0.18);
}

.sw-volunteer-info-tooltip [role="tooltip"] {
  position: absolute;
  z-index: 20;
  right: 0;
  bottom: calc(100% + 0.6rem);
  width: min(21rem, calc(100vw - 2rem));
  border: 1px solid var(--sw-color-border);
  border-radius: var(--sw-radius-control);
  padding: 0.75rem 0.85rem;
  background: var(--sw-color-text);
  color: var(--sw-color-surface);
  font-size: var(--font-size-small);
  font-weight: 500;
  line-height: var(--line-height-small);
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.25rem);
  transition: opacity 140ms ease, transform 140ms ease;
}

.sw-volunteer-info-tooltip:hover [role="tooltip"],
.sw-volunteer-info-tooltip:focus-within [role="tooltip"] {
  opacity: 1;
  transform: translateY(0);
}
