/* /static/websy/styles/toolbar.css
   Floating Toolbar (Single Source of Truth)
*/

:root {
  --topbar-height: 72px;
  --toolbar-gap: 12px;
  --toolbar-height: 0px;
  --toolbar-reserved-space: 0px;
  --toolbar-bg: rgba(255, 255, 255, 0.72);
  --toolbar-border: rgba(0, 102, 102, 0.2);
  --toolbar-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
  --toolbar-radius: 999px;
  --toolbar-item-gap: 0.35rem;
  --toolbar-padding-y: 0.45rem;
  --toolbar-padding-x: 0.55rem;
  --toolbar-link-radius: 999px;
  --toolbar-link-fg: var(--text, #1f2937);
  --toolbar-link-hover-bg: rgba(0, 102, 102, 0.1);
  --toolbar-link-active-fg: #ffffff;
  --toolbar-focus: #0b7f84;
  --toolbar-z: 980;
}

#toolbar.toolbar {
  /* Resolve the colors on the host, where the saved branding is applied. */
  --toolbar-link-active-bg: linear-gradient(135deg, var(--toolbar-brand-primary, #007f7f), var(--toolbar-brand-secondary, #006666));
  position: fixed;
  left: 50%;
  top: calc(var(--topbar-height, 72px) + var(--toolbar-gap, 12px) + env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: var(--toolbar-z);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--toolbar-item-gap);
  padding: var(--toolbar-padding-y) var(--toolbar-padding-x);
  margin: 0;

  border: 1px solid var(--toolbar-border);
  border-radius: var(--toolbar-radius);
  background: var(--toolbar-bg);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: var(--toolbar-shadow);

  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

#toolbar[hidden] {
  display: none !important;
}

#toolbar-spacer {
  height: var(--toolbar-reserved-space, 0px);
  /* Keep the reserved height in the shared footer's flex-column layout. */
  flex-shrink: 0;
  min-height: 0;
  pointer-events: none;
}

#toolbar-spacer[hidden] {
  display: none !important;
}

#toolbar.toolbar.is-at-top {
  opacity: 0.86;
}

#toolbar.toolbar.is-scroll-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-16px);
  pointer-events: none;
}

#toolbar .toolbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.25rem;
  padding: 0.48rem 0.75rem;
  border-radius: var(--toolbar-link-radius);
  border: 1px solid transparent;
  color: var(--toolbar-link-fg);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

#toolbar .toolbar-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
}

#toolbar .toolbar-label {
  white-space: nowrap;
}

#toolbar .toolbar-link:hover {
  background: var(--toolbar-link-hover-bg);
}

#toolbar .toolbar-link:focus-visible {
  outline: 2px solid var(--toolbar-focus);
  outline-offset: 2px;
  background: rgba(11, 127, 132, 0.12);
}

#toolbar .toolbar-link.is-active,
#toolbar .toolbar-link[aria-current="page"] {
  background: var(--toolbar-link-active-bg);
  color: var(--toolbar-link-active-fg);
  border-color: rgba(0, 0, 0, 0.06);
}

@media (max-width: 900px) {
  #toolbar.toolbar {
    top: calc(var(--topbar-height, 64px) + 10px + env(safe-area-inset-top));
    padding: 0.35rem 0.45rem;
    gap: 0.25rem;
  }

  #toolbar .toolbar-link {
    padding: 0.45rem 0.62rem;
    font-size: 0.8125rem;
  }
}

@media (max-width: 640px) {
  #toolbar.toolbar {
    top: auto;
    bottom: calc(0.6rem + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(96vw, 28rem);
    max-width: 28rem;
    justify-content: space-around;
    border-radius: 1.1rem;
  }

  #toolbar-spacer {
    height: 0 !important;
  }

  #toolbar.toolbar.is-scroll-hidden {
    transform: translateX(-50%) translateY(10px);
  }

  #toolbar .toolbar-link {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.56rem 0.5rem;
    font-size: 0.78rem;
    gap: 0.28rem;
  }

  #toolbar .toolbar-label {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 420px) {
  #toolbar .toolbar-label {
    display: none;
  }

  #toolbar .toolbar-link {
    min-height: 2.6rem;
    padding: 0.62rem 0.45rem;
  }

  #toolbar .toolbar-icon {
    width: 1.15rem;
    height: 1.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  #toolbar.toolbar,
  #toolbar .toolbar-link {
    transition: none !important;
  }
}
