/* Navigation layer: one floating island that changes posture per breakpoint,
   plus the compact header cluster. Nothing here is an admin sidebar - the
   island never touches an edge and never spans the full height. */

.dock {
  position: fixed;
  z-index: var(--z-nav);
  display: flex;
  border-radius: var(--r-island);
  padding: calc(var(--dock-inset) - var(--surface-border));
  --rim: 11px;
}

.dock .lens { border-radius: var(--r-dock-item); }

.dock-list {
  display: flex;
  width: 100%;
  gap: 2px;
}

.dock-list > li {
  display: flex;
  min-width: 0;
}

.nav-item {
  width: 100%;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--ink-2);
  border-radius: var(--r-dock-item);
  transition:
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-press) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.nav-item:active {
  transform: scale(0.965);
}

.nav-item[aria-current="page"] {
  color: var(--accent-ink);
}

.nav-glyph {
  position: relative;
  flex: none;
  width: 24px;
  height: 24px;
}

.nav-glyph svg {
  position: absolute;
  inset: 0;
  width: 24px;
  height: 24px;
  transition:
    opacity var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.nav-glyph .i-fill {
  opacity: 0;
  transform: scale(0.86);
}

.nav-item[aria-current="page"] .i-line {
  opacity: 0;
  transform: scale(1.08);
}

.nav-item[aria-current="page"] .i-fill {
  opacity: 1;
  transform: none;
}

.nav-label {
  font-size: 13px;
  font-weight: 520;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.nav-item[aria-current="page"] .nav-label {
  font-weight: 640;
}

/* Mobile: a single floating island at the bottom -------------------------- */
@media (max-width: 767px) {
  .dock {
    --fill: var(--glass-fill-regular);
    --blur: 30px;
    --rim-blur: 2px;
    left: max(12px, var(--safe-l));
    right: max(12px, var(--safe-r));
    bottom: calc(12px + var(--safe-b) + var(--tg-bottom));
    max-width: 480px;
    margin-inline: auto;
    justify-content: center;
  }

  .dock-list {
    margin: 0 auto;
  }

  .dock-list > li {
    flex: 1 1 0;
  }

  .nav-item {
    min-height: 50px;
    flex-direction: column;
    gap: 3px;
    padding: 5px 2px 6px;
  }

  .nav-label {
    font-size: 10.5px;
    letter-spacing: -0.01em;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* On the narrowest phones the label shrinks rather than being truncated:
   a tab whose name is cut off is a tab the user has to guess. */
@media (max-width: 359px) {
  .nav-label {
    font-size: 9px;
    letter-spacing: -0.02em;
  }
}

/* Tablet: a compact island on the left, still floating ------------------- */
@media (min-width: 768px) {
  .dock {
    --fill: var(--glass-fill-clear);
    --blur: 17px;
    --rim-blur: 0px;
    left: var(--dock-left);
    top: 50%;
    transform: translateY(-50%);
    width: var(--dock-w-compact);
    max-height: min(560px, calc(100dvh - 48px));
  }

  .dock-list {
    flex-direction: column;
    gap: 4px;
  }

  .nav-item {
    flex-direction: column;
    gap: 5px;
    min-height: 62px;
    padding: 9px 4px;
    text-align: center;
  }

  .nav-label {
    font-size: 10.5px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Desktop: the island grows a readable label column ---------------------- */
@media (min-width: 1024px) {
  .dock {
    left: var(--dock-left);
    width: var(--dock-w);
    max-height: min(520px, calc(100dvh - 64px));
  }

  .dock-list {
    gap: 2px;
  }

  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    min-height: 48px;
    padding: 0 12px;
    text-align: left;
  }

  .nav-label {
    font-size: 14px;
  }
}

/* Header cluster --------------------------------------------------------- */
.screen-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
}

.screen-head-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.head-controls {
  position: sticky;
  top: calc(var(--tg-top) + var(--safe-t) + 10px);
  z-index: var(--z-header);
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: calc(var(--control-inset) - var(--surface-border));
  border-radius: var(--r-control-group);
  --rim: 6px;
}

.tool {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--ink-2);
  cursor: pointer;
  transition:
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    transform var(--dur-press) var(--ease-out);
}

.tool svg {
  width: 20px;
  height: 20px;
}

.tool:hover {
  color: var(--accent-ink);
}

.tool:active {
  transform: scale(0.92);
}

.tool[aria-expanded="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.tool.is-busy svg {
  animation: tool-spin 900ms linear infinite;
}

@keyframes tool-spin {
  to { transform: rotate(1turn); }
}

.tool-dot {
  position: absolute;
  top: 10px;
  right: 11px;
  width: 7px;
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--warn);
  box-shadow: 0 0 0 2px rgba(255, 253, 253, 0.9);
}

/* Local back control for nested screens ---------------------------------- */
.back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px 0 13px;
  border: 0;
  border-radius: var(--r-pill);
  cursor: pointer;
  color: var(--accent-ink);
  font-size: 13.5px;
  font-weight: 600;
  --rim: 7px;
  transition: transform var(--dur-press) var(--ease-out);
}

.back svg {
  width: 17px;
  height: 17px;
}

.back:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .nav-item:hover {
    color: var(--accent-ink);
  }

  .back:hover {
    color: var(--accent-strong);
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-item,
  .nav-glyph svg,
  .tool,
  .back {
    transition-duration: 1ms;
  }

  .tool.is-busy svg {
    animation: none;
  }
}
