/*
 * 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(--my-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(--my-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(--my-backgroundcolor-text-success);
  color: var(--my-color-text-success);
  border-color: var(--my-color-text-success);
}

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

section.messages article.error {
  color: white;
  background: #ff0000;
  font-size: larger;
}

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)));
  }
}

/**
 * Use it like <p class="expandable-text"> to make multi line text expandable.
 */
.expandable-text {
  line-height: 1.5;
  max-height: 6em; /* 3 lines */
  overflow: hidden;
  transition: max-height 1s ease;
  position: relative;
  mask-image: linear-gradient(to bottom, black 60%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent);
}
.expandable-text:hover {
  max-height: 1000px;
  mask-image: none;
}

/* Tab styles */
.tabs {
  margin-bottom: var(--pico-spacing);
  border-bottom: 1px solid var(--pico-contrast-focus);
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.tab {
  padding: calc(var(--pico-spacing) / 2) var(--pico-spacing);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

.tab:hover {
  color: var(--pico-primary);
  border-bottom-color: var(--pico-primary-hover);
}
.tab:hover a {
  text-decoration: none;
}

.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;
}
.one-liner-scrollable {
  white-space: nowrap;
  overflow: scroll;
  scrollbar-width: none;
}

/**
 * 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
 */
@media screen and (max-width: 600px) {
  /* on mobile only */
  .touchable-select-as-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
  }

  .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;
    text-align: center;
  }

  .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 > *: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;
  }
}
