/*
 * offline banner
 */
#offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--my-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(--pico-color);
  text-align: center;
}

/* 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);
  margin-right: calc(var(--pico-spacing) * -1);
  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;
}

.tabs .tab:first-of-type a {
  /* left align the first tab with the headline above and the text that comes below. */
  padding-left: 0;
}

.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
 */
/* on mobile only */
.touchable-select-as-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.touchable-select-as-buttons > * {
  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;
}


.vbox,
.hbox {
  display: flex; 
  gap: var(--pico-spacing);
  align-items: center;
}

.hbox {
  flex-direction: row;
}

.vbox {
  flex-direction: column;
}

.hbox.wide {
  width: 100%;
  justify-content: space-between;
}


/**
 *  Use like so
 *    <header class=title>
 *      <h1>.... 
 *      <button class=share>...
 *    </header>
 *  Makes them all look the same
 */
header.title {
  display: flex; 
  flex-direction: row; 
  justify-content: space-between;
  margin-bottom: var(--pico-spacing);
}
header.title h1 {
  display: inline-block;
}
header.title button.share {
  white-space: nowrap;
  height: fit-content;
}


section.filter {
  text-align: center;
  margin-bottom: 0; /* Let each item inside have a bottom spacing, so when rendered multiline they also have the same space below, incl space to the next filter section below */
  
  /* Make it span all the way to the edges, right and left. */
  margin-left: -1em;
  margin-right: -1em;
}
section.filter:first-of-type {
  margin-top: calc(var(--pico-spacing) * 4);
}
section.filter:last-of-type {
  margin-bottom: calc(var(--pico-spacing) * 4);
}

section.filter .tag {
  font-size: medium;
  text-decoration: none;
  margin-bottom: 0.5em;
}
section.filter .location {
  border-width: 0;
  padding: 0.2em 0.75em;
  margin-bottom: 0.5em;
  margin-right: 0.5em;
  background: var(--pico-mark-background-color);
  border-radius: 1em;
}
section.filter .location.active {
  background: transparent;
}
