/* Site taskbar on the public pages (web/js/siteDock.js): page navigation for everyone, plus a
   separate admin section and the admin app windows for an authenticated admin. */

/* Keep page content clear of the dock. */
body.has-site-dock {
  padding-bottom: 96px;
}

.adock {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 2600;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 7px 10px 9px;
  border-radius: 18px;
  /* Solid enough to stand out over busy cards; the blur still hints at what's behind. */
  background: linear-gradient(180deg, rgba(44, 47, 58, 0.9), rgba(24, 26, 34, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 16px 44px rgba(0, 0, 0, 0.55);
  transform: translate(-50%, 150%);
  transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

.adock--shown {
  transform: translate(-50%, 0);
}

:root.light-theme .adock {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(240, 242, 247, 0.9));
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 16px 40px rgba(30, 30, 60, 0.22);
}

.adock-item {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

/* App icons are full-tile images (web/assets/apps/*.svg); the dark fill only shows while loading. */
.adock-icon--dashboard,
.adock-icon--compare,
.adock-icon--aa-ladder,
.adock-icon--alt-arts,
.adock-icon--admin,
.adock-icon--db {
  background: #120e0b;
}

/* Current page: lit icon + accent dot (the running dot is reused for admin apps). */
.adock-item--page[aria-current="page"] .adock-icon {
  box-shadow: 0 0 0 2px rgba(255, 196, 110, 0.9), 0 0 14px rgba(255, 150, 60, 0.45), 0 4px 14px rgba(0, 0, 0, 0.35);
}

.adock-item--page[aria-current="page"] .adock-dot {
  background: #ff7a2f;
  box-shadow: 0 0 6px #ff7a2f;
}

.adock-item--page:not([aria-current="page"]) .adock-icon {
  filter: saturate(0.8) brightness(0.9);
}

/* Utility: the page's theme toggle, adopted into the dock. */
.adock .theme-toggle {
  order: 0;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: inherit;
  transform: none;
}

.adock .theme-toggle:hover {
  background: none;
  transform: none;
}

/* Same stone-and-gold tile as the app icons. */
.adock-icon--theme {
  font-size: 22px;
  line-height: 1;
  background: radial-gradient(circle at 50% 38%, #3b2f27, #17120f 55%, #080605);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 0 0 1.5px rgba(212, 162, 74, 0.85);
}

/* Admin section: divider + tinted group, only rendered for an authenticated admin. */
.adock-divider {
  align-self: stretch;
  width: 1px;
  margin: 4px 2px 2px;
  background: rgba(255, 255, 255, 0.22);
}

:root.light-theme .adock-divider {
  background: rgba(0, 0, 0, 0.15);
}

.adock-admin {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: -3px -4px -5px 0;
  padding: 3px 6px 5px;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(255, 122, 47, 0.3), rgba(255, 122, 47, 0.08));
  box-shadow: inset 0 0 0 1px rgba(255, 150, 90, 0.35);
}

.adock-admin-badge {
  position: absolute;
  top: -8px;
  left: -6px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff7a2f;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.adock-admin-badge svg {
  width: 11px;
  height: 11px;
}

.adock-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease;
}

.adock-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.adock-icon svg {
  width: 26px;
  height: 26px;
}

.adock-item:hover .adock-icon,
.adock-item:focus-visible .adock-icon {
  transform: translateY(-7px) scale(1.14);
}

.adock-item:focus-visible {
  outline: none;
}

.adock-item:focus-visible .adock-icon {
  box-shadow: 0 0 0 3px rgba(255, 122, 47, 0.6), 0 4px 12px rgba(0, 0, 0, 0.35);
}

.adock-label {
  position: absolute;
  bottom: calc(100% + 16px);
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(30, 30, 32, 0.92);
  color: #fff;
  font: 12px -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}

.adock-item:hover .adock-label,
.adock-item:focus-visible .adock-label {
  opacity: 1;
}

/* Running indicator (window open or minimized) */
.adock-dot {
  position: absolute;
  bottom: -6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
}

.adock-item--running .adock-dot {
  background: rgba(255, 255, 255, 0.9);
}

:root.light-theme .adock-item--running .adock-dot {
  background: rgba(0, 0, 0, 0.65);
}

/* App window: the admin page in an iframe, floating over the current page */
.adock-window {
  position: fixed;
  inset: calc(26px + var(--cascade, 0px)) 26px 92px calc(26px + var(--cascade, 0px));
  z-index: 2400;
  overflow: hidden;
  border-radius: 14px;
  background: #1e1e20;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.1);
  transition:
    inset 0.28s ease,
    border-radius 0.28s ease,
    transform 0.36s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.3s ease;
}

.adock-window[hidden] {
  display: none;
}

.adock-window--zoomed {
  inset: 0 0 80px;
  border-radius: 0 0 14px 14px;
}

.adock-window--minimized {
  transform: scale(0.04);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.38s cubic-bezier(0.55, 0, 0.75, 0),
    opacity 0.34s ease-in;
}

.adock-window--closing {
  transform: scale(0.94);
  opacity: 0;
  pointer-events: none;
  transition-duration: 0.2s;
}

.adock-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

@media (prefers-reduced-motion: reduce) {
  .adock,
  .adock-window,
  .adock-icon {
    transition: none;
  }
}

/* Phones: a full-width bottom tab bar with labels; admin apps open as normal pages. */
@media (max-width: 760px) {
  body.has-site-dock {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }

  .adock {
    left: 0;
    right: 0;
    bottom: 0;
    justify-content: space-around;
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    border-radius: 0;
    border-width: 1px 0 0;
    transform: translateY(150%);
  }

  .adock--shown {
    transform: none;
  }

  .adock-item {
    flex: 1 1 0;
    gap: 3px;
  }

  .adock-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  .adock-icon svg {
    width: 18px;
    height: 18px;
  }

  .adock-icon--theme {
    font-size: 16px;
  }

  .adock-item:hover .adock-icon,
  .adock-item:focus-visible .adock-icon {
    transform: none;
  }

  /* Labels sit under the icons instead of as hover tooltips. */
  .adock-label {
    position: static;
    padding: 0;
    background: none;
    color: inherit;
    font-size: 10px;
    opacity: 0.85;
  }

  .adock-dot {
    display: none;
  }

  .adock-item--page[aria-current="page"] .adock-label {
    color: #ff7a2f;
    opacity: 1;
    font-weight: 600;
  }

  .adock-divider {
    margin: 6px 0;
  }

  .adock-admin {
    flex: 2 1 0;
    justify-content: space-around;
    margin: 0;
    padding: 3px 4px;
  }

  .adock-admin-badge {
    top: -6px;
    left: 2px;
  }

  .adock-window {
    display: none;
  }

  /* Floating buttons sit above the tab bar. */
  body.has-site-dock .companion-launcher,
  body.has-site-dock .back-to-top {
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
}
