/*
 * offline banner
 */
#offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--color-text-danger);
  color: white;
  text-align: center;
  padding: 0.5rem;
  z-index: var(--z-index-very-top);
  display: none;
}

#offline-banner.visible {
  display: block;
  animation: slide-down 0.3s ease-out;
}

/*
 * messages
 */

section.messages {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;

  opacity: 0.9;
  color: var(--pico-color);
  position: fixed;
  top: calc(-1 * var(--pico-border-radius) + env(safe-area-inset-top));
  z-index: var(--z-index-very-top);
}

section.messages article {
  pointer-events: all;
  cursor: hand;
  display: flex;
  align-items: center;

  position: relative;
  margin: 0.2em;
  padding: 0.2em 1em;
  border: var(--stroke-width) solid var(--color-highlight)
}

/* Reduced motion settings, because the "animations" are removed when a device has reduce-motion turned on */
@media (prefers-reduced-motion) {
  /* i dont know yet how to remove the message after 5s without some js */
}

@media (prefers-reduced-motion: no-preference) {
  section.messages {
    transform: translateY(calc(-100% - env(safe-area-inset-top)));
    animation: flyout 0.5s ease-out reverse forwards,
    flyout 1s ease-out forwards;
    animation-delay: 0s, 4s;
  }
}

section.messages article.success {
  background: var(--color-text-on-primary);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

section.messages article.success .close {
  color: var(--color-primary);
}

section.messages article.error {
  color: white;
  background: #ff7777;
}

section.messages article .close {
  color: var(--pico-color);
  margin-inline-start: var(--pico-spacing);
}


@keyframes flyout {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(calc(-100% - env(safe-area-inset-top)));
  }
}


/* Tab styles */
.tabs {
  margin-bottom: 2rem;
  border-bottom: 1px solid lightgrey;
  display: flex;
  gap: 1rem;
}

.tab {
  padding: 0 1.5rem 0.75rem 1.5rem;
  font-weight: 500;
  color: var(--pico-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
}

.tab:hover {
  color: var(--primary);
}

.tab.active {
  color: var(--pico-primary);
  border-bottom-color: var(--pico-primary);
}

/**
 * A very tiny component, how to create a one-line text element.
 * Make sure the (right) parent has overflow:hidden and use the following
 */
.one-liner {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

/**
 * A hint is structured like this: 
 * <p>
 *   <span>{% include_svg_icon 'info' %}</span>
 *   <span>your hint text</span>
 * </p>
 */
p.hint {
  color: var(--pico-muted-color); font-size: smaller;
  display: flex;
  flex-direction: row;
  gap: var(--pico-spacing);
  align-items: center;
}
p.hint:hover,
p.hint:hover * {
  color: var(--pico-primary);
  transition: color 1s;
}


/**
 * radio buttons that are touch-friendly
 */
.touchable-select-as-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin: 2rem 0;
}

.touchable-select-as-buttons > * {
  flex: 40%;
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0.5em;
}

.touchable-select-as-buttons > *:has(input:checked) {
  border-color: var(--pico-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.touchable-select-as-buttons label {
  padding: var(--pico-form-element-spacing-vertical) var(--pico-form-element-spacing-horizontal);
}

.touchable-select-as-buttons > *:has(input:checked):after {
  content: "✓";
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  background: var(--pico-primary);
  color: white;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.touchable-select-as-buttons input[type=checkbox],
.touchable-select-as-buttons input[type=radio] {
  /* DO NOT use `display:none` but this below instead. This will not remove the browser's native validation messages like "this field is required", esp. on radio boxes. */
  clip-path: inset(50%);
  position: absolute;
}


